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'.

Signed-off-by: Heinrich Schuchardt <[email protected]>
---
 functions | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/functions b/functions
index 368cbf2..a62ea4c 100644
--- a/functions
+++ b/functions
@@ -33,6 +33,15 @@ read_machine_db() {
 }
 MACHINE_DB="$(read_machine_db)"
 
+get_mkimage_architecture() {
+       local arch="$(uname -m)"
+       case "$arch" in
+               "aarch64") echo "arm64" ;;
+               *)         echo "arm"   ;;
+       esac
+       }
+MKARCH="$(get_mkimage_architecture)"
+
 error() {
        echo "$@" >&2
        exit 1
@@ -423,7 +432,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 +444,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 +468,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 +481,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
 }
-- 
2.10.2

Reply via email to