cancel
Showing results for 
Search instead for 
Did you mean: 

Runtime DFU application in STM32L4 series

Lakshmi Lavanya
Associate II
Posted on December 08, 2016 at 14:07

Hello Everyone,

I need DFU application which can load the new firmware at run time.

I want to implement DFU in stm32l476G-Eval board, tried with DFU bootloader method (Connecting Boot0 to VCC) it is working fine.

Compiled the DFU standalone example application and ran it but it is not showing as a DFU device when i connected the eval board to PC.

Can any body explain or point me to the links which can explain how to implement the DFU standalone method. How the run time DFU will work? how much space it will take for the DFU code?

#stm32l4 #usb #stm32l476g-eval #stm32l4-dfu-runtime #dfu

Note: this post was migrated and contained many threaded conversations, some content may be missing.
37 REPLIES 37
Lakshmi Lavanya
Associate II
Posted on December 13, 2016 at 07:31

Can any body give suggestions on this?

How to get the DFU run time with DFU class enabled.

Manikandan K
Associate III
Posted on July 14, 2017 at 12:04

Hi  ,

I'm also trying to implement Run Time DFU via USB in STM32F207ZG port but I can't able to get proper document for that, 

Any suggestion ? Pls share your Ideas...

With Thanks & Regards

K.Manikandan

Posted on July 14, 2017 at 17:36

This is the mechanism I use on F2/F4 designs to boot into the System Loader's DFU mode

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

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on July 15, 2017 at 09:03

Thanks a lot for your suggestion ,

I can't able to open the above link which you already share.

Posted on July 15, 2017 at 19:48

Please edit your post and remove the DEADLINKs, they are from  previous version of the forum, I've created new links below

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

 

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

 

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

 

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

 

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

 

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

 
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on July 17, 2017 at 06:56

Thanks for your information it's very useful for me...

Posted on July 18, 2017 at 09:07

Hi

K.Manikandan

‌,

Have you achieved runtime DFU on STM32F207ZG nucleo?

Posted on July 18, 2017 at 11:00

Hi ,

I just tested with  /home/STM32CubeF2/STM32Cube_FW_F2_V1.4.0/Projects/STM32F207ZG-Nucleo/Applications/USB_Device/DFU_Standalone ,by using this code I can able to detect the DFU device and also possible to upload the .dfu file.

Posted on July 20, 2017 at 07:24

Hi,

=====================================================================================

When I'm using BOOT0 pin = 1 and BOOT1 pin = 0 then I got below output        (For Making Boot0 pin as 1 , I put Jumper between BT0 and VDD ( CN 11 - pin 5 and 7)

For Making Boot1 pin as 0, I put Jumper between PB2(BOOT1) and GND (CN12- pin 20 and 22)

kmani@kmani:~$ dfu-util --list

dfu-util 0.8

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.

Copyright 2010-2014 Tormod Volden and Stefan Schmidt

This program is Free Software and has ABSOLUTELY NO WARRANTY

Please report bugs to

mailto:dfu-util@lists.gnumonks.org

Found DFU: [0483:df11] ver=2200, devnum=32, cfg=1, intf=0, alt=3, name='@Device Feature/0xFFFF0000/01*004 e', serial='377D38603335'

Found DFU: [0483:df11] ver=2200, devnum=32, cfg=1, intf=0, alt=2, name='@OTP Memory /0x1FFF7800/01*512 e,01*016 e', serial='377D38603335'

Found DFU: [0483:df11] ver=2200, devnum=32, cfg=1, intf=0, alt=1, name='@Option Bytes  /0x1FFFC000/01*016 e', serial='377D38603335'

Found DFU: [0483:df11] ver=2200, devnum=32, cfg=1, intf=0, alt=0, name='@Internal Flash  /0x08000000/04*016Kg,01*064Kg,07*128Kg', serial='377D38603335'

                                                 =================================

kmani@kmani:~$ dfu-util -a 0 -s 0x08000000:leave -D /home/kmani/ARM_Toolchain/workspaceARM/USB_CDC_VCP/Debug/USB_CDC_VCP.bin

dfu-util 0.8

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.

Copyright 2010-2014 Tormod Volden and Stefan Schmidt

This program is Free Software and has ABSOLUTELY NO WARRANTY

Please report bugs to

mailto:dfu-util@lists.gnumonks.org

dfu-util: Invalid DFU suffix signature

dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!

Opening DFU capable USB device...

ID 0483:df11

Run-time device DFU version 011a

Claiming USB DFU Interface...

Setting Alternate Setting ♯ 0 ...

Determining device status: state = dfuERROR, status = 10

dfuERROR, clearing status

Determining device status: state = dfuIDLE, status = 0

dfuIDLE, continuing

DFU mode device DFU version 011a

