Generate SB file for bootable image programming

To make the manufacturing process easier, all the commands supported by the flashloader and bootable image can be wrapped into a single SB file. Even if there are any changes in the application, MfgTool still uses this SB file to manufacture. The SB file can be updated separately without updating scripts for MfgTool use.

In this chapter, a bootable image will be created using the method in former chapter. Then corresponding SB file is generated using the bootable image. The BD file is prepared first to generate SB file for bootable image.

Generate SB file for FlexSPI NOR image programming

Generate Normal Bootable Image

For example, in RT1010, the FlexSPI NOR memory starts from address 0x6000_0000 and IVT from offset 0x1000. After following the steps in Section 4.2 (Generate unsigned normal i.MX RT bootable image) and BD file generation, here is the usage of the elftosb utility to create bootable image for FlexSPI NOR. All the BD files are provided in the release package. The figure below refers to the example command to generate a signed image.

Example command to generate signed FlexSPI boot image

After running above command, a file with suffix “_nopadding.bin” is available into destination memory via subsequent SB file based on this binary.

Generate SB file for plaintext FlexSPI NOR image programming

Usually, a BD file for FlexSPI NOR boot consists of seven parts.

  1. The bootable image file path is provided in sources block.

  2. The FlexSPI NOR Configuration Option block is provided in section block.

  3. To enable FlexSPI NOR access, the “enable” command must be used after the option block.

  4. If the flash device is not erased, an “erase” command is required before programming data to the flash device. The erase operation is time consuming and is not required for a blank flash device (factory setting) during manufacturing.

  5. The FlexSPI NOR Configuration Block (FNORCB) is required for FlexSPI NOR boot. To program the FNORCB generated by FlexSPI NOR Configuration Option block, a special magic number ‘0xF000000F” must be loaded into RAM first.

  6. To notify the flashloader to program the FNORCB, an “enable” command must be used after the magic number is loaded.

  7. After the above operation, the flashloader can program the bootable image binary into Serial NOR Flash through FlexSPI module using the load command.

Note: For redundant boot images, it is necessary to embed the FNORCB in the bin file to ensure FNORCB be programmed to 0x60000400. In this case steps 5 and 6 should be skipped.

An example containing the above steps is shown in the figure below.

Example BD file for FlexSPI NOR programming

Here is an example to generate SB file using the elftosb utility, ivt_flexspi_nor_xip.bin, and BD file shown in the figure below.

Example command to generate SB file for FlexSPI NOR programming

After the above command, a file named boot_image.sb will be created in the same folder that holds the elftosb utility executable.

Generate SB file for FlexSPI NOR Image encryption and programming

Usually, a BD file for FlexSPI NOR image encryption and programming consists of seven steps.

  1. The bootable image file path is provided in sources block.

  2. Enable FlexSPI NOR access using FlexSPI NOR Configuration Option block.

  3. Erase the flash device if it is not blank. The erase operation is time consuming and is not required for a blank flash device (factory setting) during manufacturing.

  4. Enable image encryption using FlexSPI NOR on-chip OTFAD pre-encryption option block.

  5. Program FNORCB using magic number.

  6. Program boot image binary into Serial NOR via FlexSPI module.

  7. Enable Encrypted XIP fuse bits.

Note: For redundant boot images, it is necessary to embed the FNORCB in the bin file to ensure FNORCB be programmed to 0x60000400. In this case step 5 should be skipped.

Example BD file for encrypted FlexSPI NOR image generation and programming

The steps to generate SB file is the same as in the above section.

Generate SB file for fuse programming

In certain cases, the fuse must be programmed first to enable specific features for selected boot devices or security levels. For example, to enable HAB closed mode, the fuse must be programmed first.

The elftosb utility can support programming the fuses using the built-in command load fuse. An example to program SRK table and enable HAB closed mode is shown as follows.

# The source block assign file name to identifiers
sources {
}
constants {
}
section (0) {
    # Program SRK table
    load fuse 0xD132E7F1 > 0x18;
    load fuse 0x63CD795E > 0x19;
    load fuse 0x8FF38102 > 0x1A;
    load fuse 0x22A78E77 > 0x1B;
    load fuse 0x01019c82 > 0x1C;
    load fuse 0xFC3AC699 > 0x1D;
    load fuse 0xF2C327A3 > 0x1E;
    load fuse 0xDAC9214E > 0x1F;
    # Program SEC_CONFIG to enable HAB closed mode
    load fuse 0x00000002 > 0x06;
}