mimxrt1024-EVK flash and boot

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

mimxrt1024-EVK flash and boot

6,156 Views
esben-e
Contributor II

Hi

We are trying to flash and run an application from the EVK where the boot mode is configured in "Serial Download" mode. Downloading the application seems to work fine - both with uuu and sdphost. But when we try to jump to the address for executing the application afterwards nothing happens. Our workflow designed so that the EVK (a custom board with a RT1024 later) automatically gets the firmware from a remote controller on every reboot. So it is important that the controller can both flash and trigger execution of the application while the EVK is in "Serial Download" mode.

But is this workflow even possible?

Anyone has tried a similar thing and would like to share settings, .bd-file and DCD?

We have also tried to upload the ivt_flashloader and when it loads use blhost to add our own application. But still no luck getting the application to execute

Using the ivt_flashloader as an intermediate step is acceptable is this is possible.

 

Any help or suggestions is most appreciated.

 

Thanks,

Esben Elfving - Prevas A/S

 

 

 

0 Kudos
Reply
9 Replies

6,063 Views
dereksnell
NXP Employee
NXP Employee

Hi @esben-e ,

My understanding from Run entire application from RAM is that you are trying to download the application in to ITCM, and execute from there.  I did this with the attached Zephyr application binary and MIMXRT1024-EVK, and the command line tools to interface with the RT1024 ROM.  The tools come from the package "Flash loader i.MXRT1020" found at the RT1020 Tools page.  You should be able to do the same with the mfgtool if you prefer the GUI tools.

Use sdphost to download the flashloader to DTCM, and execute the flashloader.  Note that I tried sdphost to write the app directly to ITCM, but sdphost is not able to access ITCM.

\Flashloader_RT1020_1.0_GA\Tools\sdphost\win>sdphost -u 0x1fc9,0x0130 -t 5000 -- write-file 0x20000000 "\Flashloader_RT1020_1.0_GA\Tools\mfgtools-rel\Profiles\MXRT102X\OS Firmware\ivt_flashloader.bin"
Preparing to send 60415 (0xebff) bytes to the target.
(1/1)1%Status (HAB mode) = 1450735702 (0x56787856) HAB disabled.
Reponse Status = 2290649224 (0x88888888) Write File complete.

\Flashloader_RT1020_1.0_GA\Tools\sdphost\win>sdphost -u 0x1fc9,0x0130 -t 5000 -- jump-address 0x20000400
Status (HAB mode) = 1450735702 (0x56787856) HAB disabled.

 

Use blhost tool to communicate with the flashloader.  Verifies blhost can talk to the flashloader, then writes the Zephyr application to ITCM

\Flashloader_RT1020_1.0_GA\Tools\sdphost\win>cd ..\..\blhost\win

\Flashloader_RT1020_1.0_GA\Tools\blhost\win>blhost -u 0x15A2,0x0073 -- get-property 1
Inject command 'get-property'
Response status = 0 (0x0) Success.
Response word 1 = 1258422528 (0x4b020100)
Current Version = K2.1.0

\Flashloader_RT1020_1.0_GA\Tools\blhost\win>blhost -u 0x15A2,0x0073 -- write-memory 0x0000000 zephyr.bin
Inject command 'write-memory'
Preparing to send 14512 (0x38b0) bytes to the target.
Successful generic response to command 'write-memory'
(1/1)100% Completed!
Successful generic response to command 'write-memory'
Response status = 0 (0x0) Success.
Wrote 14512 of 14512 bytes.

 

Use blhost to read the address in the reset vector.  This should be at offset 0x4 in the vector table, read below as 0x13F9.  Then use blhost to execute from that address

\Flashloader_RT1020_1.0_GA\Tools\blhost\win>blhost -u 0x15A2,0x0073 -- read-memory 0x0000000 8
Inject command 'read-memory'
Successful response to command 'read-memory'
c0 06 00 20 f9 13 00 00
(1/1)100% Completed!
Successful generic response to command 'read-memory'
Response status = 0 (0x0) Success.
Response word 1 = 8 (0x8)
Read 8 of 8 bytes.

\Flashloader_RT1020_1.0_GA\Tools\blhost\win>blhost -u 0x15A2,0x0073 -- execute 0x13f9 0 0
Inject command 'execute'
Successful generic response to command 'execute'
Response status = 0 (0x0) Success.

 

My Zephyr hello_world application then prints this to the console:

*** Booting Zephyr OS build zephyr-v2.6.0  ***
Hello World! mimxrt1024_evk

 

Best regards

0 Kudos
Reply

5,794 Views
esben-e
Contributor II

Hi

We did try your example and it works perfect using your demo zephyr.bin. Unfortunately our application uses almost 86kb so the default memory layout does not allow us to store the application in ITCM. Added a new memory layout by setting these registers in the reset function:

ldr r0, = 0x400AC040 /* IOMUXC_GPR_GPR16 */
ldr r1, = 0x00200007 /* Use FLEXRAM_BANK_CONFIG */

ldr r0, = 0x400AC044 /* IOMUXC_GPR_GPR16 */
ldr r1, = 0x0000FFA5 /* ITCM: 128kb, DTCM: 64kb, OCRAM: 64kb */

Corrected the memory layout in the device tree to match the above configuration.

Next step was to add these to our defconfig:
CONFIG_CODE_ITCM=y
CONFIG_CODE_DATA_RELOCATION=y

and added zephyr_code_relocate(<source files> ITCM) to store data in ITCM. But that only moved 6kb to ITCM as the rest is zephyr source files and will be a huge task to add 'zephyr_code_relocate' for all used source files.

When building the application we get this layout:

