mirror of
https://github.com/LuckfoxTECH/luckfox-pico.git
synced 2026-01-19 17:59:18 +01:00
project:build.sh: Added fastboot support; custom modifications to U-Boot and kernel implemented using patches.
project:cfg:BoardConfig_IPC: Added fastboot BoardConfig file and firmware post-scripts, distinguishing between the BoardConfigs for Luckfox Pico Pro and Luckfox Pico Max. project:app: Added fastboot_client and rk_smart_door for quick boot applications; updated rkipc app to adapt to the latest media library. media:samples: Added more usage examples. media:rockit: Fixed bugs; removed support for retrieving data frames from VPSS. media:isp: Updated rkaiq library and related tools to support connection to RKISP_Tuner. sysdrv:Makefile: Added support for compiling drv_ko on Luckfox Pico Ultra W using Ubuntu; added support for custom root filesystem. sysdrv:tools:board: Updated Buildroot optional mirror sources, updated some software versions, and stored device tree files and configuration files that undergo multiple modifications for U-Boot and kernel separately. sysdrv:source:mcu: Used RISC-V MCU SDK with RT-Thread system, mainly for initializing camera AE during quick boot. sysdrv:source:uboot: Added support for fastboot; added high baud rate DDR bin for serial firmware upgrades. sysdrv:source:kernel: Upgraded to version 5.10.160; increased NPU frequency for RV1106G3; added support for fastboot. Signed-off-by: luckfox-eng29 <eng29@luckfox.com>
This commit is contained in:
12
sysdrv/source/mcu/rt-thread/components/libc/time/SConscript
Normal file
12
sysdrv/source/mcu/rt-thread/components/libc/time/SConscript
Normal file
@@ -0,0 +1,12 @@
|
||||
# RT-Thread building script for component
|
||||
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = Glob('*.c') + Glob('*.cpp')
|
||||
CPPPATH = [cwd]
|
||||
|
||||
group = DefineGroup('pthreads', src,
|
||||
depend = ['RT_USING_PTHREADS'], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
188
sysdrv/source/mcu/rt-thread/components/libc/time/clock_time.c
Normal file
188
sysdrv/source/mcu/rt-thread/components/libc/time/clock_time.c
Normal file
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2012-12-08 Bernard fix the issue of _timevalue.tv_usec initialization,
|
||||
* which found by Rob <rdent@iinet.net.au>
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "clock_time.h"
|
||||
|
||||
static struct timeval _timevalue;
|
||||
int clock_time_system_init()
|
||||
{
|
||||
time_t time;
|
||||
rt_tick_t tick;
|
||||
rt_device_t device;
|
||||
|
||||
time = 0;
|
||||
device = rt_device_find("rtc");
|
||||
if (device != RT_NULL)
|
||||
{
|
||||
/* get realtime seconds */
|
||||
rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time);
|
||||
}
|
||||
|
||||
/* get tick */
|
||||
tick = rt_tick_get();
|
||||
|
||||
_timevalue.tv_usec = (tick%RT_TICK_PER_SECOND) * MICROSECOND_PER_TICK;
|
||||
_timevalue.tv_sec = time - tick/RT_TICK_PER_SECOND - 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
INIT_COMPONENT_EXPORT(clock_time_system_init);
|
||||
|
||||
int clock_time_to_tick(const struct timespec *time)
|
||||
{
|
||||
int tick;
|
||||
int nsecond, second;
|
||||
struct timespec tp;
|
||||
|
||||
RT_ASSERT(time != RT_NULL);
|
||||
|
||||
tick = RT_WAITING_FOREVER;
|
||||
if (time != NULL)
|
||||
{
|
||||
/* get current tp */
|
||||
clock_gettime(CLOCK_REALTIME, &tp);
|
||||
|
||||
if ((time->tv_nsec - tp.tv_nsec) < 0)
|
||||
{
|
||||
nsecond = NANOSECOND_PER_SECOND - (tp.tv_nsec - time->tv_nsec);
|
||||
second = time->tv_sec - tp.tv_sec - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
nsecond = time->tv_nsec - tp.tv_nsec;
|
||||
second = time->tv_sec - tp.tv_sec;
|
||||
}
|
||||
|
||||
tick = second * RT_TICK_PER_SECOND + nsecond * RT_TICK_PER_SECOND / NANOSECOND_PER_SECOND;
|
||||
if (tick < 0) tick = 0;
|
||||
}
|
||||
|
||||
return tick;
|
||||
}
|
||||
RTM_EXPORT(clock_time_to_tick);
|
||||
|
||||
int clock_getres(clockid_t clockid, struct timespec *res)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (res == RT_NULL)
|
||||
{
|
||||
rt_set_errno(EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (clockid)
|
||||
{
|
||||
case CLOCK_REALTIME:
|
||||
res->tv_sec = 0;
|
||||
res->tv_nsec = NANOSECOND_PER_SECOND/RT_TICK_PER_SECOND;
|
||||
break;
|
||||
|
||||
#ifdef RT_USING_CPUTIME
|
||||
case CLOCK_CPUTIME_ID:
|
||||
res->tv_sec = 0;
|
||||
res->tv_nsec = clock_cpu_getres();
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
ret = -1;
|
||||
rt_set_errno(EINVAL);
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
RTM_EXPORT(clock_getres);
|
||||
|
||||
int clock_gettime(clockid_t clockid, struct timespec *tp)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (tp == RT_NULL)
|
||||
{
|
||||
rt_set_errno(EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (clockid)
|
||||
{
|
||||
case CLOCK_REALTIME:
|
||||
{
|
||||
/* get tick */
|
||||
int tick = rt_tick_get();
|
||||
|
||||
tp->tv_sec = _timevalue.tv_sec + tick / RT_TICK_PER_SECOND;
|
||||
tp->tv_nsec = (_timevalue.tv_usec + (tick % RT_TICK_PER_SECOND) * MICROSECOND_PER_TICK) * 1000;
|
||||
}
|
||||
break;
|
||||
|
||||
#ifdef RT_USING_CPUTIME
|
||||
case CLOCK_CPUTIME_ID:
|
||||
{
|
||||
float unit = 0;
|
||||
long long cpu_tick;
|
||||
|
||||
unit = clock_cpu_getres();
|
||||
cpu_tick = clock_cpu_gettime();
|
||||
|
||||
tp->tv_sec = ((int)(cpu_tick * unit)) / NANOSECOND_PER_SECOND;
|
||||
tp->tv_nsec = ((int)(cpu_tick * unit)) % NANOSECOND_PER_SECOND;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
rt_set_errno(EINVAL);
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
RTM_EXPORT(clock_gettime);
|
||||
|
||||
int clock_settime(clockid_t clockid, const struct timespec *tp)
|
||||
{
|
||||
int second;
|
||||
rt_tick_t tick;
|
||||
rt_device_t device;
|
||||
|
||||
if ((clockid != CLOCK_REALTIME) || (tp == RT_NULL))
|
||||
{
|
||||
rt_set_errno(EINVAL);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* get second */
|
||||
second = tp->tv_sec;
|
||||
/* get tick */
|
||||
tick = rt_tick_get();
|
||||
|
||||
/* update timevalue */
|
||||
_timevalue.tv_usec = MICROSECOND_PER_SECOND - (tick % RT_TICK_PER_SECOND) * MICROSECOND_PER_TICK;
|
||||
_timevalue.tv_sec = second - tick/RT_TICK_PER_SECOND - 1;
|
||||
|
||||
/* update for RTC device */
|
||||
device = rt_device_find("rtc");
|
||||
if (device != RT_NULL)
|
||||
{
|
||||
/* set realtime seconds */
|
||||
rt_device_control(device, RT_DEVICE_CTRL_RTC_SET_TIME, &second);
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
RTM_EXPORT(clock_settime);
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2017-12-31 Bernard the first version
|
||||
*/
|
||||
|
||||
#ifndef CLOCK_TIME_H__
|
||||
#define CLOCK_TIME_H__
|
||||
|
||||
/* posix clock and timer */
|
||||
#define MILLISECOND_PER_SECOND 1000UL
|
||||
#define MICROSECOND_PER_SECOND 1000000UL
|
||||
#define NANOSECOND_PER_SECOND 1000000000UL
|
||||
|
||||
#define MILLISECOND_PER_TICK (MILLISECOND_PER_SECOND / RT_TICK_PER_SECOND)
|
||||
#define MICROSECOND_PER_TICK (MICROSECOND_PER_SECOND / RT_TICK_PER_SECOND)
|
||||
#define NANOSECOND_PER_TICK (NANOSECOND_PER_SECOND / RT_TICK_PER_SECOND)
|
||||
|
||||
#ifndef CLOCK_REALTIME
|
||||
#define CLOCK_REALTIME 1
|
||||
#endif
|
||||
|
||||
#define CLOCK_CPUTIME_ID 2
|
||||
|
||||
#ifndef CLOCK_PROCESS_CPUTIME_ID
|
||||
#define CLOCK_PROCESS_CPUTIME_ID CLOCK_CPUTIME_ID
|
||||
#endif
|
||||
#ifndef CLOCK_THREAD_CPUTIME_ID
|
||||
#define CLOCK_THREAD_CPUTIME_ID CLOCK_CPUTIME_ID
|
||||
#endif
|
||||
|
||||
#ifndef CLOCK_MONOTONIC
|
||||
#define CLOCK_MONOTONIC 4
|
||||
#endif
|
||||
|
||||
int clock_getres (clockid_t clockid, struct timespec *res);
|
||||
int clock_gettime (clockid_t clockid, struct timespec *tp);
|
||||
int clock_settime (clockid_t clockid, const struct timespec *tp);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <rtthread.h>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
unsigned int sleep(unsigned int seconds)
|
||||
{
|
||||
rt_tick_t delta_tick;
|
||||
|
||||
delta_tick = rt_tick_get();
|
||||
rt_thread_delay(seconds * RT_TICK_PER_SECOND);
|
||||
delta_tick = rt_tick_get() - delta_tick;
|
||||
|
||||
return seconds - delta_tick/RT_TICK_PER_SECOND;
|
||||
}
|
||||
Reference in New Issue
Block a user