From c1dfdd92b073113065bc77042b6c302379aba51d Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Thu, 17 Oct 2024 15:13:49 +0200 Subject: [PATCH] uboot: Fix repeated calls to boot_net in combination with HTTP Previously, when the `proto://path` format of `bootfile` was used, the transformed argument sent to either tftp or wget would also be stored in `bootfile` overriding the original value set by the user. If the first boot attempt failed for some reason, the protocol information was stripped from `bootfile` and the second attempt would then default to TFTP, even if the user had originally specified `http://...`. Therefore, store the transformed value in a separate variable. For some reason, setexpr's parsing of regex escapes changes when this mode is used, so we need double backslashes to fetch match groups instead of 1. Yikes. Fixes #724 --- board/common/uboot/scripts/ixprepdhcp.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/board/common/uboot/scripts/ixprepdhcp.sh b/board/common/uboot/scripts/ixprepdhcp.sh index 4d89d543..93e6c97a 100644 --- a/board/common/uboot/scripts/ixprepdhcp.sh +++ b/board/common/uboot/scripts/ixprepdhcp.sh @@ -3,17 +3,18 @@ setenv autoload no if test -n "${ipaddr}" || dhcp; then setenv proto tftp setenv dltool tftpboot + setenv dlfile "${bootfile}" if setexpr proto sub "^(http|tftp)://.*" "\\1" "${bootfile}"; then if test "${proto}" = "http"; then setenv dltool wget - setexpr bootfile sub "^http://([^/]+?)/(.*)" "\1:/\2" + setexpr dlfile sub "^http://([^/]+?)/(.*)" "\\1:/\\2" "${bootfile}" else - setexpr bootfile sub "^tftp://([^/]+?)/(.*)" "\1:\2" + setexpr dlfile sub "^tftp://([^/]+?)/(.*)" "\\1:\\2" "${bootfile}" fi fi - if ${dltool} ${ramdisk_addr_r} "${bootfile}"; then + if ${dltool} ${ramdisk_addr_r} "${dlfile}"; then setenv old_fdt_addr ${fdt_addr} if fdt addr ${ramdisk_addr_r}; then fdt get value sqoffs /images/rootfs data-position