Set USB Device Name

Hello folks,

I'm working on a device that needs a USB storage connection capability. I have put the "mass" sample into my application, and it works as expected except for one thing -- I can't seem to change the displayed name of the mounted drive.

I'm working in SDK v2.5.0 / nRF52840 / Windows 11 Host.

The nRF USB port connection connects as "USB Drive (E:)" and I can use my computer to format the drive to whatever name I want (e.g. USB_CfgTool (E:)). I want to be able to set this name programmatically.

What I have tried so far:

KConfig - CONFIG_USB_DEVICE_PRODUCT="MyName"

Code: Change the name of the mount_point (fs_mount_t *mnt ;; mnt->mnt_point="MyName" ;; usb_dc_reset();) (In the hope that changing mount point, then disconnecting / reconnecting would update the name)

Based on this post:  Set USB Device Product name on runtime

It seems like I might be fighting against Windows Driver Caching based on VID/PID -- but I'd like to set up new devices (my own) to show up with a correct USB name on their first run. In that case, the caching won't be an issue because the right information will get cached.

Could someone please point me in the right direction to name USB Devices?

Thank you,

    - Finn

  • Did you try to set it using CONFIG_USB_DEVICE_PRODUCT before you connect it to the computer for the first time? Does it appear with your name if you connect it to a new computer after setting this Kconfig? If you don't have any other computer to test on, you can try modifying the PID/VID to make the computer think it is in fact a new device, and that it needs to check it's name again.

    BR,

    Edvin

  • Hi Edvin

    Here's what I've got for now.

    The device is showing up as "USB Drive (E:)"

    On a pristine build, I use these options

    # Mounting Options
    CONFIG_USB_DEVICE_STACK=y
    CONFIG_USB_DEVICE_PRODUCT="NAME_01"
    CONFIG_USB_DEVICE_VID=0x0006
    CONFIG_USB_DEVICE_PID=0x0006

    and it reconnects still named USB Drive

    So I run another pristine build with these options

    # Mounting Options
    CONFIG_USB_DEVICE_STACK=y
    CONFIG_USB_DEVICE_PRODUCT="NAME_02"
    CONFIG_USB_DEVICE_VID=0x0007
    CONFIG_USB_DEVICE_PID=0x0007

    Flash, and the behavior is the same

    The same is true of different, duplicate boards running the same code. E.g. on my nRF52840dk, and on two different Xiao BLE Sense boards that hadn't been connected to the computer before.

  • Breakthrough!

    I checked autoconf.h

    nRF Desktop defaults override VID PID, Manufacturer, and SN user settings.

    If I set the Desktop options, but comment the standard usb options, the standard options are still overwritten by the default desktop options.

    If I set the Desktop options AND THEN set the USB options, then I can change the values in auto conf

    #define CONFIG_USB_DEVICE_VID 0x0102
    #define CONFIG_USB_DEVICE_PID 0x0102
    #define CONFIG_USB_DEVICE_MANUFACTURER "ZEPHYR"
    #define CONFIG_USB_DEVICE_PRODUCT "NAME_05"

    I was really hopeful about this since it's new VID, PID, and name.

    However -

    We're still a USB drive.

    Switching to a MacBook ----

    That same device connects as "NO NAME"

    I would be grateful for advice on what to try next.

    Thank you,

        - Finn

  • Hello Finn,

    Can you open device manager in windows, and check the device under the details view:

    (Just an old DK as an example).

    Are your customizations present there?

    BR,
    Edvin

  • Hi -- the DevKit shows up in Two places. One for the JLink UART Port, one for the nRF USB Connection.

    On the USB Connection

    and on JLINK UART

    Neither place shows my customizations.

    I'm having the device show up as "Auli_Desktop" -- and I've even tried uninstalling the drivers for both the JLink device and the USB connection from the device manager page to no effect.

Related