Updating USB String Descriptors in platformio.ini

I have a project where I’m using the usb cdc serial function and trying to update the USB Manufacturer / Product descriptors as part of the platformio.ini configuration.

I’m having at least partial success with changing the VID/PID using information from other posts but am unable to get the product name or manufacturer to update.

[env]
framework = arduino
build_flags =
    -D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
    -D USBCON 
    -D USBD_VID=0xNNNN
    -D USBD_PID=0xNNNN
    -D USB_MANUFACTURER="Test_Manufacturer"
    -D USB_PRODUCT="\"Test_Product\""

[env:leonardo]
platform = atmelavr
board = leonardo
build_flags = ${env.build_flags}
  
[env:samd21]
platform = atmelsam
board = seeed_xiao
build_flags =  ${env.build_flags}

[env:pico]
upload_port = G:\
upload_protocol = picotool
board = pico
platform = raspberrypi
build_flags = ${env.build_flags}

[env:stm32f401]
platform = ststm32
board = genericSTM32F401CE
board_build.mcu = stm32f401ceu6
board_build.f_cpu = 84000000L
build_flags = ${env.build_flags}

[env:esp32]
platform = espressif32
board = wemos_d1_mini32
build_flags = ${env.build_flags}

For which environment exactly? Every core is unique with its macro names and where it sources those strings from. You have something that looks like it belongs to the STM32 Arduino core.

It’s also missing proper stringification.

Okay, thanks, that’s at least a little clearer … I think :slight_smile:

I wasn’t sure if those were generic across all environments, at a high level I was trying to set the descriptors for potentially multiple mcu architectures using the same macro names across 5 architectures.

  • ArduinoCore-avr
  • ArduinoCore-samd
  • arduino-pico
  • Arduino_Core_STM32
  • arduino-esp32

If I follow correctly these would need to be defined at an architecture level, e.g

[env]
framework = arduino
build_flags =
    -D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
    -D USBCON 

[env:stm32f401]
platform = ststm32
board = genericSTM32F401CE
board_build.mcu = stm32f401ceu6
board_build.f_cpu = 84000000L
build_flags = ${env.build_flags}
    -D USBD_VID=0xXXXX
    -D USBD_PID=0xXXXX
    -D USB_MANUFACTURER="Test_Manufacturer"
    -D USB_PRODUCT="\\"Test_Product\\""
upload_protocol = dfu

[env:pico]
platform = raspberrypi
board = pico
upload_port = G:\
upload_protocol = picotool
build_flags = ${env.build_flags}
    -D <PICO SPECIFIC USBD VID MACRO>=0xXXXX
    -D <PICO SPECIFIC USBD PID MACRO>=0xXXXX
    -D <PICO SPECIFIC USB_MANUFACTURER MACRO>="Test_Manufacturer"
    -D <PICO SPECIFIC USB PRODUCT MACRO>="\\"Test_Product\\""

I did try this approach this morning starting with the STM32, but it still seems to show the default e.g

**GENERIC_F401CEUX CDC in FS Mode**