Bug#845779: [PATCH 1/1 v2] functions: call mkimage with correct architecture
64bit u-boot and kernel cannot load 32bit u-boot images.
Hence on 32bit arm systems use 'mkimage -A arm',
on 64bit arm systems use 'mkimage -A arm64'.
We can determine the bitness of the newly installed kernel
by using function get_kfile_suffix() which returns the last
part of the kernel version.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
v2:
Do not rely on uname -m for determining the architecture
of the newly installed kernel as it may differ from the
old architecture.
functions | 17 +++++++++++++----
test_functions | 3 +++
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/functions b/functions
index 368cbf2..893897d 100644
--- a/functions
+++ b/functions
@@ -212,6 +212,14 @@ get_machine_field() {
}
}
+get_mkimage_architecture() {
+ kfile_suffix=$(get_kfile_suffix "$1")
+ case "$kfile_suffix" in
+ "arm64") echo "arm64";;
+ *) echo "arm";;
+ esac
+}
+
get_dtb_name() {
local field="$(get_machine_field "$machine" "DTB-Id")" || :
case "$field" in
@@ -423,7 +431,7 @@ mkimage_kernel() {
local uimage="$5"
printf "Generating kernel u-boot image... " >&2
- mkimage -A arm -O linux -T kernel -C none -a "$kaddr" -e "$epoint" \
+ mkimage -A "$mkarch" -O linux -T kernel -C none -a "$kaddr" -e "$epoint" \
-n "$kdesc" -d "$kdata" "$uimage" >&2 1>/dev/null
echo "done." >&2
}
@@ -435,7 +443,7 @@ mkimage_initrd() {
local uinitrd="$4"
printf "Generating initramfs u-boot image... " >&2
- mkimage -A arm -O linux -T ramdisk -C none -a "$iaddr" -e "$iaddr" \
+ mkimage -A "$mkarch" -O linux -T ramdisk -C none -a "$iaddr" -e "$iaddr" \
-n "$idesc" -d "$idata" "$uinitrd" >&2 1>/dev/null
echo "done." >&2
}
@@ -459,7 +467,7 @@ mkimage_script() {
s/@@UBOOT_ENV_EXTRA@@//g
r $ubootenv
}" < $sdata > $tdata
- mkimage -A arm -O linux -T script -C none -a "$saddr" -e "$saddr" \
+ mkimage -A "$mkarch" -O linux -T script -C none -a "$saddr" -e "$saddr" \
-n "$sdesc" -d "$tdata" "$script" >&2 1>/dev/null
echo "done." >&2
}
@@ -472,7 +480,7 @@ mkimage_multi() {
local umulti="$5"
printf "Generating u-boot image..." >&2
- mkimage -A arm -O linux -T multi -C none -a "$maddr" -e "$maddr" \
+ mkimage -A "$mkarch" -O linux -T multi -C none -a "$maddr" -e "$maddr" \
-n "$mdesc" -d "$kdata:$idata" "$umulti" >&2 1>/dev/null
echo "done." >&2
}
@@ -765,6 +773,7 @@ fi
echo "flash-kernel: installing version $kvers" >&2
+mkarch="$(get_mkimage_architecture $kvers)"
machine_id="$(get_machine_field "$machine" "Machine-Id")" || :
method="$(get_machine_field "$machine" "Method")" || method="generic"
mtd_kernel="$(get_machine_field "$machine" "Mtd-Kernel")" || :
diff --git a/test_functions b/test_functions
index c28904e..e75b089 100755
--- a/test_functions
+++ b/test_functions
@@ -576,6 +576,7 @@ test_mkimage_kernel() {
}
. "$functions"
saved_args=""
+ mkarch="arm"
mkimage_kernel "0xdeadbeef" "0xbaddcafe" "desc" "input" "output" 2>/dev/null
expected="-A arm -O linux -T kernel -C none -a 0xdeadbeef -e 0xbaddcafe -n desc -d input output"
if [ "$expected" != "$saved_args" ]; then
@@ -593,6 +594,7 @@ test_mkimage_initrd() {
}
. "$functions"
saved_args=""
+ mkarch="arm"
mkimage_initrd "0xdeadbeef" "desc" "input" "output" 2>/dev/null
expected="-A arm -O linux -T ramdisk -C none -a 0xdeadbeef -e 0xdeadbeef -n desc -d input output"
if [ "$expected" != "$saved_args" ]; then
@@ -610,6 +612,7 @@ test_mkimage_multi() {
}
. "$functions"
saved_args=""
+ mkarch="arm"
mkimage_multi "0xdeadbeef" "desc" "kinput" "iinput" "output" 2>/dev/null
expected="-A arm -O linux -T multi -C none -a 0xdeadbeef -e 0xdeadbeef -n desc -d kinput:iinput output"
if [ "$expected" != "$saved_args" ]; then
--
2.10.2
Reply to: