fix lunch params etc.

This commit is contained in:
zhangzheng
2025-01-03 18:29:25 +08:00
parent f40ee6fab2
commit e7d1d0cba6
31 changed files with 146 additions and 185 deletions

View File

@@ -171,7 +171,9 @@
"at_surf_f437_board_sdram.h": "c", "at_surf_f437_board_sdram.h": "c",
"fs_types.h": "c", "fs_types.h": "c",
"u_rpc.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.showRTOS": false,
"cortex-debug.variableUseNaturalFormat": true, "cortex-debug.variableUseNaturalFormat": true,

View File

@@ -1,21 +1,21 @@
message("========use armv7_8.cmake") 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 \ -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__ \ -fno-stack-protector -Wl,--gc-sections -D__ARM_ARCH_7M__ \
-include ${CMAKE_SOURCE_DIR}/build/autoconf.h \ -include ${CMAKE_SOURCE_DIR}/build/autoconf.h \
" CACHE STRING "" FORCE) " 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 \ -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 \ -ffunction-sections -fdata-sections -fno-builtin -nostartfiles -nodefaultlibs -nostdlib -nostdinc -Xlinker \
-include ${CMAKE_SOURCE_DIR}/build/autoconf.h \ -include ${CMAKE_SOURCE_DIR}/build/autoconf.h \
" CACHE STRING "" FORCE) " CACHE STRING "" FORCE)
set(CMAKE_ASM_FLAGS "-mcpu=${CONFIG_ARCH} -Ofast -g3 -mfloat-abi=${CONFIG_FLOAT_TYPE} -mthumb -D=MKRTOS \ 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 -mthumb-interwork \ -u=_printf_float -std=gnu11 -ffunction-sections -fdata-sections -fno-builtin \
-nostartfiles -nodefaultlibs -nostdlib -nostdinc -Xlinker -fno-stack-protector -D__ARM_ARCH_7M__ \ -nostartfiles -nodefaultlibs -nostdlib -nostdinc -Xlinker -fno-stack-protector -D__ARM_ARCH_7M__ \
-include ${CMAKE_SOURCE_DIR}/build/autoconf.h \ -include ${CMAKE_SOURCE_DIR}/build/autoconf.h \
" CACHE STRING "" FORCE) " CACHE STRING "" FORCE)

View File

@@ -1,10 +1,10 @@
ENTRY(Reset_Handler) ENTRY(Reset_Handler)
_estack = 0x20000000 + 0x800000; _estack = 0x20000000 + 0x2000000;
_Min_Heap_Size = 0; _Min_Heap_Size = 0;
_Min_Stack_Size = 0x300; _Min_Stack_Size = 0x300;
MEMORY 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 FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 0x2000
} }
SECTIONS SECTIONS

View File

@@ -6,7 +6,7 @@ CONFIG_KNL_INFO=y
CONFIG_SYS_TEXT_ADDR=0x8000000 CONFIG_SYS_TEXT_ADDR=0x8000000
CONFIG_SYS_TEXT_SIZE=0x800000 CONFIG_SYS_TEXT_SIZE=0x800000
CONFIG_SYS_DATA_ADDR=0x20000000 CONFIG_SYS_DATA_ADDR=0x20000000
CONFIG_SYS_DATA_SIZE=0x800000 CONFIG_SYS_DATA_SIZE=0x2000000
CONFIG_BOOTSTRAP_TEXT_SIZE=0x2000 CONFIG_BOOTSTRAP_TEXT_SIZE=0x2000
CONFIG_DTBO_TEXT_SIZE=0x1000 CONFIG_DTBO_TEXT_SIZE=0x1000
CONFIG_KNL_TEXT_SIZE=0x30000 CONFIG_KNL_TEXT_SIZE=0x30000
@@ -37,77 +37,6 @@ CONFIG_SIG_THREAD_STACK_SIZE=512
CONFIG_SIG_THREAD_PRIO=3 CONFIG_SIG_THREAD_PRIO=3
# end of Sys util config # 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_CPU_TYPE="stm32f2"
CONFIG_RTT_DIR="./" CONFIG_RTT_DIR="./"
CONFIG_ARCH="cortex-m3" CONFIG_ARCH="cortex-m3"

View File

