From bc2a890ab08d163ccea323f7e719c4fdf53050cd Mon Sep 17 00:00:00 2001 From: ArdaFu Date: Thu, 31 Jul 2014 14:11:26 +0800 Subject: [PATCH] [BSP] TM4C129X: fix the bug that components_init do not work in IAR project 1. modify each dirver's INIT_EXPORT micro. 2. modify the lwip parameters' in rtconfig.h 3. insert keep section .rti_fn* in IAR link file 4. change part id from TM4C129XNCZAD to TM4C1294NCPDT --- bsp/tm4c129x/applications/application.c | 11 +------- bsp/tm4c129x/applications/board.c | 34 +++++++++++++------------ bsp/tm4c129x/drivers/drv_eth.c | 9 ++++++- bsp/tm4c129x/drivers/drv_eth.h | 2 +- bsp/tm4c129x/drivers/drv_uart.c | 4 +-- bsp/tm4c129x/libraries/SConscript | 2 -- bsp/tm4c129x/rtconfig.h | 12 ++++----- bsp/tm4c129x/rtconfig.py | 4 +-- bsp/tm4c129x/template.uvproj | 18 ++++++------- bsp/tm4c129x/tm4c_rom.icf | 3 ++- 10 files changed, 49 insertions(+), 50 deletions(-) diff --git a/bsp/tm4c129x/applications/application.c b/bsp/tm4c129x/applications/application.c index 984e62215..0ed8ab21d 100644 --- a/bsp/tm4c129x/applications/application.c +++ b/bsp/tm4c129x/applications/application.c @@ -13,23 +13,13 @@ */ #include -#include #include -#ifdef RT_USING_LWIP -#include "drv_eth.h" -#endif /* thread phase init */ void rt_init_thread_entry(void *parameter) { /* Initialization RT-Thread Components */ rt_components_init(); -#ifdef RT_USING_FINSH - finsh_set_device(RT_CONSOLE_DEVICE_NAME); -#endif -#ifdef RT_USING_LWIP - rt_hw_tiva_eth_init(); -#endif } int rt_application_init(void) @@ -42,3 +32,4 @@ int rt_application_init(void) return 0; } + diff --git a/bsp/tm4c129x/applications/board.c b/bsp/tm4c129x/applications/board.c index 2953e76c5..b0b3bd649 100644 --- a/bsp/tm4c129x/applications/board.c +++ b/bsp/tm4c129x/applications/board.c @@ -15,9 +15,9 @@ #include #include - +#include #include "board.h" -#include "drv_uart.h" + #include "driverlib/interrupt.h" #include "driverlib/sysctl.h" @@ -61,23 +61,27 @@ extern void HardFault_Handler(void); */ void rt_hw_board_init() { - MAP_IntMasterDisable(); + //init low level drivers. e.g. cpu uart etc. + rt_components_board_init(); + //redirect RTT stdio to CONSOLE device + rt_console_set_device(RT_CONSOLE_DEVICE_NAME); +} + +int rt_hw_cpu_init(void) +{ + MAP_IntMasterDisable(); IntRegister(FAULT_HARD, HardFault_Handler); IntRegister(FAULT_PENDSV, PendSV_Handler); IntRegister(FAULT_SYSTICK, SysTick_Handler); - // // Enable lazy stacking for interrupt handlers. This allows floating-point // instructions to be used within interrupt handlers, but at the expense of // extra stack usage. - // MAP_FPULazyStackingEnable(); - // // Set the clocking to run directly from the external crystal/oscillator. // TODO: The SYSCTL_XTAL_ value must be changed to match the value of the // crystal on your board. - // SysClock = MAP_SysCtlClockFreqSet( (SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), SYS_CLOCK_DEFAULT); @@ -89,13 +93,11 @@ void rt_hw_board_init() /* set pend exception priority */ //IntPrioritySet(FAULT_PENDSV, (1 << 5) - 1); - - /*init uart device*/ - rt_hw_uart_init(); - //redirect RTT stdio to CONSOLE device - rt_console_set_device(RT_CONSOLE_DEVICE_NAME); - // - // Enable interrupts to the processor. - // - MAP_IntMasterEnable(); + + /*Enable interrupts to the processor.*/ + MAP_IntMasterEnable(); + return 0; } +// rt_hw_cpu_init should be run before any other INIT_BOARD_EXPORT +// We use INIT_EXPORT here and set the sequence index to "0.xxxx" +INIT_EXPORT(rt_hw_cpu_init, "0.post"); \ No newline at end of file diff --git a/bsp/tm4c129x/drivers/drv_eth.c b/bsp/tm4c129x/drivers/drv_eth.c index 1355f533c..9d68a5d71 100644 --- a/bsp/tm4c129x/drivers/drv_eth.c +++ b/bsp/tm4c129x/drivers/drv_eth.c @@ -146,6 +146,8 @@ extern void lwIPHostGetTime(u32_t *time_s, u32_t *time_ns); #include "lwipopts.h" #include "drv_eth.h" +#include + /** * A structure used to keep track of driver state and error counts. */ @@ -1378,7 +1380,7 @@ static struct pbuf* eth_dev_rx(rt_device_t dev) return (result == RT_EOK)? (struct pbuf*)temp : RT_NULL; } -rt_err_t rt_hw_tiva_eth_init(void) +int rt_hw_tiva_eth_init(void) { rt_err_t result; @@ -1406,6 +1408,11 @@ rt_err_t rt_hw_tiva_eth_init(void) result = eth_device_init(&(eth_dev->parent), "e0"); return result; } +// eth_device_init using malloc +// We use INIT_COMPONENT_EXPORT insted of INIT_BOARD_EXPORT +INIT_COMPONENT_EXPORT(rt_hw_tiva_eth_init); + + #if 0 #ifdef RT_USING_FINSH #include "finsh.h" diff --git a/bsp/tm4c129x/drivers/drv_eth.h b/bsp/tm4c129x/drivers/drv_eth.h index 5f27139d5..54431405f 100644 --- a/bsp/tm4c129x/drivers/drv_eth.h +++ b/bsp/tm4c129x/drivers/drv_eth.h @@ -15,6 +15,6 @@ #ifndef __TIVA_ETH_H__ #define __TIVA_ETH_H__ -rt_err_t rt_hw_tiva_eth_init(void); +int rt_hw_tiva_eth_init(void); #endif diff --git a/bsp/tm4c129x/drivers/drv_uart.c b/bsp/tm4c129x/drivers/drv_uart.c index 20ce0db22..736527899 100644 --- a/bsp/tm4c129x/drivers/drv_uart.c +++ b/bsp/tm4c129x/drivers/drv_uart.c @@ -18,7 +18,7 @@ #include #include "board.h" -//#include +#include #include "inc/hw_memmap.h" #include "driverlib/sysctl.h" @@ -220,4 +220,4 @@ int rt_hw_uart_init(void) #endif return 0; } -//INIT_BOARD_EXPORT(rt_hw_uart_init); +INIT_BOARD_EXPORT(rt_hw_uart_init); diff --git a/bsp/tm4c129x/libraries/SConscript b/bsp/tm4c129x/libraries/SConscript index 02874cac1..8b48a34c7 100644 --- a/bsp/tm4c129x/libraries/SConscript +++ b/bsp/tm4c129x/libraries/SConscript @@ -14,8 +14,6 @@ elif rtconfig.CROSS_TOOL == 'keil': src += ['startup/startup_rvmdk.S'] elif rtconfig.CROSS_TOOL == 'iar': src += ['startup/startup_ewarm.c'] -elif rtconfig.CROSS_TOOL == 'ccs': - src += ['startup/startup_ccs.c'] CPPPATH = [cwd, cwd + '/inc', cwd + '/driverlib'] diff --git a/bsp/tm4c129x/rtconfig.h b/bsp/tm4c129x/rtconfig.h index 9d76c80f0..c00e4537a 100644 --- a/bsp/tm4c129x/rtconfig.h +++ b/bsp/tm4c129x/rtconfig.h @@ -180,19 +180,19 @@ // #define RT_LWIP_DNS // -#define RT_LWIP_PBUF_NUM 4 +#define RT_LWIP_PBUF_NUM 8 // -#define RT_LWIP_TCP_PCB_NUM 3 +#define RT_LWIP_TCP_PCB_NUM 5 // -#define RT_LWIP_TCP_SND_BUF 4086 +#define RT_LWIP_TCP_SND_BUF 8192 // -#define RT_LWIP_TCP_WND 2048 +#define RT_LWIP_TCP_WND 8192 // // #define RT_LWIP_SNMP // -// #define RT_LWIP_DHCP + #define RT_LWIP_DHCP // -#define RT_LWIP_TCP_SEG_NUM 12 +#define RT_LWIP_TCP_SEG_NUM 24 // #define RT_LWIP_TCPTHREAD_PRIORITY 12 // diff --git a/bsp/tm4c129x/rtconfig.py b/bsp/tm4c129x/rtconfig.py index 93e3f3e25..ba3fc51c9 100644 --- a/bsp/tm4c129x/rtconfig.py +++ b/bsp/tm4c129x/rtconfig.py @@ -29,8 +29,8 @@ elif CROSS_TOOL == 'iar': if os.getenv('RTT_EXEC_PATH'): EXEC_PATH = os.getenv('RTT_EXEC_PATH') -BUILD = 'debug' -#BUILD = 'release' +#BUILD = 'debug' +BUILD = 'release' if PLATFORM == 'gcc': # tool-chains diff --git a/bsp/tm4c129x/template.uvproj b/bsp/tm4c129x/template.uvproj index 1a84ba013..342711d8b 100644 --- a/bsp/tm4c129x/template.uvproj +++ b/bsp/tm4c129x/template.uvproj @@ -12,26 +12,26 @@ ARM-ADS - TM4C129XNCZAD + TM4C1294NCPDT Texas Instruments Keil.TM4C_DFP.1.0.0 http://www.keil.com/pack/ IROM(0x00000000,0x100000) IRAM(0x20000000,0x040000) CPUTYPE("Cortex-M4") FPU2 CLOCK(120000000) ELITTLE - UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0TM4C129_1024 -FS00 -FL0100000 -FP0($$Device:TM4C129XNCZAD$Flash\TM4C129_1024.FLM)) - 7096 - $$Device:TM4C129XNCZAD$Device\Include\TM4C129\TM4C129.h + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0TM4C129_1024 -FS00 -FL0100000 -FP0($$Device:TM4C1294NCPDT$Flash\TM4C129_1024.FLM)) + 7088 + $$Device:TM4C1294NCPDT$Device\Include\TM4C129\TM4C129.h - -DTM4C129XNCZAD + -DTM4C1294NCPDT - $$Device:TM4C129XNCZAD$SVD\TM4C129\TM4C129XNCZAD.svd + $$Device:TM4C1294NCPDT$SVD\TM4C129\TM4C1294NCPDT.svd 0 0 @@ -52,7 +52,7 @@ 0 0 1 - 0 + 1 .\ 1 0 @@ -148,7 +148,7 @@ 1 0 - 3 + 6 @@ -162,7 +162,7 @@ - BIN\lmidk-agdi.dll + Segger\JL2CM3.dll diff --git a/bsp/tm4c129x/tm4c_rom.icf b/bsp/tm4c129x/tm4c_rom.icf index b09595243..c5838c98e 100644 --- a/bsp/tm4c129x/tm4c_rom.icf +++ b/bsp/tm4c129x/tm4c_rom.icf @@ -77,4 +77,5 @@ place at start of SRAM { section VTABLE }; // place in SRAM { readwrite, block HEAP }; keep { section FSymTab }; -keep { section VSymTab }; \ No newline at end of file +keep { section VSymTab }; +keep { section .rti_fn* }; \ No newline at end of file