Re: Support for sunxi-based ARM systems in d-i
On Tue, 2014-05-06 at 21:24 +0200, Karsten Merker wrote:
> So this means that on an armhf system set up by d-i, the symlinks
> are actually in place where we need them for the boot scripts. I
> am very short on time at the moment, so I can't work on the
> topic now, but I'll look into it again some time later this week.
It was mostly a case of cherry picking the bits of your patch which were
still needed and since I had a few spare moments this evening it took a
stab at it (I hope that's ok), the result is attached.
The second patch are the relevant bits of your patch.
Works for me on a DI installed system with 3.14-1-armmp built from SVN.
My u-boot bootcmd is:
scsi scan;setenv device scsi;setenv partition 0;load ${device}
${partition} ${scriptaddr} boot.scr;source ${scriptaddr}
Ian.
>From 1380729d76d8ea951cfbca1300bb16d4baa357e0 Mon Sep 17 00:00:00 2001
From: Ian Campbell <ijc@hellion.org.uk>
Date: Thu, 8 May 2014 19:41:24 +0100
Subject: [PATCH 1/5] Support --force to install a specific kernel version
---
functions | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/functions b/functions
index 02f7381..cdd063f 100644
--- a/functions
+++ b/functions
@@ -351,6 +351,11 @@ android_flash() {
}
main() {
+force="no"
+if [ "x$1" = "x--force" ]; then
+ force="yes"
+ shift
+fi
if [ "x$1" = "x--machine" ]; then
machine="$2"
shift 2
@@ -373,7 +378,7 @@ fi
kvers="$1"
latest_version=$(linux-version list | linux-version sort | tail -1)
-if [ -n "$kvers" ] && [ "$kvers" != "$latest_version" ] && [ "$FK_KERNEL_HOOK_SCRIPT" = "postinst.d" ]; then
+if [ -n "$kvers" ] && [ "x$force" != "xyes" ] && [ "$kvers" != "$latest_version" ] && [ "$FK_KERNEL_HOOK_SCRIPT" = "postinst.d" ]; then
echo "Ignoring old or unknown version $kvers (latest is $latest_version)" >&2
exit 0
fi
@@ -395,7 +400,12 @@ if [ -n "$kvers" ] && [ "$FK_KERNEL_HOOK_SCRIPT" = "postrm.d" ]; then
fi
fi
-kvers="$latest_version"
+if [ "$kvers" != "$latest_version" ] && [ "x$force" = "xyes" ]; then
+ echo "flash-kernel: forcing install of ${kvers} instead of ${latest_version}." >&2
+ echo "flash-kernel: WARNING: Installing any new kernel package might override this." >&2
+else
+ kvers="$latest_version"
+fi
# accumulate multiple calls in a trigger to only run flash-kernel once; the
# trigger will just call flash-kernel again with FLASH_KERNEL_NOTRIGGER set to
--
1.9.0
>From 655fbf1487ca3a3b6c2fee901746a76172b36cbc Mon Sep 17 00:00:00 2001
From: Ian Campbell <ijc@hellion.org.uk>
Date: Thu, 8 May 2014 20:23:59 +0100
Subject: [PATCH 2/5] Support for sunxi Cubietruck
Based on a patch by Karsten Merker.
---
bootscript/bootscr.sunxi | 23 +++++++++++++++++++++++
db/all.db | 8 ++++++++
2 files changed, 31 insertions(+)
create mode 100644 bootscript/bootscr.sunxi
diff --git a/bootscript/bootscr.sunxi b/bootscript/bootscr.sunxi
new file mode 100644
index 0000000..fff00bb
--- /dev/null
+++ b/bootscript/bootscr.sunxi
@@ -0,0 +1,23 @@
+# boot script for Allwinner SunXi-based devices
+
+# u-boot-sunxi does - in contrast to u-boot on other platforms - not
+# predefine kernel_addr_r, fdt_addr_r and ramdisk_addr_r, therefore we
+# define them locally in the boot script.
+#
+# This script assumes that ${device} and ${partition} are set in the
+# environment already.
+
+setenv kernel_addr_r 0x46000000
+setenv fdt_addr_r 0x47000000
+setenv ramdisk_addr_r 0x48000000
+
+image_locations='/boot/ /'
+
+for pathprefix in ${image_locations}
+do
+ load ${device} ${partition} ${kernel_addr_r} ${pathprefix}vmlinuz
+ load ${device} ${partition} ${fdt_addr_r} ${pathprefix}dtb
+ load ${device} ${partition} ${ramdisk_addr_r} ${pathprefix}initrd.img
+done
+
+bootz ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r}
diff --git a/db/all.db b/db/all.db
index 93fa714..539f953 100644
--- a/db/all.db
+++ b/db/all.db
@@ -64,6 +64,14 @@ Boot-Initrd-Path: /boot/initrd.buffalo
Required-Packages: u-boot-tools
Bootloader-Sets-Incorrect-Root: yes
+Machine: Cubietech Cubietruck
+Kernel-Flavors: armmp
+Boot-Script-Path: /boot/boot.scr
+Boot-DTB-Path: /boot/dtb
+DTB-Id: sun7i-a20-cubietruck.dtb
+U-Boot-Script-Name: bootscr.sunxi
+Bootloader-Sets-Incorrect-Root: no
+
Machine: D-Link DNS-323
Kernel-Flavors: orion5x
Machine-Id: 1542
--
1.9.0
>From 6809f42851ef8f8e7ca9848a9b8b0dd1fc5bcf66 Mon Sep 17 00:00:00 2001
From: Ian Campbell <ijc@hellion.org.uk>
Date: Thu, 8 May 2014 20:45:39 +0100
Subject: [PATCH 3/5] sunxi: Only run bootz if all 3 loads succeed
Also echo something about what we are booting.
---
bootscript/bootscr.sunxi | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/bootscript/bootscr.sunxi b/bootscript/bootscr.sunxi
index fff00bb..19bb94a 100644
--- a/bootscript/bootscr.sunxi
+++ b/bootscript/bootscr.sunxi
@@ -15,9 +15,10 @@ image_locations='/boot/ /'
for pathprefix in ${image_locations}
do
- load ${device} ${partition} ${kernel_addr_r} ${pathprefix}vmlinuz
- load ${device} ${partition} ${fdt_addr_r} ${pathprefix}dtb
- load ${device} ${partition} ${ramdisk_addr_r} ${pathprefix}initrd.img
+ load ${device} ${partition} ${kernel_addr_r} ${pathprefix}vmlinuz \
+ && load ${device} ${partition} ${fdt_addr_r} ${pathprefix}dtb \
+ && load ${device} ${partition} ${ramdisk_addr_r} ${pathprefix}initrd.img \
+ && echo "Booting Debian from ${device} ${partition}..." \
+ && bootz ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r}
done
-bootz ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r}
--
1.9.0
>From 7198c3b5fd963419d2c7d26469eb49aa93f52330 Mon Sep 17 00:00:00 2001
From: Ian Campbell <ijc@hellion.org.uk>
Date: Thu, 8 May 2014 20:24:10 +0100
Subject: [PATCH 4/5] Install DTB as /boot/dtb-$kvers for all platforms which
have a DTB-Id
---
functions | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/functions b/functions
index cdd063f..b3026be 100644
--- a/functions
+++ b/functions
@@ -350,6 +350,32 @@ android_flash() {
echo "done." >&2
}
+handle_dtb() {
+ if [ "x$FK_KERNEL_HOOK_SCRIPT" = "x" ]; then
+ return
+ fi
+
+ local dtb_id="$(get_machine_field "$machine" "DTB-Id")" || :
+ if [ "x$dtb_id" = "x" ]; then
+ return
+ fi
+
+ local dtb="/usr/lib/linux-image-$kvers/$dtb_id"
+ case $FK_KERNEL_HOOK_SCRIPT in
+ postinst.d)
+ if [ -e $dtb ]; then
+ echo "Installing $dtb_id $kvers into /boot" >&2
+ cp "$dtb" "/boot/dtb-$kvers"
+ else
+ echo "$dtb not found" >&2
+ fi
+ ;;
+ postrm.d)
+ rm -f "/boot/dtb-$kvers"
+ ;;
+ esac
+}
+
main() {
force="no"
if [ "x$1" = "x--force" ]; then
@@ -377,6 +403,10 @@ fi
# kernel + initrd installation/upgrade mode, with optional version
kvers="$1"
+
+# Install/remove any DTB from postinst, regardless of version
+handle_dtb
+
latest_version=$(linux-version list | linux-version sort | tail -1)
if [ -n "$kvers" ] && [ "x$force" != "xyes" ] && [ "$kvers" != "$latest_version" ] && [ "$FK_KERNEL_HOOK_SCRIPT" = "postinst.d" ]; then
echo "Ignoring old or unknown version $kvers (latest is $latest_version)" >&2
--
1.9.0
>From 437ffe58ad37512276e64f8593e5eefa8d218dd8 Mon Sep 17 00:00:00 2001
From: Ian Campbell <ijc@hellion.org.uk>
Date: Thu, 8 May 2014 19:42:28 +0100
Subject: [PATCH 5/5] Support use of kernel version in boot scripts
Use this on sunxi
---
bootscript/bootscr.sunxi | 9 +++++----
db/all.db | 1 -
functions | 6 +++++-
3 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/bootscript/bootscr.sunxi b/bootscript/bootscr.sunxi
index 19bb94a..52894db 100644
--- a/bootscript/bootscr.sunxi
+++ b/bootscript/bootscr.sunxi
@@ -12,13 +12,14 @@ setenv fdt_addr_r 0x47000000
setenv ramdisk_addr_r 0x48000000
image_locations='/boot/ /'
+kvers='@@KERNEL_VERSION@@'
for pathprefix in ${image_locations}
do
- load ${device} ${partition} ${kernel_addr_r} ${pathprefix}vmlinuz \
- && load ${device} ${partition} ${fdt_addr_r} ${pathprefix}dtb \
- && load ${device} ${partition} ${ramdisk_addr_r} ${pathprefix}initrd.img \
- && echo "Booting Debian from ${device} ${partition}..." \
+ load ${device} ${partition} ${kernel_addr_r} ${pathprefix}vmlinuz-${kvers} \
+ && load ${device} ${partition} ${fdt_addr_r} ${pathprefix}dtb-${kvers} \
+ && load ${device} ${partition} ${ramdisk_addr_r} ${pathprefix}initrd.img-${kvers} \
+ && echo "Booting Debian ${kvers} from ${device} ${partition}..." \
&& bootz ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r}
done
diff --git a/db/all.db b/db/all.db
index 539f953..189aefd 100644
--- a/db/all.db
+++ b/db/all.db
@@ -67,7 +67,6 @@ Bootloader-Sets-Incorrect-Root: yes
Machine: Cubietech Cubietruck
Kernel-Flavors: armmp
Boot-Script-Path: /boot/boot.scr
-Boot-DTB-Path: /boot/dtb
DTB-Id: sun7i-a20-cubietruck.dtb
U-Boot-Script-Name: bootscr.sunxi
Bootloader-Sets-Incorrect-Root: no
diff --git a/functions b/functions
index b3026be..5ac1878 100644
--- a/functions
+++ b/functions
@@ -282,9 +282,13 @@ mkimage_script() {
local sdata="$3"
local script="$4"
+ local tdata="$tmpdir/$(basename $sdata)"
+
printf "Generating boot script u-boot image... " >&2
+ sed -e "s/@@KERNEL_VERSION@@/$kvers/g" \
+ < $sdata > $tdata
mkimage -A arm -O linux -T script -C none -a "$saddr" -e "$saddr" \
- -n "$sdesc" -d "$sdata" "$script" >&2 1>/dev/null
+ -n "$sdesc" -d "$tdata" "$script" >&2 1>/dev/null
echo "done." >&2
}
--
1.9.0
Reply to: