Linker copy SPIFI objects to SDRAM causes Hard Fault

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Linker copy SPIFI objects to SDRAM causes Hard Fault

623 Views
lpcware
NXP Employee
NXP Employee
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.

Thanks
Robert
Labels (1)
0 Kudos
Reply
3 Replies

571 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by rmoss on Mon Feb 09 14:37:18 MST 2015
Hi Wouter,
I did have a typo above.  I was copying the the ro code from SPIFI to SDRAM instead of SRAM.  The linker directives you listed do work.

Thanks,
0 Kudos
Reply

571 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Wouter on Mon Feb 09 11:02:00 MST 2015
Instead of:
place at start of SPIFI_region {readonly object MyFile.o};
initialize by copy { section userMyFile };
place in RAM_region {section userMyFile};


Try:
initialize by copy { section userMyFile };
place in SPIFI_region {section userMyFile_init};
place in RAM_region {rw section userMyFile}


Then two more things:
- in your post you mention you want to execute from SDRAM, but your linker script places the code in on-chip SRAM. Note that performance of code execution from SDRAM is expected to be worse compared to execution from SPIFI.
- If you really want to relocate the code to SDRAM, make sure your startup file calls SystemInit() before __main(), and that SystemInit() also initializes the EMC.

If that still does not help, please post the .map file.

Regards,
Wouter
0 Kudos
Reply

571 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bavarian on Mon Feb 09 05:50:00 MST 2015
I will look for a meaningful IAR EWARM project which is doing what you want to achieve.

The linker file format in EWARM is not that easy to handle as the one used in Keil. However, if you only do it right, then it will work   8-) 

Regards,
NXP Support Team.
0 Kudos
Reply