i.MX 95 AHAB with U-BOOT#

This notebook describes how to build a bootable AHAB image with ELE firmware and U-BOOT bootloader, and how to use NXPELE app.

1. Prerequisites#

  • SPSDK is needed with examples extension. pip install spsdk[examples] (Please refer to the installation documentation.)

  • This demo was tested with i.MX 95 EVK board with LPDDR5 memory and A0 chip revision.

1.1 Images preparation#

  • to create resulting binary containing AHAB containers, we need to prepare the binaries

  • in this section we reproduce the process which is done by the imx-mkimage tool

  • Obtain all the necessary binaries and put them into inputs directory

1.2 U-Boot#

In order to use the nxpele app, U-Boot must be built with AHAB support. CONFIG_AHAB_BOOT=y If you want to use the nxpele over fastboot, also multiplexing of console output to fastboot must be enabled by setting CONFIG_CONSOLE_MUX=y.

1.3 Requirements#

Download these files from the https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/<package name> and put them into the inputs directory.

Primary image container set:

  • ELE firmware

  • lpddr5 or lpddr4 firmware files with OEI firmware

  • CM33 OEI TCM

  • CM33 System manager image

  • U-Boot SPL

  • [Optional] M7 application image

Secondary image container set

  • bl31.bin binary (ARM Trusted Firmware)

  • U-Boot (built with AHAB support)

  • TEE binary

2. AHAB Image#

2.1 AHAB Template#

We can generate the template using the nxpimage ahab get-template command. The command will generate a template. The template is a YAML file that contains the AHAB header and the AHAB container. The AHAB header contains the information about the image, such as the version, the number of containers, and the signature. The AHAB container contains the information about the image, such as the image type, the image version, the image size, and the image signature.

The following command generates the template:

nxpimage ahab get-template -f mimx9596 -o ahab_template.yaml

2.2 Exporting of the AHAB image#

The AHAB image can be exported using the nxpimage ahab export command. The command will create the AHAB image from the template. The following command creates the AHAB image:

nxpimage ahab export -c ahab_template.yaml 

2.4 Primary image container set#

Primary image container set consists of the following images:

  • ELE firmware

  • DDR firmware with OEI

  • System manager

  • U-Boot SPL

  • [Optional] M7 application image

nxpimage ahab get-template -r a0 -f mimx9596 -o workspace/ahab_template.yaml --force
Creating workspace/ahab_template.yaml template file.

Configuration Differences

2.5 Secondary image container set#

Secondary image container set consists of the following images:

  • bl31.bin binary (ARM Trusted Firmware)

  • U-Boot (built with AHAB support)

  • TEE binary

YamlDiffWidget("inputs/mx95_ahab_secondary.diffc").html
nxpimage ahab get-template -r a0 -f mimx9596 -o workspace/ahab_template.yaml --force
Creating workspace/ahab_template.yaml template file.

Configuration Differences

2.6 Exporting of full AHAB image (container set)#

U-Boot image consist from two image container sets. The first one contains ELE firmware, DDR firmware with OEI, system manager and U-Boot SPL. This image is loaded using the SDPS protocol. Once the U-Boot SPL is loaded to OCRAM the fastboot is opened and the second container is loaded using the fastboot protocol.

If the image is intended for loading using the UUU, the memory type should be set to serial_downloader. However the type of each individual AHAB should be set to standard, because it will be stored in flash memory.

nxpimage -v bootable-image merge -c u-boot-flash_template.yaml -o flash.bin
YamlDiffWidget("inputs/mx95_ahab_bimg.diffc").html
nxpimage bootable-image get-templates -f mimx9596 -o workspace --force
Creating workspace/bootimg_mimx9596_serial_downloader.yaml template file.
Creating workspace/bootimg_mimx9596_flexspi_nor.yaml template file.
Creating workspace/bootimg_mimx9596_emmc.yaml template file.
Creating workspace/bootimg_mimx9596_sd.yaml template file.
Creating workspace/bootimg_mimx9596_recovery_spi.yaml template file.

Configuration Differences

U_BOOT_PRIMARY = "inputs/mx95_uboot_primary.yaml"
U_BOOT_SECONDARY = "inputs/mx95_uboot_secondary.yaml"
U_BOOT_FLASH_BOOT_CFG = "inputs/bootimg_mx95_serial_downloader.yaml"
U_BOOT_FLASH_BOOT = "outputs/flash.bin"

VERBOSITY = "-v"

