This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Dynamically changing USB Descriptor on NCS?

I would like to be able to use 3 different USB descriptors.

1. CDC ACM

2. Mass Storage

3. Composite device with CDC ACM and Mass Storage

These should be selectable within firmware based on what configuration is desired.

Is there a way to do this in the NCS?  I am current using v1.8.0.

I use the CDC ACM for Logging and shell, and the Mass Storage for data generated in the device.  However if I just configure the device for #3, then the data is corrupted via Windows 10.  So I would like to be able to enable/disable the Mass Storage as needed.

When the device is ejected and reattached as Mass Storage it works better, but since the CDC ACM is connected for debugging, when you try to eject the device in Windows, it will not let you if the CDC ACM is connected.

Parents
  • Hi,

    You cannot change the descriptor of a USB device, since per specification the descriptor of a USB device should be constant. This means from e.g. Windows you will always see the device as having MSD. This is also cached internally in the registers of Windows (and similarly for other OS) as it is an integral part of how USB works.

    However, there might be ways to disengage the drive exposed through the MSD, from the device side. From what I understand, the interface MCU from Segger, on our DKs, use a similar approach. There, you go in through J-Link Commander and issue the MSDDisable or the MSDEnable command. You could go for a similar approach for disabling/enabling access to your data, i.e. commands over the CDC ACM. If you are using a Zephyr File System underneath, then you might for instance have a look at fs_unmount() for disengaging the underlying data storage.

    Regards,
    Terje

Reply
  • Hi,

    You cannot change the descriptor of a USB device, since per specification the descriptor of a USB device should be constant. This means from e.g. Windows you will always see the device as having MSD. This is also cached internally in the registers of Windows (and similarly for other OS) as it is an integral part of how USB works.

    However, there might be ways to disengage the drive exposed through the MSD, from the device side. From what I understand, the interface MCU from Segger, on our DKs, use a similar approach. There, you go in through J-Link Commander and issue the MSDDisable or the MSDEnable command. You could go for a similar approach for disabling/enabling access to your data, i.e. commands over the CDC ACM. If you are using a Zephyr File System underneath, then you might for instance have a look at fs_unmount() for disengaging the underlying data storage.

    Regards,
    Terje

Children
No Data
Related