I am building application which will (besides other things) write flash memory and option bytes of STM32F091RC.

Application will run on raspberry pi, OS raspbian 4.7.7 armv6l.

I am currently successfully using st-flash utility (https://github.com/texane/stlink) to write data to flash memory using this command:

st-flash write firmware.bin 0x8000000

Now I also need to write option bytes too. I thought

st-flash write optionBytes.bin 0x1FFFF800

could work (just write to address of option bytes), but it does not. Apparently, writing option bytes is different than writing flash memory and probably it's not possible to achieve it using st-flash?

Are there any utilities which are able to write option bytes and can run:

  • raspberry/arm
  • unix/debian based
  • St-link/V2
  • STM32F091RC
  • can run from commandline

Your question unrelated to linux and raspberry pi. Your aim is programming of option bytes at 0x1FFFF800. Go to RM0091 at page 937 (A.2.5 - A.2.7). There are code examples of unlocking, programming, erasing of option bytes. This code will be executed on your STM32F091RC. So you can see this is not trivial operation. I see 2 easy ways to perform the programming option bytes.

1) If you do your firmware, then edit the source code. Perform the programming of option bytes at first execution of new firmware.

2) Programm device with firmware.bin. Make little program that perform programming of option bytes. Run it from SRAM. For this link all sections at SRAM (at 0x20000000). See README.md of st-flash.

| improve this answer | |
  • 1
    Finally we ended up using solution 2). We got little program from external engineer and we are writing it to stm32 using this project: github.com/pavelrevak/pystlink using command python3 pystlink.py reset:halt write:optionBytes.srec set:pc:0x20000a94 run – Vladiks Aug 26 '16 at 11:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.