2025-07-03 11:58 AM
I am currently facing a critical issue with reading and programming two OBK sectors (current and alternate) from within firmware while using the iCache on the STM32H562. Despite my efforts to disable iCache access to the OBK address range using the MPU, similar to the procedure for the OTP and RO regions, I have not been successful. The use of iCache has resulted in the microcontroller stalling when attempting to read from the OBK address range.
I understand that the Reference Manual does not specify the actual physical address range for the two OBK sectors, each of which is 8k in size. Instead, it indicates that both sectors share the same virtual address range, with a base of 0x0BFD0000 (non-secure) or 0x0FFD0000 (secure).
Could you please provide the actual physical address range for the two OBK sectors? This information is necessary to adjust the MPU settings for disabling iCache access.
2025-07-10 12:18 AM
Hello @zhiv12,
You have example how to use OBK in the OEMiROT secure boot code
STM32Cube_FW_H5_V1.5.0\Projects\NUCLEO-H563ZI\Applications\ROT\OEMiROT_Boot\src\low_level_obkeys.c
And also in
STM32Cube_FW_H5_V1.5.0\Projects\NUCLEO-H563ZI\Examples\FLASH\FLASH_OBK_EraseProgram\Src\main.c
Best regards
Jocelyn
2025-07-11 7:51 AM
Both programs are referring to
HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t FlashAddress, uint32_t DataAddress)
which has an error in the following part of the code
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#if defined (FLASH_SR_OBKERR)
/* If the program operation is completed, disable the PG */
CLEAR_BIT((*reg_cr), (TypeProgram & ~(FLASH_NON_SECURE_MASK | FLASH_OBK | FLASH_OTP | FLASH_OBKCFGR_ALT_SECT)));
/* Clear alternate sector bit */
if (TypeProgram == FLASH_TYPEPROGRAM_QUADWORD_OBK_ALT)
{
reg_obkcfgr = IS_FLASH_SECURE_OPERATION() ? &(FLASH->SECOBKCFGR) : &(FLASH_NS->NSOBKCFGR);
CLEAR_BIT((*reg_obkcfgr), FLASH_OBKCFGR_ALT_SECT);
}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The comment to "disable PG" is correct, but the code is clearing nonexisting flags
reg_cr = IS_FLASH_SECURE_OPERATION() ? &(FLASH->SECCR) : &(FLASH_NS->NSCR); ) CLEAR_BIT((*reg_cr), (TypeProgram & ~(FLASH_NON_SECURE_MASK | FLASH_OBK | FLASH_OTP | FLASH_OBKCFGR_ALT_SECT)));