I am trying to run a blink LED program on my STM32F401CCU6 board, and I am using basic CLI tools (in Linux) like arm-none-eabi-gcc
or dfu-util
(or openocd
) for learning purposes.
I have followed this tutorial to create the basic program, with one change. I do not have ST-Link, and am trying to use the USB-C port that comes with the board for flashing (and thus, using dfu-util
). It does not rely on any STM header files (except stdint.h
, which is for uint32_t
, and is also from the compiler).
The command I used to upload this is:
$ dfu-util -a 0 -s 0x08000000:leave -D ./main.elf
dfu-util 0.11
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2021 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/
dfu-util: Warning: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release
Opening DFU capable USB device...
Device ID 0483:df11
Device DFU version 011a
Claiming USB DFU Interface...
Setting Alternate Interface #0 ...
Determining device status...
DFU state(10) = dfuERROR, status(10) = Device's firmware is corrupt. It cannot return to run-time (non-DFU) operations
Clearing status
Determining device status...
DFU state(2) = dfuIDLE, status(0) = No error condition is present
DFU mode device DFU version 011a
Device returned transfer size 2048
DfuSe interface name: "Internal Flash "
Downloading element to address = 0x08000000, size = 9528
Erase [=========================] 100% 9528 bytes
Erase done.
Download [=========================] 100% 9528 bytes
Download done.
File downloaded successfully
Submitting leave request...
Transitioning to dfuMANIFEST state
This is the objdump of main.elf
.
However, both the on-board LED and the LED connected to A5 pin do not glow. I even tried switching the code to point to the C13 on-board LED, but still it does not glow.
I got this dfu-util
from the AUR.
Thank you in advance.
The STM32 bootloader does not load ELF files and dfu-util
cannot process ELF to load only the ROM sections from it (it simply loads the file provided to the location provided in its arguments). Unlike in the linked tutorial where the tool (ie openocd) can parse the ELF for you, you will need to preprocess it yourself:
arm-none-eabi-objcopy -O binary main.elf main.bin
dfu-util -a 0 -s 0x08000000:leave -D main.bin