From 3ea64d006ab8c7fc0fea8d3dc188136cd03d5c4e Mon Sep 17 00:00:00 2001 From: osm0sis Date: Thu, 21 Mar 2019 17:08:04 -0300 Subject: [PATCH] AK2: workaround for U-Boot dumpimage failing on untrimmed uImage dumps https://lists.denx.de/pipermail/u-boot/2019-January/355670.html --- tools/ak2-core.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/ak2-core.sh b/tools/ak2-core.sh index 9834ddf..98f259a 100755 --- a/tools/ak2-core.sh +++ b/tools/ak2-core.sh @@ -35,7 +35,7 @@ reset_ak() { # dump boot and extract ramdisk split_boot() { - local nooktest nookoff dumpfail; + local nooktest nookoff uimgsize dumpfail; if [ ! -e "$(echo $block | cut -d\ -f1)" ]; then ui_print " "; ui_print "Invalid partition. Aborting..."; exit 1; fi; @@ -63,6 +63,11 @@ split_boot() { $bin/unpackelf -i /tmp/anykernel/boot.img -o $split_img; mv -f $split_img/boot.img-ramdisk.cpio.gz $split_img/boot.img-ramdisk.gz; elif [ -f "$bin/dumpimage" ]; then + uimgsize=$(($(printf '%d\n' 0x$(hexdump -n 4 -s 12 -e '16/1 "%02x""\n"' /tmp/anykernel/boot.img)) + 64)); + if [ "$(wc -c < /tmp/anykernel/boot.img)" != "$uimgsize" ]; then + mv -f /tmp/anykernel/boot.img /tmp/anykernel/boot-orig.img; + dd bs=$uimgsize count=1 conv=notrunc if=/tmp/anykernel/boot-orig.img of=/tmp/anykernel/boot.img; + fi; $bin/dumpimage -l /tmp/anykernel/boot.img; $bin/dumpimage -l /tmp/anykernel/boot.img > $split_img/boot.img-header; grep "Name:" $split_img/boot.img-header | cut -c15- > $split_img/boot.img-name;