@@ -1,7 +1,7 @@
ENTRY(Reset_Handler) ENTRY(Reset_Handler)
MEMORY MEMORY
{ {
RAM (arw) : ORIGIN = 0x20000000, LENGTH = 0x800000 RAM (arw) : ORIGIN = 0x20000000, LENGTH = 0x2000000
FLASH (arx) : ORIGIN = 0x8000000 + 0x2000 + 0x1000, LENGTH = 0x30000 FLASH (arx) : ORIGIN = 0x8000000 + 0x2000 + 0x1000, LENGTH = 0x30000
} }
SECTIONS SECTIONS

View File

@@ -125,7 +125,8 @@ static void uart_hardware_flow_rts(USART_TypeDef *USARTx, uint16_t flow)
USARTx->CR3 = (uint16_t)tmpreg; USARTx->CR3 = (uint16_t)tmpreg;
} }
static uart_t uart = { static uart_t uart = {
.baud = 115200}; .baud = 115200,
};
uart_t *uart_get_global(void) uart_t *uart_get_global(void)
{ {

View File

@@ -18,7 +18,7 @@
printk("\n%s:%d %s\n", __FILE__, __LINE__, #cond); \ printk("\n%s:%d %s\n", __FILE__, __LINE__, #cond); \
dumpstack(); \ dumpstack(); \
mm_trace(); \ mm_trace(); \
sys_reset(); \ /*sys_reset();*/ \
while (1) \ while (1) \
; \ ; \
} \ } \

View File

@@ -7,8 +7,8 @@ if (${ARCH_NAME} STREQUAL "armv7_8m")
add_subdirectory(mr) add_subdirectory(mr)
# add_subdirectory(at_device) # add_subdirectory(at_device)
elseif(${CONFIG_ARCH} STREQUAL "aarch64") elseif(${CONFIG_ARCH} STREQUAL "aarch64")
add_subdirectory(mkrtos-musl)
endif() endif()
add_subdirectory(mkrtos-musl)
add_subdirectory(sys) add_subdirectory(sys)
add_subdirectory(sys_util) add_subdirectory(sys_util)
add_subdirectory(util) add_subdirectory(util)

View File

@@ -27,7 +27,7 @@
#include "u_sleep.h" #include "u_sleep.h"
static Shell shell; static Shell shell;
static ShellFs shellFs; static ShellFs shellFs;
static char shellBuffer[256]; static char shellBuffer[512];
// static char shellPathBuffer[128] = "/"; // static char shellPathBuffer[128] = "/";
/** /**

View File

@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.13) cmake_minimum_required(VERSION 3.13)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w -D_XOPEN_SOURCE=700 ") 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 file(GLOB_RECURSE deps
src/*.C src/*.C

View File

@@ -7,15 +7,15 @@ _longjmp:
longjmp: longjmp:
mov ip,r0 mov ip,r0
movs r0,r1 movs r0,r1
it eq
moveq r0,#1 moveq r0,#1
ldmia ip!, {v1,v2,v3,v4,v5,v6,sl,fp} ldmia ip!, {v1,v2,v3,v4,v5,v6,sl,fp}
ldmia ip!, {r2,lr} ldmia ip!, {r2,lr}
mov sp,r2 mov sp,r2
adr r1,1f //adr r1,1f
ldr r2,1f //ldr r2,1f
ldr r1,[r1,r2] //ldr r1,[r1,r2]
mov r1, #0
#if __ARM_ARCH < 8 #if __ARM_ARCH < 8
tst r1,#0x260 tst r1,#0x260
@@ -23,12 +23,12 @@ longjmp:
// HWCAP_ARM_FPA // HWCAP_ARM_FPA
tst r1,#0x20 tst r1,#0x20
beq 2f beq 2f
// ldc p2, cr4, [ip], #48 ldc p2, cr4, [ip], #48
#endif #endif
2: tst r1,#0x40 2: tst r1,#0x40
beq 2f beq 2f
// .fpu vfp .fpu vfp
// vldmia ip!, {d8-d15} vldmia ip!, {d8-d15}
.fpu softvfp .fpu softvfp
.eabi_attribute 10, 0 .eabi_attribute 10, 0
.eabi_attribute 27, 0 .eabi_attribute 27, 0
@@ -36,12 +36,12 @@ longjmp:
// HWCAP_ARM_IWMMXT // HWCAP_ARM_IWMMXT
2: tst r1,#0x200 2: tst r1,#0x200
beq 3f beq 3f
// ldcl p1, cr10, [ip], #8 ldcl p1, cr10, [ip], #8
// ldcl p1, cr11, [ip], #8 ldcl p1, cr11, [ip], #8
// ldcl p1, cr12, [ip], #8 ldcl p1, cr12, [ip], #8
// ldcl p1, cr13, [ip], #8 ldcl p1, cr13, [ip], #8
// ldcl p1, cr14, [ip], #8 ldcl p1, cr14, [ip], #8
// ldcl p1, cr15, [ip], #8 ldcl p1, cr15, [ip], #8
#endif #endif
2: 2:
3: bx lr 3: bx lr

View File

@@ -14,9 +14,10 @@ setjmp:
stmia ip!,{r2,lr} stmia ip!,{r2,lr}
mov r0,#0 mov r0,#0
adr r1,1f //adr r1,1f
ldr r2,1f //ldr r2,1f
ldr r1,[r1,r2] //ldr r1,[r1,r2]
mov r1, #0
#if __ARM_ARCH < 8 #if __ARM_ARCH < 8
tst r1,#0x260 tst r1,#0x260
@@ -24,12 +25,12 @@ setjmp:
// HWCAP_ARM_FPA // HWCAP_ARM_FPA
tst r1,#0x20 tst r1,#0x20
beq 2f beq 2f
// stc p2, cr4, [ip], #48 stc p2, cr4, [ip], #48
#endif #endif
2: tst r1,#0x40 2: tst r1,#0x40
beq 2f beq 2f
// .fpu vfp .fpu vfp
// vstmia ip!, {d8-d15} vstmia ip!, {d8-d15}
.fpu softvfp .fpu softvfp
.eabi_attribute 10, 0 .eabi_attribute 10, 0
.eabi_attribute 27, 0 .eabi_attribute 27, 0
@@ -37,12 +38,12 @@ setjmp:
// HWCAP_ARM_IWMMXT // HWCAP_ARM_IWMMXT
2: tst r1,#0x200 2: tst r1,#0x200
beq 3f beq 3f
// stcl p1, cr10, [ip], #8 stcl p1, cr10, [ip], #8
// stcl p1, cr11, [ip], #8 stcl p1, cr11, [ip], #8
// stcl p1, cr12, [ip], #8 stcl p1, cr12, [ip], #8
// stcl p1, cr13, [ip], #8 stcl p1, cr13, [ip], #8
// stcl p1, cr14, [ip], #8 stcl p1, cr14, [ip], #8
// stcl p1, cr15, [ip], #8 stcl p1, cr15, [ip], #8
#endif #endif
2: 2:
3: bx lr 3: bx lr

View File

@@ -22,10 +22,14 @@ sd_t fs_open(const char *path, int flags, int mode)
obj_handler_t hd; obj_handler_t hd;
int ret = ns_query(path, &hd, 0x1); int ret = ns_query(path, &hd, 0x1);
if (ret < 0)
{
ret = ns_query(path, &hd, 0x0);
if (ret < 0) if (ret < 0)
{ {
return ret; return ret;
} }
}
rpc_ref_file_array_t rpc_path = { rpc_ref_file_array_t rpc_path = {
.data = (uint8_t *)(&path[ret]), .data = (uint8_t *)(&path[ret]),

View File

@@ -19,6 +19,7 @@
#include "cpiofs.h" #include "cpiofs.h"
#include "u_env.h" #include "u_env.h"
#include "u_sys.h" #include "u_sys.h"
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
#include <elf.h> #include <elf.h>
@@ -125,6 +126,10 @@ int app_load(const char *name, uenv_t *cur_env, pid_t *pid,
{ {
return -ENOENT; return -ENOENT;
} }
// for (int i = 0; i < arg_cn; i++)
// {
// printf("argv[%d]:%s\n", i, argv[i]);
// }
int type; int type;
umword_t addr; umword_t addr;
int ret = cpio_find_file((umword_t)sys_info.bootfs_start_addr, (umword_t)(-1), name, NULL, &type, &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, .rev2 = HANDLER_INVALID,
}; };
umword_t *app_env; umword_t *app_env;
char *cp_args; char *cp_args[8/*FIXME:*/];
char *cp_envp; 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)); app_env = app_stack_push_array(hd_task, &usp_top, (uint8_t *)(&uenv), sizeof(uenv));
for (int i = 0; i < arg_cn; i++) for (int i = 0; i < arg_cn; i++)
{ {
cp_args = app_stack_push_str(hd_task, &usp_top, argv[i]); cp_args[i] = app_stack_push_str(hd_task, &usp_top, argv[i]);
if ((ALIGN(strlen(argv[i]) + 1, sizeof(void *)) / sizeof(void *)) % 2) params_envp_len += ALIGN(strlen(argv[i]) + 1, sizeof(void *));
{ printf("app_load 1 cp_args:%p\n", cp_args[i]);
app_stack_push_umword(hd_task, &usp_top, 0);
}
printf("app_load 1 cp_args:%p\n", cp_args);
} }
for (int i = 0; i < envp_cn; i++) for (int i = 0; i < envp_cn; i++)
{ {
cp_envp = app_stack_push_str(hd_task, &usp_top, envp[i]); cp_envp[i] = app_stack_push_str(hd_task, &usp_top, envp[i]);
if ((ALIGN(strlen(argv[i]) + 1, sizeof(void *)) / sizeof(void *)) % 2) params_envp_len += ALIGN(strlen(argv[i]) + 1, sizeof(void *));
}
if ((umword_t)usp_top & 0x7UL)
{ {
app_stack_push_umword(hd_task, &usp_top, 0); usp_top = (umword_t *)((umword_t)usp_top & ~0x7UL);
} }
}
app_stack_push_umword(hd_task, &usp_top, 0); app_stack_push_umword(hd_task, &usp_top, 0);
if ((arg_cn + envp_cn) & 0x1) // 参数是奇数是,多添加一个 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, (umword_t)AT_PAGESZ);
app_stack_push_umword(hd_task, &usp_top, 0); 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); app_stack_push_umword(hd_task, &usp_top, (umword_t)cp_envp[i]);
cp_envp += ALIGN(strlen(envp[i]), sizeof(void *));
if ((ALIGN(strlen(envp[i]) + 1, sizeof(void *)) / sizeof(void *)) % 2)
{
cp_envp += sizeof(void *);
} }
}
if (arg_cn)
{
app_stack_push_umword(hd_task, &usp_top, 0); app_stack_push_umword(hd_task, &usp_top, 0);
for (int i = 0; i < arg_cn; i++) for (int i = arg_cn - 1; i >= 0; i--)
{ {
if (i != 0) printf("app_load 2 cp_args:%p\n", cp_args[i]);
{ app_stack_push_umword(hd_task, &usp_top, (umword_t)cp_args[i]);
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 *));
}
} }
app_stack_push_umword(hd_task, &usp_top, arg_cn); app_stack_push_umword(hd_task, &usp_top, arg_cn);

