cancel
Showing results for 
Search instead for 
Did you mean: 

CubeProgrammer API: Write Memory Error via STLink V3 SET & I2C; no error via USB

NeoPete
Associate II
0

I have a device with an MCU in DFU-mode, and I want to flash new firmware to it. To do that I have the software we have developed at my company to interact with the device, mainly a Wpf-application written in C# and Xaml, which in turn uses the KSociety SharpCubeProgrammer library to make calls to the STM32 CubeProgrammer_API.

If I use the STLink V3 SET hardware over I2C I get a CubeprogrammerErrorWriteMem error (return value -10), i.e. a memory write error, but using the same firmware file but instead directly over USB, i.e. not using the STLink, I get no error and the firmware is updated. In either way the calling code is almost identical, and I have checked that the data and address is the same when calling the API over both I2C and USB. The method called from the API is in either way WriteMemoryAndVerify(...).

I found some information saying that it's the STM32_Programmer_CLI.exe that does the actual reflashing. If that's the case I have a vague idea that I must use the parameter --skiperase which will not erase flash blocks before rewriting them, or when my code grows into the next block. But because the SharpCubeProgrammer wrapper for the STM32 CubeProgrammer_Api I use doesn't include an option for setting that parameter I guess I'll have to do a PInvoke in my code to call the method in the STM32 CubeProgrammer_Api directly. 

Any help or just pointing me in the right direction would be highly appreciated. Thanks!

2 REPLIES 2
Aziz BRIGUI
ST Employee

Hello @NeoPete

I suggest first trying to download a binary via USB and I2C using only STM32CubeProgrammer CLI (To take the WPF and API parts out of the equation). This is to know if the download issue you're having is tool related. You can refer to the user manual for more details on command syntax.

PS: Please keep in mind that the use case you are performing is not officially supported by the tool.

Aziz


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Hello Aziz,

Thanks for your reply.

I forgot to mention that I have run the described use case with the STM32CubeProgrammer application in Windows 11 too, and I get kind of the same error, i.e. using the same hardware setup with the STLink and our STM32L5 mcu I connect to it in STM32CubeProgrammer over I2C and everything is "green". I then download the hex-file for the firmware update and click on 'Start Programming' in the STM32CubeProgrammer app. When starting it has 6 segments to flash, and it's when it comes to the 6th, i.e. the last, segment, which is the biggest one, it stops and signals an exception. 

When setting the logging in STM32CubeProgrammer to Verbose level 3 I get the following output when it fails:

NeoPete_0-1743070445286.png

Also, when stepping through the C# code in the application we have developed I can see that the error message comes from the ST Api (or of course the SharpCubeProgrammer, but since this is just a wrapper I assume it comes from the ST C-api).