EmbeddedRelated.com
Forums

supporting files for lpc2129

Started by raju December 11, 2009
i started to work on lpc2129(previously i was with lpc2148) to exploring CAN.Initially i am testing my LPC2129 UART.UART code is fine(compatable to lpc2148).i think no changes will done in startup file and linkerscript files.i am using GNU ARM gcc compiler with windows xp as O.S.i am posting the statup file(which is general for all arm7 boards),linker script(just changing the memory sizes of lpc2129 here(as far as i know))..But i am not getting the data on to hyperterminal.

Startup file
.section .text
.code 32
@.globl vectors

vectors:
b reset @ Reset
b . @ Undefined instruction
b . @ SWI
b . @ Prefetch abort
b . @ Data abort
b . @ reserved vector
@ The following instruction should transfer control to
@ the vector corresponding to ISR of IRQ
@ Most ARM micro-controllers include a built-in
@ Interrupt Controller. One example is the LPC2138.
@ It includes the VIC interrupt controller.
@ It will automatically put appropriate jump address
@ into the register "VICVectAddr" - provided the VIC
@ is configured appropriately by the user.
@ So the following instruction simply copies the contents
@ of "VICVectAddr" into PC.
@ This instruction is appropriate, if you are using
@ LPC2138 micro-controller (or it's cousins)
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ NOTE: You may need to change the following instruction
@ to make it work correctly for other ARM micro-controllers.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
ldr pc,[pc,#-0xFF0] @ irqs (to VICVectAddr)
b . @ fast irqs
reset:
@ clear .bss section
ldr r1, bss_start
ldr r2, bss_end
ldr r3, =0

clear_bss:
cmp r1,r2
strne r3,[r1],#+4
bne clear_bss

do_init:
ldr r1,initdata_start @ start address of init table
ldr r2,initdata_end @ end address of init table
do1init:cmp r1,r2
bhs init_done
ldr r0,[r1],#4 @ destination address
ldr r3,[r1],#4 @ number of bytes to copy
copy_loop:
ldrb r4,[r1],#1 @ read 1 byte from source
strb r4,[r0],#1 @ write 1 byte to destination
subs r3,r3,#1
bne copy_loop
@ now align the address in R1 to 4 bytes boundry
add r1,r1,#3
and r1,r1,#~3
b do1init
init_done:
@ init sp for supervisor (default) mode
ldr r13,stack_pointer

@ init sp for IRQ mode
mrs r0,cpsr
bic r1,r0,#0x1F
orr r1,r1,#0x012 @ IRQ mode= 0x12
msr cpsr_c,r1
ldr r13,irq_stack

@ enable IRQs & return to supervisor mode
bic r0,r0,#0x80 @ cpsr[7]=IRQ disable flag
msr cpsr_c,r0

@ run C program

bl main

here: b here

stack_pointer: .word _stack_top
irq_stack: .word _irq_stack_top
bss_start: .word __bss_start__
bss_end: .word __bss_end__
initdata_start: .word __initdata_start__
initdata_end: .word __initdata_end__
.end
Linker script file:-

ENTRY(vectors)

SEARCH_DIR(.)

MEMORY
{
rom (rx) : org = 0x00000000, len = 256K
ram (!rx) : org = 0x40000000, len = 16K
}

SECTIONS
{
.text :
{
startup.o (.text);
*(.text);
. = ALIGN(4);
__initdata_start__ = .;
*(.initdata);
. = ALIGN(4);
__initdata_end__ = .;
} > rom

.data :
{
datastart = .;
__data_start__ = . ;
*(.data)
. = ALIGN(4);
__data_end__ = . ;
} > ram

.bss ADDR(.data) + SIZEOF(.data) :
{
__bss_start__ = . ;
*(.bss); *(COMMON)
. = ALIGN(4);
__bss_end__ = . ;
_stack_bottom = . ;
} > ram

end = .;
_end = .;
__end__ = .;
_stack_top = 0x40007FFC;
_irq_stack_top = 0x40007BFC;
}
help me,thanks in advance.

An Engineer's Guide to the LPC2100 Series

You will need to change the linker script file as the LPC2129 and the
LPC2148 do not have the same amount of ROM and RAM.

I believe stack_top istoo high in the script, as there is only 16k worth on
RAM on the LPC2129.

Jean

On Fri, Dec 11, 2009 at 11:25 AM, raju wrote:

> i started to work on lpc2129(previously i was with lpc2148) to exploring
> CAN.Initially i am testing my LPC2129 UART.UART code is fine(compatable to
> lpc2148).i think no changes will done in startup file and linkerscript
> files.i am using GNU ARM gcc compiler with windows xp as O.S.i am posting
> the statup file(which is general for all arm7 boards),linker script(just
> changing the memory sizes of lpc2129 here(as far as i know))..But i am not
> getting the data on to hyperterminal.
>
> Startup file
>
> .section .text
> .code 32
> @.globl vectors
>
> vectors:
> b reset @ Reset
> b . @ Undefined instruction
> b . @ SWI
> b . @ Prefetch abort
> b . @ Data abort
> b . @ reserved vector
> @ The following instruction should transfer control to
> @ the vector corresponding to ISR of IRQ
> @ Most ARM micro-controllers include a built-in
> @ Interrupt Controller. One example is the LPC2138.
> @ It includes the VIC interrupt controller.
> @ It will automatically put appropriate jump address
> @ into the register "VICVectAddr" - provided the VIC
> @ is configured appropriately by the user.
> @ So the following instruction simply copies the contents
> @ of "VICVectAddr" into PC.
> @ This instruction is appropriate, if you are using
> @ LPC2138 micro-controller (or it's cousins)
> @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
> @ NOTE: You may need to change the following instruction
> @ to make it work correctly for other ARM micro-controllers.
> @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
> ldr pc,[pc,#-0xFF0] @ irqs (to VICVectAddr)
> b . @ fast irqs
>
> reset:
> @ clear .bss section
> ldr r1, bss_start
> ldr r2, bss_end
> ldr r3, =0
>
> clear_bss:
> cmp r1,r2
> strne r3,[r1],#+4
> bne clear_bss
>
> do_init:
> ldr r1,initdata_start @ start address of init table
> ldr r2,initdata_end @ end address of init table
> do1init:cmp r1,r2
> bhs init_done
> ldr r0,[r1],#4 @ destination address
> ldr r3,[r1],#4 @ number of bytes to copy
> copy_loop:
> ldrb r4,[r1],#1 @ read 1 byte from source
> strb r4,[r0],#1 @ write 1 byte to destination
> subs r3,r3,#1
> bne copy_loop
> @ now align the address in R1 to 4 bytes boundry
> add r1,r1,#3
> and r1,r1,#~3
> b do1init
> init_done:
> @ init sp for supervisor (default) mode
> ldr r13,stack_pointer
>
> @ init sp for IRQ mode
> mrs r0,cpsr
> bic r1,r0,#0x1F
> orr r1,r1,#0x012 @ IRQ mode= 0x12
> msr cpsr_c,r1
> ldr r13,irq_stack
>
> @ enable IRQs & return to supervisor mode
> bic r0,r0,#0x80 @ cpsr[7]=IRQ disable flag
> msr cpsr_c,r0
>
> @ run C program
>
> bl main
>
> here: b here
>
> stack_pointer: .word _stack_top
> irq_stack: .word _irq_stack_top
> bss_start: .word __bss_start__
> bss_end: .word __bss_end__
> initdata_start: .word __initdata_start__
> initdata_end: .word __initdata_end__
> .end
>
> Linker script file:-
>
> ENTRY(vectors)
>
> SEARCH_DIR(.)
>
> MEMORY
> {
> rom (rx) : org = 0x00000000, len = 256K
> ram (!rx) : org = 0x40000000, len = 16K
> }
>
> SECTIONS
> {
> .text :
> {
> startup.o (.text);
> *(.text);
> . = ALIGN(4);
> __initdata_start__ = .;
> *(.initdata);
> . = ALIGN(4);
> __initdata_end__ = .;
> } > rom
>
> .data :
> {
> datastart = .;
> __data_start__ = . ;
> *(.data)
> . = ALIGN(4);
> __data_end__ = . ;
> } > ram
>
> .bss ADDR(.data) + SIZEOF(.data) :
> {
> __bss_start__ = . ;
> *(.bss); *(COMMON)
> . = ALIGN(4);
> __bss_end__ = . ;
> _stack_bottom = . ;
> } > ram
>
> end = .;
> _end = .;
> __end__ = .;
> _stack_top = 0x40007FFC;
> _irq_stack_top = 0x40007BFC;
> }
>
> help me,thanks in advance.
>
>
>
with changes only(changed RAM to 16k,ROM to 256k in )Linker script file which is posted previously.
--- In l..., Jean-Sebastien Stoezel wrote:
>
> You will need to change the linker script file as the LPC2129 and the
> LPC2148 do not have the same amount of ROM and RAM.
>
> I believe stack_top istoo high in the script, as there is only 16k worth on
> RAM on the LPC2129.
>
> Jean
>
> On Fri, Dec 11, 2009 at 11:25 AM, raju wrote:
>
> >
> >
> >
> >
> > i started to work on lpc2129(previously i was with lpc2148) to exploring
> > CAN.Initially i am testing my LPC2129 UART.UART code is fine(compatable to
> > lpc2148).i think no changes will done in startup file and linkerscript
> > files.i am using GNU ARM gcc compiler with windows xp as O.S.i am posting
> > the statup file(which is general for all arm7 boards),linker script(just
> > changing the memory sizes of lpc2129 here(as far as i know))..But i am not
> > getting the data on to hyperterminal.
> >
> > Startup file
> >
> > .section .text
> > .code 32
> > @.globl vectors
> >
> > vectors:
> > b reset @ Reset
> > b . @ Undefined instruction
> > b . @ SWI
> > b . @ Prefetch abort
> > b . @ Data abort
> > b . @ reserved vector
> > @ The following instruction should transfer control to
> > @ the vector corresponding to ISR of IRQ
> > @ Most ARM micro-controllers include a built-in
> > @ Interrupt Controller. One example is the LPC2138.
> > @ It includes the VIC interrupt controller.
> > @ It will automatically put appropriate jump address
> > @ into the register "VICVectAddr" - provided the VIC
> > @ is configured appropriately by the user.
> > @ So the following instruction simply copies the contents
> > @ of "VICVectAddr" into PC.
> > @ This instruction is appropriate, if you are using
> > @ LPC2138 micro-controller (or it's cousins)
> > @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
> > @ NOTE: You may need to change the following instruction
> > @ to make it work correctly for other ARM micro-controllers.
> > @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
> > ldr pc,[pc,#-0xFF0] @ irqs (to VICVectAddr)
> > b . @ fast irqs
> >
> > reset:
> > @ clear .bss section
> > ldr r1, bss_start
> > ldr r2, bss_end
> > ldr r3, =0
> >
> > clear_bss:
> > cmp r1,r2
> > strne r3,[r1],#+4
> > bne clear_bss
> >
> > do_init:
> > ldr r1,initdata_start @ start address of init table
> > ldr r2,initdata_end @ end address of init table
> > do1init:cmp r1,r2
> > bhs init_done
> > ldr r0,[r1],#4 @ destination address
> > ldr r3,[r1],#4 @ number of bytes to copy
> > copy_loop:
> > ldrb r4,[r1],#1 @ read 1 byte from source
> > strb r4,[r0],#1 @ write 1 byte to destination
> > subs r3,r3,#1
> > bne copy_loop
> > @ now align the address in R1 to 4 bytes boundry
> > add r1,r1,#3
> > and r1,r1,#~3
> > b do1init
> > init_done:
> > @ init sp for supervisor (default) mode
> > ldr r13,stack_pointer
> >
> > @ init sp for IRQ mode
> > mrs r0,cpsr
> > bic r1,r0,#0x1F
> > orr r1,r1,#0x012 @ IRQ mode= 0x12
> > msr cpsr_c,r1
> > ldr r13,irq_stack
> >
> > @ enable IRQs & return to supervisor mode
> > bic r0,r0,#0x80 @ cpsr[7]=IRQ disable flag
> > msr cpsr_c,r0
> >
> > @ run C program
> >
> > bl main
> >
> > here: b here
> >
> > stack_pointer: .word _stack_top
> > irq_stack: .word _irq_stack_top
> > bss_start: .word __bss_start__
> > bss_end: .word __bss_end__
> > initdata_start: .word __initdata_start__
> > initdata_end: .word __initdata_end__
> > .end
> >
> > Linker script file:-
> >
> > ENTRY(vectors)
> >
> > SEARCH_DIR(.)
> >
> > MEMORY
> > {
> > rom (rx) : org = 0x00000000, len = 256K
> > ram (!rx) : org = 0x40000000, len = 16K
> > }
> >
> > SECTIONS
> > {
> > .text :
> > {
> > startup.o (.text);
> > *(.text);
> > . = ALIGN(4);
> > __initdata_start__ = .;
> > *(.initdata);
> > . = ALIGN(4);
> > __initdata_end__ = .;
> > } > rom
> >
> > .data :
> > {
> > datastart = .;
> > __data_start__ = . ;
> > *(.data)
> > . = ALIGN(4);
> > __data_end__ = . ;
> > } > ram
> >
> > .bss ADDR(.data) + SIZEOF(.data) :
> > {
> > __bss_start__ = . ;
> > *(.bss); *(COMMON)
> > . = ALIGN(4);
> > __bss_end__ = . ;
> > _stack_bottom = . ;
> > } > ram
> >
> > end = .;
> > _end = .;
> > __end__ = .;
> > _stack_top = 0x40007FFC;
> > _irq_stack_top = 0x40007BFC;
> > }
> >
> > help me,thanks in advance.
> >
> >
>

What are the changes I need to be done(in startup and linkerscript files of lpc2148) here for lpc2129?help me,thanks in advance.

--- In l..., "raju" wrote:
> with changes only(changed RAM to 16k,ROM to 256k in )Linker script file which is posted previously.
> --- In l..., Jean-Sebastien Stoezel wrote:
> >
> > You will need to change the linker script file as the LPC2129 and the
> > LPC2148 do not have the same amount of ROM and RAM.
> >
> > I believe stack_top istoo high in the script, as there is only 16k worth on
> > RAM on the LPC2129.
> >
> > Jean
> >
> > On Fri, Dec 11, 2009 at 11:25 AM, raju wrote:
> >
> > >
> > >
> > >
> > >
> > > i started to work on lpc2129(previously i was with lpc2148) to exploring
> > > CAN.Initially i am testing my LPC2129 UART.UART code is fine(compatable to
> > > lpc2148).i think no changes will done in startup file and linkerscript
> > > files.i am using GNU ARM gcc compiler with windows xp as O.S.i am posting
> > > the statup file(which is general for all arm7 boards),linker script(just
> > > changing the memory sizes of lpc2129 here(as far as i know))..But i am not
> > > getting the data on to hyperterminal.
> > >
> > > Startup file
> > >
> > > .section .text
> > > .code 32
> > > @.globl vectors
> > >
> > > vectors:
> > > b reset @ Reset
> > > b . @ Undefined instruction
> > > b . @ SWI
> > > b . @ Prefetch abort
> > > b . @ Data abort
> > > b . @ reserved vector
> > > @ The following instruction should transfer control to
> > > @ the vector corresponding to ISR of IRQ
> > > @ Most ARM micro-controllers include a built-in
> > > @ Interrupt Controller. One example is the LPC2138.
> > > @ It includes the VIC interrupt controller.
> > > @ It will automatically put appropriate jump address
> > > @ into the register "VICVectAddr" - provided the VIC
> > > @ is configured appropriately by the user.
> > > @ So the following instruction simply copies the contents
> > > @ of "VICVectAddr" into PC.
> > > @ This instruction is appropriate, if you are using
> > > @ LPC2138 micro-controller (or it's cousins)
> > > @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
> > > @ NOTE: You may need to change the following instruction
> > > @ to make it work correctly for other ARM micro-controllers.
> > > @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
> > > ldr pc,[pc,#-0xFF0] @ irqs (to VICVectAddr)
> > > b . @ fast irqs
> > >
> > > reset:
> > > @ clear .bss section
> > > ldr r1, bss_start
> > > ldr r2, bss_end
> > > ldr r3, =0
> > >
> > > clear_bss:
> > > cmp r1,r2
> > > strne r3,[r1],#+4
> > > bne clear_bss
> > >
> > > do_init:
> > > ldr r1,initdata_start @ start address of init table
> > > ldr r2,initdata_end @ end address of init table
> > > do1init:cmp r1,r2
> > > bhs init_done
> > > ldr r0,[r1],#4 @ destination address
> > > ldr r3,[r1],#4 @ number of bytes to copy
> > > copy_loop:
> > > ldrb r4,[r1],#1 @ read 1 byte from source
> > > strb r4,[r0],#1 @ write 1 byte to destination
> > > subs r3,r3,#1
> > > bne copy_loop
> > > @ now align the address in R1 to 4 bytes boundry
> > > add r1,r1,#3
> > > and r1,r1,#~3
> > > b do1init
> > > init_done:
> > > @ init sp for supervisor (default) mode
> > > ldr r13,stack_pointer
> > >
> > > @ init sp for IRQ mode
> > > mrs r0,cpsr
> > > bic r1,r0,#0x1F
> > > orr r1,r1,#0x012 @ IRQ mode= 0x12
> > > msr cpsr_c,r1
> > > ldr r13,irq_stack
> > >
> > > @ enable IRQs & return to supervisor mode
> > > bic r0,r0,#0x80 @ cpsr[7]=IRQ disable flag
> > > msr cpsr_c,r0
> > >
> > > @ run C program
> > >
> > > bl main
> > >
> > > here: b here
> > >
> > > stack_pointer: .word _stack_top
> > > irq_stack: .word _irq_stack_top
> > > bss_start: .word __bss_start__
> > > bss_end: .word __bss_end__
> > > initdata_start: .word __initdata_start__
> > > initdata_end: .word __initdata_end__
> > > .end
> > >
> > > Linker script file:-
> > >
> > > ENTRY(vectors)
> > >
> > > SEARCH_DIR(.)
> > >
> > > MEMORY
> > > {
> > > rom (rx) : org = 0x00000000, len = 256K
> > > ram (!rx) : org = 0x40000000, len = 16K
> > > }
> > >
> > > SECTIONS
> > > {
> > > .text :
> > > {
> > > startup.o (.text);
> > > *(.text);
> > > . = ALIGN(4);
> > > __initdata_start__ = .;
> > > *(.initdata);
> > > . = ALIGN(4);
> > > __initdata_end__ = .;
> > > } > rom
> > >
> > > .data :
> > > {
> > > datastart = .;
> > > __data_start__ = . ;
> > > *(.data)
> > > . = ALIGN(4);
> > > __data_end__ = . ;
> > > } > ram
> > >
> > > .bss ADDR(.data) + SIZEOF(.data) :
> > > {
> > > __bss_start__ = . ;
> > > *(.bss); *(COMMON)
> > > . = ALIGN(4);
> > > __bss_end__ = . ;
> > > _stack_bottom = . ;
> > > } > ram
> > >
> > > end = .;
> > > _end = .;
> > > __end__ = .;
> > > _stack_top = 0x40007FFC;
> > > _irq_stack_top = 0x40007BFC;
> > > }
> > >
> > > help me,thanks in advance.
> > >
> > >
> > >
>

Hello raju,

have you already had a look what info is inside the linker script file ?

Have you already compared FLASH / RAM addresses and sizes between LPC2129 and LPC2148 ?

There was already a hint by Jean:
>>> I believe stack_top is too high in the script,
>>> as there is only 16k worth on RAM on the LPC2129.

Have you understood what he is meaning ?

When you have this info it is easy to do the needed changes.
Perhaps post your comparison so it is easier for us to help you,
without doing the comparison again and again by a lot other people here on this group.

Pay special attention to the following lines (of the linker script file):

> > > > rom (rx) : org = 0x00000000, len = 256K
> > > > ram (!rx) : org = 0x40000000, len = 16K

> > > > _stack_top = 0x40007FFC;
> > > > _irq_stack_top = 0x40007BFC;

These are addresses which have a certain negative offset to RAM end of a 32 KB RAM of LPC2148.

General question to help you with your problem:
Are you reaching the main() ? Can you toggle LED's, you can see what code you reach and
if there is a bug in startup code or later in UART code ? Interrupt driven or polled mode ?

Regards,

Martin

--- In l..., "raju" wrote:
> What are the changes I need to be done(in startup and linkerscript files of lpc2148) here for lpc2129?help me,thanks in advance.
>
> --- In l..., "raju" wrote:
> >
> >
> > with changes only(changed RAM to 16k,ROM to 256k in )Linker script file which is posted previously.
> > --- In l..., Jean-Sebastien Stoezel wrote:
> > >
> > > You will need to change the linker script file as the LPC2129 and the
> > > LPC2148 do not have the same amount of ROM and RAM.
> > >
> > > I believe stack_top istoo high in the script, as there is only 16k worth on
> > > RAM on the LPC2129.
> > >
> > > Jean
> > >
> > > On Fri, Dec 11, 2009 at 11:25 AM, raju wrote:
> > >
> > > >
> > > >
> > > >
> > > >
> > > > i started to work on lpc2129(previously i was with lpc2148) to exploring
> > > > CAN.Initially i am testing my LPC2129 UART.UART code is fine(compatable to
> > > > lpc2148).i think no changes will done in startup file and linkerscript
> > > > files.i am using GNU ARM gcc compiler with windows xp as O.S.i am posting
> > > > the statup file(which is general for all arm7 boards),linker script(just
> > > > changing the memory sizes of lpc2129 here(as far as i know))..But i am not
> > > > getting the data on to hyperterminal.
> > > >
> > > > Startup file
> > > >
> > > > .section .text
> > > > .code 32
> > > > @.globl vectors
> > > >
> > > > vectors:
> > > > b reset @ Reset
> > > > b . @ Undefined instruction
> > > > b . @ SWI
> > > > b . @ Prefetch abort
> > > > b . @ Data abort
> > > > b . @ reserved vector
> > > > @ The following instruction should transfer control to
> > > > @ the vector corresponding to ISR of IRQ
> > > > @ Most ARM micro-controllers include a built-in
> > > > @ Interrupt Controller. One example is the LPC2138.
> > > > @ It includes the VIC interrupt controller.
> > > > @ It will automatically put appropriate jump address
> > > > @ into the register "VICVectAddr" - provided the VIC
> > > > @ is configured appropriately by the user.
> > > > @ So the following instruction simply copies the contents
> > > > @ of "VICVectAddr" into PC.
> > > > @ This instruction is appropriate, if you are using
> > > > @ LPC2138 micro-controller (or it's cousins)
> > > > @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
> > > > @ NOTE: You may need to change the following instruction
> > > > @ to make it work correctly for other ARM micro-controllers.
> > > > @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
> > > > ldr pc,[pc,#-0xFF0] @ irqs (to VICVectAddr)
> > > > b . @ fast irqs
> > > >
> > > > reset:
> > > > @ clear .bss section
> > > > ldr r1, bss_start
> > > > ldr r2, bss_end
> > > > ldr r3, =0
> > > >
> > > > clear_bss:
> > > > cmp r1,r2
> > > > strne r3,[r1],#+4
> > > > bne clear_bss
> > > >
> > > > do_init:
> > > > ldr r1,initdata_start @ start address of init table
> > > > ldr r2,initdata_end @ end address of init table
> > > > do1init:cmp r1,r2
> > > > bhs init_done
> > > > ldr r0,[r1],#4 @ destination address
> > > > ldr r3,[r1],#4 @ number of bytes to copy
> > > > copy_loop:
> > > > ldrb r4,[r1],#1 @ read 1 byte from source
> > > > strb r4,[r0],#1 @ write 1 byte to destination
> > > > subs r3,r3,#1
> > > > bne copy_loop
> > > > @ now align the address in R1 to 4 bytes boundry
> > > > add r1,r1,#3
> > > > and r1,r1,#~3
> > > > b do1init
> > > > init_done:
> > > > @ init sp for supervisor (default) mode
> > > > ldr r13,stack_pointer
> > > >
> > > > @ init sp for IRQ mode
> > > > mrs r0,cpsr
> > > > bic r1,r0,#0x1F
> > > > orr r1,r1,#0x012 @ IRQ mode= 0x12
> > > > msr cpsr_c,r1
> > > > ldr r13,irq_stack
> > > >
> > > > @ enable IRQs & return to supervisor mode
> > > > bic r0,r0,#0x80 @ cpsr[7]=IRQ disable flag
> > > > msr cpsr_c,r0
> > > >
> > > > @ run C program
> > > >
> > > > bl main
> > > >
> > > > here: b here
> > > >
> > > > stack_pointer: .word _stack_top
> > > > irq_stack: .word _irq_stack_top
> > > > bss_start: .word __bss_start__
> > > > bss_end: .word __bss_end__
> > > > initdata_start: .word __initdata_start__
> > > > initdata_end: .word __initdata_end__
> > > > .end
> > > >
> > > > Linker script file:-
> > > >
> > > > ENTRY(vectors)
> > > >
> > > > SEARCH_DIR(.)
> > > >
> > > > MEMORY
> > > > {
> > > > rom (rx) : org = 0x00000000, len = 256K
> > > > ram (!rx) : org = 0x40000000, len = 16K
> > > > }
> > > >
> > > > SECTIONS
> > > > {
> > > > .text :
> > > > {
> > > > startup.o (.text);
> > > > *(.text);
> > > > . = ALIGN(4);
> > > > __initdata_start__ = .;
> > > > *(.initdata);
> > > > . = ALIGN(4);
> > > > __initdata_end__ = .;
> > > > } > rom
> > > >
> > > > .data :
> > > > {
> > > > datastart = .;
> > > > __data_start__ = . ;
> > > > *(.data)
> > > > . = ALIGN(4);
> > > > __data_end__ = . ;
> > > > } > ram
> > > >
> > > > .bss ADDR(.data) + SIZEOF(.data) :
> > > > {
> > > > __bss_start__ = . ;
> > > > *(.bss); *(COMMON)
> > > > . = ALIGN(4);
> > > > __bss_end__ = . ;
> > > > _stack_bottom = . ;
> > > > } > ram
> > > >
> > > > end = .;
> > > > _end = .;
> > > > __end__ = .;
> > > > _stack_top = 0x40007FFC;
> > > > _irq_stack_top = 0x40007BFC;
> > > > }
> > > >
> > > > help me,thanks in advance.
> > > >
> > > >
> > > >
> > >
>

> > > > rom (rx) : org = 0x00000000, len = 256K
> > > > ram (!rx) : org = 0x40000000, len = 16K

> > > > _stack_top = 0x40007FFC;
> > > > _irq_stack_top = 0x40007BFC;

These are addresses which have a certain negative offset to RAM end of a 32 KB RAM of LPC2148.
I have no idea,on linker script file and how _stack_top=0x40007FFC
_irq_stack_top = 0x40007BFC
these values are kept in case of lpc2148 which has 32k RAM?thanks in advance.

--- In l..., "capiman26061973" wrote:
>
> Hello raju,
>
> have you already had a look what info is inside the linker script file ?
>
> Have you already compared FLASH / RAM addresses and sizes between LPC2129 and LPC2148 ?
>
> There was already a hint by Jean:
> >>> I believe stack_top is too high in the script,
> >>> as there is only 16k worth on RAM on the LPC2129.
>
> Have you understood what he is meaning ?
>
> When you have this info it is easy to do the needed changes.
> Perhaps post your comparison so it is easier for us to help you,
> without doing the comparison again and again by a lot other people here on this group.
>
> Pay special attention to the following lines (of the linker script file):
>
> > > > > rom (rx) : org = 0x00000000, len = 256K
> > > > > ram (!rx) : org = 0x40000000, len = 16K
>
> > > > > _stack_top = 0x40007FFC;
> > > > > _irq_stack_top = 0x40007BFC;
>
> These are addresses which have a certain negative offset to RAM end of a 32 KB RAM of LPC2148.
>
> General question to help you with your problem:
> Are you reaching the main() ? Can you toggle LED's, you can see what code you reach and
> if there is a bug in startup code or later in UART code ? Interrupt driven or polled mode ?
>
> Regards,
>
> Martin
>
> --- In l..., "raju" wrote:
> >
> >
> > What are the changes I need to be done(in startup and linkerscript files of lpc2148) here for lpc2129?help me,thanks in advance.
> >
> > --- In l..., "raju" wrote:
> > >
> > >
> > > with changes only(changed RAM to 16k,ROM to 256k in )Linker script file which is posted previously.
> > > --- In l..., Jean-Sebastien Stoezel wrote:
> > > >
> > > > You will need to change the linker script file as the LPC2129 and the
> > > > LPC2148 do not have the same amount of ROM and RAM.
> > > >
> > > > I believe stack_top istoo high in the script, as there is only 16k worth on
> > > > RAM on the LPC2129.
> > > >
> > > > Jean
> > > >
> > > > On Fri, Dec 11, 2009 at 11:25 AM, raju wrote:
> > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > i started to work on lpc2129(previously i was with lpc2148) to exploring
> > > > > CAN.Initially i am testing my LPC2129 UART.UART code is fine(compatable to
> > > > > lpc2148).i think no changes will done in startup file and linkerscript
> > > > > files.i am using GNU ARM gcc compiler with windows xp as O.S.i am posting
> > > > > the statup file(which is general for all arm7 boards),linker script(just
> > > > > changing the memory sizes of lpc2129 here(as far as i know))..But i am not
> > > > > getting the data on to hyperterminal.
> > > > >
> > > > > Startup file
> > > > >
> > > > > .section .text
> > > > > .code 32
> > > > > @.globl vectors
> > > > >
> > > > > vectors:
> > > > > b reset @ Reset
> > > > > b . @ Undefined instruction
> > > > > b . @ SWI
> > > > > b . @ Prefetch abort
> > > > > b . @ Data abort
> > > > > b . @ reserved vector
> > > > > @ The following instruction should transfer control to
> > > > > @ the vector corresponding to ISR of IRQ
> > > > > @ Most ARM micro-controllers include a built-in
> > > > > @ Interrupt Controller. One example is the LPC2138.
> > > > > @ It includes the VIC interrupt controller.
> > > > > @ It will automatically put appropriate jump address
> > > > > @ into the register "VICVectAddr" - provided the VIC
> > > > > @ is configured appropriately by the user.
> > > > > @ So the following instruction simply copies the contents
> > > > > @ of "VICVectAddr" into PC.
> > > > > @ This instruction is appropriate, if you are using
> > > > > @ LPC2138 micro-controller (or it's cousins)
> > > > > @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
> > > > > @ NOTE: You may need to change the following instruction
> > > > > @ to make it work correctly for other ARM micro-controllers.
> > > > > @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
> > > > > ldr pc,[pc,#-0xFF0] @ irqs (to VICVectAddr)
> > > > > b . @ fast irqs
> > > > >
> > > > > reset:
> > > > > @ clear .bss section
> > > > > ldr r1, bss_start
> > > > > ldr r2, bss_end
> > > > > ldr r3, =0
> > > > >
> > > > > clear_bss:
> > > > > cmp r1,r2
> > > > > strne r3,[r1],#+4
> > > > > bne clear_bss
> > > > >
> > > > > do_init:
> > > > > ldr r1,initdata_start @ start address of init table
> > > > > ldr r2,initdata_end @ end address of init table
> > > > > do1init:cmp r1,r2
> > > > > bhs init_done
> > > > > ldr r0,[r1],#4 @ destination address
> > > > > ldr r3,[r1],#4 @ number of bytes to copy
> > > > > copy_loop:
> > > > > ldrb r4,[r1],#1 @ read 1 byte from source
> > > > > strb r4,[r0],#1 @ write 1 byte to destination
> > > > > subs r3,r3,#1
> > > > > bne copy_loop
> > > > > @ now align the address in R1 to 4 bytes boundry
> > > > > add r1,r1,#3
> > > > > and r1,r1,#~3
> > > > > b do1init
> > > > > init_done:
> > > > > @ init sp for supervisor (default) mode
> > > > > ldr r13,stack_pointer
> > > > >
> > > > > @ init sp for IRQ mode
> > > > > mrs r0,cpsr
> > > > > bic r1,r0,#0x1F
> > > > > orr r1,r1,#0x012 @ IRQ mode= 0x12
> > > > > msr cpsr_c,r1
> > > > > ldr r13,irq_stack
> > > > >
> > > > > @ enable IRQs & return to supervisor mode
> > > > > bic r0,r0,#0x80 @ cpsr[7]=IRQ disable flag
> > > > > msr cpsr_c,r0
> > > > >
> > > > > @ run C program
> > > > >
> > > > > bl main
> > > > >
> > > > > here: b here
> > > > >
> > > > > stack_pointer: .word _stack_top
> > > > > irq_stack: .word _irq_stack_top
> > > > > bss_start: .word __bss_start__
> > > > > bss_end: .word __bss_end__
> > > > > initdata_start: .word __initdata_start__
> > > > > initdata_end: .word __initdata_end__
> > > > > .end
> > > > >
> > > > > Linker script file:-
> > > > >
> > > > > ENTRY(vectors)
> > > > >
> > > > > SEARCH_DIR(.)
> > > > >
> > > > > MEMORY
> > > > > {
> > > > > rom (rx) : org = 0x00000000, len = 256K
> > > > > ram (!rx) : org = 0x40000000, len = 16K
> > > > > }
> > > > >
> > > > > SECTIONS
> > > > > {
> > > > > .text :
> > > > > {
> > > > > startup.o (.text);
> > > > > *(.text);
> > > > > . = ALIGN(4);
> > > > > __initdata_start__ = .;
> > > > > *(.initdata);
> > > > > . = ALIGN(4);
> > > > > __initdata_end__ = .;
> > > > > } > rom
> > > > >
> > > > > .data :
> > > > > {
> > > > > datastart = .;
> > > > > __data_start__ = . ;
> > > > > *(.data)
> > > > > . = ALIGN(4);
> > > > > __data_end__ = . ;
> > > > > } > ram
> > > > >
> > > > > .bss ADDR(.data) + SIZEOF(.data) :
> > > > > {
> > > > > __bss_start__ = . ;
> > > > > *(.bss); *(COMMON)
> > > > > . = ALIGN(4);
> > > > > __bss_end__ = . ;
> > > > > _stack_bottom = . ;
> > > > > } > ram
> > > > >
> > > > > end = .;
> > > > > _end = .;
> > > > > __end__ = .;
> > > > > _stack_top = 0x40007FFC;
> > > > > _irq_stack_top = 0x40007BFC;
> > > > > }
> > > > >
> > > > > help me,thanks in advance.
> > > > >
> > > > >
> > > > >
> > > >
> > >
>

--- In l..., "raju" wrote:
>
> > > > > rom (rx) : org = 0x00000000, len = 256K
> > > > > ram (!rx) : org = 0x40000000, len = 16K
>
> > > > > _stack_top = 0x40007FFC;
> > > > > _irq_stack_top = 0x40007BFC;
>
> These are addresses which have a certain negative offset to RAM end of a 32 KB RAM of LPC2148.
> I have no idea,on linker script file and how _stack_top=0x40007FFC
> _irq_stack_top = 0x40007BFC
> these values are kept in case of lpc2148 which has 32k RAM?thanks in advance.
>
Those symbols (_stack_top, _irq_stack_top) are defined in the linker script and used in the startup code. There are other symbols that are defined in the startup code and referenced in the linker script.

These two files go hand-in-hand. They must both be correct for the variant of chip selected. In general, the startup code is more generic because the requirements are dictated by C. Other than the vectors, of course.

There may, or may not, be a difference in the address of the VIC. If so, one of the vectors may need to change.

In any event, those two stack addresses are wrong! You only have 16k and those are defined for 32k.

Richard

Hi richard,

thank u,

_stack_top = 0x40007FFC;
_irq_stack_top = 0x40007BFC;
Can u tell me,what are the values i need to set here for lpc2129 which 256k
flash and 16k RAM?

On Sun, Dec 13, 2009 at 1:24 AM, rtstofer wrote:

> --- In l... , "raju"
> wrote:
> >
> > > > > > rom (rx) : org = 0x00000000, len = 256K
> > > > > > ram (!rx) : org = 0x40000000, len = 16K
> >
> > > > > > _stack_top = 0x40007FFC;
> > > > > > _irq_stack_top = 0x40007BFC;
> >
> > These are addresses which have a certain negative offset to RAM end of a
> 32 KB RAM of LPC2148.
> >
> >
> > I have no idea,on linker script file and how _stack_top=0x40007FFC
> > _irq_stack_top = 0x40007BFC
> > these values are kept in case of lpc2148 which has 32k RAM?thanks in
> advance.
> > Those symbols (_stack_top, _irq_stack_top) are defined in the linker script
> and used in the startup code. There are other symbols that are defined in
> the startup code and referenced in the linker script.
>
> These two files go hand-in-hand. They must both be correct for the variant
> of chip selected. In general, the startup code is more generic because the
> requirements are dictated by C. Other than the vectors, of course.
>
> There may, or may not, be a difference in the address of the VIC. If so,
> one of the vectors may need to change.
>
> In any event, those two stack addresses are wrong! You only have 16k and
> those are defined for 32k.
>
> Richard
>
>
>

--
Raju Nalla
Application Engineer
Unistring Tech solution pvt Ltd
--- In l..., Raju N wrote:
>
> Hi richard,
>
> thank u,
>
> _stack_top = 0x40007FFC;
> _irq_stack_top = 0x40007BFC;
> Can u tell me,what are the values i need to set here for lpc2129 which 256k
> flash and 16k RAM?
>
> On Sun, Dec 13, 2009 at 1:24 AM, rtstofer wrote:

You can get the memory map from Figure 2 of the User Manual

I'm not sure why they are leaving 1 word at the top of RAM, but what's one word?

_stack_top = 0x40003FFC;
_irq_stack_top = 0x40003BFC;

So, they're putting the irq stack 1k below the regular stack. Seems like that isn't much stack for user programs but I haven't looked at the startup code to see what they are doing.

Were it me, I would put the irq stack at the top of memory becuse interrupt routines don't generally have a lot of local variables to push on the stack. I would have the user stack underneath the irq stack.

But that's a refinement. It's unlikely these values will cause a problem in the beginning.

Richard

--- In l..., "rtstofer" wrote:
>
> --- In l..., Raju N wrote:
> >

I am not interested in Raju Ns homework problem.

> > On Sun, Dec 13, 2009 at 1:24 AM, rtstofer wrote:
>
> You can get the memory map from Figure 2 of the User Manual
>
> I'm not sure why they are leaving 1 word at the top of RAM, but what's one word?
>
> _stack_top = 0x40003FFC;

Richard,

How did you calculate one word at the top ??

don