the STMF1 has two special bytes, called “User data storage option bytes”. You can write them with the Flash Loader Demonstrator. That would be highly useful for special versions, at least for me
Unfortunately, I did not find any hint on how to read these two bytes at runtime. Any ideas?
[ramimo – Thu Jul 27, 2017 12:15 pm] –
the STMF1 has two special bytes, called “User data storage option bytes”.
I don’t see any such references in datasheets, where did you saw that other than Flash Loader Demonstrator ?
Perhaps it is simple bytes written somewhere at the end of uploaded firmware …
googled “Flash Loader Demonstrator User data storage option bytes”
first answer http://www.st.com/resource/en/user_manu … 171488.pdf
basic search, so not too difficult
stephen
[zmemw16 – Thu Jul 27, 2017 2:01 pm] –
basic search, so not too difficult
But this doesn’t provide of any infos where those bytes are located in the chip, for example in STM32F103C8.
@zmemw16: It is funny when some people think that they are the only one who know about Google. Yes, I googled for about 30 minutes. Yes, I found the docs about the Demonstrator (after about 10 seconds). Yes, the Demonstrator can read and write these two bytes. And no, there is no information whatsoever on how you can do that at runtime. So I posted my question here.
http://www.st.com/content/ccc/resource/ … 283419.pdf
0x1FFFF804
EDIT : BTW, the 0x1FFFF804 is for STM32F1xx, for the F4xx it seems to be 0x1FFFC004
$ openocd -f ebay_f103c8_micro.cfg -c ‘init’ -c ‘stm32f1x options_read 0’ -c ‘exit’
Open On-Chip Debugger 0.10.0+dev-00096-gf605a23 (2017-04-22-13:47)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
none separate
none separate
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : clock speed 950 kHz
Info : STLINK v2 JTAG v28 API v2 SWIM v18 VID 0x0483 PID 0x374B
Info : using stlink api v2
Info : Target voltage: 0.007864
Error: target voltage may be too low for reliable debugging
Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : device id = 0x20036410
Info : flash size = 64kbytes
Option Byte: 0x3fffffc
Readout Protection Off
Software Watchdog
Stop: No reset generated
Standby: No reset generated
User Option0: 0xff
User Option1: 0xff
$
srp
#define USERDATASTORAGEOPTIONSBYTE1 *((byte*)0x1FFFF804)
#define USERDATASTORAGEOPTIONSBYTE2 *((byte*)0x1FFFF806)
That might be useful for the STM32 Arduino libs. With better naming, of course.
Thanks ![]()
Is there a limit to the number of times they can be written to, e.g. Like the number of erases for pages of flash
For me, reading these bytes is all I want right now. _Setting_ them would be great because they are not erased when you flash a new program on the STM32.
There are also a few bytes of special ram (I forget their name) which survive a soft reboot, but are not retained if you power cycle the board
“2.3.5 Option byte programming
The option bytes are programmed differently from normal user addresses. The number of
option bytes is limited to 8 (4 for write protection, 1 for read protection, 1 for configuration
and 2 for user data storage). After unlocking the FPEC, the user has to authorize the
programming of the option bytes by writing the same set of KEYS (KEY1 and KEY2) to the
FLASH_OPTKEYR register to set the OPTWRE bit in the FLASH_CR register (refer to
Section 2.3.1 for key values). Then the user has to set the OPTPG bit in the FLASH_CR
register and perform a half-word write operation at the desired Flash address.
… that and lots more to read
“
libopencm3 seems to have some code to deal with option bytes
