Forums

Running program from RAM

Started by Subscriber February 9, 2009
Cannot figure out how to run program from RAM.

What I have: Ubuntu, codesourcery toolchain, openocd and Olimex'
LPC-p2148 board.

I'm using "blinky" program from Olimex website link.
Very simple and works from flash.

Now I want to run it from RAM - to set breakpoints.
I've read about linker script.
Seems easy.
When I changed section's location to RAM - ld correctly set it.
However, first problem was when I added "AT" - like

.text : /* collect all sections that should
go into FLASH after startup */
{
*(.text) /* all .text sections (code) */
*(.rodata) /* all .rodata sections
(constants, strings, etc.) */
*(.rodata*) /* all .rodata* sections
(constants, strings, etc.) */
*(.glue_7) /* all .glue_7 sections (no
idea what these are) */
*(.glue_7t) /* all .glue_7t sections (no
idea what these are) */
_etext = .; /* define a global symbol _etext
just after the last code byte */
} > ram AT>flash

I thought it should give me VMA at RAM and LMA at flash - that did not
happen - everything at RAM location.

Ok, anyway, I investigated further, found that thread about Atmel:
http://www.embeddedrelated.com/groups/AT91SAM/show/2452.php

From that explanation follows that typically we compile to run program
in memory for debugging only
(excluding variant with partial code in memory with "fastrun" ), and
there is no code in flash
which will copy program from flash to memory (in crt.S) on startup, we
simply load generated program
directly in memory bypassing flash.
If so, I do not understand, how it will work on reset?
Bootloader will start, look for signature at 0x000014, if valid, pass
execution to flash.
But in examples I found ( Martin Thomas ) I do not see any code in flash
which
on startup resets MEMMAP to RAM. So, how execution passed to RAM?
So, how it works?
Can someone point me where to look?

Thanks.
Dmitriy

An Engineer's Guide to the LPC2100 Series

Seems to found
1) start with xx-gdb yyy.out
2) target remote localhost:2001
3) load image.hex
4) b main
5) j MAIN_LINENUMBER.

Yahoo!
Sorry and thanks for reading.

Dmitriy

Subscriber wrote:
>
> Cannot figure out how to run program from RAM.
>
> What I have: Ubuntu, codesourcery toolchain, openocd and Olimex'
> LPC-p2148 board.
>
> I'm using "blinky" program from Olimex website link.
> Very simple and works from flash.
>
> Now I want to run it from RAM - to set breakpoints.
> I've read about linker script.
> Seems easy.
> When I changed section's location to RAM - ld correctly set it.
> However, first problem was when I added "AT" - like
>
> .text : /* collect all sections that should
> go into FLASH after startup */
> {
> *(.text) /* all .text sections (code) */
> *(.rodata) /* all .rodata sections
> (constants, strings, etc.) */
> *(.rodata*) /* all .rodata* sections
> (constants, strings, etc.) */
> *(.glue_7) /* all .glue_7 sections (no
> idea what these are) */
> *(.glue_7t) /* all .glue_7t sections (no
> idea what these are) */
> _etext = .; /* define a global symbol _etext
> just after the last code byte */
> } > ram AT>flash
>
> I thought it should give me VMA at RAM and LMA at flash - that did not
> happen - everything at RAM location.
>
> Ok, anyway, I investigated further, found that thread about Atmel:
> http://www.embeddedrelated.com/groups/AT91SAM/show/2452.php
> >From that explanation follows that typically we compile to run program
> in memory for debugging only
> (excluding variant with partial code in memory with "fastrun" ), and
> there is no code in flash
> which will copy program from flash to memory (in crt.S) on startup, we
> simply load generated program
> directly in memory bypassing flash.
> If so, I do not understand, how it will work on reset?
> Bootloader will start, look for signature at 0x000014, if valid, pass
> execution to flash.
> But in examples I found ( Martin Thomas ) I do not see any code in flash
> which
> on startup resets MEMMAP to RAM. So, how execution passed to RAM?
>
> So, how it works?
> Can someone point me where to look?
>
> Thanks.
> Dmitriy