diff --git a/armv7_8.cmake b/armv7_8.cmake index bc66b8b21..aafbac8cf 100644 --- a/armv7_8.cmake +++ b/armv7_8.cmake @@ -1,6 +1,6 @@ message("========use armv7_8.cmake") -set(CMAKE_C_FLAGS "-mcpu=${CONFIG_ARCH} -O0 -g3 -mfloat-abi=${CONFIG_FLOAT_TYPE} -mthumb -DMKRTOS \ +set(CMAKE_C_FLAGS "-mcpu=${CONFIG_ARCH} -Ofast -g3 -mfloat-abi=${CONFIG_FLOAT_TYPE} -mthumb -DMKRTOS \ -std=gnu11 -ffunction-sections -fdata-sections -fno-builtin -u=_printf_float \ -nostartfiles -nodefaultlibs -nostdlib -nostdinc \ -fno-stack-protector -Wl,--gc-section -D__ARM_ARCH_7M__ \ diff --git a/mkrtos_knl/CMakeLists.txt b/mkrtos_knl/CMakeLists.txt index 41ffd7d22..9d622fa56 100755 --- a/mkrtos_knl/CMakeLists.txt +++ b/mkrtos_knl/CMakeLists.txt @@ -6,9 +6,9 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \ -Wno-unused-function \ -Wno-unused-variable \ -Wno-builtin-declaration-mismatch \ --Ofast \ ") +# -Ofast \ # message(编译参数:${CMAKE_C_FLAGS}) # cortex-m 系列处理器采用相同的内核arch diff --git a/mkrtos_knl/arch/cortex-m/at32f437/uart/at32f437_uart.c b/mkrtos_knl/arch/cortex-m/at32f437/uart/at32f437_uart.c index e8473b2a4..8265d478c 100755 --- a/mkrtos_knl/arch/cortex-m/at32f437/uart/at32f437_uart.c +++ b/mkrtos_knl/arch/cortex-m/at32f437/uart/at32f437_uart.c @@ -35,11 +35,15 @@ void uart_tigger(irq_entry_t *irq) { /* read one byte from the receive data register */ q_enqueue(&queue, usart_data_receive(PRINT_USARTx)); - + usart_interrupt_enable(PRINT_USARTx, USART_IDLE_INT, TRUE); + } + if (usart_interrupt_flag_get(PRINT_USARTx, USART_IDLEF_FLAG) != RESET) + { if (irq->irq->wait_thread && thread_get_status(irq->irq->wait_thread) == THREAD_SUSPEND) { thread_ready_remote(irq->irq->wait_thread, TRUE); } + usart_interrupt_enable(PRINT_USARTx, USART_IDLE_INT, FALSE); } } @@ -72,6 +76,8 @@ void uart_init(void) usart_receiver_enable(PRINT_USARTx, TRUE); usart_interrupt_enable(PRINT_USARTx, USART_RDBF_INT, TRUE); + usart_interrupt_enable(PRINT_USARTx, USART_IDLE_INT, TRUE); + usart_enable(PRINT_USARTx, TRUE); uart_is_init=1; diff --git a/mkrtos_knl/inc/knl/sleep.h b/mkrtos_knl/inc/knl/sleep.h index 9bf1f832a..31d5c1317 100644 --- a/mkrtos_knl/inc/knl/sleep.h +++ b/mkrtos_knl/inc/knl/sleep.h @@ -6,7 +6,7 @@ typedef struct thread_wait_entry slist_head_t node; thread_t *th; umword_t times; - umword_t times_debug; + // umword_t times_debug; } thread_wait_entry_t; void thread_check_timeout(void); thread_wait_entry_t *thread_sleep_del(thread_t *th); diff --git a/mkrtos_knl/knl/sleep.c b/mkrtos_knl/knl/sleep.c index a2423dc57..3fb8f5b52 100644 --- a/mkrtos_knl/knl/sleep.c +++ b/mkrtos_knl/knl/sleep.c @@ -25,7 +25,7 @@ static inline void thread_wait_entry_init(thread_wait_entry_t *entry, slist_init(&entry->node); entry->th = th; entry->times = times; - entry->times_debug = 0; + // entry->times_debug = 0; } static void thread_timeout_init(void) { @@ -48,22 +48,27 @@ void thread_check_timeout(void) thread_wait_entry_t *next = slist_next_entry( pos, (slist_head_t *)wait_list, node); - - pos->times_debug++; + // pos->times_debug++; if (pos->times != 0) { pos->times--; + // pos->times_debug = 0; if (pos->times == 0) { assert(pos->th->status == THREAD_SUSPEND); slist_del(&pos->node); thread_ready(pos->th, TRUE); } + } else { + // if (pos->times_debug >= 3000) + // { + // printk("thread:0x%x block times %d.\n", pos->th, pos->times_debug); + // } } // !< 如果是0,则一直休眠 - if (pos->times_debug%2000 == 0) - { - // printk("thread 0x%x block %d sec.\n", pos->th, pos->times_debug /1000); - } + // if (pos->times_debug%2000 == 0) + // { + // // printk("thread 0x%x block %d sec.\n", pos->th, pos->times_debug /1000); + // } pos = next; } } diff --git a/mkrtos_script/build_at32f437.sh b/mkrtos_script/build_at32f437.sh index 8a987bb58..10656b19f 100755 --- a/mkrtos_script/build_at32f437.sh +++ b/mkrtos_script/build_at32f437.sh @@ -1,15 +1,15 @@ #!/bin/bash -export TOOLCHAIN=/home/zhangzheng/toolchain/gcc-arm-10.3-2021.07-x86_64-arm-none-eabi/bin/ -export TOOLCHAIN_LIB=/home/zhangzheng/toolchain/gcc-arm-10.3-2021.07-x86_64-arm-none-eabi/lib/gcc/arm-none-eabi/10.3.1/thumb/v7-m/nofp +# export TOOLCHAIN=/home/zhangzheng/toolchain/gcc-arm-10.3-2021.07-x86_64-arm-none-eabi/bin/ +# export TOOLCHAIN_LIB=/home/zhangzheng/toolchain/gcc-arm-10.3-2021.07-x86_64-arm-none-eabi/lib/gcc/arm-none-eabi/10.3.1/thumb/v7-m/nofp # linux build # export TOOLCHAIN=/home/zhangzheng/gcc-arm-none-eabi-5_4-2016q3/bin/ # export TOOLCHAIN_LIB=/home/zhangzheng/gcc-arm-none-eabi-5_4-2016q3/lib/gcc/arm-none-eabi/5.4.1/armv7e-m/fpu # mac compile -# export TOOLCHAIN=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/bin/ -# export TOOLCHAIN_LIB=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/lib/gcc/arm-none-eabi/10.3.1/thumb/v7e-m+fp/softfp +export TOOLCHAIN=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/bin/ +export TOOLCHAIN_LIB=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/lib/gcc/arm-none-eabi/10.3.1/thumb/v7e-m+fp/softfp # windows compile # export TOOLCHAIN=/d/GNUArmEmbeddedToolchain/102021.10/bin/ diff --git a/mkrtos_user/lib/util/src/aligned_alloc.c b/mkrtos_user/lib/util/src/aligned_alloc.c index 4adca3b4f..00066e768 100644 --- a/mkrtos_user/lib/util/src/aligned_alloc.c +++ b/mkrtos_user/lib/util/src/aligned_alloc.c @@ -2,7 +2,7 @@ #include #include #include "malloc_impl.h" - +#include "u_malloc.h" void *aligned_alloc(size_t align, size_t len) { unsigned char *mem, *new; @@ -19,9 +19,9 @@ void *aligned_alloc(size_t align, size_t len) } if (align <= SIZE_ALIGN) - return malloc(len); + return u_malloc(len); - if (!(mem = malloc(len + align-1))) + if (!(mem = u_malloc(len + align-1))) return 0; new = (void *)((uintptr_t)mem + align-1 & -align); @@ -48,6 +48,6 @@ void *aligned_alloc(size_t align, size_t len) n->psize = c->csize = C_INUSE | (new-mem); n->csize = t->psize -= new-mem; - __bin_chunk(c); + u__bin_chunk(c); return new; } diff --git a/mkrtos_user/lib/util/src/malloc_impl.h b/mkrtos_user/lib/util/src/malloc_impl.h index f96fabc1f..50797cb27 100644 --- a/mkrtos_user/lib/util/src/malloc_impl.h +++ b/mkrtos_user/lib/util/src/malloc_impl.h @@ -34,5 +34,6 @@ struct bin { #define IS_MMAPPED(c) !((c)->csize & (C_INUSE)) +void u__bin_chunk(struct chunk *self); #endif diff --git a/mkrtos_user/lib/util/src/u_malloc.c b/mkrtos_user/lib/util/src/u_malloc.c index 05ebd8c61..1dfdb07b6 100644 --- a/mkrtos_user/lib/util/src/u_malloc.c +++ b/mkrtos_user/lib/util/src/u_malloc.c @@ -12,7 +12,6 @@ // #include "fork_impl.h" void u_free(void *p); -static void __bin_chunk(struct chunk *self); // #define malloc __libc_malloc_impl // #define realloc __libc_realloc // #define free __libc_free @@ -400,7 +399,7 @@ void *u_realloc(void *p, size_t n) struct chunk *split = (void *)((char *)self + n); self->csize = split->psize = n | C_INUSE; split->csize = next->psize = n0-n | C_INUSE; - __bin_chunk(split); + u__bin_chunk(split); return CHUNK_TO_MEM(self); } @@ -433,7 +432,7 @@ copy_free_ret: return new; } -static void __bin_chunk(struct chunk *self) +void u__bin_chunk(struct chunk *self) { struct chunk *next = NEXT_CHUNK(self); @@ -517,7 +516,7 @@ void u_free(void *p) if (IS_MMAPPED(self)) unmap_chunk(self); else - __bin_chunk(self); + u__bin_chunk(self); } #if 0 static void __malloc_donate(char *start, char *end) diff --git a/mkrtos_user/server/init/src/tty.c b/mkrtos_user/server/init/src/tty.c index 5f95de525..20369c71f 100644 --- a/mkrtos_user/server/init/src/tty.c +++ b/mkrtos_user/server/init/src/tty.c @@ -85,8 +85,6 @@ static void console_read_func(void) if (!sys_tty.is_nl && L_ICANON(&sys_tty)) { tty_write_hw(&sys_tty); - // 规范模式下没有成一行 - cons_read_unlock(); } else { diff --git a/mkrtos_user/server/net/src/main.c b/mkrtos_user/server/net/src/main.c index e327b00a1..c807c25d7 100644 --- a/mkrtos_user/server/net/src/main.c +++ b/mkrtos_user/server/net/src/main.c @@ -58,7 +58,7 @@ int main(int args, char *argv[]) return -1; } again: - ret = ns_query_svr("/eth", &net_drv_hd, 0x1); + ret = ns_query_svr("/dev/eth", &net_drv_hd, 0x1); if (ret < 0) { // 0代表根节点 diff --git a/mkrtos_user/user/app/test/main.c b/mkrtos_user/user/app/test/main.c index 4b6b426c1..5351c73d3 100644 --- a/mkrtos_user/user/app/test/main.c +++ b/mkrtos_user/user/app/test/main.c @@ -19,7 +19,7 @@ int main(int argc, char *argv[]) { printf("argv[%d]: %s\n", i, argv[i]); } - exit(-1); + // exit(-1); net_test(); fs_test3(); fs_test2(); diff --git a/mkrtos_user/user/drv/ATSURFF437/eth/main.c b/mkrtos_user/user/drv/ATSURFF437/eth/main.c index 1d7a29eb1..a4b3cecae 100644 --- a/mkrtos_user/user/drv/ATSURFF437/eth/main.c +++ b/mkrtos_user/user/drv/ATSURFF437/eth/main.c @@ -96,9 +96,7 @@ int main(int argc, char *argv[]) blk_drv_init(&net_drv); ret = rpc_meta_init_def(TASK_THIS, &hd); assert(ret >= 0); - // fs_svr_init(); - // mkdir("/dev", 0777); - ns_register("/eth", hd, 0); + ns_register("/dev/eth", hd, 0); meta_reg_svr_obj(&net_drv.svr, BLK_DRV_PROT); while (1) {