View File

@@ -2,5 +2,5 @@ cmake_minimum_required(VERSION 3.13)
add_subdirectory(cpiofs) add_subdirectory(cpiofs)
# add_subdirectory(fatfs) add_subdirectory(fatfs)
# add_subdirectory(lxext4) # add_subdirectory(lxext4)

View File

@@ -66,8 +66,8 @@ add_custom_target(
${CMAKE_SIZE} fatfs.elf ${CMAKE_SIZE} fatfs.elf
COMMAND COMMAND
mkdir -p ${CMAKE_SOURCE_DIR}/build/output/cpio mkdir -p ${CMAKE_SOURCE_DIR}/build/output/cpio
# COMMAND COMMAND
# cp fatfs.bin ${CMAKE_SOURCE_DIR}/build/output/cpio/fatfs cp fatfs.bin ${CMAKE_SOURCE_DIR}/build/output/cpio/fatfs
COMMAND COMMAND
cp fatfs.elf ${CMAKE_SOURCE_DIR}/build/output/cpio/fatfs.elf cp fatfs.elf ${CMAKE_SOURCE_DIR}/build/output/cpio/fatfs.elf
) )

View File

@@ -3,13 +3,22 @@
#include "u_rpc_svr.h" #include "u_rpc_svr.h"
#include "u_prot.h" #include "u_prot.h"
#include "u_env.h" #include "u_env.h"
#include "u_drv.h"
#include "cons_cli.h" #include "cons_cli.h"
#include "fs_rpc.h" #include "fs_rpc.h"
#include <ff.h> #include <ff.h>
#include <stdio.h> #include <stdio.h>
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <u_fast_ipc.h>
#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 FATFS fs;
static MKFS_PARM defopt = {FM_ANY, 0, 0, 0}; static MKFS_PARM defopt = {FM_ANY, 0, 0, 0};
@@ -17,6 +26,7 @@ int main(int args, char *argv[])
{ {
obj_handler_t hd; obj_handler_t hd;
int ret; int ret;
fast_ipc_init();
ret = rpc_meta_init(THREAD_MAIN, &hd); ret = rpc_meta_init(THREAD_MAIN, &hd);
assert(ret >= 0); assert(ret >= 0);

View File

@@ -15,7 +15,7 @@
#define STACK_SIZE (2 * 1024) //(1024 + 256) #define STACK_SIZE (2 * 1024) //(1024 + 256)
#else #else
#define HEAP_SIZE (2 * 1024) #define HEAP_SIZE (2 * 1024)
#define STACK_SIZE (4 * 1024) //(1024 + 256) #define STACK_SIZE (3 * 1024) //(1024 + 256)
#endif #endif
#if defined(__CC_ARM) #if defined(__CC_ARM)

View File

@@ -23,9 +23,7 @@
#include <u_hd_man.h> #include <u_hd_man.h>
#include <stdlib.h> #include <stdlib.h>
#define CMD_LEN 64 //!< 命令行最大长度 #include <parse_cfg.h>
#define CMD_PARAMS_CN 8 //!< 参数个数
#define CMD_PARAMS_ITEM_LEN 16 //!< 每个参数的最大长度
static char cmd_line[CMD_LEN]; //!< 命令行 static char cmd_line[CMD_LEN]; //!< 命令行
static char cmd_params[CMD_PARAMS_CN][CMD_PARAMS_ITEM_LEN]; //!< 参数数组 static char cmd_params[CMD_PARAMS_CN][CMD_PARAMS_ITEM_LEN]; //!< 参数数组
static int cmd_params_off[CMD_PARAMS_CN]; //!< 参数偏移量 static int cmd_params_off[CMD_PARAMS_CN]; //!< 参数偏移量
@@ -79,6 +77,8 @@ static int parse_cfg_cmd_line(void)
{ {
cmd_line[i] = 0; cmd_line[i] = 0;
mem_block = atol(&cmd_line[i + 1]); // 获取应用使用的内存块 mem_block = atol(&cmd_line[i + 1]); // 获取应用使用的内存块
cmd_params_num--;
break;
} }
} }
return mem_block; return mem_block;