# EXPORT U-BOOT IMAGE
%! nxpimage -v bootable-image merge --config $U_BOOT_FLASH_BOOT_CFG --output $U_BOOT_FLASH_BOOT
nxpimage -v bootable-image merge --config bootimg_mx95_serial_downloader.yaml --output outputs/flash.bin 
INFO:spsdk.apps.nxpimage:Created Bootable Image:
Name:      Bootable Image for mimx9596
Starts:    0x0
Ends:      0x26bbff
Size:      Size: 2.4 MiB; 2,538,496 B
Alignment: 1 B
Pattern:zeros
Memory type: MemoryType.SERIAL_DOWNLOADER
Revision: latest

INFO:spsdk.apps.nxpimage:Created Bootable Image memory map:

+==0x0000_0000= Bootable Image for mimx9596 =====================+
|                   Size: 2.4 MiB; 2,538,496 B                   |
|   Memory type: MemoryType.SERIAL_DOWNLOADER Revision: latest   |
|                         Pattern: zeros                         |
|+==0x0000_0000= primary_image_container_set ===================+|
||                  Size: 852.0 kiB; 872,448 B                  ||
||                  AHAB Image for mimx9596_a0                  ||
||                        Pattern: zeros                        ||
||+==0x0000_0000= AHAB Containers =============================+||
|||                   Size: 8.0 kiB; 8,192 B                   |||
|||                   AHAB Containers block                    |||
|||                       Pattern: zeros                       |||
|||+==0x0000_0000= AHAB Container 0 ==========================+|||
||||                       Size: 544 B                        ||||
||||              AHAB Container for nxp_SWver:0              ||||
|||+==0x0000_021f=============================================+|||
|||                         Gap: 480 B                         |||
|||+==0x0000_0400= AHAB Container 1 ==========================+|||
||||                       Size: 832 B                        ||||
||||              AHAB Container for oem_SWver:0              ||||
|||+==0x0000_073f=============================================+|||
|||                         Gap: 192 B                         |||
|||+==0x0000_0800= AHAB Container 2 ==========================+|||
||||                       Size: 800 B                        ||||
||||             AHAB Container for none_SWver:0              ||||
|||+==0x0000_0b1f=============================================+|||
||+==0x0000_1fff===============================================+||
||+==0x0000_2000= Container 0 AHAB Data Image 0 ===============+||
|||                  Size: 82.3 kiB; 84,288 B                  |||
||| AHAB encrypted data block for ele core and ele Image Type. |||
||+==0x0001_693f===============================================+||
||                         Gap: 5.7 kiB                         ||
||+==0x0001_8000= Container 1 AHAB Data Image 0 ===============+||
|||                  Size: 52.0 kiB; 53,248 B                  |||
||| AHAB data block for v2x-1 core and v2x_primary Image Type. |||
||+==0x0002_4fff===============================================+||
||+==0x0002_5000= Container 1 AHAB Data Image 1 ===============+||
|||                  Size: 28.0 kiB; 28,672 B                  |||
|||AHAB data block for v2x-2 core and v2x_secondary Image Type.|||
||+==0x0002_bfff===============================================+||
||+==0x0002_c000= OEI DDR =====================================+||
|||                 Size: 308.0 kiB; 315,392 B                 |||
|||  AHAB data block for cortex-m33 core and oei Image Type.   |||
||+==0x0007_8fff===============================================+||
||                        Gap: 64.0 kiB                         ||
||+==0x0008_9000= OEI TCM =====================================+||
|||                   Size: 4.0 kiB; 4,096 B                   |||
|||  AHAB data block for cortex-m33 core and oei Image Type.   |||
||+==0x0008_9fff===============================================+||
||+==0x0008_a000= System manager ==============================+||
|||                 Size: 143.0 kiB; 146,432 B                 |||
|||  AHAB data block for cortex-m33 core and executable Image  |||
|||                           Type.                            |||
||+==0x000a_dbff===============================================+||
||+==0x000a_dc00= Additional Cortex M7 application ============+||
|||                  Size: 15.0 kiB; 15,360 B                  |||
||| AHAB data block for cortex-m7-1 core and executable Image  |||
|||                           Type.                            |||
||+==0x000b_17ff===============================================+||
||+==0x000b_1800= U-Boot SPL ==================================+||
|||                 Size: 142.0 kiB; 145,408 B                 |||
|||  AHAB data block for cortex-a55 core and executable Image  |||
|||                           Type.                            |||
||+==0x000d_4fff===============================================+||
||+==0x000d_5000= V2X core Dummy record =======================+||
|||                         Size: 0 B                          |||
|||  AHAB data block for cortex-m33 core and v2x_dummy Image   |||
|||                           Type.                            |||
||+==0x000d_4fff===============================================+||
|+==0x000d_4fff=================================================+|
|+==0x000d_5000= secondary_image_container_set =================+|
||                  Size: 1.6 MiB; 1,666,048 B                  ||
||                  AHAB Image for mimx9596_a0                  ||
||                        Pattern: zeros                        ||
||+==0x000d_5000= AHAB Containers =============================+||
|||                   Size: 8.0 kiB; 8,192 B                   |||
|||                   AHAB Containers block                    |||
|||                       Pattern: zeros                       |||
|||+==0x000d_5000= AHAB Container 0 ==========================+|||
||||                       Size: 416 B                        ||||
||||             AHAB Container for none_SWver:0              ||||
|||+==0x000d_519f=============================================+|||
||+==0x000d_6fff===============================================+||
||+==0x000d_7000= ATF - ARM Trusted Firmware ==================+||
|||                  Size: 37.0 kiB; 37,888 B                  |||
|||  AHAB data block for cortex-a55 core and executable Image  |||
|||                           Type.                            |||
||+==0x000e_03ff===============================================+||
||+==0x000e_0400= U-Boot Firmware =============================+||
|||                 Size: 1.0 MiB; 1,091,584 B                 |||
|||  AHAB data block for cortex-a55 core and executable Image  |||
|||                           Type.                            |||
||+==0x001e_abff===============================================+||
||+==0x001e_ac00= U-Boot TEE - Trusted Execution Environment ==+||
|||                 Size: 516.0 kiB; 528,384 B                 |||
|||  AHAB data block for cortex-a55 core and executable Image  |||
|||                           Type.                            |||
||+==0x0026_bbff===============================================+||
|+==0x0026_bbff=================================================+|
+==0x0026_bbff===================================================+

