How to relocate code from flash to extenal SDRAM for RAM execution

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

How to relocate code from flash to extenal SDRAM for RAM execution

4,632 Views
dustin_yang
NXP Employee
NXP Employee

Hi

I'm using MIMXRT1050-EVK + MCUXpresso IDE v10.1 now.

Could you let me know another boot strategy instead of XIP? (XIP means that code can be run directly from flash)

I wish to use this boot strategy which relocates code from flash to external SDRAM for RAM execution.

Best Regards,

Dustin

0 Kudos
11 Replies

3,445 Views
jay_heng
NXP Employee
NXP Employee

You can also try this tool, with this tool, You can flash bare image into various boot devices easily and don't need to care about headers (ivt, boot data...)

GitHub - JayHeng/nxp-sec-boot-ui: A one-stop GUI tool to work with NXP MCU (Kinetis, i.MXRT, LPC) RO... 

0 Kudos

3,445 Views
lpcxpresso_supp
NXP Employee
NXP Employee

There is no single mechanism to enable project relocation to RAM. However as discussed above, there are features to enable the automatic relocation of functions from Flash to RAM. The IDE User Guide section 16.13.1 discusses this.

Without understanding your precise needs, I would consider creating a separate flash programming project, linking this to your RAM region of choice and then writing a secondary bootloader to place this at the linked location when needed (from a fixed location in flash).

Yours,

MCUXpresso IDE Support

0 Kudos

3,445 Views
yongjin2712_cho
Contributor I

Hello,

I also tried to execute code from OCRAM using elftosb.exe and MfgTool

I made "gpio_led_output" proejct from "Import SDK example" of MCUXpresso.

And I left SRAM_OC and deleted everything at memory configuration

And I checked "link application to RAM" option.

After build and connecting debugger, I saw that it didn't work well.

Next I made boot_image.sb as below

elftosb.exe -f imx -V -c imx-ocram-unsigned.bd -o test_gpio_led_output.bin test_gpio_led_output.axf
        Section: 0x0
iMX bootable image generated successfully

elftosb.exe -f kinetis -V -c program_flexspinor_image_hyperflash.bd -o boot_image.sb test_gpio_led_output_nopadding.bin
Boot Section 0x00000000:
  FILL | adr=0x00002000 | len=0x00000004 | ptn=0xc0233007
  ENA  | adr=0x00002000 | cnt=0x00000004 | flg=0x0900
  ERAS | adr=0x60000000 | cnt=0x00100000 | flg=0x0000
  FILL | adr=0x00003000 | len=0x00000004 | ptn=0xf000000f
  ENA  | adr=0x00003000 | cnt=0x00000004 | flg=0x0900
  LOAD | adr=0x60001000 | len=0x00008040 | crc=0x93ea1b6f | flg=0x0000

After setting SW7 to 0, 1, 0, 1, I downloaded boot_image.sb to EVK board using MfgTool and I succeeded it.

However, After reset, it didn't work well.

I don't know what the problem is.

please let me know what's wrong

Additionaly, I think that I can execute code from RAM with Plugin Boot.

I don't know how I can it. So Can you give me reference project and code for plugin boot?

0 Kudos

3,445 Views
yongjin2712_cho
Contributor I

Hello,

If you look at the 3.6.1.3 FlexSPI NOR boot flow chart of RT1050 reference manual, There explains that it executes image from OCRAM after being copied to OCRAM if image is not XIP.

Is it possible to execute image from OCRAM?

If it is possible, How can I make non-XIP image using MCUXpresso IDE and How can I use External SDRAM instead of OCRAM?

0 Kudos

3,445 Views
lpcxpresso_supp
NXP Employee
NXP Employee

Hi,

The MCUXpresso IDE User Guide discusses a variety of options in the Chapter 16. Memory Configuration and Linker Scripts.  Perhaps you have already done this but I would recommend performing some benchmarks comparing performance from flash vs performance from SDRAM - the cache on these parts should mitigate some of the penalties executing code from Flash. Critical routines requiring maximum performance can be relocated into one of the SRAM blocks. Execution from these locations will give the best performance and will also be deterministic.

Yours,

MCUXpresso IDE Support

0 Kudos

3,445 Views
yongjin2712_cho
Contributor I

Hello,

The reason for executing code from SDRAM is why I need to erase sector of flash or write data to flash for handling non-volatile data like filesystem.

However, I couldn't do it in executing code from flash

so I am trying to execute code from SDRAM

How can I do it?

0 Kudos

3,445 Views
lpcxpresso_supp
NXP Employee
NXP Employee

The "Plain load image" option, as described in the MCUXpresso IDE v10.2 User Manual, was designed for use with the LPC540xx MCU - as it generates an image in the format expected by the LPC540xx's boot rom. It won't provide the functionality you are looking for with i.MX RT devices.

With regards to flash drivers, MCUXpresso IDE v10.2.0 provides a QSPI flash driver suitable for use with the QSPI device fitted to the i.MX RT1050 EVK board (and another for the QSPI device on the RT1020 EVK). However, we expect to make an MCUXpresso IDE maintenance release around the end of this month that will include updated i.MX RT LinkServer flash driver support. This will include i.MX RT example projects that can be used to create cfx files for programming other flash devices.

Regards,
MCUXpresso IDE Support

0 Kudos

3,445 Views
yongjin2712_cho
Contributor I

Ok.. I understand...

And then,

I need that It can relocates code from flash to external SDRAM for RAM execution at RT1050 MCI as Plain Load image Functionality.

How can I do it with MCUXpressor IDE?

0 Kudos

3,445 Views
yongjin2712_cho
Contributor I

Hello Alice,

I am trying to boot from OCRAM with Plain Load Image.

I am using gpio_led_output example project of SDK

And I only change XIP_EXTERNAL_FLASH symbol into 0.

And at MCU Linker -> Managed Linker Script, I check Plain Load Image and set to SRAM_OC

When I run debugger with breakpoint ResetISR after being build, I get error below

No source available for "<signal handler called>() at 0xfffffff9"

Break at address "0x201434" with no debug information available, or outside of program code.

What causes the error and how do I fix it?

0 Kudos

3,445 Views
dustin_yang
NXP Employee
NXP Employee

Hi Alice_Yang,

I have one more question.

I want to use QSPI (Nor Flash) instead of HyperFlash in custom board.

Could I get a flash driver for QSPI such as MIMXRT1050-EVK_S26KS512S.cfx for HyperFlash?

Best Regards,

Dustin

0 Kudos

3,445 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Dustin,

-You can have a look at the 16.6.4 Plain Load Image of <MCUXpresso_IDE_User_Guide.pdf>.

it maybe can meet your requirement.

-Before we use SDRAM, we need to init it , there is DOC introduce it :

Overview of using the MIMXRT1050-EVK with MCUXpresso IDE  pat attention the part of

"Using the SDRAM region " .

-And  recommend you use the latest version MCUXpresso IDE v10.2 and latest SDK .


Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------