cancel
Showing results for 
Search instead for 
Did you mean: 

B-L475E-IOT01A USB DFU is stuck in different states.

Keyur Thumar
Associate III

I am using B-L475E-IOT01A (STM32L475VGTx) dev kit and this article for DFU and I am getting following issue.

Sequence of process I do is as below.

  • Erase the whole flash.
  • Flash the bootloader created based on above video.
  • Make a DFU using DfuSe Tool and It works.

But when I want to upgrade the device again with DfuSe Tool, DFU process stuck or gives me error. Please see below screenshot.

0693W00000NsWVVQA3.png0693W00000NsWVfQAN.pngUpgrade file is simple LED blinking application. It works when I do the DFU first time. But for upcoming DFU does not work.

Can anyone please help me out here ?

12 REPLIES 12
Mike_ST
ST Employee

That's because the flash is no more empty after you flashed the LED app.

I think the DFU protocol implementation is incomplete.

If you want a quick workaround for your case, just modify the following line in usbd_dfu_if.c,

function MEM_If_Erase_FS(uint32_t Add):

 //eraseinitstruct.NbPages = 1;

eraseinitstruct.NbPages = (FLASH_BANK_SIZE/FLASH_PAGE_SIZE) - GetPage(Add);

That should erase the BANK 1 until the end, instead of the first page only. So the flash operation can succeed again and again.

Please read the AN3156

https://www.st.com/resource/en/application_note/cd00264379-usb-dfu-protocol-used-in-the-stm32-bootloader-stmicroelectronics.pdf

Keyur Thumar
Associate III

@Mike_ST​  Thank you for resoultion and explanation.

I have done changes as you suggested and it worked. :grinning_face:

I have gone through the AN3156 but couldn't get an idea of why the workaround you suggested is worked or what is incomplete in my DFU protocol implementation.

Can you please elaborate ? It would be great help for me.

Mike_ST
ST Employee

This implementation is only an example and is only deleting 1 page of flash memory before programming.

So it would work for small binaries (2KB max) and that is why deleting more flash pages helps.

So you have to understand it and adapt it for your needs.