Success. (Bootable Image: outputs\flash.bin created) 
# Set the boot mode to Cortex-M Serial Downloader 1001 and download the files using the UUU tool

%! nxpuuu $VERBOSITY write -f mimx9596 -b emmc $U_BOOT_FLASH_BOOT
nxpuuu -v write -f mimx9596 -b emmc outputs/flash.bin 
SDPS: boot -f outputs/flash.bin


SDPV: write -f outputs/flash.bin -skipspl


SDPV: jump


Done

Now change the boot mode to Cortex-M EMMC 1010 and reset the board. Find the serial port that belongs to U-Boot console and interrupt the boot. When the console is switched to U-Boot menu, we can use the nxpele tool to communicate with the ELE.

%! nxpele -f mimx9596 -p COM180 -d uboot_serial get-info
nxpele -f mimx9596 -p COM180 -d uboot_serial get-info 
ELE get info ends successfully:
Command:          0xda
Version:          2
Length:           160
SoC ID:           MX95 - 0x9500
SoC version:      A100
Life Cycle:       OEM_OPEN - 0x0010
SSSM state:       4
UUID:             e1e6e6f98b514065bd991d922e30c659
SHA256 ROM PATCH: e32d8de33ee1ac953d78379b9d6c1523544e3b77a9848d1d1af9374f678a81c1
SHA256 FW:        eb3f39a5dccafb3335e8e3e340d3e5f06b386666036a30affb660a301b5ed420
Advanced information:
  OEM SRKH:       0000000000000000000000000000000000000000000000000000000000000000
  IMEM state:     This is non-existing tag(0x0) from enum: EleImemState - 0x00
  CSAL state:     EdgeLock secure enclave random context initialization succeed - 0x02
  TRNG state:     TRNG entropy is valid and ready to be read - 0x03
  OEM PQC SRKH:  00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
%! nxpele -f mimx9596 -p COM180 -d uboot_serial generate-keyblob DEK -a AES_CBC --key-id 0 --key 00000000000000000000000000000000 --key-size 128
nxpele -f mimx9596 -p COM180 -d uboot_serial generate-keyblob DEK -a AES_CBC --key-id 0 --key 00000000000000000000000000000000 --key-size 128 
ELE generate DEK key blob ends successfully:
00480081011003002021528bf3419a5498d94d8f73333fb48e1925049106cc0a28d5fb19a2c48a5797b509156279678db9b3a304af8d073ed2f8937a24e80a07381f79cede1d0577