Generating a Bootable Image for the RT1050

Document created by Manuel Pacheco Employee on Aug 17, 2018Last modified by Manuel Pacheco Employee on Aug 17, 2018
Version 3Show Document
  • View in full screen mode

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:

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. 

 

 

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.

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.

Hit apply and close.

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

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. 

 

 

 

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.

 

Click start and if successful it should look like:

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.

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.

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

 

 

 

Click build to re-build the project.

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

 

 

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. 

 

 

 

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.

 

 

Click start and if successful it should look like:

 

 

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

 

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.

 

 

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

 

 

Click build to re-build the project.

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

 

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:

 

 

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. 

 

 

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.

 

 

Click start and if successful it should look like:

 

 

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!

4 people found this helpful

Attachments

    Outcomes