Putting imxrt1170 into XIP mode and out of XIP mode

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

Putting imxrt1170 into XIP mode and out of XIP mode

543 Views
burhanhagi
Contributor IV

I am working on a custom bootloader. I put my QSPI Flash into non-XIP mode at first power on my board. If any updated firmware exists, I am writing it to the same QSPI flash. Actually I have success on that. After completing loading,  I can jump to my new loaded firmware and run it. I also succeed in run that.

In order to be able to write firmware to qspi flash, I put imxrt into Non XIP mode with Setting Xip_boot_header_enable = 0 and Xip_external_flash=0. With this settings I set imxrt to boot from External Sdram. With this settings, I first load bootlader to flash with debugger. Adter that, I can load my firmware with this bootloader.

However, after finishing write cycle of new firmware,  just prior to jumping into this newly firmware,  I want to put imxrt into XIP mode.  How can I do that? Is there any code snippet for doing it?

0 Kudos
Reply
3 Replies

478 Views
Habib_MS
NXP Employee
NXP Employee

Hello @burhanhagi ,
In order to support you better, can you provide me more details about the flow that will follow your code, and which address you want to use to put the second image?

Also, I understand that you are making the jump to the new app, in this case in order to put the XIP, before jump to the new app, is needed reconfigure the Flash in XIP mode, after, you only need to jump to the address belonging to the memory map you want to use.

Fortunately, SDK (version 2.16) offers a simple demonstration of a bootloader called "flashloader_cm7" that could be helps.

BR
Habib

0 Kudos
Reply

438 Views
burhanhagi
Contributor IV

Hello @Habib_MS , 

I am using single Qspi Flash for that. (Flexspi1 interface only) I divided my flash into 2 parts. First part includes Boot firmware, second part includes my main app. First part size is 1MB and starts from 0x30000000 address and ends with 0x30100000. My Boot firmware size is 250Kbyte roughly. 
My main app starts from 0x30100000 to 0x31000000. My main app size is nearly 1MByte. 

I am using one boot image and one app image. No backup or second image I have. If new firmware exists, I wrote it on running existing firmware but at initial power-up. Later, I turned off and on the board power to let the newly loaded firmware run.

Every time board is powered on, boot firmware is always run. It waits roughly 1sec if there will be a new firmware loaded.  If new firmware is not loading within 1sec, boot firmware jumps to 0x30102000 address, which is the ISR address of my main app. I compiled my main app with Xip_Boot_Header_Enable=1, Dcd_Enable=1 and Xip_External_Flash=1 settings with 0x30100000 flash address. So I load my main app starts from there but jumps to 0x2000 offset relative to 0x30100000.

My boot firmware is custom and proves it is working for years on different MCU Platforms.

Every time I get a new board, I first load my boot firmware with Xip_boot_header_enable =0 and Xip_External_Flash=0 with flag settings. I compiled my boot firmware with that. 
Later on, I am loading my main app over Can or Usb interface with this bootlader.

My main app is a little bit complex. I am using nearly every peripheral of imxrt1170. My problem is that, my all code is working well for a time of period as it gets planned. However after some intense user actions, it stucks and returns me undefined instruction error exception. Some time, it is very hard for me to produce the same error. Error happens but I have no idea what triggers to cause it happening.

If I do not use my boot firmware, the same stuck problem never happens. So I suspect that I am not doing the jump with correct preprocessor flags.(I mean Xip_boot_header etc.) 

Since I have to use my boot firmware, and also since it first always runs, I am starting my main app with boot header and external Flash as 0. Otherwise if I would set those flags as 1, then I can not write my Qspi flash for loading my main app with bootloader. That is why; when I jump to 0x30102000 address, which is my main app ISR address, unfortunately currently boot header info of active boot firmware is valid.  I am running it as with boot firmware preprocessor flag settings( boot header enable = 0) even though I have to set it as 1 to use flash as XIP mode. 
To summarize, I can run my app as well as bootlader well. However it is not running as stabilize. I suspect to make not putting my flash into the correct state just prior to jumping main app.

I reviewed mcu opensource bootloader, romapi and flexspi read/wirte examples in SDK 2.14 examples for that. But no valuable info exists in those examples.  

0 Kudos
Reply

394 Views
Habib_MS
NXP Employee
NXP Employee

Hello @burhanhagi,
It seems like the way that you are putting your app in XIP mode seems correct, however, in order to try a pinpoint if the dynamic memory in the boot firmware causes issues for overwrite the main app, could you move the start address of the main app? for example, starts in the address
0x30200000.

In the other hand, in order to support you better can you provide me the memory usage of your boot firmware and your main app, where is located in the window called image info?

You can load the information clicking the next button in MCUxpresso:

Habib_MS_0-1728428847133.png

Also, for stay sure that the issue is not related with the debug, can you try build both images (boot firmware and main app) with release instead debug?

Where you can change the build in the next button in MCUxpresso:

Habib_MS_1-1728428847136.png

BR
Habib

0 Kudos
Reply