cancel
Showing results for 
Search instead for 
Did you mean: 

Alternate OBK sector on STM32H56x

zhiv12
Associate II

We appreciate the example in the STM32Cube repository, located at STM32Cube_FW_H5_V1.1.1\Projects\NUCLEO\H563ZI\Examples\FLASH\FLASH_OBK_EraseProgram. We are looking to modify the product state and write the .obk file directly from the firmware, and we believe your example is a great starting point.

STM has detailed a procedure for writing to the alternate OBK sector using the non-secure FLASH_NSOBKCFGR register. The addressing for the OBK sector is set to the base address 0x0BFD0000 (non-secure) rather than 0x0FFD0000 (secure).

However, we noticed that the STM32CubeProgrammer employs secure base addressing for the OBK sector, while your example uses non-secure addressing. This difference is essential for our understanding. Could you please explain the reason for using non-secure addressing in your example?

According to Figure 32, "Swap Workflow", of the Reference Manual, the role of the current OBK sector and the alternate OBK sector is interchanged after the Swap operation. Thus, we need to clear the alternate sector bit, ALT_SECT, to a value of 0 after writing to the alternate OBK sector. Is it correct?

1 ACCEPTED SOLUTION

Accepted Solutions
Jocelyn RICARD
ST Employee

Hello @zhiv12 ,

the example provided is supposed to run with TrustZone disabled.

When you enable TrustZone, only secure can access to OBK.

So, I suppose that programmer uses the solution that will work all the time.

About OBK update, I would recommend using the functions provided in the following file

STM32Cube_FW_H5_V1.5.0\Projects\NUCLEO-H563ZI\Applications\ROT\OEMiROT_Boot\Src\low_level_obkeys.c

I'm suspicious about what example is actually doing because normally you only write to an empty sector.

The swap mechanism that work from my experience is the one provided in the OBK_Write function.

Best regards

Jocelyn

View solution in original post

1 REPLY 1
Jocelyn RICARD
ST Employee

Hello @zhiv12 ,

the example provided is supposed to run with TrustZone disabled.

When you enable TrustZone, only secure can access to OBK.

So, I suppose that programmer uses the solution that will work all the time.

About OBK update, I would recommend using the functions provided in the following file

STM32Cube_FW_H5_V1.5.0\Projects\NUCLEO-H563ZI\Applications\ROT\OEMiROT_Boot\Src\low_level_obkeys.c

I'm suspicious about what example is actually doing because normally you only write to an empty sector.

The swap mechanism that work from my experience is the one provided in the OBK_Write function.

Best regards

Jocelyn