56
56
"espressif_esp32s3_devkitc_1_n8r8" ,
57
57
],
58
58
"0x303A:0x7009" : ["espressif_esp32s2_devkitc_1_n4" , "espressif_esp32s2_devkitc_1_n4r2" ],
59
+ "0x70010001:0x00100001" : ["ai_thinker_esp32-c3s" , "ai_thinker_esp32-c3s-2m" ],
59
60
}
60
61
61
- cli_parser = argparse .ArgumentParser (description = "USB VID/PID Duplicate Checker" )
62
+ cli_parser = argparse .ArgumentParser (
63
+ description = "USB VID/PID and Creator/Creation ID Duplicate Checker"
64
+ )
62
65
63
66
64
67
def configboard_files ():
@@ -71,29 +74,38 @@ def configboard_files():
71
74
return working_dir .glob ("ports/**/boards/**/mpconfigboard.mk" )
72
75
73
76
77
+ VID_PATTERN = re .compile (r"^USB_VID\s*=\s*(.*)" , flags = re .M )
78
+ PID_PATTERN = re .compile (r"^USB_PID\s*=\s*(.*)" , flags = re .M )
79
+ CREATOR_PATTERN = re .compile (r"^CIRCUITPY_CREATOR_ID\s*=\s*(.*)" , flags = re .M )
80
+ CREATION_PATTERN = re .compile (r"^CIRCUITPY_CREATION_ID\s*=\s*(.*)" , flags = re .M )
81
+
82
+
74
83
def check_vid_pid (files , clusterlist ):
75
84
"""Compiles a list of USB VID & PID values for all boards, and checks
76
85
for duplicates. Exits with ``sys.exit()`` (non-zero exit code)
77
86
if duplicates are found, and lists the duplicates.
78
87
"""
79
88
80
- vid_pattern = re .compile (r"^USB_VID\s*=\s*(.*)" , flags = re .M )
81
- pid_pattern = re .compile (r"^USB_PID\s*=\s*(.*)" , flags = re .M )
82
89
usb_pattern = re .compile (r"^CIRCUITPY_USB\s*=\s*0$|^IDF_TARGET = (esp32|esp32c3)$" , flags = re .M )
83
90
84
91
usb_ids = defaultdict (set )
85
92
for board_config in files :
86
93
src_text = board_config .read_text ()
87
94
88
- usb_vid = vid_pattern .search (src_text )
89
- usb_pid = pid_pattern .search (src_text )
95
+ usb_vid = VID_PATTERN .search (src_text )
96
+ usb_pid = PID_PATTERN .search (src_text )
97
+ creator = CREATOR_PATTERN .search (src_text )
98
+ creation = CREATION_PATTERN .search (src_text )
90
99
non_usb = usb_pattern .search (src_text )
91
100
board_name = board_config .parts [- 2 ]
92
101
93
102
if usb_vid and usb_pid :
94
103
id_group = f"0x{ int (usb_vid .group (1 ), 16 ):04X} :0x{ int (usb_pid .group (1 ), 16 ):04X} "
95
104
elif non_usb :
96
- continue
105
+ if creator is None or creation is None :
106
+ print (f"{ board_name = } { creator = } { creation = } " , file = sys .stderr )
107
+ continue
108
+ id_group = f"0x{ int (creator .group (1 ), 16 ):08X} :0x{ int (creation .group (1 ), 16 ):08X} "
97
109
else :
98
110
raise SystemExit (f"Could not find expected settings in { board_config } " )
99
111
@@ -117,18 +129,19 @@ def check_vid_pid(files, clusterlist):
117
129
duplicate_message = (
118
130
f"Duplicate VID/PID usage found!\n { duplicates } \n "
119
131
f"If you are open source maker, then you can request a PID from http://pid.codes\n "
132
+ f"For boards without native USB, you can request a Creator ID from https://github.com/creationid/creators/\n "
120
133
f"Otherwise, companies should pay the USB-IF for a vendor ID: https://www.usb.org/getting-vendor-id"
121
134
)
122
135
sys .exit (duplicate_message )
123
136
124
137
else :
125
- print ("No USB PID duplicates found." )
138
+ print ("No unexpected ID duplicates found." )
126
139
127
140
128
141
if __name__ == "__main__" :
129
142
arguments = cli_parser .parse_args ()
130
143
131
- print ("Running USB VID/PID Duplicate Checker..." )
144
+ print ("Running USB VID/PID and Creator/Creation ID Duplicate Checker..." )
132
145
133
146
board_files = configboard_files ()
134
147
check_vid_pid (board_files , DEFAULT_CLUSTERLIST )
0 commit comments