Hi Arvid,
To do this with CrossWorks (which I presume you are using) you'll need
to put the overlay functions in their own section. This can be done
using the GCC section attribute on each function
int overlayfn(int) __attribute__ ((section("overlay")));
int overlayfn(int x)
{
return x+1;
}
or alternatively you can use the "Section Options | Code Section Name"
property to put all functions from a compilation unit into a named section.
You then need to modify the section_placement file.
Right click on the "flash_placement.xml" in the project explorer and
select "Import" to take a local copy of the section_placement file.
Double click on the "flash_placement.xml" file and using the editor add
a new section into the "FLASH" memory segment called (for example)
"overlay".
Change the "Load" property of the section to be "Yes" and change the
"Section To Run In" to be (for example) "overlay_run".
In the "SRAM" memory segment create a section called (for example)
"overlay_run".
Save the file TWICE - bug in the section_placement editor requires this.
The file should look like this
<!DOCTYPE Linker_Placement_File>
<Root name="Flash Section Placement" >
<MemorySegment name="FLASH" >
<ProgramSection load="Yes" inputsections="*(.vectors .vectors.*)"
name=".vectors" />
<ProgramSection alignment="4" load="Yes" inputsections="*(.init
.init.*)" name=".init" />
<ProgramSection alignment="4" load="No" name=".text_load" />
<ProgramSection alignment="4" load="Yes" inputsections="*(.text
.text.* .glue_7t .glue_7 .gnu.linkonce.t.*)" name=".text" />
<ProgramSection alignment="4" load="Yes" inputsections="KEEP
(*(SORT(.dtors.*))) KEEP (*(.dtors))" name=".dtors" />
<ProgramSection alignment="4" load="Yes" inputsections="KEEP
(*(SORT(.ctors.*))) KEEP (*(.ctors))" name=".ctors" />
<ProgramSection alignment="4" load="Yes" inputsections="*(.rodata
.rodata.* .gnu.linkonce.r.*)" name=".rodata" />
<ProgramSection alignment="4" load="Yes" runin=".fast_run"
inputsections="*(.fast .fast.*)" name=".fast" />
<ProgramSection alignment="4" load="Yes" runin=".data_run"
inputsections="*(.data .data.* .gnu.linkonce.d.*)" name=".data" />
<ProgramSection load="Yes" runin="overlay_run" name="overlay" />
</MemorySegment>
<MemorySegment name="External SRAM;SRAM;SDRAM;DRAM" >
<ProgramSection alignment="4" load="No" name=".data_run" />
<ProgramSection alignment="4" load="No" inputsections="*(.bss .bss.*
.gnu.linkonce.b.*) *(COMMON)" name=".bss" />
<ProgramSection alignment="4" size="__HEAPSIZE__" load="No"
name=".heap" />
<ProgramSection alignment="4" size="__STACKSIZE__" load="No"
name=".stack" />
<ProgramSection alignment="4" size="__STACKSIZE_IRQ__" load="No"
name=".stack_irq" />
<ProgramSection alignment="4" size="__STACKSIZE_FIQ__" load="No"
name=".stack_fiq" />
<ProgramSection alignment="4" size="__STACKSIZE_SVC__" load="No"
name=".stack_svc" />
<ProgramSection alignment="4" size="__STACKSIZE_ABT__" load="No"
name=".stack_abt" />
<ProgramSection alignment="4" size="__STACKSIZE_UND__" load="No"
name=".stack_und" />
<ProgramSection name="overlay_run" />
</MemorySegment>
<MemorySegment name="Internal SRAM;SRAM;SDRAM;DRAM" >
<ProgramSection size="0x3C" load="No" name=".vectors_ram" />
<ProgramSection alignment="4" load="No" name=".fast_run" />
</MemorySegment>
</Root>
you can use "Edit As.. Text to verify.
Now the overlay function must be copied (at some point) using the
following code
extern unsigned __overlay_start__, __overlay_end__, __overlay_load_start__;
{
.....
memcpy(&__overlay_start__, &__overlay_load_start__, ((unsigned
char*)&__overlay_end__)-((unsigned char *)&__overlay_start__));
.....
}
The symbols are linker generated symbols (they aren't in memory
locations) hence the odd use of & to get their value.
Now you can call the functions as normal.
I can send you a zipped example of this if you need it.
Regards
Michael
>Hi,
>
>for an in-system update of the firmware i have the following idea:
>1. store the new firmware in an external serial flash
>2. allocate memory in RAM with malloc() for the update function
>3. copy update-function from ROM to RAM
>4. call update-function in RAM
>5. update-function copies firmware from external serial flash to
>internal flash with IAP commands
>
>My question is, how code can be executed in RAM.
>How can i call a function in RAM?
>Thanks for all hints.
>
>Regards
>Arvid
>
>
>
>
>
>
>
>Yahoo! Groups Links
>
>
>
>
>
>
>
>
>Message
Re: [lpc2000] Execute Code in RAM?
2005-03-11 by Michael Johnson
Attachments
- No local attachments were found for this message.