How to define custom usb PID VID and product names with PICO?

I an not having any luck with overriding the PICO board configuration to use custom usb vendor and product ids and names. This article works fine with amtelavr but not pico or other RP2040 variants.

I also tried adding build flags such as these but no success with Pico.
-D USBD_VID=0xNNNN
-D USBD_PID=0xNNNN
-D USB_MANUFACTURER=“Sample Manufacturer”
-D USB_PRODUCT=“My Product name”

Does anyone know how we can have custom VID/PIDs and product/manufacturer names for our USB devices using Pico or rp2040 boards?

One solution I found was to do it in code. I added this to my setup method and it worked but I am not sure if this is the right way:

TinyUSBDevice.setManufacturerDescriptor("Sample Manufacturer");
TinyUSBDevice.setProductDescriptor("My Product name");
TinyUSBDevice.setID(0xNNNN, 0xNNNN);

If anyone knows a better way, please let us know.

Changing PID/VID may be different for the different available Arduino cores for the Pico. What exact platformio.ini are you using?

[env:pico]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
board = pico
framework = arduino
board_build.core = earlephilhower
upload_protocol = picotool
upload_port=D:
lib_archive = no

build_flags = -D USE_TINYUSB

Yeah the PlatformIO builder script is currently not made for havign that overriden via build_flags :frowning:

In the future I think I can file a PR where we check if USBD_VID, USBD_PID, … have been pregiven and then don’t try and set new ones.

If you’re gonna have a custom product anyways, I’d actually recommend you to creata a new board definition for that. In there you can directly put the PID/VID/Manufacturer/Product you want.

To do that:

  1. Create a new boards folder at the root of your project (same level as platformio.ini)
  2. In it, duplicate pico.json as your board JSON, e.g., my_custom_board.json
  3. Change up the attributes in the earlephilhower object as desired
  4. In the platformio.ini, reference your board definition in boards = .. but without the fileextension, e.g., board = my_custom_board
1 Like

Thank you! I like the custom board option. It worked. :slight_smile:

I have followed this but when ever I change usb_manufacturer or usb_product it still shows as RaspberryPi Pico

Please show your full platformio.ini along with your custom created board file.

[env:pico]
platform = raspberrypi
board = my_custom_board
framework = arduino
upload_port = COM30

im now getting the error unknown board ID ‘my_custom_board’

Did you place the my_custom_board.json into the boards/ folder of the project?

image

I get the error when the json file is just the exact same as the pico.json file

baord vs board. Check the spelling

god i am stupid thats fixed that issues but the name is still not changing

{
    "build": {
      "core": "arduino",
      "cpu": "cortex-m0plus",
      "extra_flags": "-D ARDUINO_RASPBERRY_PI_PICO -DARDUINO_ARCH_RP2040",
      "f_cpu": "133000000L",
      "hwids": [
        [
          "0xNNNN",
          "0xNNNN"
        ]
      ],
      "mcu": "rp2040",
      "variant": "RASPBERRY_PI_PICO"
    },
    "debug": {
      "jlink_device": "RP2040_M0_0",
      "openocd_target": "rp2040.cfg",
      "svd_path": "rp2040.svd"
    },
    "frameworks": [
      "arduino"
    ],
    "name": "Test",
    "upload": {
      "maximum_ram_size": 270336,
      "maximum_size": 2097152,
      "require_upload_port": true,
      "native_usb": true,
      "use_1200bps_touch": true,
      "wait_for_upload_port": false,
      "protocol": "picotool",
      "protocols": [
        "cmsis-dap",
        "jlink",
        "raspberrypi-swd",
        "picotool"
      ]
    },
    "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/",
    "vendor": "Test"
  }

thats my custom board json

Oh you’re using the standard ArduinoCore-mbed and not Arduino-Pico? Well in that case you don’t need a custom board JSON since it doesn’t use info from there for that. The pins_arduino.h has the values hardcoded without respect for changability (thank the Arduino core maintainers for that :slight_smile: )

Further they hardcoded the Manufacturer name “Arduino” here

So for some quick testing I can recommend you to first try and change the data locally. The pins_arduino.h should be in

C:\Users\<user>\.platformio\packages\framework-arduino-mbed\variants\RASPBERRY_PI_PICO\pins_arduino.h


that spits out that error

I can see absolutely nothing from this cropped error screenshots or the values you changed it to.

In file included from C:\Users\Kyran\.platformio\packages\framework-arduino-mbed\cores\arduino/Arduino.h:76,
                 from C:\Users\Kyran\.platformio\packages\framework-arduino-mbed\cores\arduino\USB\PluggableUSBDevice.cpp:18:
C:\Users\Kyran\.platformio\packages\framework-arduino-mbed\cores\arduino\USB\PluggableUSBDevice.cpp: In function 'arduino::PluggableUSBDevice& PluggableUSBD()':
C:\Users\Kyran\.platformio\packages\framework-arduino-mbed\variants\RASPBERRY_PI_PICO/pins_arduino.h:65:25: error: unable to find numeric literal operator 'operator""xNNNN'
   65 | #define BOARD_VENDORID  0xNNNN
      |                         ^~~~~~
C:\Users\Kyran\.platformio\packages\framework-arduino-mbed\cores\arduino\USB\PluggableUSBDevice.cpp:308:44: note: in expansion of macro 'BOARD_VENDORID'
  308 |     static arduino::PluggableUSBDevice obj(BOARD_VENDORID, BOARD_PRODUCTID);
      |                                            ^~~~~~~~~~~~~~
C:\Users\Kyran\.platformio\packages\framework-arduino-mbed\variants\RASPBERRY_PI_PICO/pins_arduino.h:66:26: error: unable to find numeric literal operator 'operator""xNNNN'
   66 | #define BOARD_PRODUCTID  0xNNNN
      |                          ^~~~~~
C:\Users\Kyran\.platformio\packages\framework-arduino-mbed\cores\arduino\USB\PluggableUSBDevice.cpp:308:60: note: in expansion of macro 'BOARD_PRODUCTID'
  308 |     static arduino::PluggableUSBDevice obj(BOARD_VENDORID, BOARD_PRODUCTID);
      |                                                            ^~~~~~~~~~~~~~~
*** [.pio\build\pico\FrameworkArduino\USB\PluggableUSBDevice.cpp.o] Error 1

#define BOARD_VENDORID		0xNNNN
#define BOARD_PRODUCTID		0xNNNN
#define BOARD_NAME			"TEST"

my bad

Since when is 0xNNNN a valid hexadecimal number o_O? Hex digits are 0-9, A-F.

That works cheers sorry im still pretty new at this