diff --git a/bsp/sam7x/application.c b/bsp/sam7x/application.c index c6cb353dcccc8803274fdedb049eba7eb02013a3..1cb09b0bf9336fd02068796afafa8ae046f31fae 100644 --- a/bsp/sam7x/application.c +++ b/bsp/sam7x/application.c @@ -15,70 +15,75 @@ /** * @addtogroup sam7x */ -/*@{*/ -#include - -#ifdef RT_USING_DFS -/* dfs init */ -#include -/* dfs filesystem:FAT filesystem init */ -#include -/* dfs filesystem:EFS filesystem init */ -#include -/* dfs Filesystem APIs */ -#include -#endif - -#ifdef RT_USING_LWIP -#include -#endif - -#ifdef RT_USING_RTGUI -#include -#endif - -/* thread phase init */ -void rt_init_thread_entry(void *parameter) -{ -/* Filesystem Initialization */ -#ifdef RT_USING_DFS - { - /* init the device filesystem */ - dfs_init(); - /* init the efsl filesystam*/ - efsl_init(); - - /* mount sd card fat partition 1 as root directory */ - if (dfs_mount("sd0", "/", "efs", 0, 0) == 0) - rt_kprintf("File System initialized!\n"); - else - rt_kprintf("File System init failed!\n"); - } -#endif - -/* LwIP Initialization */ -#ifdef RT_USING_LWIP - { - extern void lwip_sys_init(void); - - /* init lwip system */ - lwip_sys_init(); - rt_kprintf("TCP/IP initialized!\n"); - } -#endif -} - +/*@{*/ +#include + +#ifdef RT_USING_DFS +/* dfs init */ +#include +/* dfs filesystem:FAT filesystem init */ +#include +/* dfs filesystem:EFS filesystem init */ +#include +/* dfs Filesystem APIs */ +#include +#endif + +#ifdef RT_USING_LWIP +#include +#endif + +#ifdef RT_USING_RTGUI +#include +#endif + +/* thread phase init */ +void rt_init_thread_entry(void *parameter) +{ +/* Filesystem Initialization */ +#ifdef RT_USING_DFS + { + /* init the device filesystem */ + dfs_init(); + /* init the efsl filesystam*/ + efsl_init(); + + /* mount sd card fat partition 1 as root directory */ + if (dfs_mount("sd0", "/", "efs", 0, 0) == 0) + rt_kprintf("File System initialized!\n"); + else + rt_kprintf("File System init failed!\n"); + } +#endif + +/* LwIP Initialization */ +#ifdef RT_USING_LWIP + { + extern void lwip_sys_init(void); + + eth_system_device_init(); + + /* register AT91 EMAC device */ + sam7xether_register("E0"); + + /* init lwip system */ + lwip_sys_init(); + rt_kprintf("TCP/IP initialized!\n"); + } +#endif +} + int rt_application_init() -{ - rt_thread_t init_thread; - - init_thread = rt_thread_create("init", - rt_init_thread_entry, RT_NULL, - 1024, 8, 5); - rt_thread_startup(init_thread); - - rt_kprintf("enter list() to get function list!\n"); - +{ + rt_thread_t init_thread; + + init_thread = rt_thread_create("init", + rt_init_thread_entry, RT_NULL, + 1024, 8, 5); + rt_thread_startup(init_thread); + + rt_kprintf("enter list() to get function list!\n"); + return 0; } diff --git a/bsp/sam7x/board.h b/bsp/sam7x/board.h index db4c456e4e857c3eb887a526f0beb331d3b57fd2..97a1e449fcb011596f215f1305fb56055292ec3f 100644 --- a/bsp/sam7x/board.h +++ b/bsp/sam7x/board.h @@ -17,46 +17,7 @@ #include #include -// These are defined in standard header (at91sam7x256.h) of realview MDK. -//#define AT91C_US_RXRDY ((unsigned int) 0x1 << 0) /* US RXRDY Interrupt */ -//#define AT91C_US_TXRDY ((unsigned int) 0x1 << 1) /* US TXRDY Interrupt */ -//#define AT91C_US_RSTRX ((unsigned int) 0x1 << 2) /* US Reset Receiver */ -//#define AT91C_US_RSTTX ((unsigned int) 0x1 << 3) /* US Reset Transmitter */ -//#define AT91C_US_RXEN ((unsigned int) 0x1 << 4) /* US Receiver Enable */ -//#define AT91C_US_RXDIS ((unsigned int) 0x1 << 5) /* US Receiver Disable */ -//#define AT91C_US_TXEN ((unsigned int) 0x1 << 6) /* US Transmitter Enable */ -//#define AT91C_US_TXDIS ((unsigned int) 0x1 << 7) /* US Transmitter Disable */ -//#define AT91C_US_RSTSTA ((unsigned int) 0x1 << 8) /* US Reset Status Bits */ -// -//#define AT91C_US_USMODE_NORMAL ((unsigned int) 0x0) /* USAR) Normal */ -//#define AT91C_US_USMODE_RS485 ((unsigned int) 0x1) /* USAR) RS485 */ -//#define AT91C_US_USMODE_HWHSH ((unsigned int) 0x2) /* USAR) Hardware Handshaking */ -//#define AT91C_US_USMODE_MODEM ((unsigned int) 0x3) /* USAR) Modem */ -//#define AT91C_US_USMODE_ISO7816_0 ((unsigned int) 0x4) /* USAR) ISO7816 protocol: T = 0 */ -//#define AT91C_US_USMODE_ISO7816_1 ((unsigned int) 0x6) /* USAR) ISO7816 protocol: T = 1 */ -//#define AT91C_US_USMODE_IRDA ((unsigned int) 0x8) /* USAR) IrDA */ -//#define AT91C_US_USMODE_SWHSH ((unsigned int) 0xC) /* USAR) Software Handshaking */ -// -//#define AT91C_US_CLKS_CLOCK ((unsigned int) 0x0 << 4) /* USAR) Clock */ -//#define AT91C_US_CLKS_FDIV1 ((unsigned int) 0x1 << 4) /* USAR) fdiv1 */ -//#define AT91C_US_CLKS_SLOW ((unsigned int) 0x2 << 4) /* USAR) slow_clock (ARM) */ -//#define AT91C_US_CLKS_EXT ((unsigned int) 0x3 << 4) /* USAR) External (SCK) */ -// -//#define AT91C_US_CHRL_5_BITS ((unsigned int) 0x0 << 6) /* USAR) Character Length: 5 bits */ -//#define AT91C_US_CHRL_6_BITS ((unsigned int) 0x1 << 6) /* USAR) Character Length: 6 bits */ -//#define AT91C_US_CHRL_7_BITS ((unsigned int) 0x2 << 6) /* USAR) Character Length: 7 bits */ -//#define AT91C_US_CHRL_8_BITS ((unsigned int) 0x3 << 6) /* USAR) Character Length: 8 bits */ -// -//#define AT91C_US_PAR_EVEN ((unsigned int) 0x0 << 9) /* DBGU Even Parity */ -//#define AT91C_US_PAR_ODD ((unsigned int) 0x1 << 9) /* DBGU Odd Parity */ -//#define AT91C_US_PAR_SPACE ((unsigned int) 0x2 << 9) /* DBGU Parity forced to 0 (Space) */ -//#define AT91C_US_PAR_MARK ((unsigned int) 0x3 << 9) /* DBGU Parity forced to 1 (Mark) */ -//#define AT91C_US_PAR_NONE ((unsigned int) 0x4 << 9) /* DBGU No Parity */ -//#define AT91C_US_PAR_MULTI_DROP ((unsigned int) 0x6 << 9) /* DBGU Multi-drop mode */ -// -//#define AT91C_US_NBSTOP_1_BIT ((unsigned int) 0x0 << 12) /* USART 1 stop bit */ -//#define AT91C_US_NBSTOP_15_BIT ((unsigned int) 0x1 << 12) /* USART Asynchronous (SYNC=0) 2 stop bits Synchronous (SYNC=1) 2 stop bits */ -//#define AT91C_US_NBSTOP_2_BIT ((unsigned int) 0x2 << 12) /* USART 2 stop bits */ + #define MCK 48054857 #define BR 115200 /* Baud Rate */ diff --git a/bsp/sam7x/rtconfig.py b/bsp/sam7x/rtconfig.py index 983e4c5f23d0950149576f7ee61030c306752dfe..59666f0669071b73beb68021d25c3a32551dd71a 100644 --- a/bsp/sam7x/rtconfig.py +++ b/bsp/sam7x/rtconfig.py @@ -32,7 +32,7 @@ if PLATFORM == 'gcc': DEVICE = ' -mcpu=arm7tdmi' CFLAGS = DEVICE AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp' - LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=sam7x_rom_gcc.map,-cref,-u,_start -T sam7x_rom.lds' + LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=sam7x_rom_gcc.map,-cref,-u,_start -T sam7x_rom.ld' CPATH = '' LPATH = '' @@ -42,7 +42,7 @@ if PLATFORM == 'gcc': else: CFLAGS += ' -O2' - POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread-sam7x.bin\n' + SIZE + ' $TARGET \n' + POST_ACTION = OBJCPY + ' -O ihex $TARGET rtthread-sam7x.hex\n' + SIZE + ' $TARGET \n' elif PLATFORM == 'armcc': # toolchains @@ -69,7 +69,7 @@ elif PLATFORM == 'armcc': else: CFLAGS += ' -O2' - POST_ACTION = 'fromelf --bin $TARGET --output rtthread.bin \nfromelf -z $TARGET' + POST_ACTION = 'fromelf --hex $TARGET --output rtthread-asm7x.hex \nfromelf -z $TARGET' elif PLATFORM == 'iar': # toolchains diff --git a/bsp/sam7x/sam7x_ram.lds b/bsp/sam7x/sam7x_ram.lds deleted file mode 100644 index 43a56de7b50291f142f12f6aea6224c157d79b6e..0000000000000000000000000000000000000000 --- a/bsp/sam7x/sam7x_ram.lds +++ /dev/null @@ -1,37 +0,0 @@ -OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") -OUTPUT_ARCH(arm) -MEMORY -{ - DATA (rw) : ORIGIN = 0x00200000, LENGTH = 0x00010000 -} -ENTRY(_start) -SECTIONS -{ - .text : - { - *(.init) - *(.text) - } > DATA = 0 - - . = ALIGN(4); - .rodata : - { - *(.rodata) - } > DATA - - . = ALIGN(4); - .data : - { - *(.data) - } > DATA - - . = ALIGN(4); - __bss_start = .; - .bss : - { - *(.bss) - } > DATA - __bss_end = .; - - _end = .; -} diff --git a/bsp/sam7x/sam7x_rom.ld b/bsp/sam7x/sam7x_rom.ld new file mode 100644 index 0000000000000000000000000000000000000000..41522bc2cd3ee843d8bd01ea972d95e319ca3d75 --- /dev/null +++ b/bsp/sam7x/sam7x_rom.ld @@ -0,0 +1,100 @@ +OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") +OUTPUT_ARCH(arm) +MEMORY +{ + CODE (rx) : ORIGIN = 0x00100000, LENGTH = 0x00040000 + /* DATA (rw) : ORIGIN = 0x00200000, LENGTH = 0x00010000 */ + DATA (rw) : ORIGIN = 0x00204000, LENGTH = 0x0000C000 +} +ENTRY(_start) +SECTIONS +{ + .text : + { + *(.init) + *(.text) + *(.rodata) + + /* section information for finsh shell */ + . = ALIGN(4); + __fsymtab_start = .; + KEEP(*(FSymTab)) + __fsymtab_end = .; + . = ALIGN(4); + __vsymtab_start = .; + KEEP(*(VSymTab)) + __vsymtab_end = .; + . = ALIGN(4); + + } > CODE = 0 + + . = ALIGN(4); + .ctors : + { + PROVIDE(__ctors_start__ = .); + KEEP(*(SORT(.ctors.*))) + KEEP(*(.ctors)) + PROVIDE(__ctors_end__ = .); + } > CODE + + .dtors : + { + PROVIDE(__dtors_start__ = .); + KEEP(*(SORT(.dtors.*))) + KEEP(*(.dtors)) + PROVIDE(__dtors_end__ = .); + } > CODE + + /* .ARM.exidx is sorted, so has to go in its own output section. */ + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + + /* This is used by the startup in order to initialize the .data secion */ + _sidata = .; + } > CODE + __exidx_end = .; + + /* .data section which is used for initialized data */ + .data : AT (_sidata) + { + . = ALIGN(4); + /* This is used by the startup in order to initialize the .data secion */ + _sdata = . ; + + *(.data) + *(.data.*) + *(.gnu.linkonce.d*) + + . = ALIGN(4); + /* This is used by the startup in order to initialize the .data secion */ + _edata = . ; + } >DATA + __data_end = .; + + .noinit : + { + *(.bss.noinit) + } > DATA + + __bss_start = .; + .bss : + { + . = ALIGN(4); + /* This is used by the startup in order to initialize the .bss secion */ + _sbss = .; + + *(.bss) + *(COMMON) + + . = ALIGN(4); + /* This is used by the startup in order to initialize the .bss secion */ + _ebss = . ; + _estack = .; + } > DATA + __bss_end = .; + + _end = .; + +} diff --git a/bsp/sam7x/sam7x_rom.lds b/bsp/sam7x/sam7x_rom.lds deleted file mode 100644 index 12acf4b547486a0389db3536263bc673818abf7b..0000000000000000000000000000000000000000 --- a/bsp/sam7x/sam7x_rom.lds +++ /dev/null @@ -1,50 +0,0 @@ -OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") -OUTPUT_ARCH(arm) -MEMORY -{ - CODE (rx) : ORIGIN = 0x00100000, LENGTH = 0x00040000 - DATA (rw) : ORIGIN = 0x00200000, LENGTH = 0x00010000 -} -ENTRY(_start) -SECTIONS -{ - .text : - { - *(.init) - *(.text) - - /* section information for finsh shell */ - . = ALIGN(4); - __fsymtab_start = .; - KEEP(*(FSymTab)) - __fsymtab_end = .; - . = ALIGN(4); - __vsymtab_start = .; - KEEP(*(VSymTab)) - __vsymtab_end = .; - . = ALIGN(4); - - } > CODE = 0 - - . = ALIGN(4); - .rodata : - { - *(.rodata) - } > CODE - - . = ALIGN(4); - .data : - { - *(.data) - } > DATA - - . = ALIGN(4); - __bss_start = .; - .bss : - { - *(.bss) - } > DATA - __bss_end = .; - - _end = .; -} diff --git a/bsp/sam7x/startup.c b/bsp/sam7x/startup.c index 513c9244f94b8dee25eae14ac4e3ee240f658488..abf9b58c516d35814ccf7ac58b1eeccd68ffde00 100644 --- a/bsp/sam7x/startup.c +++ b/bsp/sam7x/startup.c @@ -15,16 +15,16 @@ #include #include -#include "board.h" +#include "board.h" -#ifdef RT_USING_DFS -#include "sd.h" -#endif - -#ifdef RT_USING_LWIP -#include "sam7x_emac.h" -extern rt_err_t eth_system_device_init(void); -#endif +#ifdef RT_USING_DFS +#include "sd.h" +#endif + +#ifdef RT_USING_LWIP +#include "sam7x_emac.h" +extern rt_err_t eth_system_device_init(void); +#endif #ifdef RT_USING_FINSH #include @@ -113,16 +113,9 @@ void rtthread_startup(void) /* init hardware serial device */ rt_hw_serial_init(); -#ifdef RT_USING_LWIP - eth_system_device_init(); - - /* register AT91 EMAC device */ - sam7xether_register("E0"); -#endif - -#ifdef RT_USING_DFS - rt_hw_sdcard_init(); -#endif +#ifdef RT_USING_DFS + rt_hw_sdcard_init(); +#endif /*init all registed devices*/ rt_device_init_all(); @@ -147,6 +140,7 @@ void rtthread_startup(void) return ; } +#ifdef __CC_ARM int main (void) { /* invoke rtthread_startup */ @@ -154,5 +148,6 @@ int main (void) return 0; } +#endif /*@}*/