2026-01-27 5:09 AM
Hello,
in our application, running on a H533RET6 and with no TZ enabled, we need to close debug ports in production.I preliminarly did some tests using CubeProgrammer: I generated password-based credentials (obk+bin files, which as far as I understand from AN6008 is the only option when not in TZ) and successfully managed to lock the device by moving from PRODUCT_STATE Open (0xED) to Provisioning (0x17), supplying the .obk file and then lock the device (PRODUCT_STATE = 0x72). After verifying that debug ports were closed, I unlocked the device by making a discovery and providing the bin file, with the device returning into Open state. Note that the first 3 32-bit words of my obk file are:
This code has been mainly taken from ticket https://community.st.com/t5/stm32-mcus-products/stm32h5-getting-the-provisioned-state-from-within-the-firmware/td-p/836233 (thanks!) and as far as I understand does the following:
a) unlock flash and flash option bytes
b) erase the OB flash space (alternate sector)
c) Program the flash by copying the OBK file bytes after the 12th to HDPL1 base address (whether this base address should be secure or non-secure is a critical point, see below. In the code I show it is secured, but I tried both), in the alternate sector
d) Swap alternate sector with official one
Regarding point c, the example I took the code from used non-secure address (0x0BFD0100) as OBK dfile destination, but it may be because they used a H5 where secure area is not present. I also saw that if I try to use secure base address (as the first 4 bytes of my OBK would suggest) without -mcmse compiling option (which we do not have by default) an assert is triggered when tryng to write flash at secure OBK address, here:
In my understanding I should run the code with -mcmse option and addressing secure OBK memory, but if I do and then I lock the device I am not able to unlock it through CubeProgrammer, even though in principle I supplied the same OBK file (I already locked two boards :) ). Also, I don't see a way to check whether a provisioned OBK file is valid when in provisioning state, as the DA (Debug Authentication) method is available only after I Close the device
Solved! Go to Solution.
2026-01-29 7:51 AM
Hello @ste2108 ,
The OBK encryption example you found in ST’s hotspot is only valid when TrustZone is enabled. It relies on secure‑side access to the correct DHUK/EPOCH, which is not available when TZ is disabled. On non‑TZ H5, the firmware cannot reliably select and use the same DHUK context that is used by our provisioning tools.
As a result, on current non‑TZ H5:
The only supported solution today is:
This limitation is planned to be removed in a future chip revision.
Similar issue has been faced here: Solved: STM32H533 unable to do a full regression with newe... - STMicroelectronics Community
Kind regards
2026-01-29 7:51 AM
Hello @ste2108 ,
The OBK encryption example you found in ST’s hotspot is only valid when TrustZone is enabled. It relies on secure‑side access to the correct DHUK/EPOCH, which is not available when TZ is disabled. On non‑TZ H5, the firmware cannot reliably select and use the same DHUK context that is used by our provisioning tools.
As a result, on current non‑TZ H5:
The only supported solution today is:
This limitation is planned to be removed in a future chip revision.
Similar issue has been faced here: Solved: STM32H533 unable to do a full regression with newe... - STMicroelectronics Community
Kind regards
2026-01-30 6:04 AM
Dear Khaled,
thanks a lot for your answer. I believe this limitation should be better highlighted in the AN6008 document, especially in paragraph 2.1. Just an additional question: I locked and unlocked the same device many times with the same pair of obk/bin file. Does your last point mean that the device would be locked forever had I tried to lock it with a different but legit pair of files after I first locked/unlocked it with the former pair?
Any time estimate on when this revision could take place? Debug port safety is an issue for us, as well as enabling TZ at this stage of the project.
Thanks.
Regards,
Stefano