From dd2fd0b1808a272659176e5e6de0738863703297 Mon Sep 17 00:00:00 2001 From: BernardXiong Date: Mon, 3 May 2021 13:23:21 +0800 Subject: [PATCH 1/5] [lwIP] fix ESHUTDOWN definitions issue --- .../net/lwip-2.1.2/src/arch/include/arch/cc.h | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/components/net/lwip-2.1.2/src/arch/include/arch/cc.h b/components/net/lwip-2.1.2/src/arch/include/arch/cc.h index 49c7541ed7..ea6a5ff755 100644 --- a/components/net/lwip-2.1.2/src/arch/include/arch/cc.h +++ b/components/net/lwip-2.1.2/src/arch/include/arch/cc.h @@ -45,20 +45,6 @@ #define S32_F "ld" #define X32_F "lx" -#ifdef RT_USING_LIBC -#if defined(__CC_ARM) || defined(__CLANG_ARM) || defined(__IAR_SYSTEMS_ICC__) -#include -#else -#include -/* some errno not defined in newlib */ -#define ENSRNOTFOUND 163 /* Domain name not found */ -/* WARNING: ESHUTDOWN also not defined in newlib. We chose - 180 here because the number "108" which is used - in arch.h has been assigned to another error code. */ -#define ESHUTDOWN 180 -#endif /* __CC_ARM/__IAR_SYSTEMS_ICC__ */ -#endif /* RT_USING_LIBC */ - #if defined(RT_USING_LIBC) || defined(RT_USING_MINILIBC) || defined(RT_LIBC_USING_TIME) || (defined( __GNUC__ ) && !defined(__ARMCC_VERSION)) #include #define LWIP_TIMEVAL_PRIVATE 0 -- Gitee From 13bda185cdb8f181d6a1cbb0f9cb4b36e229c107 Mon Sep 17 00:00:00 2001 From: BernardXiong Date: Mon, 3 May 2021 13:24:00 +0800 Subject: [PATCH 2/5] [kernel] change RT_VER_NUM to 0x50000 --- src/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Kconfig b/src/Kconfig index 2508c2b550..fd59cdd34d 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -343,7 +343,7 @@ endmenu config RT_VER_NUM hex - default 0x40003 + default 0x50000 help RT-Thread version number -- Gitee From 1cdb655a8b9d365ebf9765393e101f623030e4bf Mon Sep 17 00:00:00 2001 From: BernardXiong Date: Mon, 3 May 2021 13:25:00 +0800 Subject: [PATCH 3/5] [libcpu] fix the cacheflush issue when lwP is not enable --- libcpu/arm/cortex-a/cache.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libcpu/arm/cortex-a/cache.c b/libcpu/arm/cortex-a/cache.c index 826056d565..411c9838bf 100644 --- a/libcpu/arm/cortex-a/cache.c +++ b/libcpu/arm/cortex-a/cache.c @@ -123,6 +123,7 @@ rt_base_t rt_hw_cpu_dcache_status(void) return 0; } +#ifdef RT_USING_LWP #define ICACHE (1<<0) #define DCACHE (1<<1) #define BCACHE (ICACHE|DCACHE) @@ -143,3 +144,4 @@ int sys_cacheflush(void *addr, int size, int cache) } return -1; } +#endif -- Gitee From a6f6a2ff3020cce716fe075d360a92b5c5b1b70e Mon Sep 17 00:00:00 2001 From: BernardXiong Date: Mon, 3 May 2021 13:28:13 +0800 Subject: [PATCH 4/5] [libc] use musl in default when enable RT_USING_LWP --- components/libc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/libc/Kconfig b/components/libc/Kconfig index 86e42b53a1..bb17d740b5 100644 --- a/components/libc/Kconfig +++ b/components/libc/Kconfig @@ -7,7 +7,7 @@ config RT_USING_LIBC if RT_USING_LIBC && RT_USING_LWP choice prompt "Select c standard library" - default RT_USING_NEWLIB + default RT_USING_MUSL help Select c standard library -- Gitee From 901bea01dd592a51f72796c5d4a40777129e52c3 Mon Sep 17 00:00:00 2001 From: BernardXiong Date: Mon, 3 May 2021 13:29:09 +0800 Subject: [PATCH 5/5] [libc] Add set command for env in musl --- components/libc/compilers/musl/libc.c | 56 ++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 9 deletions(-) diff --git a/components/libc/compilers/musl/libc.c b/components/libc/compilers/musl/libc.c index 502cca50ed..3ef780de0d 100644 --- a/components/libc/compilers/musl/libc.c +++ b/components/libc/compilers/musl/libc.c @@ -15,15 +15,14 @@ #include "libc.h" -#ifdef RT_USING_PTHREADS -#include -#endif - int _EXFUN(putenv,(char *__string)); +extern char **__environ; int libc_system_init(void) { -#if defined(RT_USING_DFS) & defined(RT_USING_DFS_DEVFS) & defined(RT_USING_CONSOLE) +#if defined(RT_USING_DFS) & defined(RT_USING_DFS_DEVFS) + +#if defined(RT_USING_CONSOLE) rt_device_t dev_console; dev_console = rt_console_get_device(); @@ -35,16 +34,55 @@ int libc_system_init(void) libc_stdio_set_console(dev_console->parent.name, O_WRONLY); #endif } +#endif /* set PATH and HOME */ putenv("PATH=/bin"); putenv("HOME=/home"); #endif -#if defined RT_USING_PTHREADS && !defined RT_USING_COMPONENTS_INIT - pthread_system_init(); -#endif - return 0; } INIT_COMPONENT_EXPORT(libc_system_init); + +int env_set(int argc, char** argv) +{ + switch (argc) + { + case 1: + { + int index; + + /* show all of environment variables */ + for(index = 0; __environ[index]!=NULL; index++) + { + printf("%2d.%s\n", index, __environ[index]); + } + } + break; + case 2: + { + char *c = strchr(argv[1], '='); + if (c) + { + /* use setenv to add/update environment variable */ + *c = '\0'; + setenv(argv[1], c + 1, 1); + } + else + { + const char *value = getenv(argv[1]); + if (value) + { + printf("%s=%s\n", argv[1], value); + } + } + } + break; + default: + break; + } + + return 0; +} +MSH_CMD_EXPORT_ALIAS(env_set, set, set or show environment variable); -- Gitee