USB MSD device enable/disable within composite device

 I submitted this ticket about dynamically changing the USB descriptor to enable or disable the MSD device

https://devzone.nordicsemi.com/f/nordic-q-a/85653/dynamically-changing-usb-descriptor-on-ncs

The original case is locked, but to further explain the options and new observations:

The advice was to do what the Segger does for "msdenable"/"msddisable".

Upon further research of what Segger does in this case is that they actually change the USB descriptor to add/remove the MSD entries.  However the entries in the current SDK are not easily added or removed during runtime.  So I still have the same request, any suggestion on how to do this short of rewriting the SDK to store the USB descriptor in Memory or a way to skip the MSD device entries.

I can provide the descriptors sent by the Segger in each case if that helps, but the current SDK does not seem to support this type of functionality.

It seems there is a usb_fix_descriptor() function that might could filter out the MSD descriptor?

Parents
  • My impression is that in zephyr you add various USB class support during compile time by various config options, e.g. CONFIG_USB_MASS_STORAGE. It's not intended (or designed if you like) to dynamically adjust these run-time. So my suggestion would be inline with yours, that you need to manipulate the USB descriptors before you enable USB if you intermittently want to remove functionality. To switch configurations I suspect you need to do a softreset of the nRF52840, this will trigger the host to re-enumerate the USB device. To know which USB functionality you want to support at start of main() you may consider using the GPREGRET register (set it to a predefined value before you execute soft reset), since GPREGRET is a retained register between soft resets:
    https://infocenter.nordicsemi.com/topic/ps_nrf5340/chapters/power/doc/power.html#register.GPREGRET 

    Best regards,
    Kenneth

Reply
  • My impression is that in zephyr you add various USB class support during compile time by various config options, e.g. CONFIG_USB_MASS_STORAGE. It's not intended (or designed if you like) to dynamically adjust these run-time. So my suggestion would be inline with yours, that you need to manipulate the USB descriptors before you enable USB if you intermittently want to remove functionality. To switch configurations I suspect you need to do a softreset of the nRF52840, this will trigger the host to re-enumerate the USB device. To know which USB functionality you want to support at start of main() you may consider using the GPREGRET register (set it to a predefined value before you execute soft reset), since GPREGRET is a retained register between soft resets:
    https://infocenter.nordicsemi.com/topic/ps_nrf5340/chapters/power/doc/power.html#register.GPREGRET 

    Best regards,
    Kenneth

Children
Related