Linker copy SPIFI objects to SDRAM causes Hard Fault

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by rmoss on Tue Feb 03 14:48:02 MST 2015
I have the LPC1857 working with the Spansion S25FL256 using the NXP spifi_lib.

Now that the internal flash is filling up, I would like to store some of the project objects in SPIFI and execute them in SDRAM.  I have added the IAR Flashloader to place the objects in SPIFI and that seems to work by checking the map file and contents of the SPIFI in memory window.  In low_level_init() the SPIFI is setup properly.  After that, the init data process causes a Hard Fault (before main()).

Basically I want to add MyFile.c object to SPIFI and have the linker copy this to SDRAM at startup.

In the IAR 6.6 IDE:
MyFile.c (right click) Options
Override inherited Settings (checked)
Add section for the file:
--section .text=userMyFile

In the Linker ICF File:

define symbol __ICFEDIT_region_SDRAM_start__ = 0x28000000;       /* 16 MB SDRAM */
define symbol __ICFEDIT_region_SDRAM_end__   = 0x280FFFFF;           

define symbol __ICFEDIT_region_SPIFI_start__      = 0x14A70000;         // object place offset is 0xA70000
define symbol __ICFEDIT_region_SPIFI_end__        = 0x15FFFFFF;

define region SPIFI_region = mem:[from __ICFEDIT_region_SPIFI_start__ to __ICFEDIT_region_SPIFI_end__];
define region SDRAM_region = mem:[from __ICFEDIT_region_SDRAM_start__ to __ICFEDIT_region_SDRAM_end__];

initialize by copy { readwrite };

place at start of SPIFI_region {readonly object MyFile.o};

initialize by copy { section userMyFile };
place in RAM_region {section userMyFile}; 

It appears that initialization data located in the SPIFI is not being copied properly from the SPIFI to SDRAM.  If I move only the .rodata section above in place at start of like this, I don't see the Hard Fault, however there seems to still be some variable initialization data that was not copied by viewing the memory window in the debugger.

place at start of SPIFI_region {section .rodata object MyFile.o};

This may be more of a question for IAR.  Has any one tried to store objects in SPIFI and run them in SDRAM?  I have done this same operation succsssfully on an external parallel flash for the LPC1788.