cancel
Showing results for 
Search instead for 
Did you mean: 

CubeProgrammer API downlaodFile error

WhoIsJohnGalt
Associate II

Hey there,

I am using the CubeProgrammer API (2.17.0) to flash a STM32U545 MCU over USB DFU with a new firmware.
When doing so a write error occurs (downlaodFile(...) returns CUBEPROGRAMMER_ERROR_WRITE_MEM (-10)) when flashing a new hex file (when using the same hex file as already on the MCU no error occurs).

Flashing the hex file using the CubeProgrammer application (via J-LINK) works fine.
Also a full chip erase, so no write protection active.

My code:

 

CubeProgrammer::dfuDeviceInfo* dfu_list = nullptr;
int count = CubeProgrammer::getDfuDeviceList(&dfu_list, 0xdf11, 0x0483);

CubeProgrammer::connectDfuBootloader(dfu_list[0].usbIndex);

int FirmwareStartAddress = 0x08000000;
unsigned int verify = 1;      // verify download
unsigned int skip_erase = 0;  // do not skip erase
    CubeProgrammer::cubeProgrammerError result = static_cast<CubeProgrammer::cubeProgrammerError>(
        CubeProgrammer::downloadFile(file_path, FirmwareStartAddress, skip_erase, verify, L""));

 

When skipping the verify I don't get an error but the old firmware is still on the MCU after a reboot.

Does anyone might have a guess what could cause the write to fail?

Thank you and best Regards,

Howard Roak

 

PS: In case I missed somthing in the option bytes:

WhoIsJohnGalt_0-1728972907764.png

1 ACCEPTED SOLUTION

Accepted Solutions

If the original content remains it strongly suggests the ERASE is the thing that isn't successful. Start there..

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

3 REPLIES 3
Maryem
ST Employee

Hello @WhoIsJohnGalt ,

 

I apologize for the delayed response. 

Could you please provide the full part number of the STM32U545 MCU and, if possible, share the hex file you're trying to flash? Thank you in advance !

 

Maryem.


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.

If the original content remains it strongly suggests the ERASE is the thing that isn't successful. Start there..

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Thanks, after adding a mass erase before the file download it was working.

It seems that the erase flag of the downloadFile() is ignored or not working...

CubeProgrammer::dfuDeviceInfo* dfu_list = nullptr;
int count = CubeProgrammer::getDfuDeviceList(&dfu_list, 0xdf11, 0x0483);

CubeProgrammer::connectDfuBootloader(dfu_list[0].usbIndex);

// Newly added mass erase
CubeProgrammer::cubeProgrammerError result =
    static_cast<CubeProgrammer::cubeProgrammerError>(CubeProgrammer::massErase());

int FirmwareStartAddress = 0x08000000;
unsigned int verify = 1;      // verify download
unsigned int skip_erase = 0;  // do not skip erase <- not working anyways ...
    CubeProgrammer::cubeProgrammerError result = static_cast<CubeProgrammer::cubeProgrammerError>(
        CubeProgrammer::downloadFile(file_path, FirmwareStartAddress, skip_erase, verify, L""));