-
Notifications
You must be signed in to change notification settings - Fork 1k
Generic Board STM32G031J6: Flash download fails (Linux, USART) #1659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@olikraus In can see that when enabling verbose level 3:
This issue should be fixes for next STM32Cubeprogrammer release |
Closing this issue as it is not related to stm32duino Core, but STM32Cubeprogrammer. |
oh, nice finding. But yes, this explains the problem.
Great, thanks. Is there already any date planned for the next release of the tool delivery? Thanks for the great work on STM32duino and listening to the community. :-) |
I hope in the coming weeks. |
Desktop and Board
see #1637
USART connected to PA9/10
Arduino Core Version
Latest Arduino_Core_STM32, especially including PR #1653 (bootloader jump into application)
Bug Description
Overview
If a .ino file is downloaded to the STM32G031J6 device, then the download might be invalid, if the size of the flashfile has changed.
The demonstration will use two different files (difference actually is only a delay value). If one file overwrites the other, then the newly flashed file is invalid an will not work:
Flash will work successfully if the flash memory was erased fully before any of the two programs is uploaded.
The problem can be demonstrated inside Arduino IDE. The steps below however will demonstrated the bug by using CubeProgrammer only. This demonstrates, that the root problem (bug) is located in STM32CubeProgrammer, which does not flash correctly via USART.
Preparation
As a preparation I will create two HEX files
stm32_g0_serial_blink_100_600.ino:
stm32_g0_serial_blink_600_600.ino:
Compiled with Arduino IDE, the following two hex files can be obtained:
The size of the two hex files differs slightly.
For further testing both hex files are attached:
hex_files.zip
Reproducing the Bug
./STM32_Programmer.sh -c port=/dev/ttyUSB0 -e [0 31]
: This will erase all flash end ensure a fixed starting point./STM32_Programmer.sh -c port=/dev/ttyUSB0 -w stm32_g0_serial_blink_100_600.hex -g
: This will download and start the first hex file. Thanks to Bootloader jump to application #1653, the code is started directly without further boot0 mode change and without reset event../STM32_Programmer.sh -c port=/dev/ttyUSB0 -w stm32_g0_serial_blink_600_600.hex -g
: This will download and start the second hex file. Unfortunately the download fails and the start will not work.Analysis of the Bug
STMCubeProgrammer also allows the verification of the uploaded data, which is disabled by default.
Let us repeat step 4 with verification:
./STM32_Programmer.sh -c port=/dev/ttyUSB0 -w stm32_g0_serial_blink_600_600.hex -v -g
The output will finally look like this:
Obviously CubeProgrammer was not able to flash correctly and as a consequence, the newly flash code is faulty, unable to start and execute.
Let us repeat the last step, but with flash erase before:
The download now succeeds:
This means the verification error will vanish, if we have a fully erased flash memory.
Affected Devices
As described in #1637 also a STM32G031F8 is affected by the same bug, assuming that probably all STM32G devices are affected.
Assumed Root Cause
As analyzed in #1637 CubeProgrammer does not correctly erase the required target range. It probably erases too less due to a mismatch/confusion of the sector size (2k vs 1k).
Conclusion
Download via USART interface does not work reliable for STM32G devices. The problem is caused by STM32CubeProgrammer.
PR #1653 does NOT fix this problem.
The text was updated successfully, but these errors were encountered: