Modifying Option Byte Value from Program Running in SRAM and Loaded using dfu-util
I want to write a program for a fresh (first time power applied to it so there is nothing in Flash) STM32G0B1 that executes in RAM, resets the nBOOT_SEL bit in the Option Bytes (to allow DFU Mode to be invoked when Flash has been written).
The reason why I want to execute in RAM is to avoid having to run a program that is loaded in Flash (and resets nBOOT_SEL as discussed above) which is loaded into Flash that requires a power cycle to restart so that DFU Mode can be enabled in the MCU to load the actual product firmware.
This is being done in manufacturing test, so avoiding a power cycle (which takes about a minute due to other hardware in the application) would be of advantage.
Could anybody point me to:
- A dfu-util statement that a bin file at a specific SRAM address and has execution continue from there
- Pointers to how the application would be configured. What I have found so far are:
- https://community.st.com/t5/stm32-mcus/how-to-place-and-execute-stm32-code-in-sram-memory-with/ta-p/49528
- https://stackoverflow.com/questions/42612329/executing-code-from-ram-in-stm32
- https://stackoverflow.com/questions/69598820/how-does-one-run-code-from-ram-on-a-stm32
- https://stackoverflow.com/questions/55389711/stm32f7-execute-code-from-ram-and-flash
- In my research, it seems like the USB as well as another interrupt needs to be disabled while running an application like this. Does anybody have any references which explains what is required?
I think the last two links for creating a program that runs in SRAM are probably closest to what I want to do but I'm hoping that there is a crisp explanation that I can follow.
For resetting the nBOOL_SEL bit, I'm going to use the following guide (with standard STM/HAL development tools/libraries):
https://community.st.com/t5/stm32-mcus/how-to-program-stm32-option-bytes-with-the-hal-api/ta-p/49660
Any comments or suggestions are most welcome!
myke
