I am calling the runBootloader() API as described in section 10.13.3 of the i.MX RT1170 Processor Reference Manual Rev. 1. My code is pasted below. As you can see, had to blow the BT_FUSE_SEL fuse to get this to work when not run from the debugger. My goal is to be able to set the SRK hash in the fuse shadow before calling the ROM to test my boot code.
When run from the debugger, the debugger goes straight to the start address, bypassing the ROM. I assume that is why it gets stuck in the ROM code, as I show in the original post.
Since posting I found the High Assurance Boot Version 4 Application Programming Interface Reference Manual. I assume, based on its features that the RT1170 is HAB4, even though I can not find a manual that explicitly states that. Much of the HAB4 document seems to line up with the RT1170 security reference, but the API part does not, nor does it seem to match what I see in the ROM vector table.
I feel like I am missing an important piece here and hope you can help me find it.
(looks like I don't have permission to paste pictures for some reason now, so here is the messy text paste of the code)
typedef struct BootloaderTree
{
void (*runBootloader)(const uint32_t *arg);
uint32_t version;
const char *copyright;
// const flexspi_nor_flash_driver_t *flexspiNorDriver;
} bootloader_tree_t;
uint32_t __attribute__((section(".secure_ram_data"))) arg;
uint32_t __attribute__((section(".secure_ram_data"))) first;
static void testBoot()
{
#if 0
if (SCB_CCR_IC_Msk == (SCB_CCR_IC_Msk & SCB->CCR))
{
SCB_DisableICache();
}
if (SCB_CCR_DC_Msk == (SCB_CCR_DC_Msk & SCB->CCR))
{
SCB_DisableDCache();
}
ARM_MPU_Disable();
OCOTP_Init(OCOTP, 0);
uint32_t version = OCOTP_GetVersion(OCOTP);
printf("Version=%d\n", version);
// Blow BT_FUSE_SEL to ignore pads for boot config (can't just update in shadow since SRC uses it)
uint32_t addr = ((0x960 - 0x800) >> 4);
status_t otpStatus = OCOTP_WriteFuseShadowRegister(OCOTP, addr, 0x10);
printf("optStatus=%d\n", otpStatus);
#endif
// try to set the SRK HASH in shadow
// *((uint32_t*)0x40CACB00) = 0x12345678;
const uint32_t romApiPtr = 0x21001c;
bootloader_tree_t *blTree = *((bootloader_tree_t**)romApiPtr);
arg = 0xEB000000;
(*(blTree->runBootloader))(&arg);
}
int main(int argc, char **argv)
{
if (first != 0xBADCAFE)
{
first = 0xBADCAFE;
testBoot();
}