cancel
Showing results for 
Search instead for 
Did you mean: 

It is not possible to change the state to "Closed" when USB is connected (STM32H562)

Artur5
Associate III

Hi.

During production, we use USB to test the board. Finally, the MCU is supposed to be password-protected against flash reads. Unfortunately, it turns out that as long as the USB cable is connected, it's impossible to program the OBK. Segger Device Provisioner returns an "Error writing OBK". Using STLink and CubeProgrammer also doesn't work. After disconnecting the USB, changing the state to Closed works. BOOT0 is connected to ground. Is there a solution?

Artur

7 REPLIES 7
Jocelyn RICARD
ST Employee

Hello @Artur5 ,

Not sure what can prevent from provisioning OBK.

Are you first switching to PROVISIONING state ?

Could you share a STM32CubeProgrammer CLI sequence you are using  ?

Best regards

Jocelyn

 

FBL
ST Employee

Hi @Artur5  @Jocelyn RICARD 

If production test firmware enables USB, you need to consider adding a command or mechanism to disable USB peripheral before OBK programming. Since it might access to flash while programming OBKs.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.


Hi.

Yes, I'm switching the MCU to PROVISIONING state. And everything works fine as long as the USB cable is disconnected. It seems like the bootloader is blocking access to the OBK memory in some way (?) We're using the SEGGER interface and their "Device Provisioner" tool, but it seems the same applies to STMCubeProgrammer, but I'll check again and let you know.

BR

Artur

Artur5
Associate III

Hi.

This also does not work after completely erasing the MCU memory.

BR

Artur

Hi.

It seems to work with STM32_Programmer_CLI regardless if there is USB connected.

STM32_Programmer_CLI.exe -c port=SWD mode=Hotplug -ob PRODUCT_STATE=0x17
STM32_Programmer_CLI.exe -c port=SWD mode=Hotplug -sdp password.obk
STM32_Programmer_CLI.exe -c port=SWD mode=Hotplug -ob PRODUCT_STATE=0x72

 

But it does not work with Device Provisioner when USB is connected:

C:\Data\Scripts\ReadProtection>"C:\Program Files\SEGGER\JLink\DevPro.exe" -operation SetDeviceState -if SWD -speed 4000 -SetConfigVal "ProdState=PROVISIONING" -ScriptFile PCode_DevPro_ST_STM32H5.pex
SEGGER Device Provisioner V8.44a
Compiled Jun 18 2025 16:32:13
Command line: -operation SetDeviceState -if SWD -speed 4000 -SetConfigVal ProdState=PROVISIONING -ScriptFile PCode_DevPro_ST_STM32H5.pex
Firmware: J-Link Ultra V5-1 compiled Apr 1 2025 10:03:10
S/N: 505101560

J-Link log: Version: V1.00.0
J-Link log: STM32H563/573/562 device found, ID: 0x00000484
J-Link log: Product state successfully changed

 

C:\Data\Scripts\ReadProtection>"C:\Program Files\SEGGER\JLink\DevPro.exe" -operation DbgAuthProvision -if SWD -speed 4000 -SetConfigVal DataFile=password.obk -ScriptFile PCode_DevPro_ST_STM32H5.pex
SEGGER Device Provisioner V8.44a
Compiled Jun 18 2025 16:32:13
Command line: -operation DbgAuthProvision -if SWD -speed 4000 -SetConfigVal DataFile=password.obk -ScriptFile PCode_DevPro_ST_STM32H5.pex
Firmware: J-Link Ultra V5-1 compiled Apr 1 2025 10:03:10
S/N: 505101560

J-Link log: Version: V1.00.0
J-Link log: STM32H563/573/562 device found, ID: 0x00000484
J-Link log: Error! Timeout while writing option bytes
Script file function 'DbgAuthProvision' returned with error code -1

 

Artur

Hello @Artur5 ,

thank you for your update.

I guess you can report this to Segger directly.

On my side I will share this information internally to relevant people.

Best regards

Jocelyn

Hi. Thanks for your interest. As you already know, I asked on Segger forum. Regards.