cancel
Showing results for 
Search instead for 
Did you mean: 

How to store a 1-bit bootloader flag without wasting 1 Flash page

bhagat
Visitor

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.

  • Since the movement i am reserving 1 flash page(2KB) ,just to store single flag bit.
  • This feels like a waste of memory, since I only need 1 bit of storage.

My questions are:

     1. Can I use Option Bytes memory area to store the custom flag? 

  • Are Option bytes  writable at runtime for application/bootloader use, or are they limited to ST system configurations (e.g., RDP, WRP, BOR levels)?

      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.

24 REPLIES 24

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.


@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.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Apologies for not being precise in my initial description. Thank you for highlighting the distinction between reset and power cycle.

> 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.

@bhagat 

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.

@bhagat only said it needs to survive reset:

From all he said I had a good guess that it was not so! :D