From b4bc59f918cfd463877f99080543bbe70f9bdbcc Mon Sep 17 00:00:00 2001 From: wuyangyong Date: Sat, 2 Jul 2011 15:13:39 +0000 Subject: [PATCH] update lpc2148 git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1583 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- bsp/lpc2148/SConstruct | 2 +- bsp/lpc2148/application.c | 33 +++++++-- bsp/lpc2148/lpc2148_rom.ld | 143 +++++++++++++++++++++++++++++++++++++ bsp/lpc2148/project.Opt | 15 ++-- bsp/lpc2148/project.Uv2 | 8 +-- bsp/lpc2148/rtconfig.py | 2 +- bsp/lpc2148/startup.c | 5 -- 7 files changed, 184 insertions(+), 24 deletions(-) create mode 100644 bsp/lpc2148/lpc2148_rom.ld diff --git a/bsp/lpc2148/SConstruct b/bsp/lpc2148/SConstruct index 64b819cd89..2229a86e97 100644 --- a/bsp/lpc2148/SConstruct +++ b/bsp/lpc2148/SConstruct @@ -6,7 +6,7 @@ RTT_ROOT = os.path.normpath(os.getcwd() + '/../..') sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')] from building import * -TARGET = 'rtthread-lpc2148.' + rtconfig.TARGET_EXT +TARGET = 'obj/rtthread-lpc2148.' + rtconfig.TARGET_EXT env = Environment(tools = ['mingw'], AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS, diff --git a/bsp/lpc2148/application.c b/bsp/lpc2148/application.c index 84241bdd4c..0a045de610 100644 --- a/bsp/lpc2148/application.c +++ b/bsp/lpc2148/application.c @@ -75,34 +75,55 @@ void rt_init_thread_entry(void *parameter) #define LED2 (1<<17) //P1 #define LED3 (1<<18) //P1 #define LED4 (1<<19) //P1 -ALIGN(4) -char thread_led1_stack[512]; + +ALIGN(4) char thread_led1_stack[512]; struct rt_thread thread_led1; void thread_led1_entry(void* parameter) { - volatile unsigned int i; + unsigned int count=0; + IO1DIR |= LED1; while(1) { + /* led1 on */ IO1CLR = LED1; +#ifndef RT_USING_FINSH + rt_kprintf("led1 on, count : %d\r\n",count); +#endif + count++; rt_thread_delay( RT_TICK_PER_SECOND/3 ); /* delay 0.3s */ + + /* led1 off */ IO1SET = LED1; +#ifndef RT_USING_FINSH + rt_kprintf("led1 off\r\n"); +#endif rt_thread_delay( RT_TICK_PER_SECOND/3 ); } } -ALIGN(4) -char thread_led2_stack[512]; +ALIGN(4) char thread_led2_stack[512]; struct rt_thread thread_led2; void thread_led2_entry(void* parameter) { - volatile unsigned int i; + unsigned int count=0; + IO1DIR |= LED2; while(1) { + /* led2 on */ IO1CLR = LED2; +#ifndef RT_USING_FINSH + rt_kprintf("led2 on, count : %d\r\n",count); +#endif + count++; rt_thread_delay( RT_TICK_PER_SECOND/2 ); /* delay 0.5s */ + + /* led2 off */ IO1SET = LED2; +#ifndef RT_USING_FINSH + rt_kprintf("led1 off\r\n"); +#endif rt_thread_delay( RT_TICK_PER_SECOND/2 ); } } diff --git a/bsp/lpc2148/lpc2148_rom.ld b/bsp/lpc2148/lpc2148_rom.ld new file mode 100644 index 0000000000..42af52415a --- /dev/null +++ b/bsp/lpc2148/lpc2148_rom.ld @@ -0,0 +1,143 @@ +OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") + +OUTPUT_ARCH(arm) + +MEMORY +{ + CODE (rx) : ORIGIN = 0x00000000, LENGTH = 512k /* 512KB flash */ + DATA (rw) : ORIGIN = 0x40000000, LENGTH = 32k /* 32K sram */ +} + +ENTRY(_start) + +_undefined_tack_size = 0x40; +_abort_tack_size = 0x40; +_fiq_tack_size = 0x100; +_irq_tack_size = 0x200; +_svc_tack_size = 0x400; + +SECTIONS +{ + . = 0; + + . = ALIGN(4); + .text : + { + *(.init) + *(.text) + *(.rodata) + *(.rodata*) + *(.glue_7) + *(.glue_7t) + + /* section information for finsh shell */ + . = ALIGN(4); + __fsymtab_start = .; + KEEP(*(FSymTab)) + __fsymtab_end = .; + . = ALIGN(4); + __vsymtab_start = .; + KEEP(*(VSymTab)) + __vsymtab_end = .; + . = ALIGN(4); + + } >CODE + + . = 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 + + __end_of_text__ = .; + + /* .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 + + .stack : + { + . = ALIGN(4); + _undefined_stack_base = .; + . = . + _undefined_tack_size; + _undefined_stack_top = .; + + _abort_stack_base = .; + . = . + _abort_tack_size; + _abort_stack_top = .; + + _fiq_stack_base = .; + . = . + _fiq_tack_size; + _fiq_stack_top = .; + + _irq_stack_base = .; + . = . + _irq_tack_size; + _irq_stack_top = .; + + _svc_stack_base = .; + . = . + _svc_tack_size; + _svc_stack_top = .; + } >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 = .; + + /* Align here to ensure that the .bss section occupies space up to + _end. Align after .bss to ensure correct alignment even if the + .bss section disappears because there are no input sections. */ + . = ALIGN(32 / 8); +} diff --git a/bsp/lpc2148/project.Opt b/bsp/lpc2148/project.Opt index a8fcc23a44..e5bac6fcf2 100644 --- a/bsp/lpc2148/project.Opt +++ b/bsp/lpc2148/project.Opt @@ -13,11 +13,11 @@ Target (rtthread-lpc2148), 0x0004 // Tools: 'ARM-ADS' GRPOPT 1,(Startup),0,0,0 GRPOPT 2,(Kernel),0,0,0 -GRPOPT 3,(LPC214X),1,0,0 +GRPOPT 3,(LPC214X),0,0,0 GRPOPT 4,(finsh),0,0,0 OPTFFF 1,1,1,0,0,0,0,0,<.\application.c> -OPTFFF 1,2,1,2,0,130,133,0,<.\startup.c> { 44,0,0,0,2,0,0,0,3,0,0,0,255,255,255,255,255,255,255,255,252,255,255,255,226,255,255,255,0,0,0,0,0,0,0,0,117,3,0,0,254,0,0,0 } +OPTFFF 1,2,1,1073741826,0,124,124,0,<.\startup.c> { 44,0,0,0,2,0,0,0,3,0,0,0,255,255,255,255,255,255,255,255,252,255,255,255,226,255,255,255,0,0,0,0,0,0,0,0,117,3,0,0,254,0,0,0 } OPTFFF 1,3,1,0,0,0,0,0,<.\board.c> OPTFFF 2,4,1,0,0,0,0,0,<..\..\src\clock.c> OPTFFF 2,5,1,0,0,0,0,0,<..\..\src\device.c> @@ -36,7 +36,7 @@ OPTFFF 2,17,1,0,0,0,0,0,<..\..\src\thread.c> OPTFFF 2,18,1,0,0,0,0,0,<..\..\src\timer.c> OPTFFF 3,19,1,0,0,0,0,0,<..\..\libcpu\arm\lpc214x\cpuport.c> OPTFFF 3,20,1,0,0,0,0,0,<..\..\libcpu\arm\lpc214x\serial.c> -OPTFFF 3,21,2,0,0,0,0,0,<..\..\libcpu\arm\lpc214x\context_rvds.S> +OPTFFF 3,21,2,100663296,0,0,0,0,<..\..\libcpu\arm\lpc214x\context_rvds.S> OPTFFF 3,22,2,0,0,0,0,0,<..\..\libcpu\arm\lpc214x\start_rvds.S> OPTFFF 3,23,1,0,0,0,0,0,<..\..\libcpu\arm\common\backtrace.c> OPTFFF 3,24,1,0,0,0,0,0,<..\..\libcpu\arm\common\div0.c> @@ -58,19 +58,20 @@ OPTFFF 4,38,1,0,0,0,0,0,<..\..\components\finsh\symbol.c> TARGOPT 1, (rtthread-lpc2148) ADSCLK=12000000 - OPTTT 0,1,1,0 + OPTTT 1,1,1,0 OPTHX 1,65535,0,0,0 OPTLX 79,66,8,<.\obj\> OPTOX 16 OPTLT 1,1,1,0,1,1,0,1,0,0,0,0 OPTXL 1,1,1,1,1,1,1,0,0 - OPTFL 0,0,1 + OPTFL 1,0,1 OPTAX 0 OPTDL (SARM.DLL)(-cLPC2100)(DARMP.DLL)(-pLPC2148)(SARM.DLL)()(TARMP.DLL)(-pLPC2148) - OPTDBG 48125,0,()()()()()()()()()() (BIN\UL2ARM.DLL)()()() + OPTDBG 48126,0,()()()()()()()()()() (BIN\UL2ARM.DLL)()()() + OPTKEY 0,(UL2ARM)(-UV0168AVR -O14 -S1 -C0 -N00("ARM7TDMI-S Core") -D00(4F1F0F0F) -L00(4) -FO19 -FD40000000 -FC800 -FN1 -FF0LPC_IAP2_512 -FS00 -FL07D000) OPTKEY 0,(DLGDARM)((134=-1,-1,-1,-1,0)(135=-1,-1,-1,-1,0)(153=-1,-1,-1,-1,0)(154=-1,-1,-1,-1,0)(108=-1,-1,-1,-1,0)(106=-1,-1,-1,-1,0)(105=-1,-1,-1,-1,0)(145=-1,-1,-1,-1,0)(147=-1,-1,-1,-1,0)(80=-1,-1,-1,-1,0)(104=-1,-1,-1,-1,0)(100=-1,-1,-1,-1,0)(101=-1,-1,-1,-1,0)(160=-1,-1,-1,-1,0)(161=-1,-1,-1,-1,0)(113=-1,-1,-1,-1,0)(112=-1,-1,-1,-1,0)(137=-1,-1,-1,-1,0)(138=-1,-1,-1,-1,0)(117=-1,-1,-1,-1,0)(146=-1,-1,-1,-1,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,0)(114=-1,-1,-1,-1,0)(141=-1,-1,-1,-1,0)(142=-1,-1,-1,-1,0)(143=-1,-1,-1,-1,0)(144=-1,-1,-1,-1,0)(115=-1,-1,-1,-1,0)(116=-1,-1,-1,-1,0)) OPTKEY 0,(ARMDBGFLAGS)(-T5F) - OPTDF 0x90 + OPTDF 0x94 OPTLE <> OPTLC <> EndOpt diff --git a/bsp/lpc2148/project.Uv2 b/bsp/lpc2148/project.Uv2 index 2336d22f74..a0ee74a332 100644 --- a/bsp/lpc2148/project.Uv2 +++ b/bsp/lpc2148/project.Uv2 @@ -127,13 +127,13 @@ Options 1,0,0 // Target 'rtthread-lpc2148' ADSLDSC () ADSLDIB () ADSLDIC () - ADSLDMC ( --keep __fsym_* --keep __vsym_*) + ADSLDMC ( --keep __fsym_* --keep __vsym_* ) ADSLDIF () ADSLDDW () OPTDL (SARM.DLL)(-cLPC2100)(DARMP.DLL)(-pLPC2148)(SARM.DLL)()(TARMP.DLL)(-pLPC2148) - OPTDBG 48125,0,()()()()()()()()()() (BIN\UL2ARM.DLL)()()() - FLASH1 { 1,0,0,0,0,0,0,0,255,255,255,255,0,0,0,0,0,0,0,0 } - FLASH2 () + OPTDBG 48126,0,()()()()()()()()()() (BIN\UL2ARM.DLL)()()() + FLASH1 { 9,0,0,0,1,0,0,0,0,16,0,0,0,0,0,0,0,0,0,0 } + FLASH2 (BIN\UL2ARM.DLL) FLASH3 ("LPC210x_ISP.EXE" ("#H" ^X $D COM1: 38400 1)) FLASH4 () EndOpt diff --git a/bsp/lpc2148/rtconfig.py b/bsp/lpc2148/rtconfig.py index b3bcd9d582..076712cb52 100644 --- a/bsp/lpc2148/rtconfig.py +++ b/bsp/lpc2148/rtconfig.py @@ -25,7 +25,7 @@ if PLATFORM == 'gcc': OBJDUMP = PREFIX + 'objdump' OBJCPY = PREFIX + 'objcopy' - DEVICE = ' -mcpu=arm7tdmi-s -mthumb' + DEVICE = ' -mcpu=arm7tdmi-s' CFLAGS = DEVICE + ' -DRT_USING_MINILIBC' AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp' LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread-lpc2148.map,-cref,-u,_start -T lpc2148_rom.ld' diff --git a/bsp/lpc2148/startup.c b/bsp/lpc2148/startup.c index a29819b06d..d0978dc40e 100644 --- a/bsp/lpc2148/startup.c +++ b/bsp/lpc2148/startup.c @@ -86,11 +86,6 @@ void rtthread_startup(void) /* init scheduler system */ rt_system_scheduler_init(); -#ifdef RT_USING_HOOK /* if the hook is used */ - /* set idle thread hook */ - rt_thread_idle_sethook(0); -#endif - #ifdef RT_USING_DEVICE #ifdef RT_USING_DFS /* init sd card */