Skip to content

Commit abcfcbc

Browse files
committed
ci: Add rule for duplicate lines and extend vid/pid rule
1 parent c009640 commit abcfcbc

File tree

3 files changed

+210
-5
lines changed

3 files changed

+210
-5
lines changed

.github/scripts/validate_board.sh

Lines changed: 131 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ validate_board() {
5252
validate_debug_level_menu "$board_name" "$boards_file"
5353
echo ""
5454

55+
# Rule 6: Check for duplicate lines
56+
echo "Rule 6: Duplicate Lines Validation"
57+
echo "=================================="
58+
validate_no_duplicates "$board_name" "$boards_file"
59+
echo ""
60+
5561
# Add more validation rules here as needed
5662
echo "=========================================="
5763
print_success "ALL VALIDATION RULES PASSED for board '$board_name'"
@@ -112,6 +118,7 @@ validate_required_properties() {
112118
echo " ✓ Required properties validation completed"
113119
}
114120

121+
115122
# Rule 3: Check for valid partition schemes for available flash sizes
116123
validate_partition_schemes() {
117124
local board_name="$1"
@@ -352,16 +359,29 @@ validate_vid_pid_consistency() {
352359
local board_name="$1"
353360
local boards_file="$2"
354361

355-
# Get all VID and PID entries for this board
362+
# Get all VID and PID entries for this board (including upload_port entries)
356363
local vid_entries
357364
local pid_entries
358365

359366
vid_entries=$(grep "^$board_name\.vid\." "$boards_file" | sort)
360367
pid_entries=$(grep "^$board_name\.pid\." "$boards_file" | sort)
361368

369+
# Also get upload_port VID and PID entries
370+
local upload_port_vid_entries
371+
local upload_port_pid_entries
372+
373+
upload_port_vid_entries=$(grep "^$board_name\.upload_port\..*\.vid=" "$boards_file" | sort)
374+
upload_port_pid_entries=$(grep "^$board_name\.upload_port\..*\.pid=" "$boards_file" | sort)
375+
362376
# Check for duplicate VID entries with same index but different values
377+
local all_vid_entries="$vid_entries"
378+
if [ -n "$upload_port_vid_entries" ]; then
379+
all_vid_entries="$all_vid_entries
380+
$upload_port_vid_entries"
381+
fi
382+
363383
local vid_duplicates
364-
vid_duplicates=$(echo "$vid_entries" | cut -d'=' -f1 | sort | uniq -d)
384+
vid_duplicates=$(echo "$all_vid_entries" | cut -d'=' -f1 | sort | uniq -d)
365385

366386
if [ -n "$vid_duplicates" ]; then
367387
print_error "Found duplicate VID entries with different values for board '$board_name':"
@@ -370,8 +390,14 @@ validate_vid_pid_consistency() {
370390
fi
371391

372392
# Check for duplicate PID entries with same index but different values
393+
local all_pid_entries="$pid_entries"
394+
if [ -n "$upload_port_pid_entries" ]; then
395+
all_pid_entries="$all_pid_entries
396+
$upload_port_pid_entries"
397+
fi
398+
373399
local pid_duplicates
374-
pid_duplicates=$(echo "$pid_entries" | cut -d'=' -f1 | sort | uniq -d)
400+
pid_duplicates=$(echo "$all_pid_entries" | cut -d'=' -f1 | sort | uniq -d)
375401

376402
if [ -n "$pid_duplicates" ]; then
377403
print_error "Found duplicate PID entries with different values for board '$board_name':"
@@ -383,8 +409,26 @@ validate_vid_pid_consistency() {
383409
local vid_indices
384410
local pid_indices
385411

386-
vid_indices=$(echo "$vid_entries" | cut -d'=' -f1 | sed "s/^$board_name\.vid\.//" | sort -n)
387-
pid_indices=$(echo "$pid_entries" | cut -d'=' -f1 | sed "s/^$board_name\.pid\.//" | sort -n)
412+
# Get indices from regular vid/pid entries
413+
local regular_vid_indices=$(echo "$vid_entries" | cut -d'=' -f1 | sed "s/^$board_name\.vid\.//" | sort -n)
414+
local regular_pid_indices=$(echo "$pid_entries" | cut -d'=' -f1 | sed "s/^$board_name\.pid\.//" | sort -n)
415+
416+
# Get indices from upload_port entries
417+
local upload_vid_indices=$(echo "$upload_port_vid_entries" | cut -d'=' -f1 | sed "s/^$board_name\.upload_port\.//" | sed "s/\.vid$//" | sort -n)
418+
local upload_pid_indices=$(echo "$upload_port_pid_entries" | cut -d'=' -f1 | sed "s/^$board_name\.upload_port\.//" | sed "s/\.pid$//" | sort -n)
419+
420+
# Combine indices
421+
vid_indices="$regular_vid_indices"
422+
if [ -n "$upload_vid_indices" ]; then
423+
vid_indices="$vid_indices
424+
$upload_vid_indices"
425+
fi
426+
427+
pid_indices="$regular_pid_indices"
428+
if [ -n "$upload_pid_indices" ]; then
429+
pid_indices="$pid_indices
430+
$upload_pid_indices"
431+
fi
388432

389433
# Check if VID and PID indices match
390434
if [ "$vid_indices" != "$pid_indices" ]; then
@@ -394,6 +438,48 @@ validate_vid_pid_consistency() {
394438
exit 1
395439
fi
396440

441+
# Check that no VID/PID combination matches esp32_family (0x303a/0x1001)
442+
local esp32_family_vid="0x303a"
443+
local esp32_family_pid="0x1001"
444+
445+
# Check regular vid/pid entries
446+
if [ -n "$vid_entries" ] && [ -n "$pid_entries" ]; then
447+
while IFS= read -r vid_line; do
448+
if [ -n "$vid_line" ]; then
449+
local vid_index=$(echo "$vid_line" | cut -d'=' -f1 | sed "s/^$board_name\.vid\.//")
450+
local vid_value=$(echo "$vid_line" | cut -d'=' -f2)
451+
452+
# Find corresponding PID
453+
local pid_value
454+
pid_value=$(grep "^$board_name\.pid\.$vid_index=" "$boards_file" | cut -d'=' -f2)
455+
456+
if [ "$vid_value" = "$esp32_family_vid" ] && [ "$pid_value" = "$esp32_family_pid" ]; then
457+
print_error "Board '$board_name' VID/PID combination ($vid_value/$pid_value) matches esp32_family VID/PID (0x303a/0x1001) - this is not allowed"
458+
exit 1
459+
fi
460+
fi
461+
done <<< "$vid_entries"
462+
fi
463+
464+
# Check upload_port vid/pid entries
465+
if [ -n "$upload_port_vid_entries" ] && [ -n "$upload_port_pid_entries" ]; then
466+
while IFS= read -r vid_line; do
467+
if [ -n "$vid_line" ]; then
468+
local vid_index=$(echo "$vid_line" | cut -d'=' -f1 | sed "s/^$board_name\.upload_port\.//" | sed "s/\.vid$//")
469+
local vid_value=$(echo "$vid_line" | cut -d'=' -f2)
470+
471+
# Find corresponding PID
472+
local pid_value
473+
pid_value=$(grep "^$board_name\.upload_port\.$vid_index\.pid=" "$boards_file" | cut -d'=' -f2)
474+
475+
if [ "$vid_value" = "$esp32_family_vid" ] && [ "$pid_value" = "$esp32_family_pid" ]; then
476+
print_error "Board '$board_name' upload_port VID/PID combination ($vid_value/$pid_value) matches esp32_family VID/PID (0x303a/0x1001) - this is not allowed"
477+
exit 1
478+
fi
479+
fi
480+
done <<< "$upload_port_vid_entries"
481+
fi
482+
397483
echo " ✓ VID and PID consistency check passed"
398484
}
399485

@@ -445,6 +531,46 @@ validate_debug_level_menu() {
445531
echo " ✓ DebugLevel menu validation completed"
446532
}
447533

534+
# Rule 6: Check for duplicate lines
535+
validate_no_duplicates() {
536+
local board_name="$1"
537+
local boards_file="$2"
538+
539+
# Get all lines for this board
540+
local board_lines
541+
board_lines=$(grep "^$board_name\." "$boards_file")
542+
543+
# Extract just the property names (before =)
544+
local property_names
545+
property_names=$(echo "$board_lines" | cut -d'=' -f1)
546+
547+
# Find duplicates
548+
local duplicate_lines
549+
duplicate_lines=$(echo "$property_names" | sort | uniq -d)
550+
551+
if [ -n "$duplicate_lines" ]; then
552+
print_error "Found duplicate lines for board '$board_name':"
553+
echo "Duplicate line keys:"
554+
echo "$duplicate_lines"
555+
556+
echo "Duplicate content details:"
557+
while IFS= read -r line_key; do
558+
if [ -n "$line_key" ]; then
559+
echo " Key: $line_key"
560+
echo " Content with line numbers:"
561+
local key_only=$(echo "$line_key" | cut -d'=' -f1)
562+
grep -n "^$key_only=" "$boards_file" | while IFS=':' read -r line_num full_line; do
563+
echo " Line $line_num: $full_line"
564+
done
565+
echo ""
566+
fi
567+
done <<< "$duplicate_lines"
568+
exit 1
569+
fi
570+
571+
echo " ✓ No duplicate lines found"
572+
}
573+
448574
# Main execution
449575
main() {
450576
if [ $# -ne 1 ]; then
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
=== BOARD VALIDATION ERROR SUMMARY ===
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
=== BOARD VALIDATION ERROR SUMMARY ===
2+
Generated on: $(date)
3+
4+
=== OVERALL STATISTICS ===
5+
Total boards tested: 354
6+
Failed boards: 45
7+
Passed boards: 309
8+
9+
=== ERROR CATEGORIES ===
10+
11+
1. BUILD.BOARD FORMAT ERRORS (Rule 1) - 37 boards:
12+
- ttgo-lora32: contains 'ao' (only A-Z, 0-9, and _ allowed)
13+
- ttgo-t7-v13-mini32: contains 'in' (only A-Z, 0-9, and _ allowed)
14+
- ttgo-t7-v14-mini32: contains 'in' (only A-Z, 0-9, and _ allowed)
15+
- ttgo-t-oi-plus: contains '-' (only A-Z, 0-9, and _ allowed)
16+
- pocket_32: contains 'cekot' (only A-Z, 0-9, and _ allowed)
17+
- WeMosBat: contains 'cekot' (only A-Z, 0-9, and _ allowed)
18+
- espea32: contains 'ae' (only A-Z, 0-9, and _ allowed)
19+
- node32s: contains 'deos' (only A-Z, 0-9, and _ allowed)
20+
- dfrobot_beetle_esp32c3: contains 'eetle' (only A-Z, 0-9, and _ allowed)
21+
- dfrobot_beetle_esp32c6: contains 'eetle' (only A-Z, 0-9, and _ allowed)
22+
- dfrobot_firebeetle2_esp32c6: contains 'eetle' (only A-Z, 0-9, and _ allowed)
23+
- adafruit_feather_esp32c6: contains 'eather' (only A-Z, 0-9, and _ allowed)
24+
- nologo_esp32c3_super_mini: contains 'uper' (only A-Z, 0-9, and _ allowed)
25+
- nologo_esp32s3_pico: contains 'ico' (only A-Z, 0-9, and _ allowed)
26+
- esp32vn-iot-uno: contains 'n-iot-uno' (only A-Z, 0-9, and _ allowed)
27+
- esp32-devkitlipo: contains 'evkitlipo' (only A-Z, 0-9, and _ allowed)
28+
- espino32: contains 'pino' (only A-Z, 0-9, and _ allowed)
29+
- m5stack_stickc: contains 'tickc' (only A-Z, 0-9, and _ allowed)
30+
- m5stack_stickc_plus: contains 'tickc' (only A-Z, 0-9, and _ allowed)
31+
- m5stack_stickc_plus2: contains 'tickc' (only A-Z, 0-9, and _ allowed)
32+
- m5stack_atom: contains 'tom' (only A-Z, 0-9, and _ allowed)
33+
- m5stack_atoms3: contains 'toms' (only A-Z, 0-9, and _ allowed)
34+
- m5stack_timer_cam: contains 'imer' (only A-Z, 0-9, and _ allowed)
35+
- m5stack_unit_cam: contains 'nit' (only A-Z, 0-9, and _ allowed)
36+
- m5stack_poe_cam: contains 'oe' (only A-Z, 0-9, and _ allowed)
37+
- m5stack_coreink: contains 'oreink' (only A-Z, 0-9, and _ allowed)
38+
- m5stack_stamp_pico: contains 'tamp' (only A-Z, 0-9, and _ allowed)
39+
- heltec_wifi_lora_32: contains 'ifi' (only A-Z, 0-9, and _ allowed)
40+
- CoreESP32: contains 'ore' (only A-Z, 0-9, and _ allowed)
41+
- t-beam: contains 'eam' (only A-Z, 0-9, and _ allowed)
42+
- d-duino-32: contains 'duino-32' (only A-Z, 0-9, and _ allowed)
43+
- lopy: contains 'opy' (only A-Z, 0-9, and _ allowed)
44+
- lopy4: contains 'opy' (only A-Z, 0-9, and _ allowed)
45+
- fm-devkit: contains 'evkit' (only A-Z, 0-9, and _ allowed)
46+
- twatch: contains 'atch' (only A-Z, 0-9, and _ allowed)
47+
- piranha_esp-32: contains 'anha' (only A-Z, 0-9, and _ allowed)
48+
- metro_esp-32: contains 'tro' (only A-Z, 0-9, and _ allowed)
49+
- sensesiot_weizen: contains 'eizen' (only A-Z, 0-9, and _ allowed)
50+
- mPython: contains 'ython' (only A-Z, 0-9, and _ allowed)
51+
52+
2. PARTITION SCHEME SIZE ERRORS (Rule 3) - 2 boards:
53+
- esp32wrover: default_8MB (8MB) exceeds 4MB flash
54+
- pico32: custom upload size (16MB) exceeds 4MB flash
55+
56+
3. DUPLICATE LINES (Rule 6) - 4 boards:
57+
- esp32s3-octal: duplicate esp32s3-octal.menu.FlashSize.16M
58+
- lolin_s2_mini: duplicate lolin_s2_mini.build.defines
59+
- lolin_s2_pico: duplicate lolin_s2_pico.build.defines
60+
- heltec_wifi_lora_32: duplicate heltec_wifi_lora_32.menu.CPUFreq.160.build.f_cpu
61+
62+
4. MISSING REQUIRED PROPERTIES (Rule 2) - 2 boards:
63+
- Bee_Data_Logger: Missing upload.flags, upload.extra_flags
64+
- Bee_Motion_S3: Missing upload.flags, upload.extra_flags
65+
66+
=== SUMMARY ===
67+
- 37 boards have invalid build.board format (contains lowercase letters, hyphens, or special characters)
68+
- 2 boards have partition schemes that exceed their available flash memory
69+
- 4 boards have duplicate property definitions
70+
- 2 boards are missing required upload properties
71+
- Most common issue: build.board values contain lowercase letters instead of uppercase
72+
73+
=== RECOMMENDATIONS ===
74+
1. Fix build.board values to use only uppercase letters, numbers, and underscores
75+
2. Remove or adjust partition schemes that don't fit the board's flash capacity
76+
3. Remove duplicate entries from boards.txt
77+
4. Add missing upload properties for affected boards
78+

0 commit comments

Comments
 (0)