Merge pull request #2966 from sommersoft/ci_check_vid_pid
Automate USB VID/PID Uniqueness Check
This commit is contained in:
commit
4b827b25ad
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -91,6 +91,8 @@ jobs:
|
|||||||
- name: New boards check
|
- name: New boards check
|
||||||
run: python3 -u ci_new_boards_check.py
|
run: python3 -u ci_new_boards_check.py
|
||||||
working-directory: tools
|
working-directory: tools
|
||||||
|
- name: Duplicate USB VID/PID Check
|
||||||
|
run: python3 -u -m tools.ci_check_duplicate_usb_vid_pid
|
||||||
- name: Build mpy-cross.static-raspbian
|
- name: Build mpy-cross.static-raspbian
|
||||||
run: make -C mpy-cross -j2 -f Makefile.static-raspbian
|
run: make -C mpy-cross -j2 -f Makefile.static-raspbian
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v2
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
USB_VID = 0x239A
|
USB_VID = 0x239A
|
||||||
USB_PID = 0x8015
|
USB_PID = 0x80D3
|
||||||
USB_PRODUCT = "Feather M0 Adalogger"
|
USB_PRODUCT = "Feather M0 Adalogger"
|
||||||
USB_MANUFACTURER = "Adafruit Industries LLC"
|
USB_MANUFACTURER = "Adafruit Industries LLC"
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
USB_VID = 0x239A
|
USB_VID = 0x239A
|
||||||
USB_PID = 0x8023
|
USB_PID = 0x80D1
|
||||||
USB_PRODUCT = "Feather M0 Express"
|
USB_PRODUCT = "Feather M0 Express"
|
||||||
USB_MANUFACTURER = "Adafruit Industries LLC"
|
USB_MANUFACTURER = "Adafruit Industries LLC"
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
USB_VID = 0x239A
|
USB_VID = 0x239A
|
||||||
USB_PID = 0x8015
|
USB_PID = 0x80D2
|
||||||
USB_PRODUCT = "Feather M0 RFM69"
|
USB_PRODUCT = "Feather M0 RFM69"
|
||||||
USB_MANUFACTURER = "Adafruit Industries LLC"
|
USB_MANUFACTURER = "Adafruit Industries LLC"
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
USB_VID = 0x239A
|
USB_VID = 0x239A
|
||||||
USB_PID = 0x8015
|
USB_PID = 0x80D4
|
||||||
USB_PRODUCT = "Feather M0 RFM9x"
|
USB_PRODUCT = "Feather M0 RFM9x"
|
||||||
USB_MANUFACTURER = "Adafruit Industries LLC"
|
USB_MANUFACTURER = "Adafruit Industries LLC"
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
USB_VID = 0x239A
|
USB_VID = 0x239A
|
||||||
USB_PID = 0x8023
|
USB_PID = 0x80D0
|
||||||
USB_PRODUCT = "Feather RadioFruit Zigbee"
|
USB_PRODUCT = "Feather RadioFruit Zigbee"
|
||||||
USB_MANUFACTURER = "Adafruit Industries LLC"
|
USB_MANUFACTURER = "Adafruit Industries LLC"
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
USB_VID = 0x239A
|
USB_VID = 0x239A
|
||||||
USB_PID = 0x801D
|
USB_PID = 0x80D5
|
||||||
USB_PRODUCT = "PewPew 10.2"
|
USB_PRODUCT = "PewPew 10.2"
|
||||||
USB_MANUFACTURER = "Radomir Dopieralski"
|
USB_MANUFACTURER = "Radomir Dopieralski"
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
USB_VID = 0x239A
|
USB_VID = 0x239A
|
||||||
USB_PID = 0x801F
|
USB_PID = 0x80AF
|
||||||
USB_PRODUCT = "uGame10"
|
USB_PRODUCT = "uGame10"
|
||||||
USB_MANUFACTURER = "Radomir Dopieralski"
|
USB_MANUFACTURER = "Radomir Dopieralski"
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
USB_VID = 0x239A
|
USB_VID = 0x239A
|
||||||
USB_PID = 0x802A
|
USB_PID = 0x80DB
|
||||||
USB_PRODUCT = "TG-Watch02A"
|
USB_PRODUCT = "TG-Watch02A"
|
||||||
USB_MANUFACTURER = "TG-Tech"
|
USB_MANUFACTURER = "TG-Tech"
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
USB_VID = 0x239A
|
USB_VID = 0x239A
|
||||||
USB_PID = 0x803C
|
USB_PID = 0x80D7
|
||||||
USB_PRODUCT = "Blip"
|
USB_PRODUCT = "Blip"
|
||||||
USB_MANUFACTURER = "Electronut Labs"
|
USB_MANUFACTURER = "Electronut Labs"
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
USB_VID = 0x239A
|
USB_VID = 0x239A
|
||||||
USB_PID = 0x802A
|
USB_PID = 0x80DC
|
||||||
USB_PRODUCT = "nRF52840-MDK"
|
USB_PRODUCT = "nRF52840-MDK"
|
||||||
USB_MANUFACTURER = "makerdiary"
|
USB_MANUFACTURER = "makerdiary"
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
USB_VID = 0x239A
|
USB_VID = 0x239A
|
||||||
USB_PID = 0x802A
|
USB_PID = 0x80DD
|
||||||
USB_PRODUCT = "nRF52840-MDK-Dongle"
|
USB_PRODUCT = "nRF52840-MDK-Dongle"
|
||||||
USB_MANUFACTURER = "makerdiary"
|
USB_MANUFACTURER = "makerdiary"
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
USB_VID = 0x239A
|
USB_VID = 0x239A
|
||||||
USB_PID = 0x802A
|
USB_PID = 0x80DA
|
||||||
USB_PRODUCT = "PCA10056"
|
USB_PRODUCT = "PCA10056"
|
||||||
USB_MANUFACTURER = "Nordic Semiconductor"
|
USB_MANUFACTURER = "Nordic Semiconductor"
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
USB_VID = 0x239A
|
USB_VID = 0x239A
|
||||||
USB_PID = 0x802A
|
USB_PID = 0x80D9
|
||||||
USB_PRODUCT = "PCA10059"
|
USB_PRODUCT = "PCA10059"
|
||||||
USB_MANUFACTURER = "Nordic Semiconductor"
|
USB_MANUFACTURER = "Nordic Semiconductor"
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
USB_VID = 0x239A
|
USB_VID = 0x239A
|
||||||
USB_PID = 0x802A
|
USB_PID = 0x80D8
|
||||||
USB_PRODUCT = "PCA10100"
|
USB_PRODUCT = "PCA10100"
|
||||||
USB_MANUFACTURER = "Nordic Semiconductor"
|
USB_MANUFACTURER = "Nordic Semiconductor"
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
USB_VID = 0x239A
|
USB_VID = 0x239A
|
||||||
USB_PID = 0x805A
|
USB_PID = 0x80CF
|
||||||
USB_PRODUCT = "Meowbit"
|
USB_PRODUCT = "Meowbit"
|
||||||
USB_MANUFACTURER = "Kittenbot"
|
USB_MANUFACTURER = "Kittenbot"
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
USB_VID = 0x239A
|
USB_VID = 0x239A
|
||||||
USB_PID = 0x806A
|
USB_PID = 0x8069
|
||||||
USB_PRODUCT = "Thunderpack STM32F411"
|
USB_PRODUCT = "Thunderpack STM32F411"
|
||||||
USB_MANUFACTURER = "Jeremy Gillick"
|
USB_MANUFACTURER = "Jeremy Gillick"
|
||||||
|
|
||||||
|
146
tools/ci_check_duplicate_usb_vid_pid.py
Normal file
146
tools/ci_check_duplicate_usb_vid_pid.py
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
#
|
||||||
|
# This file is part of the MicroPython project, http://micropython.org/
|
||||||
|
#
|
||||||
|
# The MIT License (MIT)
|
||||||
|
#
|
||||||
|
# Copyright (c) 2020 Michael Schroeder
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import pathlib
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
DEFAULT_IGNORELIST = [
|
||||||
|
"circuitplayground_express",
|
||||||
|
"circuitplayground_express_crickit",
|
||||||
|
"circuitplayground_express_displayio",
|
||||||
|
"pycubed",
|
||||||
|
"pycubed_mram",
|
||||||
|
"pygamer",
|
||||||
|
"pygamer_advance",
|
||||||
|
"trinket_m0",
|
||||||
|
"trinket_m0_haxpress",
|
||||||
|
"sparkfun_qwiic_micro_with_flash",
|
||||||
|
"sparkfun_qwiic_micro_no_flash",
|
||||||
|
"feather_m0_express",
|
||||||
|
"feather_m0_supersized",
|
||||||
|
"cp32-m4",
|
||||||
|
"metro_m4_express"
|
||||||
|
]
|
||||||
|
|
||||||
|
cli_parser = argparse.ArgumentParser(description="USB VID/PID Duplicate Checker")
|
||||||
|
cli_parser.add_argument(
|
||||||
|
"--ignorelist",
|
||||||
|
dest="ignorelist",
|
||||||
|
nargs="?",
|
||||||
|
action="store",
|
||||||
|
default=DEFAULT_IGNORELIST,
|
||||||
|
help=(
|
||||||
|
"Board names to ignore duplicate VID/PID combinations. Pass an empty "
|
||||||
|
"string to disable all duplicate ignoring. Defaults are: "
|
||||||
|
f"{', '.join(DEFAULT_IGNORELIST)}"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def configboard_files():
|
||||||
|
""" A pathlib glob search for all ports/*/boards/*/mpconfigboard.mk file
|
||||||
|
paths.
|
||||||
|
|
||||||
|
:returns: A ``pathlib.Path.glob()`` genarator object
|
||||||
|
"""
|
||||||
|
working_dir = pathlib.Path().resolve()
|
||||||
|
if not working_dir.name.startswith("circuitpython"):
|
||||||
|
raise RuntimeError(
|
||||||
|
"Please run USB VID/PID duplicate verification at the "
|
||||||
|
"top-level directory."
|
||||||
|
)
|
||||||
|
return working_dir.glob("ports/**/boards/**/mpconfigboard.mk")
|
||||||
|
|
||||||
|
def check_vid_pid(files, ignorelist):
|
||||||
|
""" Compiles a list of USB VID & PID values for all boards, and checks
|
||||||
|
for duplicates. Exits with ``sys.exit()`` (non-zero exit code)
|
||||||
|
if duplicates are found, and lists the duplicates.
|
||||||
|
"""
|
||||||
|
|
||||||
|
duplicates_found = False
|
||||||
|
|
||||||
|
usb_ids = {}
|
||||||
|
|
||||||
|
vid_pattern = re.compile(r"^USB_VID\s*\=\s*(.*)", flags=re.M)
|
||||||
|
pid_pattern = re.compile(r"^USB_PID\s*\=\s*(.*)", flags=re.M)
|
||||||
|
|
||||||
|
for board_config in files:
|
||||||
|
src_text = board_config.read_text()
|
||||||
|
|
||||||
|
usb_vid = vid_pattern.search(src_text)
|
||||||
|
usb_pid = pid_pattern.search(src_text)
|
||||||
|
|
||||||
|
board_name = board_config.parts[-2]
|
||||||
|
|
||||||
|
board_ignorelisted = False
|
||||||
|
if board_name in ignorelist:
|
||||||
|
board_ignorelisted = True
|
||||||
|
board_name += " (ignorelisted)"
|
||||||
|
|
||||||
|
if usb_vid and usb_pid:
|
||||||
|
id_group = f"{usb_vid.group(1)}:{usb_pid.group(1)}"
|
||||||
|
if id_group not in usb_ids:
|
||||||
|
usb_ids[id_group] = {
|
||||||
|
"boards": [board_name],
|
||||||
|
"duplicate": False
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
usb_ids[id_group]['boards'].append(board_name)
|
||||||
|
if not board_ignorelisted:
|
||||||
|
usb_ids[id_group]['duplicate'] = True
|
||||||
|
duplicates_found = True
|
||||||
|
|
||||||
|
if duplicates_found:
|
||||||
|
duplicates = ""
|
||||||
|
for key, value in usb_ids.items():
|
||||||
|
if value["duplicate"]:
|
||||||
|
duplicates += (
|
||||||
|
f"- VID/PID: {key}\n"
|
||||||
|
f" Boards: {', '.join(value['boards'])}\n"
|
||||||
|
)
|
||||||
|
|
||||||
|
duplicate_message = (
|
||||||
|
f"Duplicate VID/PID usage found!\n{duplicates}\n"
|
||||||
|
f"If you are open source maker, then you can request a PID from http://pid.codes\n"
|
||||||
|
f"Otherwise, companies should pay the USB-IF for a vendor ID: https://www.usb.org/getting-vendor-id"
|
||||||
|
)
|
||||||
|
sys.exit(duplicate_message)
|
||||||
|
else:
|
||||||
|
print("No USB PID duplicates found.")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
arguments = cli_parser.parse_args()
|
||||||
|
|
||||||
|
print("Running USB VID/PID Duplicate Checker...")
|
||||||
|
print(
|
||||||
|
f"Ignoring the following boards: {', '.join(arguments.ignorelist)}",
|
||||||
|
end="\n\n"
|
||||||
|
)
|
||||||
|
|
||||||
|
board_files = configboard_files()
|
||||||
|
check_vid_pid(board_files, arguments.ignorelist)
|
Loading…
Reference in New Issue
Block a user