How to get const char arrays to external memory?
Hi,
we're reaching the end of FLASH memory on our AT91SAM7X512 processor, and unfortunately this is the biggest processor in the whole family. But we've kilobytes of texts in the flash, which is used by our embedded web server to build the configuration pages.
The plan is to get this data away from the valueable program flash of the processor into a large SPI data flash on our boards. The webserver routines can then fetch the data as needed from the data flash - in this area we don't need a fast access to these arrays.
My thoughts are to tell the compiler not to place these arrays into the FLASH section of the processor, so out of the addresseable space. The best would be having an own binary file with all these text data, which can be loaded into the SPI data flash by (this can be handled by the TFTP server in our software).
However, i would need:
- getting the webserver const char arrays away from the internal program FLASH
- get a kind of .bin or .hex file with just these data
My first tries here are:
I've created a new memory segment in the AT91SAM7X512_MemoryMap.xml, called "SPIFLASH" in an area outside the processor memory range:
<!DOCTYPE Board_Memory_Definition_File>
<Root name="AT91SAM7X512">
<MemorySegment start="0x00100000" size="0x00080000" access="ReadOnly" name="FLASH"/>
<MemorySegment start="0x10000000" size="0x00040000" access="ReadOnly" name="SPIFLASH"/>
<MemorySegment start="0x00200000" size="0x00020000" access="Read/Write" name="SRAM"/>
<MemorySegment start="0xFFFFF000" size="0x00001000" name="System Controller">
.....
Then i've added this in the flash_placement.xml file:
<MemorySegment name="SPIFLASH">
<ProgramSection alignment="4" load="No" name=".spiflash"/>
</MemorySegment>
And at least i've changed an array like this in the program code:
const char style1[] = "\
<style type=text/css>\n\
body{font-family:%s;background:%s}\n\
div.title{width:%dpx;color:%s;background:%s}\n\
h1,h4{margin-bottom:5px}\n\
h1{margin-top:5px}\n\
h4{margin-top:0px;padding-bottom:10px}\n\
th,td{font-size:%dpt;padding-left:15px;padding-right:15px}\n\
th{background:%s;color:%s}\n\
td{background:%s;color:%s}\n\
input{font-size:%dpt;color:%s}\n"; __attribute__((section(".spiflash")))
Whith the "__attribute__" command it should tell the compiler to place the string into the new "SPIFLASH" memory section - but the linker just returns the error:
Build\THUMB Flash Debug/TMO-100.elf section `.spiflash' will not fit in region `UNPLACED_SECTIONS'
After reading the manual two times i can't see what i did wrong ... and how i can get to my goal to get the strings out of the processor memory and get an own .bin or .hex file with these data.
Any ideas are highly appreciated!
Marco
-
OK, i've found the problem causing the error (the memory map file was in a different place), and i can get the data away from the flash with the following attribute in a test variable:
const char spitest1[] __attribute__((section(".spiflash"))) ="This is a test";
However, how can i get a .bin file as additional output for my data which is in the .spiflash section?
Please sign in to leave a comment.
Comments
1 comment