Serial/UART Firmware Upload
A second firmware upload method is to use serial (UART) upload, which works in much the same way as the standard way of uploading code to an Arduino. Like in the case of the Arduino serial upload this approach relies on a pre-uploaded bootloader. My understanding is that the Nucleo boards already have this bootloader in place.
UART to Nucleo connections
- Connect GND and 5V for power.
- Place a jumper between BOOT0 and VDD to select the serial upload mode.
- Connect PA9 to UART RX
- Connect PA10 to UART TX
- Power cycle to reset board and enter serial upload mode
Serial Uploader Tool
On Windows ST provide a tool for uploading firmware over serial called STM32-Flasher: FLASHER-STM32 - STM32 Flash loader demonstrator (UM0462) (replaced by STM32CubeProgrammer) - STMicroelectronics
For Linux there is a neat command line tool called stm32flash available in the package manager: Ubuntu Manpage: stm32flash - flashing utility for STM32 through UART or I2C
It can be installed with the following apt-get install:
sudo apt-get install stm32flash
I compiled the Arduino example Blink for the Nucleo64 STM32F303 using the Arduino IDE and then fetched the compliled .bin file from the /tmp folder that Arduino creates.
I could then upload to the STM32F303 by running:
sudo stm32flash -w blink.ino.bin /dev/ttyUSB0 -b 115200
Terminal output:
$ sudo stm32flash -w Blink.ino.bin /dev/ttyUSB0 -b 115200
stm32flash 0.5
http://stm32flash.sourceforge.net/
Using Parser : Raw BINARY
Interface serial_posix: 115200 8E1
Version : 0x31
Option 1 : 0x00
Option 2 : 0x00
Device ID : 0x0446 (STM32F302xD(E)/F303xD(E)/F398xx)
- RAM : 64KiB (6144b reserved by bootloader)
- Flash : 512KiB (size first sector: 2x2048)
- Option RAM : 16b
- System RAM : 8KiB
Write to memory
Erasing memory
Wrote address 0x08002c5c (100.00%) Done.