[SOLVED] Using Linkerscript to split up .text section

Last post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all,

i have the following problem:

For my current project, i use a AT32 UC3A0512 with 512 kB internal programflash. On the external SDRAM interface, i have 32 MB of SDRAM connected (16 Bit wide interface.).

As the controllers internal flash memory now gets quite full, i would like to move parts of the program code into the SDRAM. I tried moving all the program code into the SDRAM - that works fine, but slows down the execution speed very much, which i am not willing to accecpt for now.

My idea now was to only move seldomly used parts of the code (e.g. zip/unzip code used for firmware upgrade) into the SDRAM. Its not critical, if this code runs slowly, and it uses a lot of space.

I tried creating a new Memory area in the linker skript, and linking all text section from files that match *zip* in their filename to that section:

MEMORY
{
  INTRAM (wxa!ri) : ORIGIN = 0x00000004, LENGTH = 0x0000FFFC  					  
  FLASH (rxai!w) : ORIGIN = 0x80010000, LENGTH = 0x00070000
  SDRAMRO (rxai!w) : ORIGIN = 0xD0000000, LENGTH = 0x100000
  SDRAM (wxa!ri) : ORIGIN = 0xD0100000, LENGTH = 0x01F00000  
  USERPAGE : ORIGIN = 0x80800000, LENGTH = 0x00000200
}
.SDRAMTEXT       ORIGIN(SDRAMRO) :
  {
    *zip*(.text .stub .text.*)
  } >SDRAMRO AT>SDRAMRO :SDRAMRO

This ain't working. Has anybody successfully tried to do this? Is it possible to redirect code into different sections based on the outfile-name, or do i have to add section attributes to each function, i want to move to a different section?

Many thanks in advance for any hints!

Rainer

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It seems to be possible to tell the linker to place an entire file in a specified section. Read this:

http://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_mono/ld.html#SEC19

Daniel Campora
http://www.lear.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for your response Daniel - i think that is exactly what i tried - with the only difference, that i just want to put the .text section of the input file into the SDRAM code section.

Basically what i'm trying to achive is, that my zip/unzip program code (contained in out files named fw_unzip.o, zip.o, ...) goes to the SDRAM section and the rest goes to the flash memory as per default.

Then during power-up, my bootload will init the SDRAM and copy the SDRAM code from an external SPI dataflash to its position in SDRAM - thats the part i worry least about, as i had that already running with all program code inside the SDRAM (i simply replaced FLASH by SDRAMRO in the linkerskript).

UPDATE: It looks like original approach is actually working, i just didnt place enough code into SDRAM to get rid of a section overflow error. This is what my current section syntax looks like:

.SDRAMTEXT       ORIGIN(SDRAMRO) :
  {
    *zip*(.text .stub .text.*)
    *AnotherFilename.o(.text .stub .text.*)
    *SystemUpdater.o(.text .stub .text.*)
    *YetAnotherFile*(.text .stub .text.*)
  } >SDRAMRO AT>SDRAMRO :SDRAMRO
  .text           :
  {
    *(.text .stub .text.* .gnu.linkonce.t.*)
    KEEP (*(.text.*personality*))
    /* .gnu.warning sections are handled specially by elf32.em.  */
    *(.gnu.warning)
  } >FLASH AT>FLASH :FLASH
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Cool, I am glad is working now.

Daniel Campora
http://www.lear.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm looking at a similar situation. All the code now fits in the internal Flash but the client wants to make sure we can expand the code in the future. Have you ever tried running your code in the debugger? Does it know enough not to try to load code into the uninitialized SDRAM?