2025-09-15 12:12 AM
Hello,
I am working on custom bootloader + application setup on a STM32G070CBT6
Currently, I need to store bootloader flag that indicate whether the MCU should jump to the bootloader code or to the application code.
My questions are:
1. Can I use Option Bytes memory area to store the custom flag?
2. If Option Bytes memory area are not suitable ,is there another small memory area(apart from flash)
that is recommended for storing such a small boot flag?
I need only one bit for this flag, but dedicating a full 2KB flash feel inefficient.
2025-09-15 3:46 AM
Thanks, that’s a good point. In my case, I need the bootloader flag to survive a full power cycle as well, not just a reset.
2025-09-15 3:51 AM
@bhagat wrote:
Thanks, that’s a good point. In my case, I need the bootloader flag to survive a full power cycle as well, not just a reset.
Along the discussion, you didn't mention any case the Power Cycle, you mentioned only Reset. Which make a big difference here.
Next time, please be more accurate in the description to avoid unnecessary ping pongs.
Thank you.
2025-09-15 4:08 AM
Apologies for not being precise in my initial description. Thank you for highlighting the distinction between reset and power cycle.
2025-09-15 4:12 AM - edited 2025-09-15 4:13 AM
> Along the discussion, you didn't mention any case the Power Cycle, you mentioned only Reset. Which make a big difference here.
Yes, exactly. This is a totally different issue.
Except for your very much disliked Flash/EEPROM option you have two alternatives, unless you consider another MCU. But both involve additiona hardware.
One option is a backup battery, and to utilize a RAM / registers in the backup area of the MCU.
The second one is external NVM, like serial EEPROM or Flash via I2C or SPI, or FRAM.
My company mostly uses the second option, since the respective controller/ECU board is just a small component in a larger system, and this system needs persistent settings anyway.
Consider keeping your EEPROM/Flash method, and add some further persistent data.
2025-09-15 4:51 AM
> @bhagat only said it needs to survive reset:
From all he said I had a good guess that it was not so! :D
2025-09-15 5:18 AM
You can use option bytes if you find one that won't cause other issues. For example, you can use NBOOT0 freely if NBOOT_SEL = 0. There are no free bits.
Note that writing option bytes also uses a page of flash internally and that interrupting the process due to a power loss can cause them to be corrupted.
2025-09-15 6:53 AM
Dear @bhagat,
All the quick actions are described here: FAQs.
More on this particular action, you can also find on these guidelines: Help others to solve their issues.
Let me know if you will need any help either here or via DM.
Regards,
Lina
2025-09-16 10:46 PM
Thank you for offering help. Yes, I’d like to discuss here.
2025-09-17 7:36 AM
Try explain why you require this flag after power cycle ?