[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[RFC] d-i hd-media support for armhf



Hello,

I have started working on implementing hd-media support for the
armhf platform in debian-installer.  My approach is a bit
different from what we do on i386/amd64; for armhf the code
generates a tarball which can be unpacked onto a previously
formatted usb stick instead of building a disk image.

I believe that on armhf systems a tarball makes more sense than
a disk image for the following reasons:

- AFAICS the tools used to build a hd-media image in d-i can only
  build a "superfloppy" style image, and those are not detected
  as a valid storage medium by u-boot.

- We do not install a boot sector on armhf but just a u-boot
  script.  This is a normal file which can be copied onto a USB
  stick with an exiting filesystem of arbitrary size and mostly
  arbitrary type (fat16/fat32/ext2/ext3/ext4), so there is no
  need to provide a block-wise disk image with a fixed size. 
  This allows using nearly any exiting usb stick as installation
  medium without overwriting the data on it, and it provides
  flexibility regarding media size.

Due to the diversity of the various armhf platforms and their
(sometimes years-old) u-boot versions, it is nearly impossible to
provide a boot script that works on all of them.  Therefore I
target systems which run a current mainline u-boot.  Mainline
u-boot 2014.10 (which is planned to go into Jessie) introduces a
common bootcmd handling for all platforms, so that one boot
script can be used on all supported platforms.

The d-i boot script checks whether it is called on such a modern
u-boot and provides appropriate information when not.

Attached is a first preliminary attempt at an implementation. 
The long list of kernel modules in the pkg-list is currently
necessary for testing the code as the current weekly CD image
contains modules for an older kernel, so the modules must for the
moment be put into the initrd.  This will of course be changed
for the final version.

I have run some tests with the resulting tarball contents and a
Jesse CD1 iso copied onto a USB stick; booting and detecting the
ISO worked as expected on a Cubietruck (armhf/sunxi) with
mainline u-boot. I have not yet made a full installation due to
the kernel mismatch, but will do as soon kernel 3.16.3 has
made it onto the weekly CD.

Comments welcome :).

Regards,
Karsten
-- 
Gem. Par. 28 Abs. 4 Bundesdatenschutzgesetz widerspreche ich der Nutzung
sowie der Weitergabe meiner personenbezogenen Daten für Zwecke der
Werbung sowie der Markt- oder Meinungsforschung.
>From 39523c909505e610db1014ba4c4fa7baf9d17466 Mon Sep 17 00:00:00 2001
From: Karsten Merker <merker@debian.org>
Date: Sat, 20 Sep 2014 07:02:54 +0200
Subject: [PATCH] Add hd-media support for the armhf platform

---
 build/boot/arm/bootscr.mainline_common | 30 +++++++++++++++++++++
 build/config/armhf.cfg                 |  2 +-
 build/config/armhf/hd-media.cfg        | 32 ++++++++++++++++++++++
 build/pkg-lists/hd-media/armhf.cfg     | 49 ++++++++++++++++++++++++++++++++++
 4 files changed, 112 insertions(+), 1 deletion(-)
 create mode 100644 build/boot/arm/bootscr.mainline_common
 create mode 100644 build/config/armhf/hd-media.cfg
 create mode 100644 build/pkg-lists/hd-media/armhf.cfg

diff --git a/build/boot/arm/bootscr.mainline_common b/build/boot/arm/bootscr.mainline_common
new file mode 100644
index 0000000..268eeba
--- /dev/null
+++ b/build/boot/arm/bootscr.mainline_common
@@ -0,0 +1,30 @@
+# Bootscript using the new unified bootcmd handling
+# introduced with u-boot v2014.10
+
+if test -n "${boot_targets}"; then
+  echo "Mainline u-boot / new-style environment detected."
+else
+  echo "Non-mainline u-boot detected. This boot script uses the unified bootcmd"
+  echo "handling of mainline u-boot (>=v2014.10), which is not available on your"
+  echo "system. Please boot the installer manually."
+  exit 0
+fi
+
+if test -z "${fdtfile}"; then
+  echo 'fdtfile environment variable not set. Aborting boot process.'
+  exit 0
+fi
+
+if test ! -e ${devtype} ${devnum}:${bootpart} dtbs/${fdtfile}; then
+  echo "This installer medium does not contain a suitable device-tree file for"
+  echo "this system (${fdtfile}). Aborting boot process."
+  exit 0
+fi
+
+setenv bootargs "${bootargs} console=${console}"
+
+load ${devtype} ${devnum}:${bootpart} ${kernel_addr_r} vmlinuz \
+&& load ${devtype} ${devnum}:${bootpart} ${fdt_addr_r} dtbs/${fdtfile} \
+&& load ${devtype} ${devnum}:${bootpart} ${ramdisk_addr_r} initrd.gz \
+&& echo "Booting the Debian installer..." \
+&& bootz ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r}
diff --git a/build/config/armhf.cfg b/build/config/armhf.cfg
index 681eae2..1332c3a 100644
--- a/build/config/armhf.cfg
+++ b/build/config/armhf.cfg
@@ -1,4 +1,4 @@
-MEDIUM_SUPPORTED = netboot network-console netboot-gtk device-tree
+MEDIUM_SUPPORTED = hd-media netboot network-console netboot-gtk device-tree
 
 MKLIBS = mklibs --ldlib=/lib/ld-linux-armhf.so.3
 
