[OpenWrt-Devel] [PATCH] upgrade: nand: fix board_name assumtions

Jeff Kletsky lede at allycomm.com
Mon May 20 06:42:33 PDT 2019


cc-ing primary Imgtec / pistachio / Creator Ci40 contributors identified

On 5/20/19 3:14 AM, Bjørn Mork wrote:

> nand_do_platform_check assumes that the current board name is
> used as-is in the tar file sysupgrade directory.  This fails
> for any image supporting multiple device names, and it also
> fails if the board_name contains a comma.
>
> Signed-off-by: Bjørn Mork <bjorn at mork.no>
> ---
> This is a local workaround I'va had lying around for a while.  Please
> consider if it makes any sense at all, or if there are better ways
> to solve the problem.
>
> I don't have an actual upstreamed usecase, as this is an issue I've
> met while trying to prepare for a never-finished ZyXEL WAP6805
> support...
>
>
>
> Bjørn
>
>   package/base-files/files/lib/upgrade/nand.sh | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/package/base-files/files/lib/upgrade/nand.sh b/package/base-files/files/lib/upgrade/nand.sh
> index 99916a4e96fc..14856357989e 100644
> --- a/package/base-files/files/lib/upgrade/nand.sh
> +++ b/package/base-files/files/lib/upgrade/nand.sh
> @@ -320,7 +320,9 @@ nand_do_upgrade() {
>   nand_do_platform_check() {
>   	local board_name="$1"
>   	local tar_file="$2"
> -	local control_length=`(tar xf $tar_file sysupgrade-$board_name/CONTROL -O | wc -c) 2> /dev/null`
> +	local board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$')
> +	board_dir=${board_dir%/}
> +	local control_length=`(tar xf $tar_file ${board_dir}/CONTROL -O | wc -c) 2> /dev/null`
>   	local file_type="$(identify $2)"
>   
>   	[ "$control_length" = 0 -a "$file_type" != "ubi" -a "$file_type" != "ubifs" ] && {
>
Your timing as good as I've been wrestling with this as well
in context of providing ath79 support for SPI-NAND[1].

At least for me, the use case is the equivalent of

     nand_do_platform_check $(board_name) ${upgrade_file_name}

without jumping through hoops of translating the output of $(board_name)
to the expected tar-dir name for each and every instance of the call.


I don't know that there is a "better" solution, but what I have found:

* nand_do_platform_upgrade() is called by relatively few targets
   * ath79 (see [1])
   * pistachio
   * imx6
   * ar71xx

* I can see a desire to check for a *specific* tar-dir name,
   rather than just "any" tar-dir name (wrestled with this for a while)

* Only one board seems to prevent a first-comma-to-underscore approach,
   the `img,pistachio-marduk` uses `sysupgrade-img,pistachio-marduk`

   otherwise, I've got this on a development branch

+       local tar_dir_name="sysupgrade-$(echo "$board_name" | sed -e s/,/_/)"
+       local control_length=`(tar xf $tar_file ${tar_dir_name}/CONTROL -O | wc -c) 2> /dev/null`


It looks like the pistachio board could have its Makefile modified
to bring it's tar-dir name into the "standard" underscore form,
however I don't have one of these boards to test with,
nor do I know if the file-name change would impact users.

One set of changes I explored last night comes down to

-  IMAGE/sysupgrade.tar := sysupgrade-tar
+  IMAGE/sysupgrade.tar := sysupgrade-tar | append-metadata
  endef
  
-define Device/marduk
-  BOARD_NAME := img,pistachio-marduk
+define Device/img_pistachio-marduk
    DEVICE_DTS := img/pistachio_marduk
    BLOCKSIZE := 256KiB
    PAGESIZE := 4KiB
    DEVICE_TITLE := Creator Ci40
    DEVICE_PACKAGES := kmod-tpm-i2c-infineon
  endef
-
-TARGET_DEVICES += marduk
+TARGET_DEVICES += img_pistachio-marduk


commit b14444c010 (HEAD -> jmk-pistachio)
Author: Jeff Kletsky <git-commits at allycomm.com>
Date:   Sun May 19 20:28:12 2019 -0700

     pistachio: Update image/Makefile for tar root and metadata
     
     Prior to this patch, the img,pistachio-marduk was the only board that
     used the comma-delimited board name for the sysupgrade-tar directory
     rather than the underscore-delimited, DTS-compatible form.
     
     To allow for easier use of $(board_name) in upgrade scripting, this
     patch brings the sysupgrade-tar directory into the more canonical
     form. It also adds append-metadata to the sysupgrade-tar image.
     
     The board name at run time should be the same as before.
     
     However, the build results have a different name, changing from
     
         openwrt-pistachio-marduk-squashfs-sysupgrade.tar
     to
         openwrt-pistachio-img_pistachio-marduk-squashfs-sysupgrade.tar




[1] http://patchwork.ozlabs.org/project/openwrt/list/?series=107880

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/openwrt-devel/attachments/20190520/2ce2d980/attachment.html>


More information about the openwrt-devel mailing list