Changes between Version 8 and Version 9 of venice/secure_boot
- Timestamp:
- 06/23/2023 11:06:07 PM (17 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
venice/secure_boot
v8 v9 25 25 https://www.nxp.com/webapp/Download?colCode=IMX_CST_TOOL_NEW 26 26 27 == i.MX secure boot SPL (U-Boot v2021-07-venice) 28 ** This section is based on the [https://github.com/Gateworks/uboot-venice/tree/v2021.07-venice v2021-07-venice Gateworks U-Boot repository] - Instructions will differ for other versions of U-Boot ** 29 30 Boards using U-Boot SPL and U-Boot propper for boot firmware support using HABv4 authentication for both images. 27 == i.MX secure boot 28 Boards using U-Boot for boot firmware support using HABv4 authentication for both images. 31 29 32 30 The HAB library is a sub-component of the boot ROM on i.MX processors. It is responsible for verifying the digital signatures included as part of the product software and ensures that, when the processor is configured as a secure device, no unauthenticated code is allowed to run. … … 39 37 - CONFIG_CMD_FSL_CAAM_KB=y ('caam genblob' and 'caam decap' cmds) 40 38 - CONFIG_CMD_DEKBLOB=y (optional) ('dek_blob' cmd) 41 - CONFIG_ OF_LIST=<single target> (at this time only a single board can be supported by the image so replace the list of models in configs/imx8*_venice_defconfig with just the model you want to support)39 - CONFIG_SPL_LOAD_FIT_ADDRESS=0x48000000 42 40 - Create a PKI tree and SRK table via the NXP Code Signing Tool 43 41 - Construct boot firmware with a proper Command Sequence File (CSF) (CSF blobs are created with the NXP Code Signing Tool) … … 99 97 {{{#!bash 100 98 # checkout u-boot 101 git clone https://github.com/Gateworks/uboot-venice.git -b v2021.07-venice99 git clone https://github.com/Gateworks/uboot-venice.git 102 100 cd u-boot 103 101 # setup cross toolchain environment (ie source setup-environment in Venice BSP dir) … … 105 103 export CROSS_COMPILE="aarch64-linux-" 106 104 export ARCH=arm64 107 export ATF_LOAD_ADDR=0x920000 # IMX8MM108 105 # configure for venice board 109 106 make imx8mm_venice_defconfig 110 make menuconfig # select CONFIG_IMX_HAB=y 'Support i.MX HAB features' and CONFIG_OF_LIST to specify a single board dtb107 make menuconfig # select CONFIG_IMX_HAB=y and CONFIG_SPL_LOAD_FIT_ADDRESS=0x48000000 111 108 make flash.bin 112 109 }}} 113 * Use the v2021.07-venice U-Boot branch as this has support for IMX8M HAB 114 * Select a single board DTB for CONFIG_OF_LIST 115 3. create a signed_flash.bin using the [http://trac.gateworks.com/attachment/wiki/venice/secure_boot/sign_hab_imx8m.sh sign_hab_imx8m.sh script] 110 3. create a signed_flash.bin 116 111 {{{#!bash 117 112 # setup env to point to the CST 118 export CST_DIR=/usr/src/nxp/cst-3.3. 1/113 export CST_DIR=/usr/src/nxp/cst-3.3.2/ 119 114 export CST_BIN=$CST_DIR/linux64/bin/cst 120 export SIGN_KEY=$CST_DIR/crts/CSF1_1_sha256_4096_65537_v3_usr_crt.pem115 export CSF_KEY=$CST_DIR/crts/CSF1_1_sha256_4096_65537_v3_usr_crt.pem 121 116 export IMG_KEY=$CST_DIR/crts/IMG1_1_sha256_4096_65537_v3_usr_crt.pem 122 117 export SRK_TABLE=$CST_DIR/crts/SRK_1_2_3_4_table.bin 123 # sign it 124 $ wget http://trac.gateworks.com/raw-attachment/wiki/venice/secure_boot/sign_hab_imx8m.sh 125 $ chmod +x sign_hab_imx8m.sh 126 $ ./sign_hab_imx8m.sh 127 Install SRK 128 Install CSFK 129 Authenticate CSF 130 Install key 131 Authenticate data 132 CSF Processed successfully and signed data available in csf_spl.bin 133 Install SRK 134 Install CSFK 135 Authenticate CSF 136 Install key 137 Authenticate data 138 CSF Processed successfully and signed data available in csf_fit.bin 139 6472+0 records in 140 6472+0 records out 141 6472 bytes (6.5 kB, 6.3 KiB) copied, 0.0102526 s, 631 kB/s 142 6488+0 records in 143 6488+0 records out 144 6488 bytes (6.5 kB, 6.3 KiB) copied, 0.0119102 s, 545 kB/s 145 signed_flash.bin is ready! 146 # create a JTAG image if needed 147 mkimage_jtag --emmc -s signed_flash.bin@user:erase_none:66-32640 > signed_u-boot_spl-imx8mm.bin 148 }}} 149 * the script will create csf_spl.txt and csf_fit.txt which are templates used to create csf_spl.bin and csf_fit.bin which are then copied to the correct offsets in flash.bin to create signed_flash.bin 150 * on a board without SRK Hash fuses programmed and flashed with this signed image the serial console will look this this: 151 {{{#!bash 152 U-Boot SPL 2021.07-00087-g54ac394a7c74 (Jun 09 2023 - 14:39:52 -0700) 118 export PATH=$CST_DIR/linux64/bin:$PATH 119 # sign flash.bin 120 /bin/sh doc/imx/habv4/csf_examples/mx8m/csf.sh 121 # create a JTAG image (if needed) using one of the following 122 mkimage_jtag --emmc -s --partconf=boot0 \ 123 flash.bin@boot0:erase_none:66-8192 > signed_u-boot_spl-imx8mm.bin # imx8mm emmc boot0 partition 124 mkimage_jtag --emmc -s --partconf=boot0 \ 125 flash.bin@boot0:erase_none:0-8192 > signed_u-boot_spl-imx8mm.bin # imx8mp/imx8mn emmc boot0 partition 126 }}} 127 4. Program signed firmware image: 128 {{{#!bash 129 jtag_usbv4 -p signed_u-boot_spl-imx8mm.bin 130 }}} 131 * Booting this would look something like the following: 132 {{{#!bash 133 U-Boot SPL 2023.04-00034-g1f567dfbe119 (Jun 23 2023 - 15:53:20 -0700) 153 134 GSCv3 : v61 0x1d6f RST:VIN Thermal protection:disabled 154 135 RTC : 1970-01-01 0:00:31 UTC 155 Model : GW7 301-00-B1B156 Serial : 852420157 MFGDate : 11-19-2021158 PMIC : MP5416 159 DRAM : LPDDR4 1 GiB160 WDT: Started with servicing (60s timeout) 161 Trying to boot from MMC1 162 DTB : imx8mm-venice-gw73xx-0x 136 Model : GW7200-01-B1F 137 Serial : 935180 138 MFGDate : 04-05-2023 139 PMIC : MP5416 (IMX8MM) 140 DRAM : LPDDR4 4 GiB 3000MT/s 1500MHz 141 Failed to initialize caam_jr: -19 142 WDT: Started watchdog@30280000 with servicing every 1000ms (60s timeout) 143 Trying to boot from eMMC 163 144 hab fuse not enabled 164 145 165 Authenticate image from DDR location 0x401fcdc0... 146 Authenticate image from DDR location 0x48000000... 147 DTB : imx8mm-venice-gw72xx-0x 166 148 NOTICE: BL31: v2.4(release):f884ad7b0ba2 167 149 NOTICE: BL31: Built : 13:06:09, Oct 20 2021 168 150 169 151 170 U-Boot 2021.07-00087-g54ac394a7c74 (Jun 09 2023 - 14:39:52 -0700) 171 172 CPU: Freescale i.MX8MMQ rev1.0 1600 MHz (running at 1200 MHz) 173 CPU: Industrial temperature grade (-40C to 105C) at 34C 174 Reset cause: POR 175 Model: Gateworks Venice GW73xx-0x i.MX8MM Development Kit 176 DRAM: 1 GiB 177 WDT: Started with servicing (60s timeout) 178 MMC: FSL_SDHC: 0, FSL_SDHC: 1, FSL_SDHC: 2 179 Loading Environment from MMC... OK 180 In: serial 181 Out: serial 182 Err: serial 183 Net: DP83867 eth0: ethernet@30be0000 [PRIME] 184 GSC : boot watchdog disabled 185 Hit any key to stop autoboot: 0 186 u-boot=> 187 }}} 188 - Note the 'hab fuse not enabled' and the 'Authenticate image from DDR location' messages 189 4. Program SRK Hash fuses from Step 1 into IMX OTP (using U-Boot and the keys from fuse bin) 152 U-Boot 2023.04-00034-g1f567dfbe119 (Jun 23 2023 - 15:53:20 -0700) 153 }}} 154 - Note the 'hab fuse not enabled' message which means the SEC_CONFIG[1] fuse is not blown and the device is not locked 155 - Note the 'Authenticate image from DDR location' messages which shows that image authentication is able to be used 156 5. Program SRK Hash fuses from Step 1 into IMX OTP (using U-Boot and the keys from fuse bin) 190 157 {{{#!bash 191 158 fuse prog -y 6 0 0xDCE644DB … … 200 167 * **Do not use the above fuse values - use values generated above from your serial/passphrase** 201 168 * **OTP fuses can only be programmed once - be careful to use the correct values** 202 5. Program signed firmware image: 203 {{{#!bash 204 jtag_usbv4 -p signed_u-boot_spl-imx8mm.bin 205 }}} 206 6. Boot it and verify no HAB events: 169 6. Boot it again and verify no HAB events: 207 170 {{{#!bash 208 171 u-boot=> hab_status … … 217 180 }}} 218 181 * This sets the SEC_CONFIG[1] fuse on the i.MX8M and once done the processor will not load an image that has not been signed using the correct PKI tree 219 * on a board with SRK Hash fuses programmed, SEC_CONFIG[1] set and flashed with a signed image the serial console will look this this: 220 {{{#!bash 221 U-Boot SPL 2021.07-00087-g54ac394a7c74 (Jun 09 2023 - 14:39:52 -0700) 222 GSCv3 : v58 0xf098 RST:VIN Thermal protection:enabled at 96C 223 RTC : 1970-01-03 16:34:29 UTC 224 Model : GW7301-01-B1B 225 Serial : 852455 226 MFGDate : 11-10-2020 227 PMIC : MP5416 228 DRAM : LPDDR4 4 GiB 229 WDT: Started with servicing (60s timeout) 230 Trying to boot from MMC1 231 DTB : imx8mm-venice-gw73xx-0x 232 233 Authenticate image from DDR location 0x401fcdc0... 234 NOTICE: BL31: v2.4(release):f884ad7b0ba2 235 NOTICE: BL31: Built : 13:06:09, Oct 20 2021 236 237 238 U-Boot 2021.07-00087-g54ac394a7c74 (Jun 09 2023 - 14:39:52 -0700) 239 240 CPU: Freescale i.MX8MMQ rev1.0 1600 MHz (running at 1200 MHz) 241 CPU: Industrial temperature grade (-40C to 105C) at 30C 242 Reset cause: POR 243 Model: Gateworks Venice GW73xx-0x i.MX8MM Development Kit 244 DRAM: 4 GiB 245 WDT: Started with servicing (60s timeout) 246 MMC: FSL_SDHC: 0, FSL_SDHC: 1, FSL_SDHC: 2 247 Loading Environment from MMC... OK 248 In: serial 249 Out: serial 250 Err: serial 251 Net: DP83867 eth0: ethernet@30be0000 [PRIME] 252 GSC : boot watchdog disabled 253 Thermal protection:enabled at 96C 254 Hit any key to stop autoboot: 0 255 }}} 256 - Note the 'Authenticate image from DDR location' message 182 183 For more info see: 184 - https://elixir.bootlin.com/u-boot/latest/source/doc/imx/habv4/introduction_habv4.txt 185 - https://elixir.bootlin.com/u-boot/latest/source/doc/imx/habv4/guides/mx8m_spl_secure_boot.txt 186 257 187 258 188 == HABv4 encrypted boot architecture