cancel
Showing results for 
Search instead for 
Did you mean: 

Activate DFU using HAL driver on STM32F072

Arnaud Chalons
Associate
Posted on February 16, 2018 at 12:12

Hi all,

I am trying to set up my STM32F072 device so that I can connect it to my computer via USB and upgrade the firmware using DfuSe software. I did all the wiring to do so but my problem is that I want to activate the DFU mode using only software (and particularly the HAL driver) and not the BOOT0 pin.

I wrote some code in order to do so but all I get when I plug my USB cable to the computer is 'one of the USB devices attached to this computer has malfunctioned...' I know that the problem comes from my code because I tried the DFU project example in the library 'STM32F0x2_USB-FS-Device_Lib' provided by ST, and everything works fine (my computer recognizes the device as 'STM Device in DFU mode' and I can upgrade the firmware using DfuSe).

However, I can't manage to use this library in my project and that's why I need to use the HAL driver. Does anyone know how to activate the DFU mode using HAL driver on an STM32F072? I read the corresponding part in the UM1725 but it is not precise enough for me to make it work..

My current code to activite the DFU mode which is not working is the following:

PCD_HandleTypeDef hpcd_USB_FS;

static void MX_USB_PCD_Init(void);

void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)

{

  __HAL_RCC_USB_OTG_HS_CLK_ENABLE();

}

int main(void)

{

   HAL_Init();

   SystemClock_Config();

   MX_USB_PCD_Init();

   HAL_PCD_Init(&hpcd_USB_FS);

   HAL_PCD_MspInit(&hpcd_USB_FS);

   HAL_PCD_Start(&hpcd_USB_FS);

   HAL_PCD_DevConnect(&hpcd_USB_FS);

  while(1);

}

// + definition of 'SystemClock_Config();' and 'MX_USB_PCD_Init();' generated by STM32CubeMX

Thank you for your help.

AC

0 REPLIES 0