Once the firmware binary has been compiled, it must be written into the STM32F401’s internal flash memory. There are two supported methods: USB DFU (Device Firmware Upgrade), which uses the MCU’s built-in ROM bootloader over the same USB cable that the controller uses for HID operation, and ST-Link SWD (Serial Wire Debug), which uses a separate hardware debug probe. DFU requires no additional hardware and is the recommended method for end users; ST-Link is more suitable for active development where repeated flashing and debugging are needed.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/MrJefter/sdvx-controller/llms.txt
Use this file to discover all available pages before exploring further.
Method 1: USB DFU
The STM32F401 contains a factory ROM bootloader that enumerates as a DFU device over USB. No additional hardware is required.Entering DFU mode
On a blank or unflashed BlackPill (no firmware present): Hold the BOOT0 button on the BlackPill board, then briefly press and release the NRST (reset) button while continuing to hold BOOT0. Release BOOT0 after NRST is released. The MCU will boot into its ROM DFU bootloader instead of user flash. After firmware is already flashed (with the 150 nF capacitor mod): Hold the START button on the controller for 5 seconds. The firmware monitors this button and callsGoToBootloader(), which drives PA15 high and triggers a system reset. The capacitor mod holds the BOOT0 line high during the reset, causing the MCU to enter DFU mode automatically.
The software DFU entry via START requires
DFU_HOLD_TIME_MS = 5000 milliseconds of continuous hold before the reset is triggered. Releasing the button before 5 seconds elapses cancels the countdown.Verifying the device is in DFU mode
On Linux/macOS, confirm the bootloader has enumerated:Flashing with dfu-util
| Flag | Meaning |
|---|---|
-a 0 | Select alternate setting 0 (internal flash) |
-s 0x08000000:leave | Write starting at the STM32 flash base address; :leave resets into user code after flashing |
-D HID_SDVX_NEW4.bin | The flat binary produced by the STM32CubeIDE Release build |
HID_SDVX_NEW4.bin and Download to flash it.
Method 2: ST-Link SWD
An ST-Link debug adapter (any version: ST-Link V2, V2-1, V3) connects to the BlackPill’s four-pin SWD header and provides both flashing and live debug capability.Wiring
Connect the ST-Link to the BlackPill SWD header:| ST-Link Pin | BlackPill Pin |
|---|---|
| SWDIO | DIO |
| SWDCLK | CLK |
| GND | GND |
| 3.3V | 3V3 |
Flashing with STM32CubeProgrammer
- Open STM32CubeProgrammer and select ST-Link as the interface.
- Set the connection mode to Normal and click Connect. The tool will read out the MCU’s device ID and confirm it is an STM32F401.
- Use Open file to load either
HID_SDVX_NEW4.elf(preferred — contains address information) orHID_SDVX_NEW4.binwith a start address of0x08000000. - Click Download to program the flash and optionally Verify to confirm the write.
Flashing directly from STM32CubeIDE
With the ST-Link connected and the project open in the IDE, use Run → Debug Configurations to configure an ST-Link GDB session. Select theHID_SDVX_NEW4.elf as the application binary, set the debug probe to ST-Link, and click Debug. The IDE will flash the binary and halt at main(), ready for step-through debugging.