cancel
Showing results for 
Search instead for 
Did you mean: 

RunTime DFU with USB in STM32L4

dtarrago
Senior
Posted on April 10, 2017 at 12:28

Good mornign,

I'm working in my application that is based on STM32L475 device.

I'm able to flash my device by using the Dfulse Demo software and setting Boot0 to 1 when applying power to device. But I would like to implement and manage DFU functionality in run time via USB: the aim is to have dual bank functionality in order to update firmware without having to change Boot0 pin.

What I have first done is to set DFU parameters using STM32CubeMX:

 - USB_OTG_FS peripheral as device_only

 - Middlewares --> USB_DEVICE: Class For FS IP = Download Firmware Update Class (DFU)

Then I have flashed my device with this setup (project created from Cube) and I thought the device should be recognized when connecting it to PC via USB. But, it was not.

So, which are the best steps to follow to implement this functionality? Is there any example that matches this behaviour?

Best regards.

#usb #dfu #stm32l4
4 REPLIES 4
Amel NASRI
ST Employee
Posted on April 10, 2017 at 15:16

Hi Daniel,

You can take the DFU example available under following directories in the STM32CubeL4 package (just comment BSP related code if you aren't using

STM32L476G-Discovery orSTM32L476G_EVAL

:(

  • STM32Cube_FW_L4_V1.7.0\Projects\STM32L476G-Discovery\Applications\USB_Device\DFU_Standalone
  • STM32Cube_FW_L4_V1.7.0\Projects\STM32L476G_EVAL\Applications\USB_Device\DFU_Standalone

Please pay attention to replaceHSICalibrationValue by MSICalibrationValuein SystemClock_Config function (main.c) in order to avoid issue described in

https://community.st.com/0D50X00009XkeotSAB

-Amel

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.

Posted on April 10, 2017 at 16:16

Thank you Amel,

I have tried the first example you have written and it works with my proto.

But the question is: why it is not working with STM32CubeMx?

Dani.

Posted on April 10, 2017 at 16:23

May be you need to increase heap and stack size in CubeMX before generating project.

-Amel

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.

Posted on April 10, 2017 at 16:31

If I need to change these parameters, I guess there is any type of bug with Cube, right?

And how do I know the right values for heap and stack size?

On the other hand, when I proceed in the same way with the STM32F3 with Cube, it works already the first time... This is the way it should be for any device....