Skip to main content
MBand.3
Associate III
September 30, 2021
Solved

STM32L5 - User Option Byte Access

  • September 30, 2021
  • 2 replies
  • 4125 views

The STM32L5 reference manual states that there are "4 Kbytes of option bytes for user configuration" accessible via the Flash register interface (section 6.3.1), but no further details are provided on how to access that space for user data storage.

I found a question here, which answers this question for another chip (STM32F0): https://community.st.com/s/question/0D50X00009XkfPkSAJ/simple-example-program-to-read-and-write-option-bytes-on-stm32f042k6-using-hal-libraries

My problem is, the STM32L5 HAL code (1.4.0) doesn't define the HAL_FLASHEx_OBGetUserData function, or even the OPTIONBYTE_DATA type.

How is the option byte flash page for user configuration accessed on the L5? Is this actually a supported feature?

Thanks!

This topic has been closed for replies.
Best answer by TDK

The description is terribly misleading and should be changed. It reads:

4 Kbytes of option bytes for user configuration. Unlike user Flash memory and system memory, it is not mapped to any memory address and can be accessed only

through the Flash register interface.

Although the hardware has a 4kB area used to store option bytes, only those option bytes listed in the RM are able to be accessed, which is a small subset of the 4kB technically available in the hardware. Keep in mind that option bytes are stored in flash, but you interface with them via registers. You're not writing to them directly.

The L5 and most (all?) other families have no area within the accessible option bytes which can be used for user data.

The F0 has areas within the option bytes which can be used for user data and are accessible via the flash interface. This is the reason it has HAL_FLASHEx_OBGetUserData and the L5 does not.

0693W00000FB5IWQA1.png 

This is a recurring question:

https://community.st.com/s/question/0D53W00000mm98U/how-to-write-nonreserved-option-bytes-on-stm32h750xx-mcu

https://community.st.com/s/question/0D53W000003NVH1SAO/how-can-i-program-the-option-byte-on-stm32h750-for-my-device-uuid8-bytes

2 replies

TDK
TDKBest answer
September 30, 2021

The description is terribly misleading and should be changed. It reads:

4 Kbytes of option bytes for user configuration. Unlike user Flash memory and system memory, it is not mapped to any memory address and can be accessed only

through the Flash register interface.

Although the hardware has a 4kB area used to store option bytes, only those option bytes listed in the RM are able to be accessed, which is a small subset of the 4kB technically available in the hardware. Keep in mind that option bytes are stored in flash, but you interface with them via registers. You're not writing to them directly.

The L5 and most (all?) other families have no area within the accessible option bytes which can be used for user data.

The F0 has areas within the option bytes which can be used for user data and are accessible via the flash interface. This is the reason it has HAL_FLASHEx_OBGetUserData and the L5 does not.

0693W00000FB5IWQA1.png 

This is a recurring question:

https://community.st.com/s/question/0D53W00000mm98U/how-to-write-nonreserved-option-bytes-on-stm32h750xx-mcu

https://community.st.com/s/question/0D53W000003NVH1SAO/how-can-i-program-the-option-byte-on-stm32h750-for-my-device-uuid8-bytes

"If you feel a post has answered your question, please click ""Accept as Solution""."
MBand.3
MBand.3Author
Associate III
September 30, 2021

Understood, thank you!