It is possible to change the USB VID and PID within the platformio.ini
instead of changing the IDs in the board .json file?
Any ideas? I think I have seen another post.
There is Redirecting...
However, it does not work for arrays.
So, extra scripting will help here Redirecting...
Thank you, good to know.
Found this thread through google and helped me out in getting my multiple arduinos set up for a flight sim. Hereās a summary of what I did from the link provided above:
- in platformIO locate āplatform.iniā in base project folder
- add āextra_scripts = pre:custon_hwids.pyā into āplatform.iniā.
- add a file into the main project folder and label it ācustom_hwids.pyā or anything as long as it matches what was added to āplatform.iniā
- the link provided input on changing VIDS and PIDS through a HWID array (first block is VIDS, second block is PIDS)
- you can also use board_config.update(ābuild.usb_productā, āRight Leoā) to relabel the board that windows sees.
Import(āenvā)
board_config = env.BoardConfig()
board_config.update(ābuild.hwidsā, [
[ā0x2341ā, ā0x2341ā, ā0x2A03ā, ā0x2A03ā], #VIDS
[ā0x0036ā, ā0x8036ā, ā0x0036ā, ā0x8036ā] #PIDS
])
board_config.update(ābuild.usb_productā, āRight Leoā)
Tried it with an Arduino Nano Every with no luck.
Well given the automatic upload logic
This should work. Can you fully describe your setup with the attached devices and corresponding PIDs, VIDs and product IDs? Also a log of pio run -t upload -v
?
It is an āArduino Nano Everyā, VID 2341, PID 0058
I want to change the PID to 0043 an the name ā#lighthackā
PIO version Home 3.0.1 and Core 4.1.0 and macOS Catalina 10.15.2
Where can I find the code in system?
Here the log:
sstaub1:#lighthack USB test sstaub$ pio run -t upload -v
Processing nano_every (platform: atmelmegaavr; board: nano_every; framework: arduino; extra_scripts: pre:custon_hwids.py)
---------------------------------------------------------------------------------------------------------------------------------------
CONFIGURATION: https://docs.platformio.org/page/boards/atmelmegaavr/nano_every.html
PLATFORM: Atmel megaAVR 1.0.0 > Arduino Nano Every
HARDWARE: ATMEGA4809 16MHz, 6KB RAM, 47.50KB Flash
PACKAGES: toolchain-atmelavr 1.70300.191015 (7.3.0), tool-avrdude-megaavr 1.60300.191015 (6.3.0), framework-arduino-megaavr 1.8.5
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 6 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <OSC> (/Users/sstaub/Dateien/Development/Arduino/#lighthack USB test/lib/OSC)
Building in release mode
MethodWrapper(["checkprogsize"], [".pio/build/nano_every/firmware.elf"])
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
DATA: [= ] 8.0% (used 489 bytes from 6144 bytes)
PROGRAM: [== ] 15.3% (used 7450 bytes from 48640 bytes)
.pio/build/nano_every/firmware.elf :
section size addr
.data 10 8398848
.text 7440 0
.rodata 167 23824
.bss 479 8398858
.comment 17 0
.note.gnu.avr.deviceinfo 64 0
.debug_aranges 480 0
.debug_info 12058 0
.debug_abbrev 9172 0
.debug_line 2899 0
.debug_str 3979 0
Total 36765
<lambda>(["upload"], [".pio/build/nano_every/firmware.hex"])
AVAILABLE: jtag2updi
CURRENT: upload_protocol = jtag2updi
BeforeUpload(["upload"], [".pio/build/nano_every/firmware.hex"])
Auto-detected: /dev/cu.usbmodem14301
Forcing reset using 1200bps open/close on port /dev/cu.usbmodem14301
Waiting for the new upload port...
avrdude -v -p atmega4809 -C /Users/sstaub/.platformio/packages/tool-avrdude-megaavr/avrdude.conf -c jtag2updi -D -V -b 115200 -e -P "/dev/cu.usbmodem14301" -U flash:w:.pio/build/nano_every/firmware.hex:i -Ufuse2:w:0x01:m -Ufuse5:w:0xC9:m -Ufuse8:w:0x00:m
avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "/Users/sstaub/.platformio/packages/tool-avrdude-megaavr/avrdude.conf"
User configuration file is "/Users/sstaub/.avrduderc"
User configuration file does not exist or is not a regular file, skipping
Using Port : /dev/cu.usbmodem14301
Using Programmer : jtag2updi
Overriding Baud Rate : 115200
JTAG ICE mkII sign-on message:
Communications protocol version: 1
M_MCU:
boot-loader FW version: 1
firmware version: 6.00
hardware version: 1
S_MCU:
boot-loader FW version: 1
firmware version: 6.00
hardware version: 1
Serial number: 00:00:00:00:00:00
Device ID: JTAGICE mkII
AVR Part : ATmega4809
Chip Erase delay : 0 us
PAGEL : P00
BS2 : P00
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 0
StabDelay : 0
CmdexeDelay : 0
SyncLoops : 0
ByteDelay : 0
PollIndex : 0
PollValue : 0x00
Memory Detail :
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
prodsig 0 0 0 0 no 61 61 0 0 0 0x00 0x00
fuses 0 0 0 0 no 9 0 0 0 0 0x00 0x00
fuse0 0 0 0 0 no 1 0 0 0 0 0x00 0x00
fuse1 0 0 0 0 no 1 0 0 0 0 0x00 0x00
fuse2 0 0 0 0 no 1 0 0 0 0 0x00 0x00
fuse4 0 0 0 0 no 1 0 0 0 0 0x00 0x00
fuse5 0 0 0 0 no 1 0 0 0 0 0x00 0x00
fuse6 0 0 0 0 no 1 0 0 0 0 0x00 0x00
fuse7 0 0 0 0 no 1 0 0 0 0 0x00 0x00
fuse8 0 0 0 0 no 1 0 0 0 0 0x00 0x00
lock 0 0 0 0 no 1 0 0 0 0 0x00 0x00
data 0 0 0 0 no 0 0 0 0 0 0x00 0x00
usersig 0 0 0 0 no 64 64 0 0 0 0x00 0x00
flash 0 0 0 0 no 49152 128 0 0 0 0x00 0x00
eeprom 0 0 0 0 no 256 64 0 0 0 0x00 0x00
Programmer Type : JTAGMKII_PDI
Description : JTAGv2 to UPDI bridge
M_MCU hardware version: 1
M_MCU firmware version: 6.00
S_MCU hardware version: 1
S_MCU firmware version: 6.00
Serial number: 00:00:00:00:00:00
Vtarget : 5.0 V
avrdude: jtagmkII_initialize(): Cannot locate "flash" and "boot" memories in description
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.27s
avrdude: Device signature = 0x1e9651 (probably m4809)
avrdude: erasing chip
avrdude: reading input file ".pio/build/nano_every/firmware.hex"
avrdude: writing flash (7618 bytes):
Writing | ################################################## | 100% 5.55s
avrdude: 7618 bytes of flash written
avrdude: reading input file "0x01"
avrdude: writing fuse2 (1 bytes):
Writing | ################################################## | 100% 0.01s
avrdude: 1 bytes of fuse2 written
avrdude: reading input file "0xC9"
avrdude: writing fuse5 (1 bytes):
Writing | ################################################## | 100% 0.01s
avrdude: 1 bytes of fuse5 written
avrdude: reading input file "0x00"
avrdude: writing fuse8 (1 bytes):
Writing | ################################################## | 100% 0.01s
avrdude: 1 bytes of fuse8 written
avrdude: safemode: Fuses OK (E:FF, H:FF, L:FF)
avrdude done. Thank you.
==================================================== [SUCCESS] Took 12.95 seconds ====================================================
sstaub1:#lighthack USB test sstaub$
The script changes the USB PIDs and VIDs to search for, not the PID and VID of the USB device. This is sent by the USB device in the USB descriptors and youād have to change the firmware or bootloader in order to change these values. Iām not sure where the bootloader for the Arduino Every is. I think the usecase for these scripts is that, given some devices with a customized VID/PID, you can all connect them at once and flash them in a targeted manner.
build.hwids
is incorrect in your case. See docs Redirecting...
It should be an array of [VID, PID]
pairs.
There is a general misunderstood, I want to change the VID/PID of a board itself, not the search for. When I understood right, this must be done by boot loader or other tools.
I was thinking that youād need to alter the bootloader like is done with some other boards, but it might be simpler than that. From the looks of the BSP for the megaAVR, the VID/PID are set compile time
I donāt have any of the boards, so canāt try itā¦ but perhaps set those two flags (or all four if you want) as platformio.ini
build_flags
and see if that changes themā¦ and if it does, youāll probably need to do the PID/VID override for platformio so that it recognises the new IDs.
This does not work, I tried first.
Same problems here as well.
Just to recap, hereās my platformio.ini
config:
[env:teensy2pp]
platform = teensy
board = teensy2pp
framework = arduino
build_flags = -D USB_HID
extra_scripts = pre:custon_hwids.py
and my custon_hwids.py
python script file:
Import("env")
board_config = env.BoardConfig()
# should be array of VID:PID pairs
board_config.update("build.hwids", [
["0x2341", "0x0243"] # VID, PID ?
])
I have reduced edits to the minimum and followed https://docs.platformio.org/en/latest/projectconf/advanced_scripting.html#override-board-configuration as suggested before but problem still persists.
When I type: lsusb
to see all my peripherals I cannot see anything like 2341:0243.
What am I doing wrong ?
PS: python 3.8.2, Arch Linux AMD64, latest PlatformIO inside latest VSCode to date (2020-05)
Thanks
Ben
Sure youāre not having the same misunderstanding? As it says above
Since youāre using Teensy 2 with the USB-HID code, the PID and VID is hardcoded for you.
Try to first change that in the soruce code (<home folder>\.platformio\package\framework-arduinoteensy\...
) and see if that works, then you can still do a custom platform_package
or script to change it on the fly.
Thanks @maxgerhardt, after careful reading your advice Iāve solved it.
Iām fine with current Teensy platform and Iām not that expert (yet) so instead of creating a custom platform_package
I have just altered usb_private.h
file. After my first successful attempt Iāve scripted it in platformio.ini
with something like:
extra_scripts = buildHooks.py
and a 10 lines script to change VID/PID before and after compilation
Hi @beninside
I have made a simple joystick and controller and have been trying to change the VID, PID, and name on the Teensy LC boards that are being used in them. I am a hardware guy and trying to figure this out is scrambling my brain. I changed the VID, PID, and name in the C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\usb_hid\usb_private.h file but have had no success in getting the boards to be identified properly. They both are just listed in the device manager as keyboard+mouse+joystick.
Do I have to add anything to the sketch? Iāve read about writing an .ini file but that is so far beyond me.
Iāve been searching for an answer for several weeks now but have yet to find an answer.
Sorry if this is such a noob request but can you help me out?
Thanks
John
Hi @doon1 ,
I have just changed VID,PID defines in usb_private.h
to see what happens and it worked, in the same files Iāve also seen descriptions and common information published when I need to collect some usb info (lsusb -v
with my OS, but youāll surely have something like that on Win as well). After that Iāve had some troubles with the Teensy Loader (GUI) and I manually need to reset the Teensy with its button to upload new code.
Now Iāve switched to the cli utility (adding a line in my platformio.ini project file) so when Visual Studio uploads everything I can see output on console without switching to other graphical programs. but Iāve reset VID/PID information to defaults, Iāll do some tests again when Iāll finish real code and real project.
In my final release Iād like to change device descriptions and VID:PID, Iād like to upload new code to device when needed and I donāt want to press reset button to do this. Iāll have more than one teensy device in a closed box without external reset buttons, each Teensy must have different VID:PIDs because theyāre doing different things and when I upload my code Iād like to upload to proper device. I still donāt know how to achieve that but hopefully Iāll find a way.
This is something Iāve already had with older AVR devices (ATMega 168,328,ā¦) with V-USB (gcc without Arduino) and avrdude without troubles, Iād like to do the same even if TeensyLoader doesnāt want it.
Still looking information for that, PlatformIO environment is complex but seems to be a really good tool I only need to get āsuggested wayā and keep it maintainable with more than one device.
Iāll share info when Iāll find something.