From 04d3d130815d8dd8f1817b3fbcc251bee0bd670c Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Tue, 30 Nov 2021 10:34:42 -0500 Subject: [PATCH 1/4] =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E5=AE=8F=E5=AE=9A?= =?UTF-8?q?=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bsp/lpc55sxx/lpc55s69_nxp_evk/board/Kconfig | 1 - bsp/stm32/stm32l475-atk-pandora/board/Kconfig | 2 +- components/cplusplus/Kconfig | 2 +- components/utilities/ymodem/ry_sy.c | 4 ++++ 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/bsp/lpc55sxx/lpc55s69_nxp_evk/board/Kconfig b/bsp/lpc55sxx/lpc55s69_nxp_evk/board/Kconfig index a73ae472d7..94669d3736 100644 --- a/bsp/lpc55sxx/lpc55s69_nxp_evk/board/Kconfig +++ b/bsp/lpc55sxx/lpc55s69_nxp_evk/board/Kconfig @@ -137,7 +137,6 @@ menu "On-chip Peripheral Drivers" select RT_USING_SDIO select RT_USING_DFS select RT_USING_DFS_ELMFAT - select RT_USING_LIBC select RT_LIBC_USING_TIME default y diff --git a/bsp/stm32/stm32l475-atk-pandora/board/Kconfig b/bsp/stm32/stm32l475-atk-pandora/board/Kconfig index d71766c5d1..d4ea946684 100644 --- a/bsp/stm32/stm32l475-atk-pandora/board/Kconfig +++ b/bsp/stm32/stm32l475-atk-pandora/board/Kconfig @@ -137,8 +137,8 @@ menu "Onboard Peripheral Drivers" select RT_WLAN_PROT_LWIP_PBUF_FORCE select RT_USING_LWIP select RT_USING_LIBC - select RT_USING_POSIX select RT_USING_DFS + select DFS_USING_POSIX select PKG_USING_FAL select PKG_USING_EASYFLASH select RT_USING_WIFI_6181_LIB diff --git a/components/cplusplus/Kconfig b/components/cplusplus/Kconfig index dfab433da0..42b5cf9556 100644 --- a/components/cplusplus/Kconfig +++ b/components/cplusplus/Kconfig @@ -10,7 +10,7 @@ if RT_USING_CPLUSPLUS bool "Enable c++11 threading feature support" default n select RT_USING_LIBC - select RT_USING_DFS + select RT_LIBC_USING_FILEIO select RT_USING_PTHREADS select RT_USING_RTC diff --git a/components/utilities/ymodem/ry_sy.c b/components/utilities/ymodem/ry_sy.c index caad51d6cd..3f3b022d7e 100644 --- a/components/utilities/ymodem/ry_sy.c +++ b/components/utilities/ymodem/ry_sy.c @@ -17,6 +17,10 @@ #include #include +#ifndef DFS_USING_POSIX +#error "Please enable DFS_USING_POSIX" +#endif + struct custom_ctx { struct rym_ctx parent; From b61cc91d14a392de17fa1c5250a842b02b6b7e2c Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Tue, 30 Nov 2021 14:50:10 -0500 Subject: [PATCH 2/4] =?UTF-8?q?[posix]=20=E5=B0=86posix=E5=8D=95=E7=8B=AC?= =?UTF-8?q?=E5=88=92=E5=88=86=E4=B8=BA=E4=B8=80=E4=B8=AAKconfig=E7=9B=AE?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/libc/Kconfig | 57 ++-------------------------------- components/libc/posix/Kconfig | 58 +++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 55 deletions(-) create mode 100644 components/libc/posix/Kconfig diff --git a/components/libc/Kconfig b/components/libc/Kconfig index dfbe73aa14..69f8e1ae36 100644 --- a/components/libc/Kconfig +++ b/components/libc/Kconfig @@ -1,7 +1,7 @@ menu "POSIX layer and C standard library" config RT_USING_LIBC - bool "Enable libc APIs from toolchain" + bool "Enable libc APIs from the toolchain" default n if RT_USING_LIBC @@ -37,59 +37,6 @@ config RT_LIBC_DEFAULT_TIMEZONE range -12 12 default 8 -config RT_USING_POSIX_FS - bool "Enable POSIX file system, open()/read()/write()/close() etc" - select RT_USING_DFS - select DFS_USING_POSIX - default n - -if RT_USING_POSIX_FS - config RT_USING_POSIX_DEVIO - bool "Enable devices as file descriptors" - select RT_USING_DFS_DEVFS - default n - - config RT_USING_POSIX_POLL - bool "Enable poll()" - default n - - config RT_USING_POSIX_SELECT - bool "Enable select()" - select RT_USING_POSIX_POLL - default n -endif - -config RT_USING_POSIX_DELAY - bool "Enable delay APIs, sleep()/usleep()/msleep() etc" - default n - -config RT_USING_POSIX_GETLINE - bool "Enable getline()/getdelim()" - select RT_USING_LIBC - select RT_LIBC_USING_FILEIO - default n - -config RT_USING_POSIX_MMAP - bool "Enable mmap()" - select RT_USING_POSIX_FS - default n - -config RT_USING_POSIX_TERMIOS - bool "Enable termios APIs" - default n - -config RT_USING_POSIX_AIO - bool "Enable AIO APIs" - default n - -config RT_USING_PTHREADS - bool "Enable pthreads APIs" - default n - -if RT_USING_PTHREADS - config PTHREAD_NUM_MAX - int "Maximum number of pthreads" - default 8 -endif +source "$RTT_DIR/components/libc/posix/Kconfig" endmenu diff --git a/components/libc/posix/Kconfig b/components/libc/posix/Kconfig new file mode 100644 index 0000000000..0afff161ff --- /dev/null +++ b/components/libc/posix/Kconfig @@ -0,0 +1,58 @@ +menu "POSIX (Portable Operating System Interface) layer" + +config RT_USING_POSIX_FS + bool "Enable POSIX file system, open()/read()/write()/close() etc" + select RT_USING_DFS + select DFS_USING_POSIX + default n + +if RT_USING_POSIX_FS + config RT_USING_POSIX_DEVIO + bool "Enable devices as file descriptors" + select RT_USING_DFS_DEVFS + default n + + config RT_USING_POSIX_POLL + bool "Enable poll()" + default n + + config RT_USING_POSIX_SELECT + bool "Enable select()" + select RT_USING_POSIX_POLL + default n +endif + +config RT_USING_POSIX_DELAY + bool "Enable delay APIs, sleep()/usleep()/msleep() etc" + default n + +config RT_USING_POSIX_GETLINE + bool "Enable getline()/getdelim()" + select RT_USING_LIBC + select RT_LIBC_USING_FILEIO + default n + +config RT_USING_POSIX_MMAP + bool "Enable mmap()" + select RT_USING_POSIX_FS + default n + +config RT_USING_POSIX_TERMIOS + bool "Enable termios APIs" + default n + +config RT_USING_POSIX_AIO + bool "Enable AIO APIs" + default n + +config RT_USING_PTHREADS + bool "Enable pthreads APIs" + default n + +if RT_USING_PTHREADS + config PTHREAD_NUM_MAX + int "Maximum number of pthreads" + default 8 +endif + +endmenu From 43ebe094e34449221e9716e3168f08764b6f7fd6 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Tue, 30 Nov 2021 18:03:48 -0500 Subject: [PATCH 3/4] =?UTF-8?q?[pipe]=20=E8=A1=A5=E5=85=85=E6=B3=A8?= =?UTF-8?q?=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/drivers/src/pipe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/drivers/src/pipe.c b/components/drivers/src/pipe.c index 1d803e9a4c..89b544bc4e 100644 --- a/components/drivers/src/pipe.c +++ b/components/drivers/src/pipe.c @@ -439,7 +439,7 @@ const static struct rt_device_ops pipe_ops = rt_pipe_write, rt_pipe_control, }; -#endif +#endif /* RT_USING_DEVICE_OPS */ rt_pipe_t *rt_pipe_create(const char *name, int bufsz) { @@ -481,7 +481,7 @@ rt_pipe_t *rt_pipe_create(const char *name, int bufsz) } #ifdef RT_USING_POSIX_DEVIO dev->fops = (void*)&pipe_fops; -#endif +#endif /* RT_USING_POSIX_DEVIO */ return pipe; } From 7b1f65a690c8f28d172e640989643df12597fa7a Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Wed, 1 Dec 2021 02:19:15 -0500 Subject: [PATCH 4/4] [libc][keil] fix the bug of _sys_read and _sys_write --- components/libc/compilers/armlibc/syscalls.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/components/libc/compilers/armlibc/syscalls.c b/components/libc/compilers/armlibc/syscalls.c index bfd3777193..0e965d62af 100644 --- a/components/libc/compilers/armlibc/syscalls.c +++ b/components/libc/compilers/armlibc/syscalls.c @@ -156,22 +156,26 @@ int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode) return 0; /* error, but keep going */ } size = read(STDIN_FILENO, buf, len); - return 0; /* success */ + return len - size; /* success */ #else return 0; /* error */ #endif /* RT_USING_POSIX_DEVIO */ } else if (fh == STDOUT || fh == STDERR) { - return 0; /* error */ + return -1; /* 100% error */ } else { size = read(fh, buf, len); if (size >= 0) + { return len - size; /* success */ + } else + { return 0; /* error */ + } } #else return 0; /* error */ @@ -209,16 +213,20 @@ int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode) } else if (fh == STDIN) { - return 0; /* error */ + return -1; /* 100% error */ } else { #ifdef DFS_USING_POSIX size = write(fh, buf, len); if (size >= 0) - return 0; /* success */ + { + return len - size; /* success */ + } else + { return 0; /* error */ + } #else return 0; /* error */ #endif /* DFS_USING_POSIX */