2025-02-06 01:09 PM
Hi,
I am evaluating/learning the SBSFU application example on STM32WBA55CG and having issues getting it up and running.
Below is the screenshot of the example log:
To begin with, I want to be able to do the following.
1. Flash the bootloader and flash the application.
2. Reset and bootloader validates the image, all verification pass.
3. Bootloader now allows the application to launch.
I have made a few changes to the project to disable security features for simplification. All changes are contained to the below files (attached) and disabled FLOW_CONTROL(via flags). And I have removed the static protection check calls from boot_platform_init( ), inserting the code snippet below as unable to attach the file.
int32_t boot_platform_init(void)
{
#ifdef MCUBOOT_EXT_LOADER
GPIO_InitTypeDef GPIO_Init;
#endif /* MCUBOOT_EXT_LOADER */
/* STM32WBAxx HAL library initialization:
- Systick timer is configured by default as source of time base, but user
can eventually implement his proper time base source (a general purpose
timer for example or other time source), keeping in mind that Time base
duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
handled in milliseconds basis.
- Set NVIC Group Priority to 3
- Low Level Initialization
*/
HAL_Init();
#ifdef TFM_DEV_MODE
/* Init for log */
stdio_init();
#endif /* TFM_DEV_MODE */
#ifdef TFM_ICACHE_ENABLE
/* Configure and enable ICache */
icache_init();
#endif /* ICACHE_ENABLED */
/* Start HW randomization */
RNG_Init();
(void)fih_delay_init();
// /* Apply Run time Protection */
// LL_SECU_ApplyRunTimeProtections();
// /* Check static protections */
// LL_SECU_CheckStaticProtections();
/* Check Flow control state */
// FLOW_CONTROL_CHECK(uFlowProtectValue, FLOW_CTRL_STAGE_1);
// uFlowStage = FLOW_STAGE_CHK;
/* Double protections apply / check to resist to basic fault injections */
/* Apply Run time Protection */
(void)fih_delay();
// LL_SECU_ApplyRunTimeProtections();
// /* Check static protections */
// LL_SECU_CheckStaticProtections();
if (FLASH_DEV_NAME.Initialize(NULL) != ARM_DRIVER_OK)
{
BOOT_LOG_ERR("Error while initializing Flash Interface");
Error_Handler();
}
#if defined(MCUBOOT_USE_HASH_REF)
/* Load all images hash references (for mcuboot) */
if (boot_hash_ref_load())
{
BOOT_LOG_ERR("Error while loading Hash references from FLash");
Error_Handler();
}
#endif
#ifdef MCUBOOT_EXT_LOADER
/* configure Button pin */
BUTTON_CLK_ENABLE;
GPIO_Init.Pin = BUTTON_PIN;
GPIO_Init.Mode = 0;
GPIO_Init.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_Init.Pull = GPIO_NOPULL;
GPIO_Init.Alternate = 0;
HAL_GPIO_Init(BUTTON_PORT, &GPIO_Init);
/* read pin value */
if (HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN) == GPIO_PIN_RESET)
{
boot_platform_noimage();
}
#endif /* MCUBOOT_EXT_LOADER */
return 0;
}
Please advise.
Thanks,
Vinay Divakar
2025-02-06 06:08 PM
Update:
I did some debugging, and it seems like the TLV of type 50 is the security counter, IMAGE_TLV_SEC_CNT. Since I have disabled rollback protection, i.e., MCUBOOT_HW_ROLLBACK_PROT, this condition isn't being handled.
I believe this TLV type and its associated data are in the image. How do I ensure the image to not have this TLV? - I think this happens during the build/image generation process?