This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

A problem with USB mas storage.

Hello.
have a problem with usbd_msc .
When I plug the device by usb and Windows sees the device how mass storage. After I copy files to the device - it copies and all is good. But when I plug off and plug on USB again - some files are broken. It happens some times and random. In the biggest part of the times help "Safely Remove", but not all time.

Note! I use demo APP from SDK15 

Parents
  • Hi Sergii,

    I think you should try to add the code suggested in this answer and see if that helps. 

    Best regards

    Bjørn 

  • Hi Bjørn,

    Have tried - didn't help (((.
    I add this code in the function:

    static ret_code_t block_dev_qspi_uninit(nrf_block_dev_t const * p_blk_dev)
    {
    ASSERT(p_blk_dev);
    nrf_block_dev_qspi_t const * p_qspi_dev =
    CONTAINER_OF(p_blk_dev, nrf_block_dev_qspi_t, block_dev);
    nrf_block_dev_qspi_work_t * p_work = p_qspi_dev->p_work;

    //*******************************************Added code*************************************************//
    if ((p_work-> state != NRF_BLOCK_DEV_QSPI_STATE_IDLE))
    {
    wait_for_idle (p_qspi_dev);
    }
    //*******************************************Added code*************************************************// 



    if (m_active_qspi_dev != p_qspi_dev)
    {
    /* QSPI instance is BUSY*/
    return NRF_ERROR_BUSY;
    }

    if (p_work->state != NRF_BLOCK_DEV_QSPI_STATE_IDLE)
    {
    /* Previous asynchronous operation in progress*/
    return NRF_ERROR_BUSY;
    }

    if (p_work->ev_handler)
    {
    /*Asynchronous operation*/
    const nrf_block_dev_event_t ev = {
    NRF_BLOCK_DEV_EVT_UNINIT,
    NRF_BLOCK_DEV_RESULT_SUCCESS,
    NULL,
    p_work->p_context
    };

    p_work->ev_handler(p_blk_dev, &ev);
    }

    p_work->state = NRF_BLOCK_DEV_QSPI_STATE_DISABLED;
    nrf_drv_qspi_uninit();

    memset(p_work, 0, sizeof(nrf_block_dev_qspi_work_t));
    m_active_qspi_dev = NULL;
    return NRF_SUCCESS;
    }

     Please let me know, maybe some thing else. 

Reply
  • Hi Bjørn,

    Have tried - didn't help (((.
    I add this code in the function:

    static ret_code_t block_dev_qspi_uninit(nrf_block_dev_t const * p_blk_dev)
    {
    ASSERT(p_blk_dev);
    nrf_block_dev_qspi_t const * p_qspi_dev =
    CONTAINER_OF(p_blk_dev, nrf_block_dev_qspi_t, block_dev);
    nrf_block_dev_qspi_work_t * p_work = p_qspi_dev->p_work;

    //*******************************************Added code*************************************************//
    if ((p_work-> state != NRF_BLOCK_DEV_QSPI_STATE_IDLE))
    {
    wait_for_idle (p_qspi_dev);
    }
    //*******************************************Added code*************************************************// 



    if (m_active_qspi_dev != p_qspi_dev)
    {
    /* QSPI instance is BUSY*/
    return NRF_ERROR_BUSY;
    }

    if (p_work->state != NRF_BLOCK_DEV_QSPI_STATE_IDLE)
    {
    /* Previous asynchronous operation in progress*/
    return NRF_ERROR_BUSY;
    }

    if (p_work->ev_handler)
    {
    /*Asynchronous operation*/
    const nrf_block_dev_event_t ev = {
    NRF_BLOCK_DEV_EVT_UNINIT,
    NRF_BLOCK_DEV_RESULT_SUCCESS,
    NULL,
    p_work->p_context
    };

    p_work->ev_handler(p_blk_dev, &ev);
    }

    p_work->state = NRF_BLOCK_DEV_QSPI_STATE_DISABLED;
    nrf_drv_qspi_uninit();

    memset(p_work, 0, sizeof(nrf_block_dev_qspi_work_t));
    m_active_qspi_dev = NULL;
    return NRF_SUCCESS;
    }

     Please let me know, maybe some thing else. 

Children
No Data
Related