Skip to content

Commit 4f10f45

Browse files
committed
initrd: strip layout flags from flashprog wp invocations
flashprog wp subcommands (status, list, enable, disable, range) do not accept --ifd, -i <region>, or --image <region> layout flags. Boards like novacustom-v560tu/v540tu include these in CONFIG_FLASH_OPTIONS, causing 'unrecognized option' errors from check_spi_wp() and the config-gui WP status check. Strip --ifd, --image <region>, and -i <region> alongside --progress when building wp_opts in both flash.sh and config-gui.sh. Signed-off-by: Thierry Laurion <insurgo@riseup.net>
1 parent 3284a4a commit 4f10f45

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

initrd/bin/config-gui.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -708,9 +708,14 @@ while true; do
708708
;;
709709
"w")
710710
unset wp_out wp_title wp_opts
711-
# flashprog wp subcommand; strip binary and --progress (not accepted by wp)
711+
# flashprog wp subcommand; strip binary name, --progress, and layout
712+
# flags (--ifd, -i <region>) which wp subcommands do not accept.
712713
wp_opts="${CONFIG_FLASH_OPTIONS#flashprog}"
713-
wp_opts="${wp_opts//--progress/}"
714+
wp_opts="$(echo "$wp_opts" | \
715+
sed 's/--progress[[:space:]]*//' | \
716+
sed 's/--ifd[[:space:]]*//' | \
717+
sed 's/--image[[:space:]]*[a-z][a-z]*[[:space:]]*//g' | \
718+
sed 's/-i[[:space:]]*[a-z][a-z]*[[:space:]]*//g')"
714719
wp_out=$(flashprog wp status $wp_opts 2>&1) || true
715720
if echo "$wp_out" | grep -q "Protection mode: disabled"; then
716721
wp_title="SPI Write Protection: DISABLED"

initrd/bin/flash.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,14 @@ check_spi_wp() {
3636
TRACE_FUNC
3737
local wp_out wp_rc wp_opts
3838
flash_status "Checking SPI write protection status..."
39-
# Build 'flashprog wp status' args: strip binary name and --progress flag
39+
# Build 'flashprog wp status' args: strip binary name, --progress, and layout
40+
# flags (--ifd, -i <region>) which wp subcommands do not accept.
4041
wp_opts="${CONFIG_FLASH_OPTIONS#flashprog}"
41-
wp_opts="${wp_opts//--progress/}"
42+
wp_opts="$(echo "$wp_opts" | \
43+
sed 's/--progress[[:space:]]*//' | \
44+
sed 's/--ifd[[:space:]]*//' | \
45+
sed 's/--image[[:space:]]*[a-z][a-z]*[[:space:]]*//g' | \
46+
sed 's/-i[[:space:]]*[a-z][a-z]*[[:space:]]*//g')"
4247
wp_rc=0
4348
wp_out=$(flashprog wp status $wp_opts 2>&1) || wp_rc=$?
4449
echo "$wp_out"

0 commit comments

Comments
 (0)