diff --git a/.vscode/settings.json b/.vscode/settings.json index 01bbeee79..68eccfcd2 100755 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -171,7 +171,9 @@ "at_surf_f437_board_sdram.h": "c", "fs_types.h": "c", "u_rpc.h": "c", - "u_env.h": "c" + "u_env.h": "c", + "u_app_loader.h": "c", + "crt_arch_init.h": "c" }, "cortex-debug.showRTOS": false, "cortex-debug.variableUseNaturalFormat": true, diff --git a/armv7_8.cmake b/armv7_8.cmake index cc74f5bdc..66a8fee5e 100644 --- a/armv7_8.cmake +++ b/armv7_8.cmake @@ -1,21 +1,21 @@ message("========use armv7_8.cmake") -set(CMAKE_C_FLAGS "-mcpu=${CONFIG_ARCH} -Ofast -g3 -mfloat-abi=${CONFIG_FLOAT_TYPE} -mthumb -D=MKRTOS \ +set(CMAKE_C_FLAGS "-mcpu=${CONFIG_ARCH} -O0 -g3 -mfloat-abi=${CONFIG_FLOAT_TYPE} -mthumb -DMKRTOS \ -std=gnu11 -ffunction-sections -fdata-sections -fno-builtin -u=_printf_float \ --nostartfiles -nodefaultlibs -nostdlib -nostdinc -Xlinker -mthumb-interwork \ +-nostartfiles -nodefaultlibs -nostdlib -nostdinc -Xlinker \ -fno-stack-protector -Wl,--gc-sections -D__ARM_ARCH_7M__ \ -include ${CMAKE_SOURCE_DIR}/build/autoconf.h \ " CACHE STRING "" FORCE) -set(CMAKE_CXX_FLAGS "-mcpu=${CONFIG_ARCH} -Ofast -g3 -mfloat-abi=${CONFIG_FLOAT_TYPE} -mthumb -D=MKRTOS -std=c++11 \ +set(CMAKE_CXX_FLAGS "-mcpu=${CONFIG_ARCH} -Ofast -g3 -mfloat-abi=${CONFIG_FLOAT_TYPE} -mthumb -DMKRTOS -std=c++11 \ -fmessage-length=0 -Xlinker --print-map -Wall -W -fno-stack-protector -g \ - -u=_printf_float -D__ARM_ARCH_7M__ -mthumb-interwork \ + -u=_printf_float -D__ARM_ARCH_7M__ \ -ffunction-sections -fdata-sections -fno-builtin -nostartfiles -nodefaultlibs -nostdlib -nostdinc -Xlinker \ -include ${CMAKE_SOURCE_DIR}/build/autoconf.h \ " CACHE STRING "" FORCE) -set(CMAKE_ASM_FLAGS "-mcpu=${CONFIG_ARCH} -Ofast -g3 -mfloat-abi=${CONFIG_FLOAT_TYPE} -mthumb -D=MKRTOS \ --u=_printf_float -std=gnu11 -ffunction-sections -fdata-sections -fno-builtin -mthumb-interwork \ +set(CMAKE_ASM_FLAGS "-mcpu=${CONFIG_ARCH} -Ofast -g3 -mfloat-abi=${CONFIG_FLOAT_TYPE} -mthumb -DMKRTOS \ +-u=_printf_float -std=gnu11 -ffunction-sections -fdata-sections -fno-builtin \ -nostartfiles -nodefaultlibs -nostdlib -nostdinc -Xlinker -fno-stack-protector -D__ARM_ARCH_7M__ \ -include ${CMAKE_SOURCE_DIR}/build/autoconf.h \ " CACHE STRING "" FORCE) diff --git a/mkrtos_bootstrap/bsp/STM32F2/link.lds b/mkrtos_bootstrap/bsp/STM32F2/link.lds index e78544635..070e698e6 100644 --- a/mkrtos_bootstrap/bsp/STM32F2/link.lds +++ b/mkrtos_bootstrap/bsp/STM32F2/link.lds @@ -1,10 +1,10 @@ ENTRY(Reset_Handler) -_estack = 0x20000000 + 0x800000; +_estack = 0x20000000 + 0x2000000; _Min_Heap_Size = 0; _Min_Stack_Size = 0x300; MEMORY { -RAM (xrw) : ORIGIN = 0x20000000 + 0x800000 - 0x4000, LENGTH = 0x4000 - 0x300 +RAM (xrw) : ORIGIN = 0x20000000 + 0x2000000 - 0x4000, LENGTH = 0x4000 - 0x300 FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 0x2000 } SECTIONS diff --git a/mkrtos_configs/STM32F205_defconfig b/mkrtos_configs/STM32F205_defconfig index 59e154d85..f3293f7b1 100644 --- a/mkrtos_configs/STM32F205_defconfig +++ b/mkrtos_configs/STM32F205_defconfig @@ -6,7 +6,7 @@ CONFIG_KNL_INFO=y CONFIG_SYS_TEXT_ADDR=0x8000000 CONFIG_SYS_TEXT_SIZE=0x800000 CONFIG_SYS_DATA_ADDR=0x20000000 -CONFIG_SYS_DATA_SIZE=0x800000 +CONFIG_SYS_DATA_SIZE=0x2000000 CONFIG_BOOTSTRAP_TEXT_SIZE=0x2000 CONFIG_DTBO_TEXT_SIZE=0x1000 CONFIG_KNL_TEXT_SIZE=0x30000 @@ -37,77 +37,6 @@ CONFIG_SIG_THREAD_STACK_SIZE=512 CONFIG_SIG_THREAD_PRIO=3 # end of Sys util config -# -# DFS: device virtual file system -# -CONFIG_RT_USING_DFS=y -CONFIG_DFS_USING_POSIX=y -CONFIG_DFS_USING_WORKDIR=y -# CONFIG_RT_USING_DFS_MNTTABLE is not set -CONFIG_DFS_FD_MAX=16 -CONFIG_RT_USING_DFS_V1=y -# CONFIG_RT_USING_DFS_V2 is not set -CONFIG_DFS_FILESYSTEMS_MAX=4 -CONFIG_DFS_FILESYSTEM_TYPES_MAX=4 -# CONFIG_RT_USING_DFS_ELMFAT is not set -CONFIG_RT_USING_DFS_DEVFS=y -# CONFIG_RT_USING_DFS_ROMFS is not set -# CONFIG_RT_USING_DFS_CROMFS is not set -# CONFIG_RT_USING_DFS_RAMFS is not set -# CONFIG_RT_USING_DFS_TMPFS is not set -# CONFIG_RT_USING_DFS_MQUEUE is not set -# end of DFS: device virtual file system - -# -# Device Drivers -# -# CONFIG_RT_USING_DM is not set -CONFIG_RT_USING_DEVICE_IPC=y -CONFIG_RT_UNAMED_PIPE_NUMBER=64 -# CONFIG_RT_USING_SYSTEM_WORKQUEUE is not set -CONFIG_RT_USING_SERIAL=y -CONFIG_RT_USING_SERIAL_V1=y -# CONFIG_RT_USING_SERIAL_V2 is not set -CONFIG_RT_SERIAL_USING_DMA=y -CONFIG_RT_SERIAL_RB_BUFSZ=64 -# CONFIG_RT_USING_CAN is not set -# CONFIG_RT_USING_HWTIMER is not set -# CONFIG_RT_USING_CPUTIME is not set -# CONFIG_RT_USING_I2C is not set -# CONFIG_RT_USING_PHY is not set -CONFIG_RT_USING_PIN=y -# CONFIG_RT_USING_ADC is not set -# CONFIG_RT_USING_DAC is not set -# CONFIG_RT_USING_NULL is not set -# CONFIG_RT_USING_ZERO is not set -# CONFIG_RT_USING_RANDOM is not set -# CONFIG_RT_USING_PWM is not set -# CONFIG_RT_USING_MTD_NOR is not set -# CONFIG_RT_USING_MTD_NAND is not set -# CONFIG_RT_USING_PM is not set -# CONFIG_RT_USING_RTC is not set -# CONFIG_RT_USING_SDIO is not set -# CONFIG_RT_USING_SPI is not set -# CONFIG_RT_USING_WDT is not set -# CONFIG_RT_USING_AUDIO is not set -# CONFIG_RT_USING_SENSOR is not set -# CONFIG_RT_USING_TOUCH is not set -# CONFIG_RT_USING_LCD is not set -# CONFIG_RT_USING_HWCRYPTO is not set -# CONFIG_RT_USING_PULSE_ENCODER is not set -# CONFIG_RT_USING_INPUT_CAPTURE is not set -# CONFIG_RT_USING_DEV_BUS is not set -# CONFIG_RT_USING_WIFI is not set -# CONFIG_RT_USING_VIRTIO is not set - -# -# Using USB -# -# CONFIG_RT_USING_USB_HOST is not set -# CONFIG_RT_USING_USB_DEVICE is not set -# end of Using USB -# end of Device Drivers - CONFIG_CPU_TYPE="stm32f2" CONFIG_RTT_DIR="./" CONFIG_ARCH="cortex-m3" diff --git a/mkrtos_knl/arch/cortex-m3/link.lds b/mkrtos_knl/arch/cortex-m3/link.lds index 04c380480..4a905ad02 100644 --- a/mkrtos_knl/arch/cortex-m3/link.lds +++ b/mkrtos_knl/arch/cortex-m3/link.lds @@ -1,7 +1,7 @@ ENTRY(Reset_Handler) MEMORY { - RAM (arw) : ORIGIN = 0x20000000, LENGTH = 0x800000 + RAM (arw) : ORIGIN = 0x20000000, LENGTH = 0x2000000 FLASH (arx) : ORIGIN = 0x8000000 + 0x2000 + 0x1000, LENGTH = 0x30000 } SECTIONS diff --git a/mkrtos_knl/drivers/stm32f2/uart/stm32f2_uart.c b/mkrtos_knl/drivers/stm32f2/uart/stm32f2_uart.c index 412904aa1..8f572fa8e 100755 --- a/mkrtos_knl/drivers/stm32f2/uart/stm32f2_uart.c +++ b/mkrtos_knl/drivers/stm32f2/uart/stm32f2_uart.c @@ -125,7 +125,8 @@ static void uart_hardware_flow_rts(USART_TypeDef *USARTx, uint16_t flow) USARTx->CR3 = (uint16_t)tmpreg; } static uart_t uart = { - .baud = 115200}; + .baud = 115200, +}; uart_t *uart_get_global(void) { diff --git a/mkrtos_knl/inc/lib/assert.h b/mkrtos_knl/inc/lib/assert.h index b78131b7f..80d5918ba 100755 --- a/mkrtos_knl/inc/lib/assert.h +++ b/mkrtos_knl/inc/lib/assert.h @@ -18,7 +18,7 @@ printk("\n%s:%d %s\n", __FILE__, __LINE__, #cond); \ dumpstack(); \ mm_trace(); \ - sys_reset(); \ + /*sys_reset();*/ \ while (1) \ ; \ } \ diff --git a/mkrtos_user/lib/CMakeLists.txt b/mkrtos_user/lib/CMakeLists.txt index 116649b8f..c35f412a0 100644 --- a/mkrtos_user/lib/CMakeLists.txt +++ b/mkrtos_user/lib/CMakeLists.txt @@ -7,8 +7,8 @@ if (${ARCH_NAME} STREQUAL "armv7_8m") add_subdirectory(mr) # add_subdirectory(at_device) elseif(${CONFIG_ARCH} STREQUAL "aarch64") - add_subdirectory(mkrtos-musl) endif() +add_subdirectory(mkrtos-musl) add_subdirectory(sys) add_subdirectory(sys_util) add_subdirectory(util) diff --git a/mkrtos_user/lib/letter-shell/demo/mkrtos/shell_port.c b/mkrtos_user/lib/letter-shell/demo/mkrtos/shell_port.c index 62e641964..fd679198c 100644 --- a/mkrtos_user/lib/letter-shell/demo/mkrtos/shell_port.c +++ b/mkrtos_user/lib/letter-shell/demo/mkrtos/shell_port.c @@ -27,7 +27,7 @@ #include "u_sleep.h" static Shell shell; static ShellFs shellFs; -static char shellBuffer[256]; +static char shellBuffer[512]; // static char shellPathBuffer[128] = "/"; /** diff --git a/mkrtos_user/lib/mlibc/CMakeLists.txt b/mkrtos_user/lib/mlibc/CMakeLists.txt index 0062a3887..47cb7ac21 100644 --- a/mkrtos_user/lib/mlibc/CMakeLists.txt +++ b/mkrtos_user/lib/mlibc/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.13) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w -D_XOPEN_SOURCE=700 ") -set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -w -D_XOPEN_SOURCE=700 ") +set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -w -D_XOPEN_SOURCE=700 -Wa,-mimplicit-it=thumb ") file(GLOB_RECURSE deps src/*.C diff --git a/mkrtos_user/lib/mlibc/src/setjmp/arm/longjmp.S b/mkrtos_user/lib/mlibc/src/setjmp/arm/longjmp.S index 0cb3de159..72944b1db 100644 --- a/mkrtos_user/lib/mlibc/src/setjmp/arm/longjmp.S +++ b/mkrtos_user/lib/mlibc/src/setjmp/arm/longjmp.S @@ -7,15 +7,15 @@ _longjmp: longjmp: mov ip,r0 movs r0,r1 - it eq moveq r0,#1 ldmia ip!, {v1,v2,v3,v4,v5,v6,sl,fp} ldmia ip!, {r2,lr} mov sp,r2 - adr r1,1f - ldr r2,1f - ldr r1,[r1,r2] + //adr r1,1f + //ldr r2,1f + //ldr r1,[r1,r2] + mov r1, #0 #if __ARM_ARCH < 8 tst r1,#0x260 @@ -23,12 +23,12 @@ longjmp: // HWCAP_ARM_FPA tst r1,#0x20 beq 2f -// ldc p2, cr4, [ip], #48 + ldc p2, cr4, [ip], #48 #endif 2: tst r1,#0x40 beq 2f -// .fpu vfp -// vldmia ip!, {d8-d15} + .fpu vfp + vldmia ip!, {d8-d15} .fpu softvfp .eabi_attribute 10, 0 .eabi_attribute 27, 0 @@ -36,12 +36,12 @@ longjmp: // HWCAP_ARM_IWMMXT 2: tst r1,#0x200 beq 3f -// ldcl p1, cr10, [ip], #8 -// ldcl p1, cr11, [ip], #8 -// ldcl p1, cr12, [ip], #8 -// ldcl p1, cr13, [ip], #8 -// ldcl p1, cr14, [ip], #8 -// ldcl p1, cr15, [ip], #8 + ldcl p1, cr10, [ip], #8 + ldcl p1, cr11, [ip], #8 + ldcl p1, cr12, [ip], #8 + ldcl p1, cr13, [ip], #8 + ldcl p1, cr14, [ip], #8 + ldcl p1, cr15, [ip], #8 #endif 2: 3: bx lr diff --git a/mkrtos_user/lib/mlibc/src/setjmp/arm/setjmp.S b/mkrtos_user/lib/mlibc/src/setjmp/arm/setjmp.S index ddbc6aba3..b574fc848 100644 --- a/mkrtos_user/lib/mlibc/src/setjmp/arm/setjmp.S +++ b/mkrtos_user/lib/mlibc/src/setjmp/arm/setjmp.S @@ -14,9 +14,10 @@ setjmp: stmia ip!,{r2,lr} mov r0,#0 - adr r1,1f - ldr r2,1f - ldr r1,[r1,r2] + //adr r1,1f + //ldr r2,1f + //ldr r1,[r1,r2] + mov r1, #0 #if __ARM_ARCH < 8 tst r1,#0x260 @@ -24,12 +25,12 @@ setjmp: // HWCAP_ARM_FPA tst r1,#0x20 beq 2f -// stc p2, cr4, [ip], #48 + stc p2, cr4, [ip], #48 #endif 2: tst r1,#0x40 beq 2f -// .fpu vfp -// vstmia ip!, {d8-d15} + .fpu vfp + vstmia ip!, {d8-d15} .fpu softvfp .eabi_attribute 10, 0 .eabi_attribute 27, 0 @@ -37,12 +38,12 @@ setjmp: // HWCAP_ARM_IWMMXT 2: tst r1,#0x200 beq 3f -// stcl p1, cr10, [ip], #8 -// stcl p1, cr11, [ip], #8 -// stcl p1, cr12, [ip], #8 -// stcl p1, cr13, [ip], #8 -// stcl p1, cr14, [ip], #8 -// stcl p1, cr15, [ip], #8 + stcl p1, cr10, [ip], #8 + stcl p1, cr11, [ip], #8 + stcl p1, cr12, [ip], #8 + stcl p1, cr13, [ip], #8 + stcl p1, cr14, [ip], #8 + stcl p1, cr15, [ip], #8 #endif 2: 3: bx lr diff --git a/mkrtos_user/lib/sys_svr/src/fs_cli.c b/mkrtos_user/lib/sys_svr/src/fs_cli.c index f2126d299..8631cf243 100644 --- a/mkrtos_user/lib/sys_svr/src/fs_cli.c +++ b/mkrtos_user/lib/sys_svr/src/fs_cli.c @@ -24,7 +24,11 @@ sd_t fs_open(const char *path, int flags, int mode) if (ret < 0) { - return ret; + ret = ns_query(path, &hd, 0x0); + if (ret < 0) + { + return ret; + } } rpc_ref_file_array_t rpc_path = { diff --git a/mkrtos_user/lib/sys_util/src/u_app_loader.c b/mkrtos_user/lib/sys_util/src/u_app_loader.c index 54ae04d57..b5520b42a 100644 --- a/mkrtos_user/lib/sys_util/src/u_app_loader.c +++ b/mkrtos_user/lib/sys_util/src/u_app_loader.c @@ -19,6 +19,7 @@ #include "cpiofs.h" #include "u_env.h" #include "u_sys.h" + #include #include #include @@ -125,6 +126,10 @@ int app_load(const char *name, uenv_t *cur_env, pid_t *pid, { return -ENOENT; } + // for (int i = 0; i < arg_cn; i++) + // { + // printf("argv[%d]:%s\n", i, argv[i]); + // } int type; umword_t addr; int ret = cpio_find_file((umword_t)sys_info.bootfs_start_addr, (umword_t)(-1), name, NULL, &type, &addr); @@ -254,28 +259,26 @@ int app_load(const char *name, uenv_t *cur_env, pid_t *pid, .rev2 = HANDLER_INVALID, }; umword_t *app_env; - char *cp_args; - char *cp_envp; + char *cp_args[8/*FIXME:*/]; + char *cp_envp[8]; + size_t params_envp_len = 0; app_env = app_stack_push_array(hd_task, &usp_top, (uint8_t *)(&uenv), sizeof(uenv)); for (int i = 0; i < arg_cn; i++) { - cp_args = app_stack_push_str(hd_task, &usp_top, argv[i]); - if ((ALIGN(strlen(argv[i]) + 1, sizeof(void *)) / sizeof(void *)) % 2) - { - app_stack_push_umword(hd_task, &usp_top, 0); - } - printf("app_load 1 cp_args:%p\n", cp_args); + cp_args[i] = app_stack_push_str(hd_task, &usp_top, argv[i]); + params_envp_len += ALIGN(strlen(argv[i]) + 1, sizeof(void *)); + printf("app_load 1 cp_args:%p\n", cp_args[i]); } for (int i = 0; i < envp_cn; i++) { - cp_envp = app_stack_push_str(hd_task, &usp_top, envp[i]); - if ((ALIGN(strlen(argv[i]) + 1, sizeof(void *)) / sizeof(void *)) % 2) - { - app_stack_push_umword(hd_task, &usp_top, 0); - } + cp_envp[i] = app_stack_push_str(hd_task, &usp_top, envp[i]); + params_envp_len += ALIGN(strlen(argv[i]) + 1, sizeof(void *)); + } + if ((umword_t)usp_top & 0x7UL) + { + usp_top = (umword_t *)((umword_t)usp_top & ~0x7UL); } - app_stack_push_umword(hd_task, &usp_top, 0); if ((arg_cn + envp_cn) & 0x1) // 参数是奇数是,多添加一个 { @@ -289,31 +292,15 @@ int app_load(const char *name, uenv_t *cur_env, pid_t *pid, app_stack_push_umword(hd_task, &usp_top, (umword_t)AT_PAGESZ); app_stack_push_umword(hd_task, &usp_top, 0); - for (int i = 0; i < envp_cn; i++) + for (int i = envp_cn - 1; i >= 0; i--) { - app_stack_push_umword(hd_task, &usp_top, (umword_t)cp_envp); - cp_envp += ALIGN(strlen(envp[i]), sizeof(void *)); - if ((ALIGN(strlen(envp[i]) + 1, sizeof(void *)) / sizeof(void *)) % 2) - { - cp_envp += sizeof(void *); - } + app_stack_push_umword(hd_task, &usp_top, (umword_t)cp_envp[i]); } - if (arg_cn) + app_stack_push_umword(hd_task, &usp_top, 0); + for (int i = arg_cn - 1; i >= 0; i--) { - app_stack_push_umword(hd_task, &usp_top, 0); - for (int i = 0; i < arg_cn; i++) - { - if (i != 0) - { - if ((ALIGN(strlen(argv[i]) + 1, sizeof(void *)) / sizeof(void *)) % 2) - { - cp_args += sizeof(void *); - } - } - printf("app_load 2 cp_args:%p\n", cp_args); - app_stack_push_umword(hd_task, &usp_top, (umword_t)cp_args); - cp_args += ALIGN(strlen(argv[i]) + 1, sizeof(void *)); - } + printf("app_load 2 cp_args:%p\n", cp_args[i]); + app_stack_push_umword(hd_task, &usp_top, (umword_t)cp_args[i]); } app_stack_push_umword(hd_task, &usp_top, arg_cn); diff --git a/mkrtos_user/server/fs/CMakeLists.txt b/mkrtos_user/server/fs/CMakeLists.txt index cc4e7e470..577266385 100644 --- a/mkrtos_user/server/fs/CMakeLists.txt +++ b/mkrtos_user/server/fs/CMakeLists.txt @@ -2,5 +2,5 @@ cmake_minimum_required(VERSION 3.13) add_subdirectory(cpiofs) -# add_subdirectory(fatfs) +add_subdirectory(fatfs) # add_subdirectory(lxext4) diff --git a/mkrtos_user/server/fs/fatfs/CMakeLists.txt b/mkrtos_user/server/fs/fatfs/CMakeLists.txt index 5d19c33a1..79cfc3a6e 100644 --- a/mkrtos_user/server/fs/fatfs/CMakeLists.txt +++ b/mkrtos_user/server/fs/fatfs/CMakeLists.txt @@ -66,8 +66,8 @@ add_custom_target( ${CMAKE_SIZE} fatfs.elf COMMAND mkdir -p ${CMAKE_SOURCE_DIR}/build/output/cpio - # COMMAND - # cp fatfs.bin ${CMAKE_SOURCE_DIR}/build/output/cpio/fatfs + COMMAND + cp fatfs.bin ${CMAKE_SOURCE_DIR}/build/output/cpio/fatfs COMMAND cp fatfs.elf ${CMAKE_SOURCE_DIR}/build/output/cpio/fatfs.elf ) diff --git a/mkrtos_user/server/fs/fatfs/main.c b/mkrtos_user/server/fs/fatfs/main.c index 1f0f63198..a5854c0c8 100644 --- a/mkrtos_user/server/fs/fatfs/main.c +++ b/mkrtos_user/server/fs/fatfs/main.c @@ -3,13 +3,22 @@ #include "u_rpc_svr.h" #include "u_prot.h" #include "u_env.h" -#include "u_drv.h" #include "cons_cli.h" #include "fs_rpc.h" #include #include #include #include +#include +#define STACK_COM_ITME_SIZE (2048) +ATTR_ALIGN(8) +uint8_t stack_coms[STACK_COM_ITME_SIZE]; +uint8_t msg_buf_coms[MSG_BUG_LEN]; +void fast_ipc_init(void) +{ + u_fast_ipc_init(stack_coms, msg_buf_coms, 1, STACK_COM_ITME_SIZE); +} + static FATFS fs; static MKFS_PARM defopt = {FM_ANY, 0, 0, 0}; @@ -17,6 +26,7 @@ int main(int args, char *argv[]) { obj_handler_t hd; int ret; + fast_ipc_init(); ret = rpc_meta_init(THREAD_MAIN, &hd); assert(ret >= 0); diff --git a/mkrtos_user/server/init/src/heap_stack.c b/mkrtos_user/server/init/src/heap_stack.c index 11c8f0cab..5994e4978 100644 --- a/mkrtos_user/server/init/src/heap_stack.c +++ b/mkrtos_user/server/init/src/heap_stack.c @@ -15,7 +15,7 @@ #define STACK_SIZE (2 * 1024) //(1024 + 256) #else #define HEAP_SIZE (2 * 1024) -#define STACK_SIZE (4 * 1024) //(1024 + 256) +#define STACK_SIZE (3 * 1024) //(1024 + 256) #endif #if defined(__CC_ARM) diff --git a/mkrtos_user/server/init/src/init.cfg b/mkrtos_user/server/init/src/init.cfg index f2fcc0de6..d650f4d8e 100644 --- a/mkrtos_user/server/init/src/init.cfg +++ b/mkrtos_user/server/init/src/init.cfg @@ -9,4 +9,4 @@ cpiofs -m /bin # snd # net # nes -sh \ No newline at end of file +sh \ No newline at end of file diff --git a/mkrtos_user/server/init/src/parse_cfg.c b/mkrtos_user/server/init/src/parse_cfg.c index 059704f8a..7f7c5776c 100644 --- a/mkrtos_user/server/init/src/parse_cfg.c +++ b/mkrtos_user/server/init/src/parse_cfg.c @@ -23,9 +23,7 @@ #include #include -#define CMD_LEN 64 //!< 命令行最大长度 -#define CMD_PARAMS_CN 8 //!< 参数个数 -#define CMD_PARAMS_ITEM_LEN 16 //!< 每个参数的最大长度 +#include static char cmd_line[CMD_LEN]; //!< 命令行 static char cmd_params[CMD_PARAMS_CN][CMD_PARAMS_ITEM_LEN]; //!< 参数数组 static int cmd_params_off[CMD_PARAMS_CN]; //!< 参数偏移量 @@ -79,6 +77,8 @@ static int parse_cfg_cmd_line(void) { cmd_line[i] = 0; mem_block = atol(&cmd_line[i + 1]); // 获取应用使用的内存块 + cmd_params_num--; + break; } } return mem_block; diff --git a/mkrtos_user/server/init/src/parse_cfg.h b/mkrtos_user/server/init/src/parse_cfg.h index a56f0a002..946759b83 100644 --- a/mkrtos_user/server/init/src/parse_cfg.h +++ b/mkrtos_user/server/init/src/parse_cfg.h @@ -11,6 +11,8 @@ */ #include - +#define CMD_LEN 64 //!< 命令行最大长度 +#define CMD_PARAMS_CN 8 //!< 参数个数 +#define CMD_PARAMS_ITEM_LEN 16 //!< 每个参数的最大长度 void parse_cfg_init(void); int parse_cfg(const char *parse_cfg_file_name, uenv_t *env); diff --git a/mkrtos_user/server/init/src/pm.c b/mkrtos_user/server/init/src/pm.c index a811b2a3d..920cb2e24 100644 --- a/mkrtos_user/server/init/src/pm.c +++ b/mkrtos_user/server/init/src/pm.c @@ -18,10 +18,12 @@ #include "u_hd_man.h" #include "u_sig.h" #include "pm.h" +#include "parse_cfg.h" #include #include #include #include +#include static pm_t pm; void pm_init(void) @@ -210,13 +212,27 @@ int pm_rpc_run_app(const char *path, int flags, char *params, int params_len) pid_t pid; int ret; printf("pm run %s.\n", path); - char *args[] = { + char *args[CMD_PARAMS_CN] = { (char *)path, - NULL, /*TODO:支持传递参数*/ }; obj_handler_t sem; + int i; + int j = 0; - ret = app_load(path, u_get_global_env(), &pid, args, 1, NULL, 0, &sem, 0); + for (i = 1; *params && i < CMD_PARAMS_CN; i++) + { + if (j >= params_len) + { + break; + } + args[i] = params; + printf("params[%d]: %s\n", i, params); + j += strlen(params) + 1; + params += strlen(params) + 1; + } + + ret = app_load(path, u_get_global_env(), &pid, args, i, + NULL, 0, &sem, 0); if (ret > 0) { if (!(flags & PM_APP_BG_RUN)) diff --git a/mkrtos_user/server/shell/src/heap_stack.c b/mkrtos_user/server/shell/src/heap_stack.c index 994a07c10..2f0100348 100644 --- a/mkrtos_user/server/shell/src/heap_stack.c +++ b/mkrtos_user/server/shell/src/heap_stack.c @@ -1,7 +1,7 @@ #include #if !IS_ENABLED(CONFIG_MMU) -#define HEAP_SIZE 32 * 1024 -#define STACK_SIZE (3 * 1024) +#define HEAP_SIZE 16 * 1024 +#define STACK_SIZE (2 * 1024) #if defined(__CC_ARM) #define HEAP_ATTR SECTION("HEAP") __attribute__((zero_init)) diff --git a/mkrtos_user/user/app/CMakeLists.txt b/mkrtos_user/user/app/CMakeLists.txt index 2a7717bc4..bde80d14a 100644 --- a/mkrtos_user/user/app/CMakeLists.txt +++ b/mkrtos_user/user/app/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.13) add_subdirectory(coremark) add_subdirectory(tinycc-arm-thumb) -add_subdirectory(app_test) +add_subdirectory(test) if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${CONFIG_BOARD_NAME}) add_subdirectory(${CONFIG_BOARD_NAME}) endif() diff --git a/mkrtos_user/user/app/app_test/CMakeLists.txt b/mkrtos_user/user/app/test/CMakeLists.txt similarity index 62% rename from mkrtos_user/user/app/app_test/CMakeLists.txt rename to mkrtos_user/user/app/test/CMakeLists.txt index 22dea6f0b..9d98b0a76 100644 --- a/mkrtos_user/user/app/app_test/CMakeLists.txt +++ b/mkrtos_user/user/app/test/CMakeLists.txt @@ -7,12 +7,12 @@ file( ) add_executable( - app_test.elf + tst.elf ${deps} ${START_SRC} ) target_link_libraries( - app_test.elf + tst.elf PUBLIC -Bstatic ${LIBC_NAME} @@ -26,7 +26,7 @@ target_link_libraries( ${GCC_LIB_PATH}/libgcc.a ) target_include_directories( - app_test.elf + tst.elf PUBLIC ${CMAKE_SOURCE_DIR}/mkrtos_user/lib/sys/inc ${CMAKE_SOURCE_DIR}/mkrtos_user/lib/sys_svr/inc @@ -38,31 +38,31 @@ target_include_directories( ${CMAKE_SOURCE_DIR}/mkrtos_user/user/drv/lib/mk_display ) add_dependencies( - app_test.elf + tst.elf ${START_LIB} sys sys_util ) set_target_properties( - app_test.elf PROPERTIES LINK_FLAGS + tst.elf PROPERTIES LINK_FLAGS "-T ${CMAKE_CURRENT_LIST_DIR}/${ARCH_NAME}/link.lds ${CORTEX_M_LINK_FLAGS} --gc-section -no-dynamic-linker " #--no-warn-rwx-segments ) add_custom_target( - app_test_dump ALL + tst_dump ALL COMMAND - ${CMAKE_OBJDUMP} -s -S app_test.elf > ${CMAKE_SOURCE_DIR}/build/output/app_test.S + ${CMAKE_OBJDUMP} -s -S tst.elf > ${CMAKE_SOURCE_DIR}/build/output/tst.S COMMAND - ${CMAKE_READELF} -a app_test.elf > ${CMAKE_SOURCE_DIR}/build/output/app_test.txt + ${CMAKE_READELF} -a tst.elf > ${CMAKE_SOURCE_DIR}/build/output/tst.txt COMMAND - ${CMAKE_OBJCOPY} -O binary -S app_test.elf app_test.bin + ${CMAKE_OBJCOPY} -O binary -S tst.elf tst.bin COMMAND - ${CMAKE_SIZE} app_test.elf + ${CMAKE_SIZE} tst.elf COMMAND - ${CMAKE_COMMAND} -E copy app_test.bin ${CMAKE_SOURCE_DIR}/build/output/cpio/app_test + ${CMAKE_COMMAND} -E copy tst.bin ${CMAKE_SOURCE_DIR}/build/output/cpio/tst COMMAND - cp app_test.elf ${CMAKE_SOURCE_DIR}/build/output/app_test.elf + cp tst.elf ${CMAKE_SOURCE_DIR}/build/output/tst.elf ) -add_dependencies(app_test_dump app_test.elf) +add_dependencies(tst_dump tst.elf) \ No newline at end of file diff --git a/mkrtos_user/user/app/app_test/armv7_8m/link.lds b/mkrtos_user/user/app/test/armv7_8m/link.lds similarity index 100% rename from mkrtos_user/user/app/app_test/armv7_8m/link.lds rename to mkrtos_user/user/app/test/armv7_8m/link.lds diff --git a/mkrtos_user/user/app/app_test/heap_stack.c b/mkrtos_user/user/app/test/heap_stack.c similarity index 100% rename from mkrtos_user/user/app/app_test/heap_stack.c rename to mkrtos_user/user/app/test/heap_stack.c diff --git a/mkrtos_user/user/app/app_test/main.c b/mkrtos_user/user/app/test/main.c similarity index 67% rename from mkrtos_user/user/app/app_test/main.c rename to mkrtos_user/user/app/test/main.c index 864510de7..707d09331 100644 --- a/mkrtos_user/user/app/app_test/main.c +++ b/mkrtos_user/user/app/test/main.c @@ -9,6 +9,9 @@ int main(int argc, char *argv[]) { - printf("%s init..\n", argv[0]); + for (int i = 0; i < argc; i++) + { + printf("argv[%d]: %s\n", i, argv[i]); + } return 0; } diff --git a/mkrtos_user/user/app/tinycc-arm-thumb/CMakeLists.txt b/mkrtos_user/user/app/tinycc-arm-thumb/CMakeLists.txt index b801d6a88..10ac52ee1 100644 --- a/mkrtos_user/user/app/tinycc-arm-thumb/CMakeLists.txt +++ b/mkrtos_user/user/app/tinycc-arm-thumb/CMakeLists.txt @@ -76,6 +76,8 @@ add_custom_target( ${CMAKE_SIZE} tcc.elf COMMAND ${CMAKE_COMMAND} -E copy tcc.bin ${CMAKE_SOURCE_DIR}/build/output/cpio/tcc + COMMAND + ${CMAKE_COMMAND} -E copy tcc.elf ${CMAKE_SOURCE_DIR}/build/output/tcc.elf ) if ((DEFINED CONFIG_ELF_LAUNCH) AND (CONFIG_ELF_LAUNCH STREQUAL "y")) diff --git a/mkrtos_user/user/app/tinycc-arm-thumb/armv7_8m/heap_stack.c b/mkrtos_user/user/app/tinycc-arm-thumb/armv7_8m/heap_stack.c index 909fd0668..e378f0cba 100644 --- a/mkrtos_user/user/app/tinycc-arm-thumb/armv7_8m/heap_stack.c +++ b/mkrtos_user/user/app/tinycc-arm-thumb/armv7_8m/heap_stack.c @@ -1,6 +1,6 @@ -#define HEAP_SIZE 1024*1024*3 -#define STACK_SIZE 8192 +#define HEAP_SIZE (1024*1024*8) +#define STACK_SIZE (8192) #if defined(__CC_ARM) #define HEAP_ATTR SECTION("HEAP") __attribute__((zero_init)) diff --git a/mkrtos_user/user/app/tinycc-arm-thumb/tcc.c b/mkrtos_user/user/app/tinycc-arm-thumb/tcc.c index 412d48e0f..bc6e5ac3a 100644 --- a/mkrtos_user/user/app/tinycc-arm-thumb/tcc.c +++ b/mkrtos_user/user/app/tinycc-arm-thumb/tcc.c @@ -255,11 +255,11 @@ char *fake_argv[] = { "-nostdinc", "-nostdlib", "-c", - "/mnt/1.c", + "/bin/1.c", "-o", "/mnt/a.out" }; - +//tcc -nostdinc -nostdlib -c /bin/1.c -o /mnt/a.out int main(int argc0, char **argv0) { TCCState *s, *s1; @@ -270,9 +270,13 @@ int main(int argc0, char **argv0) char **argv; FILE *ppfp = stdout; + for(int i=0;i