Re: Support for sunxi-based ARM systems in d-i
On Mon, 2014-05-12 at 21:40 +0100, Ian Campbell wrote:
> On Mon, 2014-05-12 at 20:27 +0100, Ian Campbell wrote:
> > On Sat, 2014-05-10 at 21:38 +0100, Ian Campbell wrote:
> > > I think the best approach
> > > would be to add generic to XB-Subarchitecture and handle it using the
> > > db, leaving the other subarches as the are.
> >
> > I've not managed to test it yet, but I suspect something like the
> > following ought to do it...
> >
>
> Not even close... This needs to run in the installer environment, which
> doesn't have /usr/bin/flash-kernel, and it can't use in-target because
> f-k won't be in the target yet.
>
> ./usr/share/flash-kernel/functions is available in the udeb so I think I
> have a plan...
I think I've got it working, there were a few yakks to shave but I have
now done a full install from sid on a cubietruck. I'll clean up the
patches (rough versions attached), push and upload ASAP (hopefully
tonight).
Ian.
>From 5c01072eee13cfe1a5ec8f71cc2e5634515b56db Mon Sep 17 00:00:00 2001
From: Ian Campbell <ijc@hellion.org.uk>
Date: Thu, 15 May 2014 21:06:46 +0100
Subject: [PATCH 4/4] Install DTB in boot when invoked directly too
This is needed at installation time or when flash-kernel is installed after the
kernel (since the kernel postinst hooks aren't run for kernels which are
already installed).
---
functions | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/functions b/functions
index d4b9271..f23e457 100644
--- a/functions
+++ b/functions
@@ -356,29 +356,22 @@ android_flash() {
}
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 [ "x$FK_KERNEL_HOOK_SCRIPT" = "xpostrm.d" ] ; then
+ rm -f "/boot/dtb-$kvers"
+ else
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
+ fi
}
main() {
@@ -410,7 +403,9 @@ fi
kvers="$1"
# Install/remove any DTB from postinst, regardless of version
-handle_dtb
+if [ -n "$kvers" ] ; then
+ handle_dtb
+fi
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
@@ -440,6 +435,8 @@ if [ "$kvers" != "$latest_version" ] && [ "x$force" = "xyes" ]; then
echo "flash-kernel: WARNING: Installing any new kernel package might override this." >&2
else
kvers="$latest_version"
+ # Make sure we install the DTB for $latest_version
+ handle_dtb
fi
# accumulate multiple calls in a trigger to only run flash-kernel once; the
--
1.7.10.4
>From 656e1372cf30d8425c9a972e57a968aaa698ae07 Mon Sep 17 00:00:00 2001
From: Ian Campbell <ijc@hellion.org.uk>
Date: Thu, 15 May 2014 20:58:27 +0100
Subject: [PATCH 3/4] Support for arm*/generic subarch, based on db
---
debian/changelog | 2 ++
debian/control | 2 +-
debian/flash-kernel-installer.isinstallable | 11 +++++++++++
3 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/debian/changelog b/debian/changelog
index d5e816d..8c6c3b0 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,8 @@ flash-kernel (3.18) UNRELEASED; urgency=medium
* Copy the dtb (if any) to /boot/dtb-$kversion in kernel postinst hook.
* Allow use of the kernel version in boot scripts.
* Support kernel flavours with a hyphen in (e.g. armmp-lpae).
+ * Run installer udeb on arm*/generic subarch iff the machine is listed in the
+ db.
-- Ian Campbell <ijc@hellion.org.uk> Mon, 12 May 2014 20:12:39 +0100
diff --git a/debian/control b/debian/control
index 561625d..835f28f 100644
--- a/debian/control
+++ b/debian/control
@@ -30,7 +30,7 @@ Section: debian-installer
Priority: standard
Package-Type: udeb
Architecture: armel armhf
-XB-Subarchitecture: iop32x ixp4xx kirkwood orion5x s3c24xx mx5
+XB-Subarchitecture: iop32x ixp4xx kirkwood orion5x s3c24xx mx5 generic
Provides: bootable-system
Depends: cdebconf-udeb, installed-base
XB-Installer-Menu-Item: 7300
diff --git a/debian/flash-kernel-installer.isinstallable b/debian/flash-kernel-installer.isinstallable
index ce85af3..51bf153 100755
--- a/debian/flash-kernel-installer.isinstallable
+++ b/debian/flash-kernel-installer.isinstallable
@@ -20,6 +20,17 @@ case "`archdetect`" in
arm*/s3c24xx)
exit 0
;;
+ arm*/generic)
+ FK_DIR="/usr/share/flash-kernel"
+
+ . ${FK_DIR}/functions
+ get_machine
+ if check_supported "$machine" ; then
+ exit 0
+ else
+ exit 1
+ fi
+ ;;
# Don't activate it by default
*)
exit 1
--
1.7.10.4
>From d7dcf7fdc69b6cb3eb842157072f42890ba8ee46 Mon Sep 17 00:00:00 2001
From: Ian Campbell <ijc@hellion.org.uk>
Date: Thu, 15 May 2014 20:58:04 +0100
Subject: [PATCH 2/4] Fix support for kernel flavours containing a hyphen (e.g
armmp-lpae)
---
debian/changelog | 3 ++-
functions | 21 +++++++++++++++------
test_functions | 24 ++++++++++++++++++++++++
3 files changed, 41 insertions(+), 7 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 734618d..d5e816d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,7 +3,8 @@ flash-kernel (3.18) UNRELEASED; urgency=medium
* Add --force option to install a specific kernel version.
* Add support for the Cubietruck.
* Copy the dtb (if any) to /boot/dtb-$kversion in kernel postinst hook.
- * Allow use the kernel version in boot scripts.
+ * Allow use of the kernel version in boot scripts.
+ * Support kernel flavours with a hyphen in (e.g. armmp-lpae).
-- Ian Campbell <ijc@hellion.org.uk> Mon, 12 May 2014 20:12:39 +0100
diff --git a/functions b/functions
index 523c080..d4b9271 100644
--- a/functions
+++ b/functions
@@ -121,8 +121,9 @@ get_machine() {
get_kfile_suffix() {
local kfile="$1"
+ local tail="${2:+-$2}"
- echo "$kfile" | sed -e 's/.*-//'
+ echo "$kfile" | sed -e "s/.*-\([^-]*$tail\)/\\1/"
}
# this is case-sensitive and doesn't support fields spanning multiple lines
@@ -471,17 +472,25 @@ ifilesize=$(stat -c '%s' "$ifile")
if [ -L "$kfile" ]; then
kfile=$(readlink -e "$kfile")
fi
-kfile_suffix=$(get_kfile_suffix "$kfile")
if ! check_supported "$machine"; then
error "Unsupported platform."
fi
if kflavors="$(get_machine_field "$machine" "Kernel-Flavors")"; then
- if ! check_kflavors "$kfile_suffix" $kflavors; then
- echo "Kernel suffix $kfile_suffix does not match any of the expected flavors ($kflavors), therefore not writing it to flash." >&2
- exit 0
- fi
+ kfile_suffix=""
+ while [ "$kfile_suffix" != "$kfile" ] ; do
+ kfile_suffix=$(get_kfile_suffix "$kfile" "$kfile_suffix")
+
+ if check_kflavors "$kfile_suffix" $kflavors; then
+ break;
+ fi
+ done
+fi
+
+if [ "$kfile_suffix" = "$kfile" ]; then
+ echo "Kernel $kfile does not match any of the expected flavors ($kflavors), therefore not writing it to flash." >&2
+ exit 0
fi
echo "flash-kernel: installing version $kvers" >&2
diff --git a/test_functions b/test_functions
index 25c56d6..664782d 100755
--- a/test_functions
+++ b/test_functions
@@ -93,6 +93,14 @@ test_check_kflavors() {
echo "Expected check_kflavors to succeed with kernel suffix in expected flavors, but it failed" >&2
exit 1
fi
+ if ! check_kflavors "kflavor1-suffix" "klavor1" "kflavor1-suffix" "kflavor2"; then
+ echo "Expected check_kflavours to succeed with double-barrelled kernel suffix in expected flavours, but it failed" >&2
+ exit 1
+ fi
+ if check_kflavors "kflavor1-suffix" "klavor1" "kflavor2"; then
+ echo "Expected check_kflavours to fail with double-barrelled kernel suffix not in expected flavours, but it succeeded" >&2
+ exit 1
+ fi
if ! check_kflavors "" "kflavor1" "kflavor2" "kflavor3"; then
echo "Expected check_kflavors to succeed with empty kernel suffix, but it failed" >&2
exit 1
@@ -301,6 +309,22 @@ test_get_kfile_suffix() {
echo "Expected kernel file suffix to be kirkwood but got $kfile_suffix" >&2
exit 1
fi
+ kfile_suffix=""
+ kfile_suffix=$(get_kfile_suffix "/boot/vmlinuz-3.10-1-armmp-lpae" "$kfile_suffix")
+ if [ "$kfile_suffix" != "lpae" ]; then
+ echo "Expected kernel file suffix to be lpae but got $kfile_suffix" >&2
+ exit 1
+ fi
+ kfile_suffix=$(get_kfile_suffix "/boot/vmlinuz-3.10-1-armmp-lpae" "$kfile_suffix")
+ if [ "$kfile_suffix" != "armmp-lpae" ]; then
+ echo "Expected kernel file suffix to be armmp-lpae but got $kfile_suffix" >&2
+ exit 1
+ fi
+ kfile_suffix=$(get_kfile_suffix "/boot/vmlinuz-3.10-1-armmp")
+ if [ "$kfile_suffix" != "armmp" ]; then
+ echo "Expected kernel file suffix to be armmp but got $kfile_suffix" >&2
+ exit 1
+ fi
)
}
add_test test_get_kfile_suffix
--
1.7.10.4
>From 957719f38baa5edfa90b4987011664213189e794 Mon Sep 17 00:00:00 2001
From: Ian Campbell <ijc@hellion.org.uk>
Date: Thu, 15 May 2014 20:40:01 +0100
Subject: [PATCH 1/4] cubietruck: Allow armmp-lpae kernel and install
u-boot-tools
---
db/all.db | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/db/all.db b/db/all.db
index 189aefd..68f85b4 100644
--- a/db/all.db
+++ b/db/all.db
@@ -65,10 +65,11 @@ Required-Packages: u-boot-tools
Bootloader-Sets-Incorrect-Root: yes
Machine: Cubietech Cubietruck
-Kernel-Flavors: armmp
+Kernel-Flavors: armmp armmp-lpae
Boot-Script-Path: /boot/boot.scr
DTB-Id: sun7i-a20-cubietruck.dtb
U-Boot-Script-Name: bootscr.sunxi
+Required-Packages: u-boot-tools
Bootloader-Sets-Incorrect-Root: no
Machine: D-Link DNS-323
--
1.7.10.4
Reply to: