From d6b60300a5953555d988947633fc8c19a5080ea0 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Mon, 20 Sep 2021 15:46:53 -0400 Subject: [.ignore_format] 将ignore_format分散到各个文件夹中,不必集中在根目录下 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/net/.ignore_format.yml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 components/net/.ignore_format.yml (limited to 'components') diff --git a/components/net/.ignore_format.yml b/components/net/.ignore_format.yml new file mode 100644 index 0000000000..20c40e6436 --- /dev/null +++ b/components/net/.ignore_format.yml @@ -0,0 +1,9 @@ +# files format check exclude path, please follow the instructions below to modify; +# If you need to exclude an entire folder, add the folder path in dir_path; +# If you need to exclude a file, add the path to the file in file_path. + +dir_path: +- lwip-1.4.1 +- lwip-2.0.2 +- lwip-2.0.3 +- lwip-2.1.2 -- cgit v1.3.1 From ee4b7916a35cff4c97103fe631a2eba7eccd69ac Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Wed, 22 Sep 2021 16:45:21 -0400 Subject: [libc标准化]脱敏dfs_select.h 由标准sys/select.h代替 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/dfs/src/dfs_select.c | 2 +- components/lwp/lwp_syscall.c | 2 +- components/net/sal_socket/SConscript | 3 --- .../sal_socket/include/dfs_net/sys_select/sys/select.h | 16 ---------------- examples/libc/termios_test.c | 2 +- examples/rt-link/rtlink_dev_example.c | 2 +- 6 files changed, 4 insertions(+), 23 deletions(-) delete mode 100644 components/net/sal_socket/include/dfs_net/sys_select/sys/select.h (limited to 'components') diff --git a/components/dfs/src/dfs_select.c b/components/dfs/src/dfs_select.c index ca9c549259..795b816354 100644 --- a/components/dfs/src/dfs_select.c +++ b/components/dfs/src/dfs_select.c @@ -12,7 +12,7 @@ #include #include -#include +#include #ifdef RT_USING_POSIX diff --git a/components/lwp/lwp_syscall.c b/components/lwp/lwp_syscall.c index d9112eed3e..f9bc84ea97 100644 --- a/components/lwp/lwp_syscall.c +++ b/components/lwp/lwp_syscall.c @@ -14,7 +14,7 @@ #include #include -#include +#include #if (defined(RT_USING_SAL) && defined(SAL_USING_POSIX)) #include diff --git a/components/net/sal_socket/SConscript b/components/net/sal_socket/SConscript index cc7634f7d9..3903dce89a 100644 --- a/components/net/sal_socket/SConscript +++ b/components/net/sal_socket/SConscript @@ -26,9 +26,6 @@ if GetDepend('SAL_USING_POSIX'): CPPPATH += [cwd + '/include/dfs_net'] src += Glob('socket/net_sockets.c') src += Glob('dfs_net/*.c') - - if not GetDepend('HAVE_SYS_SELECT_H'): - CPPPATH += [cwd + '/include/dfs_net/sys_select'] if not GetDepend('HAVE_SYS_SOCKET_H'): CPPPATH += [cwd + '/include/socket/sys_socket'] diff --git a/components/net/sal_socket/include/dfs_net/sys_select/sys/select.h b/components/net/sal_socket/include/dfs_net/sys_select/sys/select.h deleted file mode 100644 index f174bc6504..0000000000 --- a/components/net/sal_socket/include/dfs_net/sys_select/sys/select.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2015-05-02 Bernard First version - */ - -#ifndef SELECT_H__ -#define SELECT_H__ - -#include - -#endif diff --git a/examples/libc/termios_test.c b/examples/libc/termios_test.c index f3a6ce3a1c..855bc82b96 100644 --- a/examples/libc/termios_test.c +++ b/examples/libc/termios_test.c @@ -16,7 +16,7 @@ #if defined (RT_USING_POSIX) #include - #include + #include #if defined (RT_USING_POSIX_TERMIOS) #include #else diff --git a/examples/rt-link/rtlink_dev_example.c b/examples/rt-link/rtlink_dev_example.c index d00f916efd..523b67ba53 100644 --- a/examples/rt-link/rtlink_dev_example.c +++ b/examples/rt-link/rtlink_dev_example.c @@ -48,7 +48,7 @@ static rt_err_t rtlink_dev_tx_done(rt_device_t dev, void *buffer) #ifdef RT_USING_POSIX #include #include -#include +#include #define RTLINK01_PATH "/dev/rtlink01" int fd = -1; -- cgit v1.3.1 From d60c968902ce01ebcbb9347d11d78bc8fa2c1b39 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Fri, 24 Sep 2021 23:41:09 -0400 Subject: [libc] 优化fcntl.h定义 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/libc/compilers/common/fcntl.h | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'components') diff --git a/components/libc/compilers/common/fcntl.h b/components/libc/compilers/common/fcntl.h index b98f540627..3460926708 100644 --- a/components/libc/compilers/common/fcntl.h +++ b/components/libc/compilers/common/fcntl.h @@ -12,13 +12,10 @@ #include -#if defined(_WIN32) -#define O_ACCMODE (_O_RDONLY | _O_WRONLY | _O_RDWR) -#endif - -#define O_RDONLY 00 -#define O_WRONLY 01 -#define O_RDWR 02 +#define O_RDONLY 0x0000 /* open for reading only */ +#define O_WRONLY 0x0001 /* open for writing only */ +#define O_RDWR 0x0002 /* open for reading and writing */ +#define O_ACCMODE 0x0003 /* mask for above modes */ #define O_CREAT 0100 #define O_EXCL 0200 @@ -43,8 +40,6 @@ #define O_SEARCH O_PATH #define O_EXEC O_PATH -#define O_ACCMODE (03|O_SEARCH) - #define F_DUPFD 0 #define F_GETFD 1 #define F_SETFD 2 -- cgit v1.3.1 From cba2dd901652ec6705da6922d0a0923f111a9768 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Sat, 25 Sep 2021 11:59:13 -0400 Subject: [fatfs] 修改互斥保护超时时间 防止因一些正常复杂耗时操作,导致fatfs认为 timeout failure。 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/dfs/filesystems/elmfat/ffconf.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'components') diff --git a/components/dfs/filesystems/elmfat/ffconf.h b/components/dfs/filesystems/elmfat/ffconf.h index a17a07d8ea..d62ee4906a 100644 --- a/components/dfs/filesystems/elmfat/ffconf.h +++ b/components/dfs/filesystems/elmfat/ffconf.h @@ -295,12 +295,13 @@ / lock control is independent of re-entrancy. */ /* #include // O/S definitions */ +#include #ifdef RT_DFS_ELM_REENTRANT #define FF_FS_REENTRANT 1 /* 0 or 1 */ #else #define FF_FS_REENTRANT 0 /* 0:Disable or 1:Enable */ #endif -#define FF_FS_TIMEOUT 1000 +#define FF_FS_TIMEOUT 3000 #define FF_SYNC_t rt_mutex_t /* The option FF_FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs / module itself. Note that regardless of this option, file access to different -- cgit v1.3.1 From 50e215cfd4ef4bd9b57c70612a4704454e689130 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Sat, 25 Sep 2021 12:00:44 -0400 Subject: [dfs][filesystems] 增加format_ignore文件,排除fatfs格式检查 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/dfs/filesystems/.ignore_format.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 components/dfs/filesystems/.ignore_format.yml (limited to 'components') diff --git a/components/dfs/filesystems/.ignore_format.yml b/components/dfs/filesystems/.ignore_format.yml new file mode 100644 index 0000000000..e72719df1d --- /dev/null +++ b/components/dfs/filesystems/.ignore_format.yml @@ -0,0 +1,4 @@ +# files format check exclude path, please follow the instructions below to modify; + +dir_path: +- elmfat -- cgit v1.3.1 From 32e9aa21c4afc5b1f6f163d58644174d3783032f Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Sat, 25 Sep 2021 12:15:41 -0400 Subject: [fatfs] 修复time相关函数开启条件 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/dfs/filesystems/elmfat/dfs_elm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'components') diff --git a/components/dfs/filesystems/elmfat/dfs_elm.c b/components/dfs/filesystems/elmfat/dfs_elm.c index 41f99d7b62..01d303f71f 100644 --- a/components/dfs/filesystems/elmfat/dfs_elm.c +++ b/components/dfs/filesystems/elmfat/dfs_elm.c @@ -945,7 +945,7 @@ DWORD get_fattime(void) { DWORD fat_time = 0; -#ifdef RT_LIBC_USING_TIME +#if defined(RT_LIBC_USING_TIME) || defined(RT_USING_LIBC) time_t now; struct tm *p_tm; struct tm tm_now; @@ -968,7 +968,7 @@ DWORD get_fattime(void) (DWORD)tm_now.tm_hour << 11 | (DWORD)tm_now.tm_min << 5 | (DWORD)tm_now.tm_sec / 2 ; -#endif /* RT_USING_LIBC */ +#endif /* defined(RT_LIBC_USING_TIME) || defined(RT_USING_LIBC) */ return fat_time; } -- cgit v1.3.1 From d4a5edf0747de4d1d0604ec8ef394efa6e1bb2c5 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Sat, 25 Sep 2021 13:03:23 -0400 Subject: [libc]重构_libc_init_array 防止gcc下芯片无法启动 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/libc/compilers/newlib/minilib.c | 6 ++++++ components/libc/compilers/newlib/syscalls.c | 1 + 2 files changed, 7 insertions(+) (limited to 'components') diff --git a/components/libc/compilers/newlib/minilib.c b/components/libc/compilers/newlib/minilib.c index 612554ca66..7aed3aa36e 100644 --- a/components/libc/compilers/newlib/minilib.c +++ b/components/libc/compilers/newlib/minilib.c @@ -64,3 +64,9 @@ void * _sbrk_r(struct _reent *ptr, ptrdiff_t incr) return RT_NULL; } #endif /*RT_USING_HEAP*/ + +void __libc_init_array(void) +{ + /* we not use __libc init_aray to initialize C++ objects */ + /* __libc_init_array is ARM code, not Thumb; it will cause hardfault. */ +} diff --git a/components/libc/compilers/newlib/syscalls.c b/components/libc/compilers/newlib/syscalls.c index aeb4d123e7..b2258c3345 100644 --- a/components/libc/compilers/newlib/syscalls.c +++ b/components/libc/compilers/newlib/syscalls.c @@ -303,6 +303,7 @@ void _system(const char *s) void __libc_init_array(void) { /* we not use __libc init_aray to initialize C++ objects */ + /* __libc_init_array is ARM code, not Thumb; it will cause hardfault. */ } mode_t umask(mode_t mask) -- cgit v1.3.1 From 1d00635ee92760b59e45e55b1d47199201c0a390 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Sat, 25 Sep 2021 13:45:55 -0400 Subject: [fatfs] 互斥量保护超时可通过Kconfig配置时间 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/dfs/Kconfig | 6 ++++++ components/dfs/filesystems/elmfat/ffconf.h | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'components') diff --git a/components/dfs/Kconfig b/components/dfs/Kconfig index 442c3bb260..7a4fbb655d 100644 --- a/components/dfs/Kconfig +++ b/components/dfs/Kconfig @@ -122,6 +122,12 @@ if RT_USING_DFS config RT_DFS_ELM_REENTRANT bool "Enable the reentrancy (thread safe) of the FatFs module" default y + + config RT_DFS_ELM_MUTEX_TIMEOUT + int "Timeout of thread-safe protection mutex" + range 0 1000000 + default 3000 + depends on RT_DFS_ELM_REENTRANT endmenu endif diff --git a/components/dfs/filesystems/elmfat/ffconf.h b/components/dfs/filesystems/elmfat/ffconf.h index d62ee4906a..a6dcebe228 100644 --- a/components/dfs/filesystems/elmfat/ffconf.h +++ b/components/dfs/filesystems/elmfat/ffconf.h @@ -301,7 +301,10 @@ #else #define FF_FS_REENTRANT 0 /* 0:Disable or 1:Enable */ #endif -#define FF_FS_TIMEOUT 3000 +#ifndef RT_DFS_ELM_MUTEX_TIMEOUT +#define RT_DFS_ELM_MUTEX_TIMEOUT 3000 +#endif +#define FF_FS_TIMEOUT RT_DFS_ELM_MUTEX_TIMEOUT #define FF_SYNC_t rt_mutex_t /* The option FF_FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs / module itself. Note that regardless of this option, file access to different -- cgit v1.3.1 From a0e800617cb9b2e76ec1807a24af189c42ab456f Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Sat, 25 Sep 2021 14:56:10 -0400 Subject: [libc][newlib] 优化syscall 将minilib.c并入syscalls.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/libc/compilers/newlib/SConscript | 3 +- components/libc/compilers/newlib/minilib.c | 72 -------------- components/libc/compilers/newlib/syscalls.c | 143 +++++++++++++++------------- 3 files changed, 76 insertions(+), 142 deletions(-) delete mode 100644 components/libc/compilers/newlib/minilib.c (limited to 'components') diff --git a/components/libc/compilers/newlib/SConscript b/components/libc/compilers/newlib/SConscript index 542cdecd40..cef546e17c 100644 --- a/components/libc/compilers/newlib/SConscript +++ b/components/libc/compilers/newlib/SConscript @@ -18,11 +18,10 @@ if rtconfig.PLATFORM == 'gcc': LIBS += ['c', 'm'] src += Glob('*.c') - SrcRemove(src, ['minilib.c']) if GetDepend('RT_USING_MODULE') == False: SrcRemove(src, ['libc_syms.c']) else: - src += ['minilib.c'] + src += ['syscalls.c'] group = DefineGroup('libc', src, depend = [], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES, LIBS = LIBS) diff --git a/components/libc/compilers/newlib/minilib.c b/components/libc/compilers/newlib/minilib.c deleted file mode 100644 index 7aed3aa36e..0000000000 --- a/components/libc/compilers/newlib/minilib.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2021-02-23 Meco Man first version - */ - -#include -#include - -#ifdef RT_USING_HEAP /* Memory routine */ -#include - -void * _malloc_r (struct _reent *ptr, size_t size) -{ - void* result; - - result = (void*)rt_malloc (size); - if (result == RT_NULL) - { - ptr->_errno = ENOMEM; - } - - return result; -} - -void * _realloc_r (struct _reent *ptr, void *old, size_t newlen) -{ - void* result; - - result = (void*)rt_realloc (old, newlen); - if (result == RT_NULL) - { - ptr->_errno = ENOMEM; - } - - return result; -} - -void *_calloc_r (struct _reent *ptr, size_t size, size_t len) -{ - void* result; - - result = (void*)rt_calloc (size, len); - if (result == RT_NULL) - { - ptr->_errno = ENOMEM; - } - - return result; -} - -void _free_r (struct _reent *ptr, void *addr) -{ - rt_free (addr); -} - -#else -void * _sbrk_r(struct _reent *ptr, ptrdiff_t incr) -{ - return RT_NULL; -} -#endif /*RT_USING_HEAP*/ - -void __libc_init_array(void) -{ - /* we not use __libc init_aray to initialize C++ objects */ - /* __libc_init_array is ARM code, not Thumb; it will cause hardfault. */ -} diff --git a/components/libc/compilers/newlib/syscalls.c b/components/libc/compilers/newlib/syscalls.c index b2258c3345..29ffd41ac1 100644 --- a/components/libc/compilers/newlib/syscalls.c +++ b/components/libc/compilers/newlib/syscalls.c @@ -11,17 +11,81 @@ * 2020-02-24 Meco Man fix bug of _isatty_r() */ -#include -#include -#include -#include - #include +#include +#include + +#define DBG_TAG "newlib.syscalls" +#define DBG_LVL DBG_INFO +#include + +#ifdef RT_USING_HEAP /* Memory routine */ +void *_malloc_r (struct _reent *ptr, size_t size) +{ + void* result; + result = (void*)rt_malloc (size); + if (result == RT_NULL) + { + ptr->_errno = ENOMEM; + } + + return result; +} + +void *_realloc_r (struct _reent *ptr, void *old, size_t newlen) +{ + void* result; + + result = (void*)rt_realloc (old, newlen); + if (result == RT_NULL) + { + ptr->_errno = ENOMEM; + } + + return result; +} + +void *_calloc_r (struct _reent *ptr, size_t size, size_t len) +{ + void* result; + + result = (void*)rt_calloc (size, len); + if (result == RT_NULL) + { + ptr->_errno = ENOMEM; + } + + return result; +} + +void _free_r (struct _reent *ptr, void *addr) +{ + rt_free (addr); +} + +#else +void * +_sbrk_r(struct _reent *ptr, ptrdiff_t incr) +{ + LOG_E("Please enable RT_USING_HEAP or RT_USING_LIBC"); + RT_ASSERT(0); + return RT_NULL; +} +#endif /*RT_USING_HEAP*/ + +void __libc_init_array(void) +{ + /* we not use __libc init_aray to initialize C++ objects */ + /* __libc_init_array is ARM code, not Thumb; it will cause a hardfault. */ +} + +#ifdef RT_USING_LIBC +#include +#include #ifdef RT_USING_DFS #include #endif - #ifdef RT_USING_MODULE #include #endif @@ -233,58 +297,11 @@ _ssize_t _write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes) #endif } -#ifdef RT_USING_HEAP /* Memory routine */ -void *_malloc_r (struct _reent *ptr, size_t size) -{ - void* result; - - result = (void*)rt_malloc (size); - if (result == RT_NULL) - { - ptr->_errno = ENOMEM; - } - - return result; -} - -void *_realloc_r (struct _reent *ptr, void *old, size_t newlen) -{ - void* result; - - result = (void*)rt_realloc (old, newlen); - if (result == RT_NULL) - { - ptr->_errno = ENOMEM; - } - - return result; -} - -void *_calloc_r (struct _reent *ptr, size_t size, size_t len) -{ - void* result; - - result = (void*)rt_calloc (size, len); - if (result == RT_NULL) - { - ptr->_errno = ENOMEM; - } - - return result; -} - -void _free_r (struct _reent *ptr, void *addr) -{ - rt_free (addr); -} - -#else -void * -_sbrk_r(struct _reent *ptr, ptrdiff_t incr) +void _system(const char *s) { - return RT_NULL; + extern int __rt_libc_system(const char *string); + __rt_libc_system(s); } -#endif /*RT_USING_HEAP*/ /* for exit() and abort() */ __attribute__ ((noreturn)) void _exit (int status) @@ -294,18 +311,6 @@ __attribute__ ((noreturn)) void _exit (int status) while(1); } -void _system(const char *s) -{ - extern int __rt_libc_system(const char *string); - __rt_libc_system(s); -} - -void __libc_init_array(void) -{ - /* we not use __libc init_aray to initialize C++ objects */ - /* __libc_init_array is ARM code, not Thumb; it will cause hardfault. */ -} - mode_t umask(mode_t mask) { return 022; @@ -321,3 +326,5 @@ These functions are implemented and replaced by the 'common/time.c' file int _gettimeofday_r(struct _reent *ptr, struct timeval *__tp, void *__tzp); _CLOCK_T_ _times_r(struct _reent *ptr, struct tms *ptms); */ + +#endif /* RT_USING_LIBC */ -- cgit v1.3.1 From df04d970261a0a9c3609b64ae99486508a8b1574 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Sat, 25 Sep 2021 15:03:57 -0400 Subject: [libc]在开启libc后依然保持RT_LIBC_USING_TIME定义存在 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/libc/Kconfig | 3 +++ 1 file changed, 3 insertions(+) (limited to 'components') diff --git a/components/libc/Kconfig b/components/libc/Kconfig index 37a98ba836..b9600ef389 100644 --- a/components/libc/Kconfig +++ b/components/libc/Kconfig @@ -41,6 +41,9 @@ if RT_USING_LIBC && RT_USING_DFS endif if RT_USING_LIBC + config RT_LIBC_USING_TIME + default y + config RT_USING_MODULE bool "Enable dynamic module with dlopen/dlsym/dlclose feature" default n -- cgit v1.3.1