LPC2294 external memory

Hi Everyone,

I have an Olimex LPC-L2294 board and using Eclipse with Yagarto and

GNUARM. For quick tests and debugging I build my project to run from

the internal RAM, but it’s only 16K and my project had been grown a

bit bigger.

My idea is to build this project to have the stack, the interrupt

vector table and the startup code be placed into internal RAM, but all

the other code and data into external RAM. My only problem is that I’m

not sure whether it can work or not and how can I achieve this. I

think I’ll have to tell LD to link the project this way but I have not

enough practice to know the best method.

Is there anyone who can help me?

An other question is that how can I utilize the external Flash memory?

As I know LPC2000 Flash Utility programs the internal Flash only. Is

there any other tool to program the external Flash, or should I use

IAP (if yes, then are there any examples available to see the correct

method?) or I’m on an absolutely wrong path?

Thanks,

Blaise

My idea is to build this project to have the stack, the interrupt

vector table and the startup code be placed into internal RAM, but all

the other code and data into external RAM. My only problem is that I’m

not sure whether it can work or not and how can I achieve this.

It's possible and the way I'm pursuading with my E2214 board indeed.

I think I’ll have to tell LD to link the project this way

Yes, but ld.script (LD linker script for code layout) is not complicated so much.
  • initial code (== startup code in your words) is carefully designed as “position independent”, in which code is to use program counter relative addresses (+/- offset of current instruction running at any moment) to load/store/jump ops. Not worry; ARM code is mostly position independent besides explicit absolute address references.

  • initial code copies TEXT and DATA from flash to external SRAM.

  • these are linked against CS1 (0x8100’0000) external SRAM address region.

  • initial code is part of TEXT whose link address is CS1, but it can run ok since it’s designed position independent while running around internal flash address region (0x0000’0000~).

  • initial code prepares zero cleared BSS segment in CS1.

  • initial code assigns stack pointer with an address somewhere in internal SRAM (it’d be plain easy to have external SRAM stack instead).

  • initial code copies vector table (64 bytes) to 0x4000’0000 of internal SRAM region. ARM vector table takes the following convention in most cases;

newvector:
        ldr     pc, Ljmptbl+0
        ldr     pc, Ljmptbl+4
        ldr     pc, Ljmptbl+8
        ldr     pc, Ljmptbl+12
        ldr     pc, Ljmptbl+16
        nop     
        ldr     pc, Ljmptbl+24
        ldr     pc, Ljmptbl+28
Ljmptbl: 
        .word   ini_entry 
        .word   und_entry 
        .word   swi_entry 
        .word   abt_entry 
        .word   abt_entry 
        .word   0
        .word   irq_entry
        .word   frq_entry

note that these ldr instructions are all identical; ldr pc, [pc, #24].

  • initial code changes MEMMAP register to have 0x2.

  • then jumps to C program entry point and hands over its control.


Dear Boothowto,

Thanks a lot for Your kind and detailed answer, I’ll try this way.

Regards,

Blaise

I was vague about ld.script for CS1. Since your TEXT+DATA will be in train, there is no need to have fancy ld.script after all. Just should be ok to have;

$(LD) -e _start -Ttext 0x81000000 ...

here _start is the very beginnig of TEXT. You may check how the entire address was laid out with “nm -Bon” command. The resulting .hex executable image can be written straight in flash.