Memory region Used Size Region Size %age Used
FLASH: 85548 B 128 KB 65.27%
SRAM: 48800 B 64 KB 74.46%
ITCM: 5912 B 128 KB 4.51%
DTCM: 2 KB 64 KB 3.12%
IDT_LIST: 0 GB 2 KB 0.00%

When we write the application at address 0x00 we get this error:

Response status = 10200 (0x27d8) kStatusMemoryRangeInvalid
Wrote 85548 of 85548 bytes.

So guess we have missed something in the configuration

Questions:

Do you know if the zephyr_code_relocate is necessary for what we try to do here?

Since we upload the ivt_flashloader.bin to DTCM first, could the problem be that we have to rebuild the flashloader with a similar memory layout.

Thanks in advance  for any hints or suggestions which can help us move forward flashing and executing the application on each boot.

 

BR

Esben Elfving - Prevas A/S

0 Kudos
Reply

5,735 Views
dereksnell
NXP Employee
NXP Employee

Hi @esben-e ,

Reviewing these threads, the goal is to boot in Serial Download mode, and have the Linux host download the application directly to ITCM and execute from there, right?  The problem now is that your code has exceeded the default 64KB allocated to ITCM at boot.

In that case, I don't think using Zephyr's CONFIG_CODE_DATA_RELOCATION feature is the solution here.  Relocation is intended for storing code in one memory type (like flash that SoC cannot execute directly from).  And then in the startup code, Zephyr relocates that code to the destination memory used by the application.  In your case, I think it is best to build the app with all code in ITCM and executes directly from ITCM.  You just need the Linux host to be able to download the full app to ITCM.  I already shared the steps to modify Zephyr to place the code in ITCM at Run entire application from RAM.

For production, we recommend burning the OTP fuses that control the FlexRAM configuration at boot.  See application note AN12077: Using the i.MX RT FlexRAM for more details.  Then the SoC boots with 128KB of ITCM, and the blhost flashloader tool should be able to download the full app from the Linux host.

For development, and to test this before burning fuses, we could modify the flashloader source to enable this.  The modified flashloader could update the GPR16 & 17 registers for the desired FlexRAM config, and then receive the full application into the 128KB ITCM.  If this is on the right track for what you want, I can work further on testing this.  Best regards

0 Kudos
Reply

5,717 Views
esben-e
Contributor II

Hi Derek

Thanks! - You are right: We need to execute the application from ITCM to speed up execution.

Following your suggestions, do you know where we can find the source and build information for a matching ivt_flashloader?

 

BR

Esben Elfving - Prevas A/S

 

 

0 Kudos
Reply

5,700 Views
dereksnell
NXP Employee
NXP Employee

Hi @esben-e ,

The flashloader source code is included in our MCUXpresso SDK package.  To access it, go to https://mcuxpresso.nxp.com and click Select Development Board.  Select the board MIMXRT1024-EVK.  When building the SDK package, be sure to include the MCU Boot middleware, see screenshot below.  After downloading the SDK package, the flashloader example project is located at \boards\evkmimxrt1024\bootloader_examples\flashloader

Let us know how this works for you.

 
 

mcux.jpg

 

0 Kudos
Reply

6,056 Views
esben-e
Contributor II

Hi Derek

Thanks! - seems spot on as we also use Zephyr for our application so guess we can reuse quite a bit from your example. Will try it out within the next couple of days.

Appreciate the help!

BR

Esben Elfving - Prevas A/S

0 Kudos
Reply

6,124 Views
esben-e
Contributor II

Hi Kerry
Thanks for a prompt reply.

In short, what we need is to be able to download and execute an application every time our board (the iMX rt1024 EVK for now, but will switch to a custom board later) restarts.

 

As of now we can download our firmware automatically using serial download. That part works fine. But the next step is to start executing the new firmware without a restart after the serial download has completed.

Will this be possible?

BR

Esben Elfving - Prevas A/S

0 Kudos
Reply

6,116 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @esben-e 

  Yes, I understand your requirement, you need both the download function and app function in the flash right?

  Just as I tell you, this normally is the secondary bootloader+app method, then each time after boot, it will run the bootloader at first, then jump to your app.

   You are using the serial download mode which will load the flashloader to the internal RAM, then run it. But the serial download mode need to use the external BOOT_MODE pin to detect it, and after you finish the download function, you need to switch the BOOT_MODE pin to the internal boot mode to run your APP code.

   So your method can add the secondary bootloader mode, after the download finished, you just need to reset the chip and jump to the APP.  You also can design yourself code, after the download do the reset automatically, then jump to the new APP.

 

Wish it helps you!

Best Regards,

Kerry

 

0 Kudos
Reply

6,141 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @esben-e 

   Do you want to have both the ISP download function and the app running?

   If yes, you can use this method: secondary bootloader+ app.

   You can refer to our RT1060 SDK code: 

SDK_2.9.3_EVK-MIMXRT1060\boards\evkmimxrt1060\bootloader_examples\ota_bootloader

and app:

SDK_2.9.3_EVK-MIMXRT1060\boards\evkmimxrt1060\lwip_examples\lwip_httpssrv_ota

bootloader will put in the front of the flash, eg, 0x60000000, then the app put from 0x60040000. 

After reset, the code will run the bootloader at first, then check the app area has data or not, if yes, then after 6 seconds, jump to the app.

About the DCD, you can add it in the secondary bootloader.

This method, you don't need to enter the serail download mode, as even you enter serial download mode, you still need to download the flashloader to the internal RAM and run it.

Wish it helps you!

If you still have questions about it, please kindly let me know.

Best Regards,

Kerry

0 Kudos
Reply