Skip to content

Commit a255559

Browse files
committed
fix(boards): Fix board validation script
1 parent 6aa7d51 commit a255559

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

.github/scripts/validate_board.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ validate_build_board_format() {
7474

7575
# Get the build.board value
7676
local build_board_value
77-
build_board_value=$(grep "^$board_name.build.board=" "$boards_file" | cut -d'=' -f2)
77+
build_board_value=$(grep "^$board_name.build.board=" "$boards_file" | cut -d'=' -f2 || true)
7878

7979
if [ -z "$build_board_value" ]; then
8080
print_error "build.board property not found for '$board_name'"
@@ -128,13 +128,13 @@ validate_partition_schemes() {
128128

129129
# Get all available flash sizes for this board
130130
local flash_sizes
131-
flash_sizes=$(grep "^$board_name.menu.FlashSize\." "$boards_file" | grep "\.build\.flash_size=" | cut -d'=' -f2 | sort -V)
131+
flash_sizes=$(grep "^$board_name.menu.FlashSize\." "$boards_file" | grep "\.build\.flash_size=" | cut -d'=' -f2 | sort -V || true)
132132

133133
# Check if board has menu.FlashSize entries
134134
if [ -z "$flash_sizes" ]; then
135135
# If no menu.FlashSize entries, check if board has build.flash_size entry at least
136136
local has_flash_size
137-
has_flash_size=$(grep "^$board_name\." "$boards_file" | grep "\.build\.flash_size=" | head -1)
137+
has_flash_size=$(grep "^$board_name\." "$boards_file" | grep "\.build\.flash_size=" | head -1 || true)
138138

139139
if [ -z "$has_flash_size" ]; then
140140
print_error "No flash size options found for board '$board_name' (needs build.flash_size entry at least)"
@@ -167,7 +167,7 @@ validate_partition_schemes() {
167167

168168
# Find all partition schemes for this board
169169
local partition_schemes
170-
partition_schemes=$(grep "^$board_name.menu.PartitionScheme\." "$boards_file" | grep -v "\.build\." | grep -v "\.upload\." | sed 's/.*\.PartitionScheme\.\([^=]*\)=.*/\1/' | sort -u)
170+
partition_schemes=$(grep "^$board_name.menu.PartitionScheme\." "$boards_file" | grep -v "\.build\." | grep -v "\.upload\." | sed 's/.*\.PartitionScheme\.\([^=]*\)=.*/\1/' | sort -u || true)
171171

172172
if [ -n "$partition_schemes" ]; then
173173
# Validate each partition scheme against the maximum flash size
@@ -340,7 +340,7 @@ validate_scheme_upload_size() {
340340

341341
# Get upload maximum size for this specific scheme
342342
local upload_size
343-
upload_size=$(grep "^$board_name.menu.PartitionScheme\.$scheme\." "$boards_file" | grep "\.upload\.maximum_size=" | head -1 | cut -d'=' -f2)
343+
upload_size=$(grep "^$board_name.menu.PartitionScheme\.$scheme\." "$boards_file" | grep "\.upload\.maximum_size=" | head -1 | cut -d'=' -f2 || true)
344344

345345
if [ -z "$upload_size" ]; then
346346
echo " ✓ Partition scheme '$scheme' is valid for ${max_flash_mb}MB flash (no upload size limit)"
@@ -370,15 +370,15 @@ validate_vid_pid_consistency() {
370370
local vid_entries
371371
local pid_entries
372372

373-
vid_entries=$(grep "^$board_name\.vid\." "$boards_file" | sort)
374-
pid_entries=$(grep "^$board_name\.pid\." "$boards_file" | sort)
373+
vid_entries=$(grep "^$board_name\.vid\." "$boards_file" | sort || true)
374+
pid_entries=$(grep "^$board_name\.pid\." "$boards_file" | sort || true)
375375

376376
# Also get upload_port VID and PID entries
377377
local upload_port_vid_entries
378378
local upload_port_pid_entries
379379

380-
upload_port_vid_entries=$(grep "^$board_name\.upload_port\..*\.vid=" "$boards_file" | sort)
381-
upload_port_pid_entries=$(grep "^$board_name\.upload_port\..*\.pid=" "$boards_file" | sort)
380+
upload_port_vid_entries=$(grep "^$board_name\.upload_port\..*\.vid=" "$boards_file" | sort || true)
381+
upload_port_pid_entries=$(grep "^$board_name\.upload_port\..*\.pid=" "$boards_file" | sort || true)
382382

383383
# Check for duplicate VID entries with same index but different values
384384
local all_vid_entries="$vid_entries"
@@ -458,7 +458,7 @@ $upload_pid_indices"
458458

459459
# Find corresponding PID
460460
local pid_value
461-
pid_value=$(grep "^$board_name\.pid\.$vid_index=" "$boards_file" | cut -d'=' -f2)
461+
pid_value=$(grep "^$board_name\.pid\.$vid_index=" "$boards_file" | cut -d'=' -f2 || true)
462462

463463
if [ "$vid_value" = "$esp32_family_vid" ] && [ "$pid_value" = "$esp32_family_pid" ]; then
464464
print_error "Board '$board_name' VID/PID combination ($vid_value/$pid_value) matches esp32_family VID/PID (0x303a/0x1001) - this is not allowed"
@@ -477,7 +477,7 @@ $upload_pid_indices"
477477

478478
# Find corresponding PID
479479
local pid_value
480-
pid_value=$(grep "^$board_name\.upload_port\.$vid_index\.pid=" "$boards_file" | cut -d'=' -f2)
480+
pid_value=$(grep "^$board_name\.upload_port\.$vid_index\.pid=" "$boards_file" | cut -d'=' -f2 || true)
481481

482482
if [ "$vid_value" = "$esp32_family_vid" ] && [ "$pid_value" = "$esp32_family_pid" ]; then
483483
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"
@@ -525,7 +525,7 @@ validate_debug_level_menu() {
525525
for level in "${required_debug_levels[@]}"; do
526526
local expected_value="${code_debug_values[$debug_level_index]}"
527527
local actual_value
528-
actual_value=$(grep "^$board_name.menu.DebugLevel.$level.build.code_debug=" "$boards_file" | cut -d'=' -f2)
528+
actual_value=$(grep "^$board_name.menu.DebugLevel.$level.build.code_debug=" "$boards_file" | cut -d'=' -f2 || true)
529529

530530
if [ "$actual_value" != "$expected_value" ]; then
531531
print_error "Invalid code_debug value for DebugLevel '$level' in board '$board_name': expected '$expected_value', found '$actual_value'"

0 commit comments

Comments
 (0)