diff --git a/build/config/armhf/hd-media.cfg b/build/config/armhf/hd-media.cfg
new file mode 100644
index 0000000..4c1345e
--- /dev/null
+++ b/build/config/armhf/hd-media.cfg
@@ -0,0 +1,32 @@
+FLAVOUR_SUPPORTED = ""
+
+GZIPPED = .gz
+EXTRANAME = hd-media/
+
+TARGET = $(KERNEL) $(INITRD) hd-media_dtbs hd-media_bootscript hd-media_tarball
+
+MANIFEST-INITRD = "Initrd for use on USB memory sticks"
+MANIFEST-KERNEL = "Kernel for use on USB memory sticks"
+
+.PHONY: hd-media_dtbs
+hd-media_dtbs: $(TEMP_DTBS)
+	echo DEST=$(DEST)
+	echo SOME_DEST=$(SOME_DEST)
+	mkdir -p $(SOME_DEST)/$(EXTRANAME)dtbs
+	set -ex ; for dtb in $(TEMP_DTBS)/*.dtb ; do \
+		tgt=$(SOME_DEST)/$(EXTRANAME)dtbs/$$(basename $$dtb); \
+		cp $$dtb $$tgt ; \
+		update-manifest $$tgt "Device Tree Blob: $$(basename $$dtb)";\
+	done
+	cp boot/README.device-tree $(SOME_DEST)/$(EXTRANAME)dtbs/README
+	update-manifest $(SOME_DEST)/$(EXTRANAME)dtbs/README  "Device Tree Blobs README"
+
+.PHONY: hd-media_bootscript
+hd-media_bootscript:
+	mkimage -T script -A arm -d boot/arm/bootscr.mainline_common $(SOME_DEST)/$(EXTRANAME)boot.scr
+	update-manifest $(SOME_DEST)/$(EXTRANAME)boot.scr "Universal boot script for mainline u-boot (>= v2014.10)"
+
+.PHONY: hd-media_tarball
+hd-media_tarball: $(KERNEL) $(INITRD) hd-media_dtbs hd-media_bootscript
+	tar -C $(SOME_DEST)/$(EXTRANAME) -zcf $(TEMP)/hd-media.tar.gz .
+	mv  $(TEMP)/hd-media.tar.gz $(SOME_DEST)/$(EXTRANAME)
diff --git a/build/pkg-lists/hd-media/armhf.cfg b/build/pkg-lists/hd-media/armhf.cfg
new file mode 100644
index 0000000..9cd1b27
--- /dev/null
+++ b/build/pkg-lists/hd-media/armhf.cfg
@@ -0,0 +1,49 @@
+console-setup-pc-ekmap
+
+console-setup-udeb
+kbd-udeb
+bogl-bterm-udeb
+hw-detect
+
+#ethdetect
+#netcfg
+
+ata-modules-${kernel:Version}
+core-modules-${kernel:Version}
+ext4-modules-${kernel:Version}
+sata-modules-${kernel:Version}
+scsi-core-modules-${kernel:Version}
+fat-modules-${kernel:Version}
+usb-modules-${kernel:Version}
+usb-storage-modules-${kernel:Version}
+btrfs-modules-${kernel:Version}
+crc-modules-${kernel:Version}
+crypto-dm-modules-${kernel:Version}
+crypto-modules-${kernel:Version}
+event-modules-${kernel:Version}
+fuse-modules-${kernel:Version}
+input-modules-${kernel:Version}
+isofs-modules-${kernel:Version}
+jfs-modules-${kernel:Version}
+loop-modules-${kernel:Version}
+md-modules-${kernel:Version}
+mmc-modules-${kernel:Version}
+multipath-modules-${kernel:Version}
+nbd-modules-${kernel:Version}
+nic-modules-${kernel:Version}
+nic-shared-modules-${kernel:Version}
+nic-usb-modules-${kernel:Version}
+nic-wireless-modules-${kernel:Version}
+pata-modules-${kernel:Version}
+ppp-modules-${kernel:Version}
+scsi-modules-${kernel:Version}
+squashfs-modules-${kernel:Version}
+udf-modules-${kernel:Version}
+uinput-modules-${kernel:Version}
+zlib-modules-${kernel:Version}
+
+fb-modules-${kernel:Version} ?
+input-modules-${kernel:Version} ?
+
+usb-serial-modules-${kernel:Version} ?
+uinput-modules-${kernel:Version} ?
-- 
2.1.0


Reply to: