AnsweredAssumed Answered

USB DFU using USB_OTG_FS and no VBUS sensing doesn't work

Question asked by Thomas Damgaard on Dec 16, 2016
Latest reply on Dec 20, 2016 by Thomas Damgaard

I've modified the DFU_Standalone application from the STM32Cube STM32746G-Discovery source and added support for external flash and ported it to our STM32F769I-Discovery board. It works fine if I use the USB_HS connector and configure it to use USB_OTG_HS.

On our target hardware I have only DATA-/+ available, so I have connected the DATA pins from the usb cable to the PA11 and PA12 pins and connected GND. Then configured the app to use USB_OTG_FS with no VBUS sensing:

void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
{
  GPIO_InitTypeDef GPIO_InitStruct;

  if(hpcd->Instance == USB_OTG_FS)
  {
    /* Configure USB FS GPIOs */
    __HAL_RCC_GPIOA_CLK_ENABLE();

    /* Configure DM DP Pins */
    GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12);
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
    GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

 

    /* Enable USB FS Clock */
    __HAL_RCC_USB_OTG_FS_CLK_ENABLE();

    /* Set USBFS Interrupt priority */
    HAL_NVIC_SetPriority(OTG_FS_IRQn, 7, 0);

    /* Enable USBFS Interrupt */
    HAL_NVIC_EnableIRQ(OTG_FS_IRQn);
  }
}

 

USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev)
{
#ifdef USE_USB_FS
  /* Set LL Driver parameters */
  hpcd.Instance = USB_OTG_FS;
  hpcd.Init.dev_endpoints = 6;
  hpcd.Init.speed = PCD_SPEED_FULL;
  hpcd.Init.dma_enable = DISABLE;
  hpcd.Init.ep0_mps = DEP0CTL_MPS_64;
  hpcd.Init.phy_itface = PCD_PHY_EMBEDDED;
  hpcd.Init.Sof_enable = DISABLE;
  hpcd.Init.low_power_enable = DISABLE;
  hpcd.Init.lpm_enable = DISABLE;
  hpcd.Init.vbus_sensing_enable = DISABLE;
  hpcd.Init.use_dedicated_ep1 = DISABLE;

  /* Link The driver to the stack */
  hpcd.pData = pdev;
  pdev->pData = &hpcd;

  /* Initialize LL Driver */
  if (HAL_PCD_Init(&hpcd) != HAL_OK)
  {
    extern void Error_Handler();
    Error_Handler();
  }

  HAL_PCDEx_SetRxFiFo(&hpcd, 0x80);
  HAL_PCDEx_SetTxFiFo(&hpcd, 0, 0x40);
  HAL_PCDEx_SetTxFiFo(&hpcd, 1, 0x80);
#endif
  return USBD_OK;
}

But HAL_PCD_SetupStageCallback() is never called and my device just registers in Windows as "Unknown Device".

 

Any hints to what I might have missed?

Thanks!

 

/Thomas

Outcomes