Skip to content

MSC hard fault on unplug #18

@friesendrywall

Description

@friesendrywall

I'm getting a Hard Fault on USB disconnect on USB MSC at USBH_MSC_UnitIsReady at line 741

I think this should be something like

  * @brief  USBH_MSC_UnitIsReady
  *         The function check whether a LUN is ready
  * @param  phost: Host handle
  * @param  lun: logical Unit Number
  * @retval Lun status (0: not ready / 1: ready)
  */
uint8_t USBH_MSC_UnitIsReady(USBH_HandleTypeDef *phost, uint8_t lun)
{
  if(phost && phost->pActiveClass) { // Check for pActiveClass not NULL
    MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) phost->pActiveClass->pData;
    uint8_t res;
  
    /* Store the current lun */
    MSC_Handle->current_lun = lun;
  
    if ((phost->gState == HOST_CLASS) && (MSC_Handle->unit[lun].error == MSC_OK))
    {
      res = 1U;
    }
    else
    {
      res = 0U;
    }
  } else {
    res = 0U;
  }
  return res;
}```

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinginternal bug trackerIssue confirmed and reported into a ticket in the internal bug tracking system.mwMiddleware-related issue or pull-request.usbUSB-related (host or device) issue or pull-request

Type

Projects

Status

Analyzed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions