Generating a Bootable Image for the RT1050

cancel
Showing results for 
Search instead for 
Did you mean: 

Generating a Bootable Image for the RT1050

Generating a Bootable Image for the RT1050

Testing Boot times – Generating a bootable image

Bootable Image Structure:

The bootable image consists of:

  • FlexSPI Configuration Block (FCB)
  • Image Vector Table (IVT)
  • Boot Data
  • Device Configuration Data (DCD)
  • Program image
  • CSF, Certificates, and signatures (this stuff is optional and only comes with high-assurance boot

I’ll briefly explain each below:

FlexSPI Configuration Block (FCB)

The FCB will configure the settings of the FlexSPI communication. It will establish how many ports will be used, what clock speed to run the FlexSPI controller at, etc. This is the first thing that happens, as everything else is stored in Flash memory. In order to read anything else, the flash must first be configured. 

Image Vector Table (IVT) 

The IVT is a table that tells the memory the addresses of where everything is stored.

Boot Data

The Boot Data contains pointers to the start address of the Memory.

Device Configuration Data (DCD)

The DCD contains configuration data to configure any peripherals.

Program image

The program image contains the code you write to go into the application.

CSF, Certificates, and signatures

These things are optional. They come with high-assurance boot sequence and will not be covered in this writeup.

Below is a rough table outlining these different parts of the boot image:

pastedImage_1.png

Bootable Image generation software / tools:

  1. MCUXpresso – download the MCUXpresso IDE
  2. Flash Loader – download from RT1050 page > software and tools > flashloader
  3. This entire folder will include the MFGTool, elftosb tool, and more documentation.
  4. DCD.bin file: I found mine included in this document: https://community.nxp.com/docs/DOC-340655

Bootable Image Generation Overview

MCUXpresso can generate bootable images for Hyperflash and QSPI XiP, but if trying to boot and execute in place of SDRAM or intern SRAM, or from your own memory module, then you must generate a bootable image by through a combination of generating an s record or elf image on MCUXpresso, and then using the flashloader tool suite (elftosb and mfgtool) to create a bootable image and then a bootable program to upload to the board.

The entire general process is described below. In subsequent sections, a more detailed step-by-step guide is provided for Hyperflash XiP, SDRAM, and SRAM, each.

MCUXpresso Configurations and output:

Begin with your application code in MCUXpresso. Change memory allocation in the memory configuration editor of the MCU Settings part of MCUXpresso according to where you would like to boot from. If applicable, be sure to specify in the preprocessor settings if you would like to enable the dcd in the boot image.

Generate an s-record (.s19) file from MCUXpresso using binary utilities.

Elftosb tool – .bin file generation

You can find this tool in the flashloader. Call an imx command to it which will take as input the s-record file containing the program image, a dcd.bin file (may or may not be in the s-record), a FCB?, and a bd_file (given to you, specific to your memory configuration). The elftosb tool will generate as an output a .bin file.

Elftosb tool – Bootable image generation

Then call the elftosb tool again with a kinetis command. This will take the .bin file and convert it to a boot_image.sb file.

MFG tool

Then we can use the mfg tool to generate the program image for the board, and upload it.

In order to do this, the board SW7 must be set to OFF-ON-OFF-ON, and switch the jumper from J1  (5-6) to J1 (3-4). Connect the USB cable to J9 to power the board. Then connect the board to your computer and run the Mfg tool. Click start and the image will be uploaded. 

 pastedImage_1.png

 

After this the bootable image will be uploaded to the board and you’ll be good to go!

Remember to switch the pin headers back, so the board can boot normally. J1 (5-6) and SW7 to OFF-ON -ON -OFF to boot from Hyperflash.

Now in the following sections I’ll break down specific examples of what to do depending on the specific memory location you’d like to boot from.

Bootable Image Generation – XiP Hyperflash

Please note that this can also be done in MCUXpresso, but In order to use my own dcd file, I did this project using the traditional flashloader tools.  

MCUXpresso Configurations and output:

Begin by changing memory allocation in the memory configuration editor (edit project settings >> C/C++ Build >> MCU settings >>edit. It should look like the one below.

pastedImage_1.png

Then go to C/C++ Build >>settings > MCU C compiler > preprocessor and set the XIP_boot_header enable and and XIP_boot_header_DCD_enable both to 0 if you have a dcd.bin file to use. Otherwise set these fields to 1.

pastedImage_2.png

Hit apply and close.

Go to the debug portion and click on binary utilities, then generate an s-record (.s19) file from MCUXpresso. 

pastedImage_3.png

Click build to re-build the project.

Copy this .s19 file.

Elftosb tool – .bin file generation

In the flashloader tool, go to Tools > elftosb > Win, and drop the .s19 file in this folder, as well as the dcd.bin file.

Fire up command prompt in administrator mode, and use command cd [elftosb directory] to get to this folder

To generate the .bin file, call the command:

 

elftosb.exe -f imx -V -c ../../bd_file/imx10xx/imx-flexspinor-normal-unsigned-dcd.bd -o ivt_flexspi_nor_led_blinky.bin HYPERFLASH_led_blinky.s19

 

This command essentially uses the imx-flexspinor bd linker file to generate a .bin file that will include the dcd.bin header inside. Note that HYPERFLASH_led_blinky.s19 should be renamed to your actual file name acquired from MCUXpresso

 

Elftosb tool – Bootable image generation

Then we must generate the boot_image.sb

Then call the elftosb tool again with a kinetis command. This will take the .bin file and convert it to a boot_image.sb file.

The command is:

 

elftosb.exe -f kinetis -V -c ../../bd_file/imx10xx/program_flexspinor_image_hyperflash.bd -o boot_image.sb ivt_flexspi_nor_led_blinky_nopadding.bin

 

Note: The output of the first imx command we made must match the input of this one (ivt_flexspi_nor_led_blinky_nopadding.bin). Also, the output must remain named boot_image.sb, otherwise it will not work.

MFG tool

Then we can use the mfg tool to generate the program image for the board, and upload it.

In order to do this, the board SW7 must be set to OFF-ON-OFF-ON, and switch the jumper from J1  (5-6) to J1 (3-4). Connect the USB cable to J9 to power the board. Then connect the board to your computer and run the Mfg tool. Click start and the image will be uploaded. 

 

 pastedImage_4.png

 

Copy the boot_image.sb file that we created in the last step. Move it to the directory Tools > mfgtools-rel > Profiles > MXRT105X > OS Firmware, and drop it in here.

Next, set SW7 on the board to OFF-ON-OFF-ON, and switch the jumper at the bottom to power the board. Then connect the USB cable to J9. This will allow you to program the board.

Go back to the folder mfgtools-rel and Open the Mfg Tool. It should say HID- compliant vendor-defined device. Otherwise double check SW7 and the power pin at the bottom right.

 pastedImage_5.png

Click start and if successful it should look like:

pastedImage_6.png

Please note that this success only means that it was able to upload the bootable image to the board. This usually works well. However, if you find later that the board doesn’t do what it’s supposed to, then there might be a problem in the other steps of the processor. Check to make sure you used the right linker file, and that the settings in MCUXpresso are configured correctly.

Press stop and exit

Remember to switch the pin headers back, so the board can boot normally. J1 (5-6) and SW7 to OFF-ON -ON -OFF to boot from Hyperflash.

 

Bootable Image Generation – SDRAM

The guide is based off this link: https://community.nxp.com/docs/DOC-340655 . Download the files provided there, and unzip. Everything is good except the first step of that pdf document is a little unclear.

MCUXpresso Configurations and output:

Begin by changing memory allocation in the memory configuration editor of the MCU Settings part of MCUXpresso. It should look like the one below.

pastedImage_7.png

Then go to settings > MCU C compiler > preprocessor and set the XIP_boot_header enable and and XIP_boot_header_DCD_enable both to 0

Hit apply and close.

Go to C/C++ Build >> Settings >> MCU Linker >> Manage linker script, and check the box Link application to RAM.

pastedImage_8.png

Go to the debug portion and click on binary utilities, then generate an s-record (.s19) file from MCUXpresso. 

pastedImage_9.png

Click build to re-build the project.

You can check the console to verify the correct allocations of memory:

pastedImage_10.png

Copy this .s19 file.

Elftosb tool – .bin file generation

In the flashloader tool, go to Tools > elftosb > Win, and drop the .s19 file in this folder, as well as the dcd.bin file.

There’s another step for booting from SDRAM. Take the file imx-sdram-normal-unsigned-dcd.bd (included in the link posted) and drag it into Tools > bd_file > imx10xx

Fire up command prompt in administrator mode, and use command cd [elftosb directory] to get to this folder

To generate the .bin file, call the command:

 

elftosb.exe -f imx -V -c ../../bd_file/imx10xx/imx-sdram-normal-unsigned-dcd.bd -o evkbimxrt1050_led_blinky.bin SDRAM1_led_blinky.s19

 

This command essentially uses the imx-flexspinor bd linker file to generate a .bin file that will include the dcd.bin header inside. Note that HYPERFLASH_led_blinky.s19 should be renamed to your actual file name acquired from MCUXpresso

 

Elftosb tool – Bootable image generation

Then we must generate the boot_image.sb

Then call the elftosb tool again with a kinetis command. This will take the .bin file and convert it to a boot_image.sb file.

The command is:

 

elftosb.exe -f kinetis -V -c ../../bd_file/imx10xx/program_flexspinor_image_hyperflash.bd -o boot_image.sb evkbimxrt1050_led_blinky_nopadding.bin

 

The output of the first imx command we made must match the input of this one. Also, the output must remain named boot_image.sb, otherwise it will not work. Also note that this says flexspinor image hyperflash, but that is correct since we are still technically needing to boot from Hyperflash initially before we copy everything over to SDRAM.

Copy the boot_image.sb file.

MFG tool

Then we can use the mfg tool to generate the program image for the board, and upload it.

In order to do this, the board SW7 must be set to OFF-ON-OFF-ON, and switch the jumper from J1  (5-6) to J1 (3-4). Connect the USB cable to J9 to power the board. Then connect the board to your computer and run the Mfg tool. Click start and the image will be uploaded. 

 

 pastedImage_11.png

 

Copy the boot_image.sb file that we created in the last step. Move it to the directory Tools > mfgtools-rel > Profiles > MXRT105X > OS Firmware, and drop it in here.

Next, set SW7 on the board to OFF-ON-OFF-ON, and switch the jumper at the bottom to power the board. Then connect the USB cable to J9. This will allow you to program the board.

Go back to the folder mfgtools-rel and Open the Mfg Tool. It should say HID- compliant vendor-defined device. Otherwise double check SW7 and the power pin at the bottom right.

 

pastedImage_12.png

Click start and if successful it should look like:

pastedImage_13.png

Please note that this success only means that it was able to upload the bootable image to the board. This usually works well. However, if you find later that the board doesn’t do what it’s supposed to, then there might be a problem in the other steps of the processor. Check to make sure you used the right linker file, and that the settings in MCUXpresso are configured correctly.

Press stop and exit

Remember to switch the pin headers back, so the board can boot normally. J1 (5-6) and SW7 to OFF-ON -ON -OFF to boot from Hyperflash.

 

Bootable Image Generation – SRAM

This one was a little trickier as there was no appnote, but not too bad.

MCUXpresso Configurations and output:

Begin by changing memory allocation in the memory configuration editor of the MCU Settings part of MCUXpresso. It should look like the one below. We are linking to copy everything to dtc RAM

pastedImage_14.png

Then go to settings > MCU C compiler > preprocessor and set the XIP_boot_header enable and and XIP_boot_header_DCD_enable both to 0

Hit apply and close.

Go to C/C++ Build >> Settings >> MCU Linker >> Manage linker script, and check the box Link application to RAM.

pastedImage_15.png 

Go to the debug portion and click on binary utilities, then generate an s-record (.s19) file from MCUXpresso. 

pastedImage_16.png

Click build to re-build the project.

You can verify that application is linked to SRAM in the console:

pastedImage_17.png

Copy this .s19 file.

Elftosb tool – .bin file generation

In the flashloader tool, go to Tools > elftosb > Win, and drop the .s19 file in this folder, as well as the dcd.bin file

Fire up command prompt in administrator mode, and use command cd [elftosb directory] to get to this folder

This step is specific to dtcm ram: Go to Tools >>bd_file >> imx10xx, and open up the imx-dtcm-unsigned-dcd.bd file and change the ivtOffset address to 0x1000. 0x400 is the default for SDCARD booting.

To be clear, the bd file should look as below:

pastedImage_18.png

To generate the .bin file, call the command:

 

elftosb.exe -f imx -V -c ../../bd_file/imx10xx/imx-dtcm-unsigned-dcd.bd -o evkbimxrt1050_led_blinky.bin SRAM1_led_blinky.s19

 

This command essentially uses the imx-flexspinor bd linker file to generate a .bin file that will include the dcd.bin header inside. Note that SRAM_led_blinky.s19 should be renamed to your actual file name acquired from MCUXpresso.

Elftosb tool – Bootable image generation

Then we must generate the boot_image.sb

Then call the elftosb tool again with a kinetis command. This will take the .bin file and convert it to a boot_image.sb file.

The command is:

 

elftosb.exe -f kinetis -V -c ../../bd_file/imx10xx/program_flexspinor_image_hyperflash.bd -o boot_image.sb evkbimxrt1050_led_blinky_nopadding.bin

 

The output of the first imx command we made must match the input of this one. Also, the output must remain named boot_image.sb, otherwise it will not work. Also note that this says flexspinor image hyperflash, but that is correct since we are still technically needing to boot from Hyperflash initially before we copy everything over to SDRAM.

MFG tool

Then we can use the mfg tool to generate the program image for the board, and upload it.

In order to do this, the board SW7 must be set to OFF-ON-OFF-ON, and switch the jumper from J1  (5-6) to J1 (3-4). Connect the USB cable to J9 to power the board. Then connect the board to your computer and run the Mfg tool. Click start and the image will be uploaded. 

pastedImage_19.png

 

Copy the boot_image.sb file that we created in the last step. Move it to the directory Tools > mfgtools-rel > Profiles > MXRT105X > OS Firmware, and drop it in here.

Next, set SW7 on the board to OFF-ON-OFF-ON, and switch the jumper at the bottom to power the board. Then connect the USB cable to J9. This will allow you to program the board.

Go back to the folder mfgtools-rel and Open the Mfg Tool. It should say HID- compliant vendor-defined device. Otherwise double check SW7 and the power pin at the bottom right.

pastedImage_20.png

 

Click start and if successful it should look like:

pastedImage_21.png

Please note that this success only means that it was able to upload the bootable image to the board. This usually works well. However, if you find later that the board doesn’t do what it’s supposed to, then there might be a problem in the other steps of the processor. Check to make sure you used the right linker file, and that the settings in MCUXpresso are configured correctly.

Press stop and exit

Remember to switch the pin headers back, so the board can boot normally. J1 (5-6) and SW7 to OFF-ON -ON -OFF to boot from Hyperflash.

Please note that this success only means that it was able to upload the bootable image to the board. This usually works well. However, if you find later that the board doesn’t do what it’s supposed to, then there might be a problem with the other steps of the processor. Check to make sure you used the right linker file, and that the settings in MCUXpresso are configured correctly.

After this the bootable image will be uploaded to the board and you’ll be good to go!

Labels (1)
Comments

Hello, very interesting document.

Its possible also apply run software from SDRAM, with boot from SD or QSPI ?
These instructions are also useful for RT1020 or only for RT1050 ?

Hi Manuel, thank you for this interesting document.

Unfortunately elftosb crashes when I attempt to create the binaries. It keeps looking for "section 0x0", although the addresses in the S19 file are correct. This happens both with SDRAM and internal RAM version.

Thanks

Giuseppe

In the end, I discovered that my flashloader has some problems.

Today I was able to create an image, write it in flash and run it in SDRAM.

Later, we were also able to have MCUXpresso create the binary image (no flashloader). You need to load it to the right location via Segger Ozone, but everything works well.

Manuel, if you ever pass in Firenze, there is a free beer for you ;-)

Giuseppe

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... 

Why we need .s19 file.

Adrian,

In my Flashloader download, I don't see any of the "-dcd"  bd files  that you used. 

Ive been banging my head against the wall for the past three days.  RT1050-EVKB.  I can download images happily via MCUXpresso.  I have been able to create images that I burn into flash, that are copied into either DTC or ITC ram.  I use either NXP-MCUBootutility or MCUXpresso Secure provisioning tool.  Both work for me.  Next on the list is creating images that XIP and run from SDRam.  I have tried every thing that I have found - NG. I can take the sample images from the provisioning tool: evkbimxrt1050_iled_blinky_ext_FLASH and evkbimxrt1050_iled_blinky_SDRAM, and burn these, and have them run.  So its not my toolset - its obviously something Im doing wrong or not doing.  I have SDK ver 2.3.  The guides look really simple, but I must be missing something on each.  Thoughts?  If I were to ask for somewhere to start, it would be give me the steps to get an XIP image built and downloaded, using MCUXpresso.  Which compiler defs need to be set.  I know I have to have the image running at 0x60002000, with the flash as the top item.  What else is there?  


Thanks in advance.

Larry

EDIT:

   OH MY GOD!!! I will tell you what else there is: The MCUXPresso IDE doesnt know that it isnt the latest version!!!!!!!!!!!!!!!!!!  I've been using V10.3 for a year now, for another project.  I have REPEATEDLY had it check for updates, and it said there were none available.  It doesnt know that there is a version 11.1 available.  And RT1050 SDK v 2.7 works with that and automatically provides all of the flash burning functionality!!!  WOW!  RT1050 SDK2.3 does not.  

Version history
Revision #:
1 of 1
Last update:
‎08-17-2018 12:47 PM
Updated by: