STM32: Enable Legacy Boot

Some STM32 families such as STM32C0 and STM32G0 are released from factory with the BOOT0 pin set as a normal GPIO, which means that as soon as there's a valid firmware downloaded to the flash memory, it won't boot to DFU mode by shorting this pin to ground.

There are several ways to fix that, but the easiest and least error-prone way is using the STM32CubeProgrammer tool from ST Microelectronics.

With the software installed, start it and follow these steps on the initial screen:

  1. Select "USB" as the connection type.
  2. Reload the device list, if needed. If nothing appears, the microcontroller likely isn't in DFU mode and you may need access to a SWD programmer, such as the STLink to recover it.
  3. Select the USB port to be used. If there's only one DFU device connected, it will be already selected.
  4. Click the "Connect" button.
  5. Select the "Option Bytes" screen on the left menu.

STM32CubeProgrammer Initial Screen

On the "Option Bytes" screen, expand the "User Configuration" section:

STM32CubeProgrammer Option Bytes Screen

With the section expanded, follow these steps:

  1. Scroll down until you find the nBOOT_SEL flag and uncheck it.
  2. Click the "Apply" button.

STM32CubeProgrammer Option Bytes Screen 2

After applying the changes, the software will present a message reporting success or failure.