View File

@@ -11,6 +11,8 @@
*/ */
#include <u_env.h> #include <u_env.h>
#define CMD_LEN 64 //!< 命令行最大长度
#define CMD_PARAMS_CN 8 //!< 参数个数
#define CMD_PARAMS_ITEM_LEN 16 //!< 每个参数的最大长度
void parse_cfg_init(void); void parse_cfg_init(void);
int parse_cfg(const char *parse_cfg_file_name, uenv_t *env); int parse_cfg(const char *parse_cfg_file_name, uenv_t *env);

View File

@@ -18,10 +18,12 @@
#include "u_hd_man.h" #include "u_hd_man.h"
#include "u_sig.h" #include "u_sig.h"
#include "pm.h" #include "pm.h"
#include "parse_cfg.h"
#include <errno.h> #include <errno.h>
#include <malloc.h> #include <malloc.h>
#include <stdio.h> #include <stdio.h>
#include <assert.h> #include <assert.h>
#include <string.h>
static pm_t pm; static pm_t pm;
void pm_init(void) 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; pid_t pid;
int ret; int ret;
printf("pm run %s.\n", path); printf("pm run %s.\n", path);
char *args[] = { char *args[CMD_PARAMS_CN] = {
(char *)path, (char *)path,
NULL, /*TODO:支持传递参数*/
}; };
obj_handler_t sem; 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 (ret > 0)
{ {
if (!(flags & PM_APP_BG_RUN)) if (!(flags & PM_APP_BG_RUN))

View File

@@ -1,7 +1,7 @@
#include <u_util.h> #include <u_util.h>
#if !IS_ENABLED(CONFIG_MMU) #if !IS_ENABLED(CONFIG_MMU)
#define HEAP_SIZE 32 * 1024 #define HEAP_SIZE 16 * 1024
#define STACK_SIZE (3 * 1024) #define STACK_SIZE (2 * 1024)
#if defined(__CC_ARM) #if defined(__CC_ARM)
#define HEAP_ATTR SECTION("HEAP") __attribute__((zero_init)) #define HEAP_ATTR SECTION("HEAP") __attribute__((zero_init))

View File

@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.13)
add_subdirectory(coremark) add_subdirectory(coremark)
add_subdirectory(tinycc-arm-thumb) add_subdirectory(tinycc-arm-thumb)
add_subdirectory(app_test) add_subdirectory(test)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${CONFIG_BOARD_NAME}) if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${CONFIG_BOARD_NAME})
add_subdirectory(${CONFIG_BOARD_NAME}) add_subdirectory(${CONFIG_BOARD_NAME})
endif() endif()

