Skip to content

Allow USB VID/PID to be overridden from the command line - #292

Open
vaulttec-dev wants to merge 1 commit into
polhenarejos:mainfrom
vaulttec-dev:fix/allow-usb-vid-pid-override
Open

vaulttec-dev wants to merge 1 commit into
polhenarejos:mainfrom
vaulttec-dev:fix/allow-usb-vid-pid-override

Conversation

@vaulttec-dev

Copy link
Copy Markdown

Problem

-DUSB_VID / -DUSB_PID have no effect: CMakeLists.txt assigns both
unconditionally at the top, before anything can override them.

On ESP-IDF there is a second path that looks like it should work —
picokeys_sdk_import.cmake reads CONFIG_TINYUSB_DESC_CUSTOM_VID — but it cannot:
CONFIG_* variables only exist after project(), and these assignments run before
it. Setting the values in sdkconfig therefore does nothing, and the build silently
keeps 2E8A:10FE.

Reproduced on ESP-IDF v5.5.5, target esp32s3: with
CONFIG_TINYUSB_DESC_USE_ESPRESSIF_VID=n and CONFIG_TINYUSB_DESC_CUSTOM_VID=0x1209
present in the generated sdkconfig, the build still reports
USB VID/PID: 0x2E8A:0x10FE.

This matters for anyone building their own device: the README notes that
distributing a binary under a VID/PID you do not own is not allowed, but the
documented way to change it does not work.

Fix

Guard the two assignments so an externally supplied value wins:

idf.py -DUSB_VID=0x1209 -DUSB_PID=0x0001 build

Defaults are unchanged, so existing builds behave exactly as before. The VIDPID=
presets keep working. Verified on esp32s3; the value now reaches the descriptor.

The ESP path resolved them from CONFIG_TINYUSB_DESC_CUSTOM_VID, but CONFIG_*
only exist after project(), while these assignments run before it, so the
sdkconfig values were always ignored. Guard the defaults instead so
-DUSB_VID/-DUSB_PID work on every target.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant