I got it working with a teensy 2.0. Here are the steps I took (likely there are ways to optimize this)
Caution: Once you change PID and VID, platform.io will no longer recognize the device as a teensy and you won’t be able to reupload code with platform.io. (Work around is to use teensyduino application)
- Find all
usb_private.h
files in~/.platform.io
directory
find ~/.platformio -type f -name usb_private.h
/Users/foobar/.platformio/packages/framework-arduinoteensy/cores/usb_disk/usb_private.h
/Users/foobar/.platformio/packages/framework-arduinoteensy/cores/usb_hid/usb_private.h
/Users/foobar/.platformio/packages/framework-arduinoteensy/cores/usb_flightsim/usb_private.h
/Users/foobar/.platformio/packages/framework-arduinoteensy/cores/usb_serial/usb_private.h
/Users/foobar/.platformio/packages/framework-arduinoteensy/cores/usb_serial_hid/usb_private.h
/Users/foobar/.platformio/packages/framework-arduinoteensy/cores/teensy/usb_private.h
/Users/foobar/.platformio/packages/framework-arduinoteensy/cores/usb_rawhid/usb_private.h
/Users/foobar/.platformio/packages/framework-arduinoteensy/cores/usb_midi/usb_private.h
Since I’m using a teensy, I want .platformio/packages/framework-arduinoteensy/cores/teensy/usb_private.h
Looking in that file I see conditional includes depending on what type of device it is (HID, Keyboard, joystick ect…)
#if defined(USB_SERIAL)
#include "usb_serial/usb_private.h"
#elif defined(USB_HID)
#include "usb_hid/usb_private.h"
#elif defined(USB_SERIAL_HID)
#include "usb_serial_hid/usb_private.h"
#elif defined(USB_DISK) || defined(USB_DISK_SDFLASH)
#include "usb_disk/usb_private.h"
#elif defined(USB_MIDI)
#include "usb_midi/usb_private.h"
#elif defined(USB_RAWHID)
#include "usb_rawhid/usb_private.h"
#elif defined(USB_FLIGHTSIM)
#include "usb_flightsim/usb_private.h"
#endif
I chose to set my device to a USB_SERIAL_HID
. To do that I modified platform.ini
to include a build flag build_flags = -D USB_SERIAL_HID
[env:teensy2]
platform = teensy
board = teensy2
framework = arduino
build_flags = -D USB_SERIAL_HID
I then manually modified usb_serial_hid/usb_private.h
with the PID and VID I want
59 //TODO: Revert these lines
60 //#define VENDOR_ID 0x16C0
61 //#define PRODUCT_ID 0x0487
62
63 #define VENDOR_ID 0xAAAA
64 #define PRODUCT_ID 0xBBBB
Build and upload and observe the PID and VID are now the programmed value.
I would much rather do this in a more repeatable way, but this is good enough for a proof of concept.
system_profiler SPUSBDataType
(OSX)
lsusb
(linux)