Relocating code .text .data to spifi flash and external SDRAM MCUxpresso

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

Relocating code .text .data to spifi flash and external SDRAM MCUxpresso

3,406 Views
A_M
Contributor III

Hello,

I need to relocate code (folders with .c, .h files and .a files) in my project.
I readed the exampels but they are only for single funktions or variabels, so the don't fit.
I have BOARD SDRAM, BOARD FLASH (SPIFI Flash) and LPC54608.

I need to place Code(.text .data … ) in BOARD FLASH (lma) and load this code in external BOARD SDRAM (vma).

To test it I created a .c/.h file with a function. There result a test2.o file with .text (68byte) and .data (1Kbyte), everything in this file should go to SPIFI Flash and to runtime the .data should be loaded in SDRAM (vma).

With “Managed Linker Script -> Extra linker script input sections”
*test2.o(.text*) BOARD FLASH .text
put the linker the .text of the test2.o in BOARD_FLASH. And it works.

But with
*test2.o(.data*) BOARD SDRAM .data
it doesn’t work. The Linker put the *test2.o(.data*) in the LPC546008 internal Flash and load it in BOARD SDRAM.
Memory region Used Size Region Size %age Used
PROGRAM_FLASH: 11864 B 512 KB 2.26%
BOARD_FLASH: 68 B 16 MB 0.00%
SRAM_UPPER: 8476 B 160 KB 5.17%
SRAMX: 0 GB 32 KB 0.00%
USB_RAM: 0 GB 8 KB 0.00%
BOARD_SDRAM: 1 KB 16 MB 0.01%

Is there a possibility in “Properties->Managed Linker Script -> Extra linker script input sections” to tell the linker that he have to place *test2.o(.data*) in BOARD FLASH(lma) and load this in BOARD SDRAM?
If possible, I would like to avoid writing my own linker script.

Labels (1)
0 Kudos
Reply
3 Replies

3,349 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @A_M 

Enabling the “Plain load image” will program main code into flash, and execute in RAM:

 

Alice_Yang_0-1695616449597.png

 

BR

Alice

 

0 Kudos
Reply

3,339 Views
A_M
Contributor III

Hello
Unfortunately it does not work because PROGRAM_FLASH is the first on the flash order.

PROGRAM_FLASH:       11924 B       512 KB      2.27%
BOARD_FLASH:                    0 GB        16 MB      0.00%
SRAM_UPPER:                9500 B       160 KB      5.80%
SRAMX:                                 0 GB        32 KB      0.00%
USB_RAM:                            0 GB         8 KB      0.00%
BOARD_SDRAM:             10896 B        16 MB      0.06%

And when I change the flash order. The stays problem is the same.
All .data which should be store in PROGRAM_FLASH go to BOARD_FLASH.

I need to use internal flash(PROGRAM_FLASH) with internal ram (SRAM_UPPER).

Example, everything from folder “internal” .test .data should be placed in internal PROGRAM_FLASH and use internal SRAM_UPPER for .data .noinit .bss.

The code from folder “external” .test .data should be placed in external flash BOARD_FLASH and use external ram BOARD_SDRAM for .data .noinit .bss.

 

BR

0 Kudos
Reply

3,287 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @A_M 

Have a look at: How to place data/function/file in specified memory under MCUXpresso IDE

https://community.nxp.com/t5/LPC-Microcontrollers-Knowledge/LPC-How-to-place-data-function-file-in-s...  

 

BR

Alice

0 Kudos
Reply