View File

@@ -7,12 +7,12 @@ file(
) )
add_executable( add_executable(
app_test.elf tst.elf
${deps} ${deps}
${START_SRC} ${START_SRC}
) )
target_link_libraries( target_link_libraries(
app_test.elf tst.elf
PUBLIC PUBLIC
-Bstatic -Bstatic
${LIBC_NAME} ${LIBC_NAME}
@@ -26,7 +26,7 @@ target_link_libraries(
${GCC_LIB_PATH}/libgcc.a ${GCC_LIB_PATH}/libgcc.a
) )
target_include_directories( target_include_directories(
app_test.elf tst.elf
PUBLIC PUBLIC
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/sys/inc ${CMAKE_SOURCE_DIR}/mkrtos_user/lib/sys/inc
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/sys_svr/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 ${CMAKE_SOURCE_DIR}/mkrtos_user/user/drv/lib/mk_display
) )
add_dependencies( add_dependencies(
app_test.elf tst.elf
${START_LIB} ${START_LIB}
sys sys
sys_util sys_util
) )
set_target_properties( 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 " "-T ${CMAKE_CURRENT_LIST_DIR}/${ARCH_NAME}/link.lds ${CORTEX_M_LINK_FLAGS} --gc-section -no-dynamic-linker "
#--no-warn-rwx-segments #--no-warn-rwx-segments
) )
add_custom_target( add_custom_target(
app_test_dump ALL tst_dump ALL
COMMAND 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 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 COMMAND
${CMAKE_OBJCOPY} -O binary -S app_test.elf app_test.bin ${CMAKE_OBJCOPY} -O binary -S tst.elf tst.bin
COMMAND COMMAND
${CMAKE_SIZE} app_test.elf ${CMAKE_SIZE} tst.elf
COMMAND 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 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)

View File

@@ -9,6 +9,9 @@
int main(int argc, char *argv[]) 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; return 0;
} }

