Skip to main content
Visitor II
October 24, 2024
Question

Writing Option Bytes on STM32F1

  • October 24, 2024
  • 2 replies
  • 1467 views

Hello,

Im developing an program that controls an ST-Link to flash an STM32F1. The program needs to be able to remove RDP on the MCU its trying to flash.

Im doing the following steps:

1) Unlocking Flash - confirmed working (registers confirm)

2) Unlocking option bytes - confirmed working (registers confirm)

3) Erasing Option Bytes - confirmed Working (If I have no RDP on, and erase, RDP gets set, as 0xFF = RDP on)

4) Writing new Option Bytes, 16 Bit Operation. Here it fails.

 

Any Ideas? Ive attached two Logic Analyser captures (Saleae Logic 2 Software), one from slightly modified OpenOCD which unlocks successfully, and my implementation, which doesnt work.

 

My implementation:

guandast_2-1729788721514.png

 

OpenOCD:

guandast_1-1729788647355.png

 

Happy to hear your Ideas!

    This topic has been closed for replies.

    2 replies

    Graduate II
    October 24, 2024

    After optiion byte erase, a reset happens. You need to reconnect.

    BUt why do you want to write a new stlink program?

    guandastAuthor
    Visitor II
    October 24, 2024

    Are they? Kind of hard to believe:

    - OPTB is still unlocked after erasing

    - If I have an GPIO (LED) high, the LED stays on, even after erase, and only turns off when I do an actual reset

     

    Please correct my if Im wrong.

    Why I want to build an STLink Program? Because there isnt anything out there yet that is WebUSB based. (or well there is, but that doesnt allow option bytes)

    ST Employee
    October 25, 2024

    Do you mean you develop a PC program that controls an ST-Link to flash an STM32F1?

    In such case, you may 1st try with STM32CubeProgrammer, to be able to remove RDP on the MCU its trying to flash. Then you just need to repeat the same steps with your PC program.

    guandastAuthor
    Visitor II
    October 25, 2024

    Thats exactly what Im trying to do, however with OpenOCD as I can browse the source code. My question is, why the Option Byte Write fails, what part I am missing.

    ST Employee
    October 28, 2024

    You need to take care of following point.

    The options must be reloaded after every change of the Option bytes in the NVM, so that the
    changes can apply.