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

Parents
  • 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.

  • What USB port on the DK are you using when you see this?

    Is it the J2 port or the J3 (nRF USB)?

    BR,
    Edvin

  • I'm using both ports -- I'm routing Serial and Power through J2, but the USB Drive is set up through the J3 (nrf USB) port.

    Best,

       - Finn

  • Hello Finn,

    I am onto something, but I have not yet succeeded. 

    The USB mass storage device name is not set by the USB driver at all. It is part of the fatfs file system (or whatever file system you are using). Please see:
    https://devzone.nordicsemi.com/f/nordic-q-a/72280/msc-disk-name?ReplySortBy=CreatedDate&ReplySortOrder=Ascending

    However, I only get the return value 12 when trying to do this, so it suggests that I have not found the correct place to do so in Zephyr (the answer in the ticket above is for the nRF5 SDK). 

    I don't have time for more digging today, but perhaps you can experiment with this. 

    Best regards,

    Edvin

  • Hello Edvin,

    Helpful pointer! I can set those values without getting an error, but I have some config options expanding memory that's available, which may be helpful.

    In particular, `CONFIG_MAIN_STACK_SIZE` may need an increase.

    Unfortunately, the additions from the linked post don't change the behavior of the USB connections. It's an interesting direction though, and I'll let you know if I find something while poking around the ffconf.h file or similar.

    Best,

        - Finn

  • Hi, 

    Sorry to hijack the post, I have the exact same issue. The provided link is not valid because : 

    1) There is no such _USE_LABEL in ffconf.h, but it is FF_USE_LABEL (ncs v2.7.0)

    2) I think it is a bad practice to modify the SDK files directly for an industrial sized project. One have to maintain it (with a fork or something) 

    On my side, when I click on the bottom right of my screen to see my USB devices and I click on my device, the name is the right one, But "USB Drive" is displayed everywhere else.

    On a PC that never seen any nordic device, it shows as SDCH. 

    Help is appreciated

    Best regards

    [EDIT] I tried to use f_setlabel anyway (just to see), and it didn't worked for me. Still "USB Drive" displayed.

Reply
  • Hi, 

    Sorry to hijack the post, I have the exact same issue. The provided link is not valid because : 

    1) There is no such _USE_LABEL in ffconf.h, but it is FF_USE_LABEL (ncs v2.7.0)

    2) I think it is a bad practice to modify the SDK files directly for an industrial sized project. One have to maintain it (with a fork or something) 

    On my side, when I click on the bottom right of my screen to see my USB devices and I click on my device, the name is the right one, But "USB Drive" is displayed everywhere else.

    On a PC that never seen any nordic device, it shows as SDCH. 

    Help is appreciated

    Best regards

    [EDIT] I tried to use f_setlabel anyway (just to see), and it didn't worked for me. Still "USB Drive" displayed.

Children
No Data
Related