Igor, I have made some progress. (I was pulling the source code from the wrong repositories and/or tags.) I am getting close, but there are still some problems with the code signing.
Building and running U-Boot "normally" (i.e. no secure boot) works fine. I think the problem is with how I'm using the mkimage tool.
After compiling, I build an SD card image with:
$ cd <working>/imx-mkimage
# Copy U-Boot binary into target folder
$ cp -v ../uboot-imx/u-boot.bin ./iMX8QM/
# Copy Firmware, AHAB Container into target folder
$ cp -v ~/imx-yocto-bsp/build-xwayland/tmp/work/imx8qmmek-poky-linux/imx-boot/0.2-r0/git/iMX8QM/scfw_tcm.bin ./iMX8QM/
$ cp -v ~/imx-yocto-bsp/build-xwayland/tmp/work/imx8qmmek-poky-linux/imx-boot/0.2-r0/git/iMX8QM/bl31.bin ./iMX8QM/
$ cp -v ~/imx-yocto-bsp/build-xwayland/tmp/work/imx8qmmek-poky-linux/imx-boot/0.2-r0/git/iMX8QM/mx8qm-ahab-container.img ./iMX8QM/
# Build the SD Card Boot Binary
$ make SOC=iMX8QM flash
$ cp -v ~/imx-yocto-bsp/build-xwayland/tmp/work/imx8qmmek-poky-linux/imx-boot/0.2-r0/git/iMX8QM/tee.bin ./iMX8QM/
$ cp -v <working>/uboot-imx/spl/u-boot-spl.bin ./iMX8QM/
# Make SD Card Boot SPL Container
$ make SOC=iMX8QM flash_spl
The resulting flash.bin file can be programmed with the "dd" command onto an SD card and it boots correctly.
Separately, I have generated the keys with the ahab_pki_tree.sh script and programmed the fuses. I did NOT close the AHAB lifecycle.
# ahab_close <--- Did NOT YET run this command.
When I boot the UNSIGNED image, as expected, it does boot, but I have AHAB events:
=> ahab_status
Lifecycle: 0x0020, NXP closed
SECO Event[0] = 0x0087EE00
CMD = AHAB_AUTH_CONTAINER_REQ (0x87)
IND = AHAB_NO_AUTHENTICATION_IND (0xEE)
SECO Event[1] = 0x0087EE00
CMD = AHAB_AUTH_CONTAINER_REQ (0x87)
IND = AHAB_NO_AUTHENTICATION_IND (0xEE)
sc_seco_get_event: idx: 2, res:3
What is interesting here are that there are TWO events (not just one).
Next, I edit the "csf_boot_image" configuration file so that it points to my own SRK table, cert, and flash.bin, then run the command to make the signed boot image:
$ ../../nxp_code_signing_tool/release/linux64/bin/cst -i my_csf_boot_image.txt -o flash.signed.bin
CSF Processed successfully and signed image available in flash.signed.bin
Once I again, I program the new image, flash.signed.bin to the SD card with dd. Now, when I boot the signed SD card image, I get ONE AHAB event:
=> ahab_status
Lifecycle: 0x0020, NXP closed
SECO Event[0] = 0x0087EE00
CMD = AHAB_AUTH_CONTAINER_REQ (0x87)
IND = AHAB_NO_AUTHENTICATION_IND (0xEE)
sc_seco_get_event: idx: 1, res:3
The way I read this is:
I actually have two containers in my boot image. One of them is properly signed, the other is unsigned (as opposed to incorrectly signed, as indicated by the error 0xEE).
My guess is that that the boot image is actually broken into two parts, the SPL and U-Boot proper.
So, perhaps there are two ways to fix this:
- Build U-Boot without an SPL; just have one binary which is the effectively the SPL and U-Boot application. I tried this even without signatures and could not get it run.
- Sign both SPL and U-Boot binaries individually. I'm not sure how to do this.
Or maybe I'm just doing something wrong.
Thank you very much for your help!