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

USBD connect/disconnect

Hi,

Is it possible to fool the system (via software) to perform a USB connect/disconnect as if it was physically connected and disconnected?

  • Look at the nrf_usbd_pullup_disable  and nrf_usbd_pullup_enable  functions. If you disable the pull-up, the host will see this as a disconnect. 

  • Thanks for your reply, however, it does not seem to do the trick.

    There seems to be an issue with the USBD as follows:

       - Create a file

       - Modify it (write some date to it)

       - Connect the USB

       - I am able to see the file on the USB drive

       - Disconnect the USB

       * at this point everything is file as fatfs_init() works fine and I can log more data to the file

      However:

       - Connect the USB

       - Copy (Drag/Drop) the file from the USB drive

       - Disconnect the USB

       - fatfs_init() fails and I no longer can access the file; unless I physically connect/disconnect the USB again.

    My intention is in failed times to mimic a USB connect/disconnect without the user's knowledge.

       

  • The pullup enable/disable should disconnect the device from the PC's perspective. Can you verify this happens?
    I suppose on the microcontroller, you'll need to manually generate a disconnect event after disabling the pullup. 

  • I ended up using this suggestion and it solved the issue. Thanks.

    Hi.


    I had the almost the same issue. After any access to the files via the USB, the file system was demolished after internal flash access.
    I added additional logs to the SDK in QSPI module and it has shown me, that QSPI uninit function (block_dev_qspi_uninit), called after unplugging the USB, was busy (return with NRF_ERROR_BUSY).

    I add this code at the beggining of block_dev_qspi_uninit:


    if ((p_work->state != NRF_BLOCK_DEV_QSPI_STATE_IDLE))

    {

     wait_for_idle(p_qspi_dev);

    }


    It fixed the problem.

    Best regards
    Artur

Related