I'm using usb-serial download via uuu. When downloading an u-boot image signed with key 1 or 2, a lot of boot information is printed on the debug uart - normal u-boot output. but when signing the u-boot image (flash.bin) with ex. key 4 there is nothing printede out - not even an CSF error-code. of course uuu fails with
Wait for Known USB Device Appear...
New USB Device Attached at 3:12
3:12>Start Cmd:SDPS: boot -f "flash.bin"
13%3:12>Fail HID(W):LIBUSB_ERROR_IO(0.034s)
but I don't think you can use uuu's error to finde the problem.
Therefore to go a step deeper, I have tried to sign the spl with key 1 and the fit-image with key 4, simply by having csf_spl.txt to point at source index 0 and csf_fit.txt to point at source index 3. Now spl boots as expected but the fit-images fails - still without any error-code
U-Boot SPL 2023.07-00049-g6a6d86cd3d (Nov 06 2023 - 11:01:52 +0100)
SEC0: RNG instantiated
Normal Boot
WDT: Started watchdog@30280000 with servicing every 1000ms (60s timeout)
Trying to boot from BOOTROM
Boot Stage: USB boot
Find img info 0x4802c000, size 763443
Need continue download 762880
Authenticate image from DDR location 0x44000000...
spl: ERROR: image authentication unsuccessful
resetting ...
To get a step deeper I have modify the hab.c to print debug out and to get the hab status when the authentication fails - with the following changes:
diff --git a/arch/arm/mach-imx/hab.c b/arch/arm/mach-imx/hab.c
index 439cdaf07a..70d5966786 100644
--- a/arch/arm/mach-imx/hab.c
+++ b/arch/arm/mach-imx/hab.c
@@ -3,6 +3,8 @@
* Copyright (C) 2010-2015 Freescale Semiconductor, Inc.
*/
+#define DEBUG
+
#include <common.h>
#include <command.h>
#include <config.h>
@@ -246,7 +248,7 @@ void *hab_rvt_authenticate_image(uint8_t cid, ptrdiff_t ivt_offset,
return ret;
}
-#if !defined(CONFIG_SPL_BUILD)
+// #if !defined(CONFIG_SPL_BUILD)
#define MAX_RECORD_BYTES (8*1024) /* 4 kbytes */
@@ -555,7 +557,7 @@ static int get_hab_status_m4(void)
return 0;
}
#endif
-
+#if !defined(CONFIG_SPL_BUILD)
static int do_hab_status(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
@@ -937,7 +939,7 @@ int imx_hab_authenticate_image(uint32_t ddr_start, uint32_t image_size,
puts("Dumping CSF Header\n");
print_buffer(ivt->csf, (void *)(uintptr_t)(ivt->csf), 4, 0x10, 0);
-#if !defined(CONFIG_SPL_BUILD)
+#if defined(CONFIG_SPL_BUILD)
get_hab_status();
#endif
@@ -987,7 +989,7 @@ int imx_hab_authenticate_image(uint32_t ddr_start, uint32_t image_size,
}
hab_exit_failure_print_status:
-#if !defined(CONFIG_SPL_BUILD)
+#if defined(CONFIG_SPL_BUILD)
get_hab_status();
#endif
The debug-output now comes with the following hab event:
U-Boot SPL 2023.07-00049-g6a6d86cd3d-dirty (Nov 06 2023 - 13:16:40 +0100)
SEC0: RNG instantiated
Normal Boot
WDT: Started watchdog@30280000 with servicing every 1000ms (60s timeout)
Trying to boot from BOOTROM
Boot Stage: USB boot
Find img info 0x4802ae00, size 764147
Need continue download 763904
Authenticate image from DDR location 0x44000000...
ivt_offset = 0xbb000, ivt addr = 0x440bb000
ivt entry = 0x440bb000, dcd = 0x00000000, csf = 0x440bb020
Dumping IVT
.. A...D........
.......D ..D....
Dumping CSF Header
..`C...........`
................
................
...!............
Secure boot enabled
HAB Configuration: 0xcc, HAB State: 0x99
No HAB Events Found!
Calling authenticate_image in ROM
ivt_offset = 0xbb000
start = 0x44000000
bytes = 0x440bb000
Secure boot enabled
HAB Configuration: 0xcc, HAB State: 0x99
--------- HAB Event 1 -----------------
event data:
0xdb 0x00 0x14 0x45 0x33 0x1d 0xc0 0x00
0xbe 0x00 0x0c 0x00 0x03 0x17 0x03 0x00
0x00 0x00 0x00 0x60
STS = HAB_FAILURE (0x33)
RSN = HAB_INV_KEY (0x1D)
CTX = HAB_CTX_COMMAND (0xC0)
ENG = HAB_ENG_ANY (0x00)
spl: ERROR: image authentication unsuccessful
resetting ...
From this event message the error see to be invalid key, but how can the key be invalid if it is part of the SRK pki tree structure generated via the cst-3.3.1 tool?