Failed to init device STM32F446RE

I’m trying to upload to my STM board and everything is going well up until this message in yellow stating:

Failed to init device.

Has anyone else come across this error? What can I do to fix it?

Not enough info.

  • post link to the board you are using, or if custom made, its schematics
  • what programmer are you using?
  • how did you wire them up together?
  • what is the platformio.ini?
  • full error message when you do a ‘Upload’?

Don’t have it in front of me but it’s a F446RE. Just plugged in via USB at the moment with no components just to make sure I can upload to it.

Init has the standard platform and board setup with arruino as the framework.

That is the full error message. Everything else is fine there’s just a yellow line with those words and there’s no blinking rx/upload light on the board as there usually is when uploading.

So you are talking about the specific Nucleo-F446RE board or a custom board with a STM32F446?

Have you installed a recent version of the ST-Link driver in order to flash the board?

Also if Linux is your host OS, you need to install udev rules.

Nucleo, I’m on OSX M1

So what about those?

Executing task: platformio run --target upload
Processing genericSTM32F446RE (platform: ststm32; board: genericSTM32F446RE; framework: arduino)
-------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: Redirecting...
PLATFORM: ST STM32 (14.0.1) > STM32F446RE (128k RAM. 512k Flash)
HARDWARE: STM32F446RET6 180MHz, 128KB RAM, 512KB Flash
DEBUG: Current (blackmagic) External (blackmagic, jlink, stlink)
PACKAGES: - framework-arduinoststm32 4.20000.210603 (2.0.0) - framework-cmsis 2.50700.210515 (5.7.0) - tool-dfuutil 1.9.200310 - tool-openocd 2.1100.0 (11.0)- tool-stm32duino 1.0.1 - toolchain-gccarmnoneeabi 1.90201.191206 (9.2.1)
LDF: Library Dependency Finder → Library Dependency Finder (LDF) — PlatformIO latest documentation
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 10 compatible libraries
Scanning dependencies…
No dependencies
Building in release mode
Checking size .pio/build/genericSTM32F446RE/firmware.elf
Advanced Memory Usage is available via “PlatformIO Home > Project Inspect”
RAM: [ ] 0.7% (used 872 bytes from 131072 bytes)
Flash: [ ] 2.7% (used 14160 bytes from 524288 bytes)
Configuring upload protocol…
AVAILABLE: blackmagic, dfu, jlink, serial, stlink
CURRENT: upload_protocol = serial
Looking for upload port…
Auto-detected: /dev/cu.usbmodem103
Uploading .pio/build/genericSTM32F446RE/firmware.bin
Failed to init device.
stm32flash Arduino_STM32_0.9
Using Parser : Raw BINARY
Interface serial_posix: 115200 8E1
*** [upload] Error 1
======================================== [FAILED] Took 1.48 seconds ========================================
The terminal process “platformio ‘run’, ‘–target’, ‘upload’” terminated with exit code: 1.
Terminal will be reused by tasks, press any key to close it.


platform = ststm32

board = genericSTM32F446RE

framework = arduino

By using that board you are using the default upload method via serial, as it says in the documentation. For that the board has to be in bootloader mode (BOOT0 to HIGH, then reset) and a USB/Serial adapter has to be connected the dedicated UART bootloader pins. That’s not what you want for a a Nucleo F446RE, which has an on-board ST-Link, using that you can upload via the stlink upload protocol.

Simply use the correct board.

platform = ststm32
board = nucleo_f446re
framework = arduino

if you really realy want to keep using the generic variant, see documentation on how to change to the STLink upload method. If you are working with a Nucleo however, it is better to use the Nucleo variant instead of the generic one.

platform = ststm32
board = genericSTM32F446RE
framework = arduino
upload_protocol = stlink

I see. Thank you very much. I’ll look more closely at documentation next time.