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!