I clone the repository from Sourceforge in my Projects folder.
$ cd ~/Projects $ git clone https://git.code.sf.net/p/stm32flash/code stm32flash-code Cloning into 'stm32flash-code'... remote: Enumerating objects: 1357, done. remote: Counting objects: 100% (1357/1357), done. remote: Compressing objects: 100% (682/682), done. remote: Total 1357 (delta 912), reused 996 (delta 671) Receiving objects: 100% (1357/1357), 1.04 MiB | 74.00 KiB/s, done. Resolving deltas: 100% (912/912), done.Build on Linux doesn’t show any warnings.
$ cd stm32flash-code $ make cc -Wall -g -c -o dev_table.o dev_table.c cc -Wall -g -c -o i2c.o i2c.c cc -Wall -g -c -o init.o init.c cc -Wall -g -c -o main.o main.c cc -Wall -g -c -o port.o port.c cc -Wall -g -c -o serial_common.o serial_common.c cc -Wall -g -c -o serial_platform.o serial_platform.c cc -Wall -g -c -o stm32.o stm32.c cc -Wall -g -c -o utils.o utils.c cd parsers && make parsers.a make[1]: Entering directory '~/Projects/stm32flash-code/parsers' cc -Wall -g -c -o binary.o binary.c cc -Wall -g -c -o hex.o hex.c ar rc parsers.a binary.o hex.o make[1]: Leaving directory '~/Projects/stm32flash-code/parsers' cc -o stm32flash dev_table.o i2c.o init.o main.o port.o serial_common.o serial_ platform.o stm32.o utils.o parsers/parsers.aI test the newly compiled command first by calling it without argument
./stm32flah
then with the serial port where the USB to UART
adapter is plugged in.
./stm32flash
gives a detailed help of the command.
Calling it with the serial port argument where the board is plugged in and set in bootloader mode gives a description of the chipset detected.
$ ./stm32flash /dev/ttyUSB0 stm32flash 0.7 http://stm32flash.sourceforge.net/ Interface serial_posix: 57600 8E1 Version : 0x31 Option 1 : 0x00 Option 2 : 0x00 Device ID : 0x0444 (STM32F03xx4/6) - RAM : Up to 4KiB (2048b reserved by bootloader) - Flash : Up to 32KiB (size first sector: 4x1024) - Option RAM : 16b - System RAM : 3KiBI install the command by moving the executable to my local bin directory.
$ mv stm32flash ~/binIf everything goes well, I will later
strip
and compress (with
upx
) the executable.
$ stm32flash -r read.bin -S 0x08000000:1024 /dev/ttyUSB0Writing the executable in hex format.
$ stm32flash -w f030f4.hex /dev/ttyUSB0Comparing the memory read-out using
od
, there is no difference.
The build phase gave more warnings than the Linux version, this is mostly due to stricter warnings in the GCC compiler version.
Usage of stm32flash only differs in the name of the serial device, in my case COM4 instead of /dev/ttyUSB0.
Next, I will write an application which make better use of transmission than hello.