View File

@@ -76,6 +76,8 @@ add_custom_target(
${CMAKE_SIZE} tcc.elf ${CMAKE_SIZE} tcc.elf
COMMAND COMMAND
${CMAKE_COMMAND} -E copy tcc.bin ${CMAKE_SOURCE_DIR}/build/output/cpio/tcc ${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")) if ((DEFINED CONFIG_ELF_LAUNCH) AND (CONFIG_ELF_LAUNCH STREQUAL "y"))

View File

@@ -1,6 +1,6 @@
#define HEAP_SIZE 1024*1024*3 #define HEAP_SIZE (1024*1024*8)
#define STACK_SIZE 8192 #define STACK_SIZE (8192)
#if defined(__CC_ARM) #if defined(__CC_ARM)
#define HEAP_ATTR SECTION("HEAP") __attribute__((zero_init)) #define HEAP_ATTR SECTION("HEAP") __attribute__((zero_init))

View File

@@ -255,11 +255,11 @@ char *fake_argv[] = {
"-nostdinc", "-nostdinc",
"-nostdlib", "-nostdlib",
"-c", "-c",
"/mnt/1.c", "/bin/1.c",
"-o", "-o",
"/mnt/a.out" "/mnt/a.out"
}; };
//tcc -nostdinc -nostdlib -c /bin/1.c -o /mnt/a.out
int main(int argc0, char **argv0) int main(int argc0, char **argv0)
{ {
TCCState *s, *s1; TCCState *s, *s1;
@@ -270,9 +270,13 @@ int main(int argc0, char **argv0)
char **argv; char **argv;
FILE *ppfp = stdout; FILE *ppfp = stdout;
for(int i=0;i<argc0;i++)
{
printf("%s \n", argv0[i]);
}
printf("\n");
redo: redo:
// argc = argc0, argv = argv0; argc = argc0, argv = argv0;
argc = 7, argv = fake_argv;
s = s1 = tcc_new(); s = s1 = tcc_new();
opt = tcc_parse_args(s, &argc, &argv, 1); opt = tcc_parse_args(s, &argc, &argv, 1);