cancel
Showing results for 
Search instead for 
Did you mean: 

Need to invoke DFU mode by sending command over USB CDC while application is running

P D
Associate
Posted on August 01, 2017 at 09:46

Hi there,

I am trying to use DFU in my application, I have seen the sample codes available in STM32cube package but it requires user button to be pressed in order to enter into DFU mode.

I want my application should go in DFU mode just by using software command (like over USB_CDC if i am sending 'enter DFU' it should enter in DFU mode). 

Do I need add USB CDC in DFU code? is it possible to achieve by using cubeMX?

#dfu
4 REPLIES 4
MDS
Associate III
Posted on September 21, 2017 at 14:07

I have done this on a PIC32MX. It would be great if I could do with my STM32F7.

Posted on September 21, 2017 at 14:49

I want my application should go in DFU mode just by using software command (like over USB_CDC if i am sending 'enter DFU' it should enter in DFU mode). 

This statement is the answer to your next question.

Do I need add USB CDC in DFU code?

Your application needs to have USB CDC functionality to be able to receive the 'enter DFU' command.

It is easy to do this by CubeMx There are also examples inside your device's firmware.

yuri CH
Senior
Posted on March 01, 2018 at 10:41

'I am trying to use DFU in my application, I have seen the sample codes available in STM32cube package but it requires user button to be pressed in order to enter into DFU mode.'

could you please say exactly where did you find that example code? i am currently looking for it.

MDS
Associate III
Posted on March 01, 2018 at 14:26

As I stated above, I did this for a PIC32 implementation. Now I have this working for the STM32. I send a command over the CDC interface. The command sets a 32-bit variable to a specific value then does a soft reset. I inserted code at the beginning of the startup file that checks the variable for the DFU value. If the value is correct, the code sets the SP to the DFU stack and jumps to the DFU vector in flash. This is no more than about 10 lines of C code, plus the command execution code. I do not have any DFU code in my application, I just jump the flash DFU. I realize that there is a 1 in 2^^32  chance that the board will boot with the correct value in the variable. If that is a problem, set an array or string to a longer value.