Repeated attempts to flash over UART fails
Open source flash program for STM32 using the ST serial bootloader
Brought to you by:
tormod
Apologoies if this is not the right place to post but I'm seeing some wierd behaviour that I don't quite understand.
I am currently using an RPi CM4 hooked up to an stm32f446re on a custom carrier board and am trying to setup flash over the UART line I have between the two devices (/dev/serial0). I wrote a wrapper script to reset the MCU using the RPI GPIO and set it in the proper boot mode and then runs the flash command. This works perfectly fine the first time upon power up, but the next attempt to flash the MCU fails to init or ACK on 0x01.
Here is my terminal output:
➜ ~ flash_mcu.sh ~/main_board_peripheral_config.bin
stm32flash 0.7
http://stm32flash.sourceforge.net/
Using Parser : Raw BINARY
Location : 0x8000000
Size : 46288
Interface serial_posix: 115200 8E1
Version : 0x31
Option 1 : 0x00
Option 2 : 0x00
Device ID : 0x0421 (STM32F446xx)
- RAM : Up to 128KiB (12288b reserved by bootloader)
- Flash : Up to 512KiB (size first sector: 1x16384)
- Option RAM : 16b
- System RAM : 30KiB
Write to memory
Erasing memory
Wrote and verified address 0x0800b4d0 (100.00%) Done.
Starting execution at address 0x08000000... done.
➜ ~
➜ ~ flash_mcu.sh ~/main_board_peripheral_config.bin
stm32flash 0.7
http://stm32flash.sourceforge.net/
Using Parser : Raw BINARY
Location : 0x8000000
Size : 46288
Interface serial_posix: 115200 8E1
Failed to read ACK byte
Unexpected reply from device on command 0x01
➜ ~ flash_mcu.sh ~/main_board_peripheral_config.bin
stm32flash 0.7
http://stm32flash.sourceforge.net/
Using Parser : Raw BINARY
Location : 0x8000000
Size : 46288
Interface serial_posix: 115200 8E1
Failed to init device, timeout.
➜ ~
➜ ~
Anonymous
Looks like the issue was tied to me having openned minicom on the same UART port during the first attempt to flash the MCU. The second attempt after closing minicom worked succesfully and the following attempts failed.
After power cycling one more time I've been able to flash 3 times in a row without issues. Still don't quite understand what's going on.