Design flaw in HAL?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-02-22 5:34 AM
I am using CubeIDE 1.11.2 with a STM32F3DISCOVERY board and have created an IDE project via the integrated CubeMX GUI.
I want to activate read protection via HAL_FLASHEx_OBProgram as well as the write protection for the FLASH area of my firmware (applying the same HAL function).
But HAL only allows one of the two features at a time.
The reason is that for every single action (write RDP and write WRP) HAL completely erases the OptionBytes via the FLASH peripheral (as you can see in the HAL source code).
It is important for us to enable RDP and WRP at the same time!
I could do it the bare metal way, but our project is intended for all our used STM32 MCUs and that's exactly what HAL was created for.
Please, can you tell me a way to enable both RDP and WRP with the HAL functions at the same time?
Thanks in advance!
Solved! Go to Solution.
- Labels:
-
RDP
-
STM32Cube MCU Packages
-
STM32F3 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-03-07 7:53 AM
Hi @Gahlen Feld​
taking into account the current HAL FLASH driver and given the automatic user option bytes erase the recommended sequence to program RDP, WRP and other user data option bytes is as follows:
- call HAL_FLASHEx_OBProgram() to program RDP level (all option bytes will be erased),
- call HAL_FLASHEx_OBProgram() to program write protection on desired pages (all option bytes except RDP will be erased),
- call HAL_FLASHEx_OBProgram() to program user data option bytes (can be done in the same call than write protection or through several calls),
- call HAL_FLASH_OB_Launch() to apply whole option bytes configuration.
Thanks to share your feedback on this proposition
Regards
Patrice
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-03-07 7:53 AM
Hi @Gahlen Feld​
taking into account the current HAL FLASH driver and given the automatic user option bytes erase the recommended sequence to program RDP, WRP and other user data option bytes is as follows:
- call HAL_FLASHEx_OBProgram() to program RDP level (all option bytes will be erased),
- call HAL_FLASHEx_OBProgram() to program write protection on desired pages (all option bytes except RDP will be erased),
- call HAL_FLASHEx_OBProgram() to program user data option bytes (can be done in the same call than write protection or through several calls),
- call HAL_FLASH_OB_Launch() to apply whole option bytes configuration.
Thanks to share your feedback on this proposition
Regards
Patrice
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-03-08 6:03 AM
Hello Patrice, many thanks! This way it works fine :smiling_face_with_smiling_eyes:
