diff --git a/mkrtos_knl/CMakeLists.txt b/mkrtos_knl/CMakeLists.txt index 83a4eedd3..381081210 100755 --- a/mkrtos_knl/CMakeLists.txt +++ b/mkrtos_knl/CMakeLists.txt @@ -35,10 +35,10 @@ target_link_libraries( PUBLIC --whole-archive knl - --no-whole-archive arch - drv lib + drv + --no-whole-archive ) add_dependencies(mkrtos.elf arch) add_dependencies(mkrtos.elf drv) @@ -76,4 +76,10 @@ add_custom_target( ${CMAKE_SIZE} mkrtos.elf ) add_dependencies(mkrtos.elf link_file_dump) -add_dependencies(mkrtos_dump mkrtos.elf) \ No newline at end of file +add_dependencies(mkrtos_dump mkrtos.elf) +add_dependencies(mkrtos_dump knl) +add_dependencies(mkrtos_dump arch) +add_dependencies(mkrtos_dump lib) +add_dependencies(mkrtos_dump drv) + + diff --git a/mkrtos_knl/inc/knl/init.h b/mkrtos_knl/inc/knl/init.h index 4fc0f0bc2..acfdacc70 100755 --- a/mkrtos_knl/inc/knl/init.h +++ b/mkrtos_knl/inc/knl/init.h @@ -4,17 +4,17 @@ typedef void (*init_func)(void); void sys_call_init(void); -#define INIT_LOW_HARD(f) USED __attribute__((__section__(".init_array." \ +#define INIT_LOW_HARD(f) static USED __attribute__((__section__(".init_array." \ "102"))) init_func init_##f = f -#define INIT_HIGH_HAD(f) USED __attribute__((__section__(".init_array." \ +#define INIT_HIGH_HAD(f) static USED __attribute__((__section__(".init_array." \ "103"))) init_func init_##f = f -#define INIT_MEM(f) USED __attribute__((__section__(".init_array." \ +#define INIT_MEM(f) static USED __attribute__((__section__(".init_array." \ "104"))) init_func init_##f = f -#define INIT_KOBJ_MEM(f) USED __attribute__((__section__(".init_array." \ +#define INIT_KOBJ_MEM(f) static USED __attribute__((__section__(".init_array." \ "105"))) init_func init_##f = f -#define INIT_KOBJ(f) USED __attribute__((__section__(".init_array." \ +#define INIT_KOBJ(f) static USED __attribute__((__section__(".init_array." \ "106"))) init_func init_##f = f -#define INIT_STAGE1(f) USED __attribute__((__section__(".init_array." \ +#define INIT_STAGE1(f) static USED __attribute__((__section__(".init_array." \ "107"))) init_func init_##f = f -#define INIT_STAGE2(f) USED __attribute__((__section__(".init_array." \ +#define INIT_STAGE2(f) static USED __attribute__((__section__(".init_array." \ "108"))) init_func init_##f = f diff --git a/mkrtos_knl/knl/globals.c b/mkrtos_knl/knl/globals.c index d8641eb22..054e40635 100755 --- a/mkrtos_knl/knl/globals.c +++ b/mkrtos_knl/knl/globals.c @@ -18,7 +18,7 @@ #include "mm_man.h" #include "ipc.h" static mem_t global_mem; //!< 全局内存管理块 -static uint8_t mem_block[55 * 1024]; //!< 内核内存分配堆 TODO:自动识别大小,或者从bootstrap中读取 +static uint8_t mem_block[59 * 1024]; //!< 内核内存分配堆 TODO:自动识别大小,或者从bootstrap中读取 static kobject_t *kobj_ls[FACTORY_FUNC_MAX]; //!< 全局静态内核对象 void global_reg_kobj(kobject_t *kobj, int inx) diff --git a/mkrtos_knl/knl/thread.c b/mkrtos_knl/knl/thread.c index 833087870..d00bb28ce 100755 --- a/mkrtos_knl/knl/thread.c +++ b/mkrtos_knl/knl/thread.c @@ -73,6 +73,7 @@ static void thread_timeout_init(void) slist_init(&wait_send_queue); slist_init(&wait_recv_queue); } + INIT_KOBJ(thread_timeout_init); /** @@ -433,6 +434,7 @@ static int thread_ipc_recv(msg_tag_t *ret_msg, ipc_timeout_t timeout, umword_t * assert(ret_user_id); thread_t *cur_th = thread_get_current(); umword_t lock_status; + thread_wait_entry_t wait; lock_status = cpulock_lock(); cur_th->ipc_status = THREAD_RECV; //!< 因为接收挂起 @@ -454,7 +456,6 @@ static int thread_ipc_recv(msg_tag_t *ret_msg, ipc_timeout_t timeout, umword_t * //!< 加入等待队列 if (timeout.recv_timeout) { - thread_wait_entry_t wait; thread_wait_entry_init(&wait, cur_th, timeout.recv_timeout); slist_add_append(&wait_recv_queue, &wait.node); //!< 放到等待队列中 @@ -855,7 +856,7 @@ static kobject_t *thread_create_func(ram_limit_t *lim, umword_t arg0, umword_t a * @brief 工厂注册函数 * */ -void thread_factory_register(void) +static void thread_factory_register(void) { factory_register(thread_create_func, THREAD_PROT); } 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 5cdc2f480..8595539ea 100644 --- a/mkrtos_user/lib/letter-shell/demo/mkrtos/shell_port.c +++ b/mkrtos_user/lib/letter-shell/demo/mkrtos/shell_port.c @@ -38,10 +38,8 @@ signed short userShellWrite(char *data, unsigned short len) */ signed short userShellRead(char *data, unsigned short len) { - int ret = 0; - while (ret <= 0) + while (cons_read((uint8_t *)data, len) <= 0) { - ret = cons_read((uint8_t *)data, len); u_sleep_ms(5); } } diff --git a/mkrtos_user/server/init/src/heap_stack.c b/mkrtos_user/server/init/src/heap_stack.c index fd3b7e393..3317ceb9b 100644 --- a/mkrtos_user/server/init/src/heap_stack.c +++ b/mkrtos_user/server/init/src/heap_stack.c @@ -8,7 +8,7 @@ * @copyright Copyright (c) 2023 * */ -#define HEAP_SIZE 8192 +#define HEAP_SIZE 512 #define STACK_SIZE 1024 * 2 #if defined(__CC_ARM) diff --git a/mkrtos_user/server/shell/src/heap_stack.c b/mkrtos_user/server/shell/src/heap_stack.c index 989b92b9f..fcf8574aa 100644 --- a/mkrtos_user/server/shell/src/heap_stack.c +++ b/mkrtos_user/server/shell/src/heap_stack.c @@ -1,5 +1,5 @@ -#define HEAP_SIZE 1024 +#define HEAP_SIZE 512 #define STACK_SIZE 2048 #if defined(__CC_ARM) diff --git a/setting.cmake b/setting.cmake index 4cd0726e6..9784c5a54 100755 --- a/setting.cmake +++ b/setting.cmake @@ -21,20 +21,20 @@ set(CMAKE_SIZE "${CROSS_COMPILE}size" CACHE PATH "" FORCE) set(MKRTOS_ARCH $ENV{ARCH}) # -mfloat-abi=soft -u _printf_float -set(CMAKE_C_FLAGS "-mcpu=${MKRTOS_ARCH} -mthumb -O0 -g3 -lc -lrdimon -msoft-float -u _printf_float -D=MKRTOS \ +set(CMAKE_C_FLAGS "-mcpu=${MKRTOS_ARCH} -mthumb -Os -g3 -lc -lrdimon -msoft-float -u _printf_float -D=MKRTOS \ -std=gnu11 -ffunction-sections -fdata-sections -fno-builtin -mfix-cortex-m3-ldrd \ -nostartfiles -nodefaultlibs -nostdlib -nostdinc -Xlinker \ -fno-stack-protector -Wl,--gc-sections \ " CACHE STRING "" FORCE) set(CMAKE_CXX_FLAGS "-mcpu=${MKRTOS_ARCH}-mthumb -mno-thumb-interwork -D=MKRTOS \ --mfix-cortex-m3-ldrd -O0 -g -std=c++11 \ +-mfix-cortex-m3-ldrd -Os -g3 -std=c++11 \ -fmessage-length=0 -Xlinker --print-map -Wall -W -fno-stack-protector -g \ -mfloat-abi=soft -lc -lrdimon -u _printf_float \ -ffunction-sections -fdata-sections -fno-builtin -nostartfiles -nodefaultlibs -nostdlib -nostdinc -Xlinker \ " CACHE STRING "" FORCE) -set(CMAKE_ASM_FLAGS "-mcpu=${MKRTOS_ARCH} -mthumb -O0 -g -mfloat-abi=soft -lc -lrdimon -D=MKRTOS \ +set(CMAKE_ASM_FLAGS "-mcpu=${MKRTOS_ARCH} -mthumb -Os -g3 -mfloat-abi=soft -lc -lrdimon -D=MKRTOS \ -u _printf_float -std=gnu11 -ffunction-sections -fdata-sections -fno-builtin \ -nostartfiles -nodefaultlibs -nostdlib -nostdinc -Xlinker -fno-stack-protector \ " CACHE STRING "" FORCE)