Device returned transfer size 2048

DfuSe interface name: 'Internal Flash '

Downloading to address = 0x08000000, size = 17288

Download [=========================] 100% 17288 bytes

Download done.

File downloaded successfully

Transitioning to dfuMANIFEST state

DFU mode working good.

========================================================================================

But When I'm using ...

/* DFU Class Config */

♯ define USBD_DFU_MAX_ITF_NUM                   1

♯ define USBD_DFU_XFER_SIZE                     1024   /* Max DFU Packet Size   = 1024 bytes */

♯ define USBD_DFU_APP_DEFAULT_ADD               0x08008000 /* The first 3 sectors (48 KB) are reserved for DFU code */

♯ define USBD_DFU_MAX_NB_OF_SECTORS             12 /* Max number of sectors: 12 sectors in Bank1 */

int main(void)

{

  /* STM32F207xx HAL library initialization */

  HAL_Init();

 

  /* Configure the System clock to have a frequency of 120 MHz */

  SystemClock_Config();

    

  /* Configure User Button */

  BSP_PB_Init(BUTTON_USER, BUTTON_MODE_GPIO);

 

  /* Check if the User Button is pressed */

  if(BSP_PB_GetState(BUTTON_USER) == 0x00)

  {

    /* Test if user code is programmed starting from USBD_DFU_APP_DEFAULT_ADD address */

    if(((*(__IO uint32_t*)USBD_DFU_APP_DEFAULT_ADD) & 0x2FFE0000 ) == 0x20000000)

    {

      /* Jump to user application */

      JumpAddress = *(__IO uint32_t*) (USBD_DFU_APP_DEFAULT_ADD + 4);

      JumpToApplication = (pFunction) JumpAddress;

      /* Initialize user application's Stack Pointer */

      __set_MSP((*(__IO uint32_t*) USBD_DFU_APP_DEFAULT_ADD ));

      JumpToApplication();

    }

  }

  /* Otherwise enters DFU mode to allow user programming his application */

  /* Init Device Library */

  USBD_Init(&USBD_Device, &DFU_Desc, 0);

 

  /* Add Supported Class */

  USBD_RegisterClass(&USBD_Device, USBD_DFU_CLASS);

 

  /* Add DFU Media interface */

  USBD_DFU_RegisterMedia(&USBD_Device, &USBD_DFU_Flash_fops);

  /* Start Device Process */

  USBD_Start(&USBD_Device);

 

  /* Run Application (Interrupt mode) */

  while (1)

  {

  }

}

                    =========================================================

I got the below output when i'm using above bootloader program without BOOT0 and BOOT1 pin

kmani@kmani:~$ dfu-util --list

dfu-util 0.8

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.

Copyright 2010-2014 Tormod Volden and Stefan Schmidt

This program is Free Software and has ABSOLUTELY NO WARRANTY

Please report bugs to

mailto:dfu-util@lists.gnumonks.org

Found DFU: [0483:df11] ver=0200, devnum=35, cfg=1, intf=0, alt=0, name='@Internal Flash /0x08000000/02*016Ka,02*016Kg,01*064Kg,07*128Kg,04*016Kg,01*064Kg,07*128Kg', serial='377D38603335'

                       ==============================================================

kmani@kmani:~$ dfu-util -a 0 -s 0x08000000:leave -D /home/kmani/ARM_Toolchain/workspaceARM/USB_CDC_VCP/Debug/USB_CDC_VCP.bin

dfu-util 0.8

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.

Copyright 2010-2014 Tormod Volden and Stefan Schmidt

This program is Free Software and has ABSOLUTELY NO WARRANTY

Please report bugs to

mailto:dfu-util@lists.gnumonks.org

dfu-util: Invalid DFU suffix signature

dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!

Opening DFU capable USB device...

ID 0483:df11

Run-time device DFU version 011a

Claiming USB DFU Interface...

Setting Alternate Setting ♯ 0 ...

Determining device status: state = dfuIDLE, status = 0

dfuIDLE, continuing

DFU mode device DFU version 011a

Device returned transfer size 2048

DfuSe interface name: 'Internal Flash '

Downloading to address = 0x08000000, size = 17288

dfu-util: Last page at 0x08004387 is not writeable

========================================================================================

Form both output i noted that the version is difference ie., ver =2200 and ver 0200 ,but i don't know what is the exact problem please guide me.

With Thanks & Regards

K.Manikandan

Akos Pasztor
Associate II
Posted on July 20, 2017 at 10:37

Hi,

Check out my self-made bootloader. It does not require to utilize the BOOT pins, it features firmware update from an SD card, and also provides possibility to jump and launch the built-in st-bootloader (tested and works in DFU mode).

https://github.com/akospasztor/stm32-bootloader