2022-12-14 01:01 PM
(Project meant to run on STM32L4R9I-EVAL attached)
Ultimately, I am trying to put my device into DFU mode by having the device erase its own flash and reboot into system memory (the erase and reset code executes from RAM). Then flash firmware to the device via STM32CubeProgrammer and have the device automatically restart into this newly flashed firmware without having to remove power from the device.
The problem I am having is that after the device successfully wipes itself, boots into system memory, and is re-flashed, it restarts back to system memory (DFU). The BOOT0 pin is pulled low but regardless of my option byte user configuration in FLASH, or the MEM_MODE in SYSCFG, the device keeps booting back to system memory. If I fully power off the device or toggle any user configuration option bytes in flash (using STM32CubeProgrammer), it will boot into main flash. I need it to restart into main flash without changing option bytes or power cycling.
I have tried all valid combinations of option bytes, verified the BFB2 bit is not set and that the data at 0x08000000 is a valid SRAM address to use as the stack pointer.
The firmware I am re-flashing to it is the original firmware that puts it into DFU. This firmware simply starts the device and sits in a loop toggling an LED until a button is pressed. It then wipes itself and reboots.
I am using the STM32L4R9I-EVAL board with the BOOT0 selection set to 0. Below is a screenshot of the option bytes when in DFU mode:
The references I have been using are the following:
Any and all ideas are welcome. Thank you in advance for your time.
-Brian