From 7d7f67e32fdc94ae7548430cc44197d0e80121d1 Mon Sep 17 00:00:00 2001 From: Jingru Date: Wed, 18 Mar 2020 17:00:19 +0800 Subject: [PATCH] board: nsim: sbrk.c:(.text+0x10) undefined reference to end Signed-off-by: Jingru --- .vscode/settings.json | 5 ++- board/ARC_NSIM_EM/BSP/Src/main.c | 7 ++- board/ARC_NSIM_EM/GCC/hello_world/Makefile | 9 ++-- .../GCC/hello_world/linker_template_gnu.ldf | 44 +++++++++++-------- 4 files changed, 39 insertions(+), 26 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index f9ab7df4..50723130 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,9 @@ { "files.associations": { "arc_exception.h": "c", - "arc_timer.h": "c" + "arc_timer.h": "c", + "board.h": "c", + "console_io.h": "c", + "xprintf.h": "c" } } \ No newline at end of file diff --git a/board/ARC_NSIM_EM/BSP/Src/main.c b/board/ARC_NSIM_EM/BSP/Src/main.c index bf5da6c8..b475a453 100644 --- a/board/ARC_NSIM_EM/BSP/Src/main.c +++ b/board/ARC_NSIM_EM/BSP/Src/main.c @@ -1,8 +1,6 @@ #include "cmsis_os.h" -#include "arc/arc_exception.h" -#include "arc/arc_cache.h" -#include "nsim.h" -#include "board.h" +#include "embARC.h" +#include "embARC_debug.h" static uint32_t cyc_hz_count = (BOARD_CPU_CLOCK / BOARD_SYS_TIMER_HZ); @@ -42,6 +40,7 @@ int main(void) arc_cache_init(); board_init(); board_timer_init(); + xprintf_setup(); printf("Welcome to TencentOS tiny\r\n"); osKernelInitialize(); // TOS Tiny kernel initialize osThreadCreate(osThread(application_entry), NULL); // Create TOS Tiny task diff --git a/board/ARC_NSIM_EM/GCC/hello_world/Makefile b/board/ARC_NSIM_EM/GCC/hello_world/Makefile index 80b4b523..a75e8116 100644 --- a/board/ARC_NSIM_EM/GCC/hello_world/Makefile +++ b/board/ARC_NSIM_EM/GCC/hello_world/Makefile @@ -64,7 +64,9 @@ HAL_DRIVER_SRC = \ $(TOP_DIR)/platform/vendor_bsp/embarc_bsp/arc/arc_udma.c \ $(TOP_DIR)/platform/vendor_bsp/embarc_bsp/arc/arc_util.c \ $(TOP_DIR)/platform/vendor_bsp/embarc_bsp/library/clib/embARC_sbrk.c \ - $(TOP_DIR)/platform/vendor_bsp/embarc_bsp/library/clib/embARC_syscalls.c + $(TOP_DIR)/platform/vendor_bsp/embarc_bsp/library/clib/embARC_syscalls.c \ + $(TOP_DIR)/platform/vendor_bsp/embarc_bsp/library/console/xprintf/xprintf.c \ + $(TOP_DIR)/platform/vendor_bsp/embarc_bsp/library/console/console_io.c C_SOURCES += $(HAL_DRIVER_SRC) # ASM sources @@ -118,6 +120,7 @@ AS_DEFS = # C defines -DLIB_CONSOLE C_DEFS = \ +-DLIB_CONSOLE \ -DBOARD_NSIM \ -DCURRENT_CORE=arcem \ -DEMBARC_TCF_GENERATED \ @@ -156,9 +159,9 @@ HAL_DRIVER_INC = \ C_INCLUDES += $(HAL_DRIVER_INC) # compile gcc flags -ASFLAGS = -mcpu=em4_dmips -mlittle-endian -mcode-density -mdiv-rem -mswap -mnorm -mmpy-option=6 -mbarrel-shifter --param l1-cache-size=16384 --param l1-cache-line-size=32 $(C_DEFS) $(C_INCLUDES) $(OPT) -fdata-sections -ffunction-sections -std=gnu99 +ASFLAGS = -mcpu=em4_dmips -mlittle-endian -mcode-density -mdiv-rem -mswap -mnorm -mmpy-option=6 -mbarrel-shifter --param l1-cache-size=16384 --param l1-cache-line-size=32 $(C_DEFS) $(C_INCLUDES) $(OPT) -fdata-sections -ffunction-sections -mno-sdata -g -CFLAGS = -mcpu=em4_dmips -mlittle-endian -mcode-density -mdiv-rem -mswap -mnorm -mmpy-option=6 -mbarrel-shifter --param l1-cache-size=16384 --param l1-cache-line-size=32 $(C_DEFS) $(C_INCLUDES) $(OPT) -fdata-sections -ffunction-sections -std=gnu99 +CFLAGS = -mcpu=em4_dmips -mlittle-endian -mcode-density -mdiv-rem -mswap -mnorm -mmpy-option=6 -mbarrel-shifter --param l1-cache-size=16384 --param l1-cache-line-size=32 $(C_DEFS) $(C_INCLUDES) $(OPT) -fdata-sections -ffunction-sections -mno-sdata -g -std=gnu99 # ifeq ($(DEBUG), 1) # CFLAGS += -g -gdwarf-2 diff --git a/board/ARC_NSIM_EM/GCC/hello_world/linker_template_gnu.ldf b/board/ARC_NSIM_EM/GCC/hello_world/linker_template_gnu.ldf index 992b9647..077f1a15 100644 --- a/board/ARC_NSIM_EM/GCC/hello_world/linker_template_gnu.ldf +++ b/board/ARC_NSIM_EM/GCC/hello_world/linker_template_gnu.ldf @@ -1,30 +1,38 @@ MEMORY { - ICCM : ORIGIN = 0x00000000, LENGTH = 0x80000 - DCCM : ORIGIN = 0x80000000, LENGTH = 0x80000 + REGION_ICCM : ORIGIN = 0x00000000, LENGTH = 0x80000 + REGION_DCCM : ORIGIN = 0x80000000, LENGTH = 0x80000 + REGION_YCCM : ORIGIN = 0xe0000000, LENGTH = 8192 } ENTRY(_start) SECTIONS { .init : { + . = . + 0x0; _f_init = .; - KEEP (*(.init_vector)) - KEEP (*(.init_bootstrap)) + KEEP (*(.init_vector .init_vector.*)) + KEEP (*(.init_bootstrap .init_bootstrap.*)) _e_init = .; - } > ICCM + } > REGION_ICCM .vector : ALIGN(1024) { _f_vector = .; - *(.vector) + *(.vector .vector.*) _e_vector = .; - } > ICCM + } > REGION_ICCM + .y_ccm (NOLOAD) : ALIGN(8) + { + _f_y_ccm = .; + *(.y_ccm .y_ccm.*) + _e_y_ccm = .; + } > REGION_YCCM .text : ALIGN(4) { _f_text = .; *(.text .text.* .gnu.linkonce.t.*) _e_text = .; - } > ICCM + } > REGION_ICCM .rodata : ALIGN(4) { _f_rodata = .; @@ -46,7 +54,7 @@ SECTIONS __DTOR_END__ = .; *(.rodata .rodata.* .gnu.linkonce.r.*) _e_rodata = .; - } > ICCM + } > REGION_ICCM .data : ALIGN(4) { _f_data = .; @@ -54,14 +62,8 @@ SECTIONS _f_sdata = .; __SDATA_BEGIN__ = .; *(.sdata .sdata.* .gnu.linkonce.s.*) - _e_sdata = .; - _e_data = .; - } > DCCM AT > ICCM - .bss (NOLOAD) : ALIGN(8) - { PROVIDE (__sbss_start = .); PROVIDE (___sbss_start = .); - _f_bss = .; _f_sbss = .; *(.dynsbss) *(.sbss .sbss.* .gnu.linkonce.sb.*) @@ -69,18 +71,24 @@ SECTIONS _e_sbss = .; PROVIDE (__sbss_end = .); PROVIDE (___sbss_end = .); + _e_sdata = .; + _e_data = .; + } > REGION_DCCM AT > REGION_ICCM + .bss (NOLOAD) : ALIGN(8) + { + _f_bss = .; *(.dynbss) *(.bss .bss.* .gnu.linkonce.b.*) *(COMMON) _e_bss = .; - } > DCCM + } > REGION_DCCM .stack (NOLOAD) : { . = ALIGN(4); _f_stack = .; . = . + 2048; _e_stack = .; - } > DCCM + } > REGION_DCCM .heap (NOLOAD) : { . = ALIGN(4); @@ -89,7 +97,7 @@ SECTIONS . = . + 8192; _e_heap = .; __end_heap = . ; - } > DCCM + } > REGION_DCCM _load_addr_text = LOADADDR(.text); _load_addr_rodata = LOADADDR(.rodata); _load_addr_data = LOADADDR(.data);