1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

usb: Use separate Makefile for configuration and checks

This commit is contained in:
chrysn 2020-02-17 09:30:42 +01:00
parent c0cc03a09a
commit a181c0dbcd
2 changed files with 36 additions and 34 deletions

View File

@ -662,40 +662,6 @@ endif
@$(COLOR_ECHO) '$(COLOR_GREEN)Building application "$(APPLICATION)" for "$(BOARD)" with MCU "$(MCU)".$(COLOR_RESET)'
@$(COLOR_ECHO)
# Set USB VID/PID via CFLAGS if not being set via Kconfig
ifndef CONFIG_USB_VID
ifdef USB_VID
CFLAGS += -DCONFIG_USB_VID=0x$(USB_VID)
endif
else
USB_VID = $(patsubst 0x%,%,$(CONFIG_USB_VID))
endif
ifndef CONFIG_USB_PID
ifdef USB_PID
CFLAGS += -DCONFIG_USB_PID=0x$(USB_PID)
endif
else
USB_PID = $(patsubst 0x%,%,$(CONFIG_USB_PID))
endif
# 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
@if [ "$(USB_VID) $(subst D,d,$(USB_PID))" = "1209 7d00" ]; then \
$(COLOR_ECHO) "$(COLOR_RED)RIOT standard peripherals code (1209/7D00) cannot be set explicitly.$(COLOR_RESET)" 1>&2 ; \
$(COLOR_ECHO) "$(COLOR_RED)Unset USB_VID / USB_PID for the code to be picked automatically, or set$(COLOR_RESET)" 1>&2 ; \
$(COLOR_ECHO) "$(COLOR_RED)them to \$${USB_VID_TESTING} / \$${USB_PID_TESTING} during development.$(COLOR_RESET)" 1>&2 ; \
exit 1; \
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)
@ -839,6 +805,9 @@ include $(RIOTMAKE)/vars.inc.mk
# Include build targets for selected tools
include $(RIOTMAKE)/tools/targets.inc.mk
# Checks and defaults for USB Vendor and Product ID
include $(RIOTMAKE)/usb-codes.inc.mk
# Warn if the selected board and drivers don't provide all needed features:
ifneq (, $(filter all flash, $(if $(MAKECMDGOALS), $(MAKECMDGOALS), all)))
EXPECT_ERRORS :=

View File

@ -0,0 +1,33 @@
# Set USB VID/PID via CFLAGS if not being set via Kconfig
ifndef CONFIG_USB_VID
ifdef USB_VID
CFLAGS += -DCONFIG_USB_VID=0x$(USB_VID)
endif
else
USB_VID = $(patsubst 0x%,%,$(CONFIG_USB_VID))
endif
ifndef CONFIG_USB_PID
ifdef USB_PID
CFLAGS += -DCONFIG_USB_PID=0x$(USB_PID)
endif
else
USB_PID = $(patsubst 0x%,%,$(CONFIG_USB_PID))
endif
# 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
@if [ "$(USB_VID) $(subst D,d,$(USB_PID))" = "1209 7d00" ]; then \
$(COLOR_ECHO) "$(COLOR_RED)RIOT standard peripherals code (1209/7D00) cannot be set explicitly.$(COLOR_RESET)" 1>&2 ; \
$(COLOR_ECHO) "$(COLOR_RED)Unset USB_VID / USB_PID for the code to be picked automatically, or set$(COLOR_RESET)" 1>&2 ; \
$(COLOR_ECHO) "$(COLOR_RED)them to \$${USB_VID_TESTING} / \$${USB_PID_TESTING} during development.$(COLOR_RESET)" 1>&2 ; \
exit 1; \
fi
.PHONY: usb_id_check
all: | usb_id_check