STM32G0B0 BRICKING AFTER OPTION BYTES CHANGE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-05 4:57 AM
We are having an issue of the MCU bricking when we change the n_SWAP_Bank bit of the User Option bytes. What could be the issue? The issue occurs when we are clearing this bit. Once we clear it the chip bricks.
- Labels:
-
STM32G0 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-05 8:15 AM
Bricks how? No code runs? No SWD connectivity?
What exactly is getting written in to the Option Bytes, and HOW?
Can you put functional code instance at beginning of both banks?
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-05 8:57 AM
Hello @EmbedDev and welcome to the community,
How you did handle Option bytes? using STM32CubeProgrammer or in your code?
If in the code you need to share it and please use </> button.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-06 12:08 AM
Hello @mÆŽALLEm ,
This happened when handling Option bytes using STM32Programmer as well as in code.
void OTAFlashInt_SwapBanks(){
HAL_FLASHEx_OBGetConfig(&OpBytesRW);
if(OpBytesRW.USERConfig & FLASH_OPTR_nSWAP_BANK){
OpBytesRW.USERConfig &= ~FLASH_OPTR_nSWAP_BANK; //set bit high to make next active bank1
}else{
OpBytesRW.USERConfig |= FLASH_OPTR_nSWAP_BANK; //set bit low to make next active bank 2
}
HAL_FLASH_Unlock();
HAL_FLASH_OB_Unlock();
if(HAL_FLASHEx_OBProgram(&OpBytesRW)== HAL_OK){
HAL_FLASH_OB_Launch();
}
HAL_FLASH_OB_Lock();
HAL_FLASH_Lock();
#ifndef TEST
NVIC_SystemReset();
#endif
}
That is a snippet of the code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-06 12:10 AM
No SWD Connectivity. Here is a snippet of the code
void OTAFlashInt_SwapBanks(){
HAL_FLASHEx_OBGetConfig(&OpBytesRW);
if(OpBytesRW.USERConfig & FLASH_OPTR_nSWAP_BANK){
OpBytesRW.USERConfig &= ~FLASH_OPTR_nSWAP_BANK; //set bit high to make next active bank1
}else{
OpBytesRW.USERConfig |= FLASH_OPTR_nSWAP_BANK; //set bit low to make next active bank 2
}
HAL_FLASH_Unlock();
HAL_FLASH_OB_Unlock();
if(HAL_FLASHEx_OBProgram(&OpBytesRW)== HAL_OK){
HAL_FLASH_OB_Launch();
}
HAL_FLASH_OB_Lock();
HAL_FLASH_Lock();
#ifndef TEST
NVIC_SystemReset();
#endif
}
.
