-
Notifications
You must be signed in to change notification settings - Fork 67
STM32CubeProgrammer (v2.10.0) is trashing option bytes on the STM32L4R5; leaving the device in an unusable state. #84
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
Hi @zfields What I suspect is the workaround used to flash properly each time is no longer OK. Which STM32CubeProgrammer version you used ? Note that I'm always waiting feedback internally on the issue with the flash. |
Hi @zfields, |
I do not. This happened while I was working on testing the behavior of stm32duino/Arduino_Core_STM32#1672 (comment) I'm using STM32CubeProgrammer v2.10.0 |
Please, could you retry with the previous version you used? |
You mean to install the previous version of STM32CubeProgrammer? In case it is important, my older STM32CubeProgrammer was v2.9.0. I did notice that installing software using STM32CubeProgrammer v2.10.0 directly, require me to flash the software twice before it started running on the device. |
Yes 😉
That is normal. This is the issue you raised some month ago: stm32duino/Arduino_Core_STM32#1495 So using directly the STM32CubeProgrammer you haven't the workaround which has been proposed in our mail exchange (-ob nBOOT0=0 -ob nBOOT0=1). |
I'll install the old STM32CubeProgrammer and test. |
It seems to play nice with v2.9.0. 🤷 However, after I switched it to v2.9.0, then it started working fine in v2.10.0 as well. Do we know what's causing the option bytes to become invalid? |
@fpistm I am confused when you say, "That is normal." in regard to have to flash firmware two times. Could you offer an in-depth explanation as to why that is "normal"? It seems odd to me, but obviously I don't understand it like you do. |
Well, you told that using direclty STM32CubeProgrammer requires to flash twice time the board. I said it is normal as there is an issue with STM32L4+ serie. Remember that this issue was raised by you --> stm32duino/Arduino_Core_STM32#1495 I didn't says it is the normal behavior just you met again the issue as without using Arduino IDE upload method the workaround we deploy is not used. |
Unfortunately no. This issue is linked to STM32CubeProgrammer and not to STM32duino stuff. So are you able to reproduce this issue? If not maybe you got an issue with previous install of the 2.10.0? |
No, I have not been able to reproduce the issue - yet. I'll leave my Notes here, in case any one else were to encounter this issue. Recover STM32L4R5 (Swan)Occasionally, when flashing firmware with the ST-LINK v3 using the Arduino IDE via Example of invalid register values: FLASH Registers
When the Option Byte registers get into this state, the STM32L4R5 will no longer execute firmware or allow programming. Fortunately, the STM32L4R5 can be recovered using the STM32CubeProgrammer, by updating the following FLASH registers (in the [REG] tab) to the following values: FLASH Registers
After updating the option bytes, the STM32L4R5 can now be programmed using the STM32CubeProgrammer and execute firmware. However, this state is unstable and will likely be short-lived. For unknown reasons, the STM32L4R5 will return to the bad state the next time you try to flash using the Arduino IDE via However, if you immediately program the STM32L4R5 using the Arduino IDE via |
I was not able to reproduce your issue.
As it works on your side, I could not reproduce and it is clearly linked to the STM32CubeProgrammer. I close this one. |
I'm using a Swan R5 (STM32L4R5). About 50% of the time when I flash code using the Arduino IDE, then my option bytes are left in such a state that the device will no longer operate.
I can reset the option bytes and flash the firmware using STM32Programmer application, and the Swan will work as expected.
Here is the bad state set by the Arduino IDE when it errors:

Here is the state I am restoring it to:

I'm running Pop!_OS (Debian) Linux 21.10 and Arduino IDE 1.8.19.
This has happened on two separate boards now. Should I be modifying any additional registers to restore the board, and is there something I can do to prevent this from happening in the future. It did not used to happen before (older version of Linux and Arduino IDE), and now it happens quite frequently.
The text was updated successfully, but these errors were encountered: