diff --git a/Makefile.include b/Makefile.include index 8056a026f3..4a6ffc7769 100644 --- a/Makefile.include +++ b/Makefile.include @@ -662,6 +662,17 @@ endif @$(COLOR_ECHO) '$(COLOR_GREEN)Building application "$(APPLICATION)" for "$(BOARD)" with MCU "$(MCU)".$(COLOR_RESET)' @$(COLOR_ECHO) +# Exported for the benefit of Kconfig +export USB_VID_TESTING = 1209 +export USB_PID_TESTING = 7D01 +usb_id_check: + @if grep --quiet --ignore-case "^$(USB_VID) $(USB_PID)$$" $(RIOTBASE)/dist/usb_id_testing; then \ + $(COLOR_ECHO) "$(COLOR_RED)Private testing pid.codes USB VID/PID used!, do not use it outside of test environments!$(COLOR_RESET)" 1>&2 ; \ + $(COLOR_ECHO) "$(COLOR_RED)MUST NOT be used on any device redistributed, sold or manufactured, VID/PID is not unique!$(COLOR_RESET)" 1>&2 ; \ + fi +.PHONY: usb_id_check +all: | usb_id_check + # The `clean` needs to be serialized before everything else. all $(BASELIBS) $(BUILDDEPS) ..in-docker-container: | $(CLEAN) diff --git a/dist/usb_id_testing b/dist/usb_id_testing new file mode 100644 index 0000000000..289c267374 --- /dev/null +++ b/dist/usb_id_testing @@ -0,0 +1,20 @@ +# This file contains all codes that should trigger the usb_id_check warning +# about a test PID being used + +1209 0001 +1209 0002 +1209 0003 +1209 0004 +1209 0005 +1209 0006 +1209 0007 +1209 0008 +1209 0009 +1209 000a +1209 000b +1209 000c +1209 000d +1209 000e +1209 000f +1209 0010 +1209 7d01 diff --git a/examples/usbus_minimal/Kconfig b/examples/usbus_minimal/Kconfig deleted file mode 100644 index a31bf18547..0000000000 --- a/examples/usbus_minimal/Kconfig +++ /dev/null @@ -1,5 +0,0 @@ -config USB_VID - default 0x$(DEFAULT_VID) if KCONFIG_USB - -config USB_PID - default 0x$(DEFAULT_PID) if KCONFIG_USB diff --git a/examples/usbus_minimal/Makefile b/examples/usbus_minimal/Makefile index c4a0d293d4..21f182f584 100644 --- a/examples/usbus_minimal/Makefile +++ b/examples/usbus_minimal/Makefile @@ -16,10 +16,8 @@ USEMODULE += usbus USEMODULE += auto_init_usbus # USB device vendor and product ID -export DEFAULT_VID = 1209 -export DEFAULT_PID = 7D00 -USB_VID ?= $(DEFAULT_VID) -USB_PID ?= $(DEFAULT_PID) +USB_VID ?= $(USB_VID_TESTING) +USB_PID ?= $(USB_PID_TESTING) # Change this to 0 show compiler invocation lines by default: QUIET ?= 1 @@ -41,12 +39,3 @@ ifndef CONFIG_USB_PID else USB_PID = $(patsubst 0x%,%,$(CONFIG_USB_PID)) endif - -.PHONY: usb_id_check -usb_id_check: - @if [ $(USB_VID) = $(DEFAULT_VID) -o $(USB_PID) = $(DEFAULT_PID) ] ; then \ - $(COLOR_ECHO) "$(COLOR_RED)Private testing pid.codes USB VID/PID used!, do not use it outside of test environments!$(COLOR_RESET)" 1>&2 ; \ - $(COLOR_ECHO) "$(COLOR_RED)MUST NOT be used on any device redistributed, sold or manufactured, VID/PID is not unique!$(COLOR_RESET)" 1>&2 ; \ - fi - -all: | usb_id_check diff --git a/sys/usb/Kconfig b/sys/usb/Kconfig index d4a20f88b7..7317d14098 100644 --- a/sys/usb/Kconfig +++ b/sys/usb/Kconfig @@ -45,12 +45,14 @@ endchoice config USB_PID hex "Product ID" range 0x0000 0xFFFF + default 0x$(USB_PID_TESTING) if KCONFIG_USB help You must provide your own PID. config USB_VID hex "Vendor ID" range 0x0000 0xFFFF + default 0x$(USB_VID_TESTING) if KCONFIG_USB help You must provide your own VID. diff --git a/tests/usbus/Makefile b/tests/usbus/Makefile index 9d6340926c..43abe21364 100644 --- a/tests/usbus/Makefile +++ b/tests/usbus/Makefile @@ -6,20 +6,9 @@ FEATURES_PROVIDED += periph_usbdev DISABLE_MODULE += auto_init_usbus # USB device vendor and product ID -DEFAULT_VID = 1209 -DEFAULT_PID = 7D00 -USB_VID ?= $(DEFAULT_VID) -USB_PID ?= $(DEFAULT_PID) +USB_VID ?= $(USB_VID_TESTING) +USB_PID ?= $(USB_PID_TESTING) CFLAGS += -DCONFIG_USB_VID=0x$(USB_VID) -DCONFIG_USB_PID=0x$(USB_PID) include $(RIOTBASE)/Makefile.include - -.PHONY: usb_id_check -usb_id_check: - @if [ $(USB_VID) = $(DEFAULT_VID) ] || [ $(USB_PID) = $(DEFAULT_PID) ] ; then \ - $(COLOR_ECHO) "$(COLOR_RED)Private testing pid.codes USB VID/PID used!, do not use it outside of test environments!$(COLOR_RESET)" 1>&2 ; \ - $(COLOR_ECHO) "$(COLOR_RED)MUST NOT be used on any device redistributed, sold or manufactured, VID/PID is not unique!$(COLOR_RESET)" 1>&2 ; \ - fi - -all: | usb_id_check diff --git a/tests/usbus_cdc_acm_stdio/Makefile b/tests/usbus_cdc_acm_stdio/Makefile index 634bea9503..e3e13039a9 100644 --- a/tests/usbus_cdc_acm_stdio/Makefile +++ b/tests/usbus_cdc_acm_stdio/Makefile @@ -6,21 +6,4 @@ USEMODULE += shell USEMODULE += shell_commands USEMODULE += ps -# USB device vendor and product ID -DEFAULT_VID = 1209 -DEFAULT_PID = 7D00 -USB_VID ?= $(DEFAULT_VID) -USB_PID ?= $(DEFAULT_PID) - -CFLAGS += -DCONFIG_USB_VID=0x$(USB_VID) -DCONFIG_USB_PID=0x$(USB_PID) - include $(RIOTBASE)/Makefile.include - -.PHONY: usb_id_check -usb_id_check: - @if [ $(USB_VID) = $(DEFAULT_VID) ] || [ $(USB_PID) = $(DEFAULT_PID) ] ; then \ - $(COLOR_ECHO) "$(COLOR_RED)Private testing pid.codes USB VID/PID used!, do not use it outside of test environments!$(COLOR_RESET)" 1>&2 ; \ - $(COLOR_ECHO) "$(COLOR_RED)MUST NOT be used on any device redistributed, sold or manufactured, VID/PID is not unique!$(COLOR_RESET)" 1>&2 ; \ - fi - -all: | usb_id_check diff --git a/tests/usbus_cdc_ecm/Makefile b/tests/usbus_cdc_ecm/Makefile index 346b8cb0c3..ae7a94bb4d 100644 --- a/tests/usbus_cdc_ecm/Makefile +++ b/tests/usbus_cdc_ecm/Makefile @@ -9,36 +9,4 @@ USEMODULE += shell USEMODULE += shell_commands USEMODULE += ps -# USB device vendor and product ID -# pid.codes test VID/PID, not globally unique -export DEFAULT_VID = 1209 -export DEFAULT_PID = 7D00 -USB_VID ?= $(DEFAULT_VID) -USB_PID ?= $(DEFAULT_PID) - include $(RIOTBASE)/Makefile.include - -# Set USB VID/PID via CFLAGS if not being set via Kconfig -ifndef CONFIG_USB_VID - CFLAGS += -DCONFIG_USB_VID=0x$(USB_VID) -else - USB_VID = $(patsubst 0x%,%,$(CONFIG_USB_VID)) -endif - -ifndef CONFIG_USB_PID - CFLAGS += -DCONFIG_USB_PID=0x$(USB_PID) -else - USB_PID = $(patsubst 0x%,%,$(CONFIG_USB_PID)) -endif - -# There is a Kconfig in the app folder, we need to indicate not to run it by default -SHOULD_RUN_KCONFIG ?= - -.PHONY: usb_id_check -usb_id_check: - @if [ $(USB_VID) = $(DEFAULT_VID) -o $(USB_PID) = $(DEFAULT_PID) ] ; then \ - $(COLOR_ECHO) "$(COLOR_RED)Private testing pid.codes USB VID/PID used!, do not use it outside of test environments!$(COLOR_RESET)" 1>&2 ; \ - $(COLOR_ECHO) "$(COLOR_RED)MUST NOT be used on any device redistributed, sold or manufactured, VID/PID is not unique!$(COLOR_RESET)" 1>&2 ; \ - fi - -all: | usb_id_check