Bug#626434: flash-kernel: please add u-boot script support
Package: flash-kernel
Version: 2.40
Severity: wishlist
Tags: patch
Hi,
I have been working out support for u-boot scripts.
I would like to know your comments or input about it as might might push it
to the efika flash-kernel branch which someday I hope to merge into master.
Right now, I am a bit stuck on how to set ROOTPARTITION on the bootscript,
at the moment I have it hardcoded, but hopefully we can find a way around it.
>From 93003a5b3affc1a5f3b3abac98d22d077a06f388 Mon Sep 17 00:00:00 2001
From: Hector Oron <zumbi@debian.org>
Date: Wed, 11 May 2011 23:15:17 +0000
Subject: [PATCH] flash-kernel: add u-boot script support
* flash-kernel: add u-boot script support
* bootscript/bootscr.mx5: u-boot script for mx5 supported devices.
* debian/control: add devio as build-dep and armhf support.
* debian/flash-kernel.install: install u-boot scripts
Signed-off-by: Hector Oron <zumbi@debian.org>
---
bootscript/bootscr.mx5 | 12 ++++++++++++
debian/control | 8 ++++----
debian/flash-kernel.install | 1 +
flash-kernel | 38 ++++++++++++++++++++++++++++++++++++++
4 files changed, 55 insertions(+), 4 deletions(-)
create mode 100644 bootscript/bootscr.mx5
diff --git a/bootscript/bootscr.mx5 b/bootscript/bootscr.mx5
new file mode 100644
index 0000000..8f992e3
--- /dev/null
+++ b/bootscript/bootscr.mx5
@@ -0,0 +1,12 @@
+setenv ramdisk uInitrd;
+setenv kernel uImage;
+setenv bootargs console=ttymxc0,115200 console=tty1 root=@ROOTPARTITION@ rootwait rw;
+${loadcmd} ${ramdiskaddr} ${ramdisk};
+if imi ${ramdiskaddr}; then; else
+ setenv bootargs ${bootargs} noinitrd;
+ setenv ramdiskaddr "";
+fi;
+${loadcmd} ${kerneladdr} ${kernel}
+if imi ${kerneladdr}; then
+ bootm ${kerneladdr} ${ramdiskaddr}
+fi;
diff --git a/debian/control b/debian/control
index 465a495..2e50500 100644
--- a/debian/control
+++ b/debian/control
@@ -5,13 +5,13 @@ Maintainer: Debian Install System Team <debian-boot@lists.debian.org>
Uploaders: Loïc Minier <lool@debian.org>,
Martin Michlmayr <tbm@cyrius.com>,
Wouter Verhelst <wouter@debian.org>
-Build-Depends: debhelper (>= 7.3.10)
+Build-Depends: debhelper (>= 7.3.10), devio
Standards-Version: 3.9.1
Vcs-Browser: http://git.debian.org/?p=d-i/flash-kernel.git
Vcs-Git: git://git.debian.org/d-i/flash-kernel.git
Package: flash-kernel
-Architecture: arm armel armeb
+Architecture: arm armel armeb armhf
Depends: ${misc:Depends}, devio, initramfs-tools (>= 0.92f)
Suggests: uboot-mkimage
Description: utility to make certain embedded devices bootable
@@ -25,8 +25,8 @@ Package: flash-kernel-installer
Section: debian-installer
Priority: standard
XC-Package-Type: udeb
-Architecture: arm armel armeb
-XB-Subarchitecture: iop32x ixp4xx kirkwood orion5x s3c24xx
+Architecture: arm armel armeb armhf
+XB-Subarchitecture: iop32x ixp4xx kirkwood orion5x s3c24xx mx5
Provides: bootable-system
Depends: cdebconf-udeb, installed-base
XB-Installer-Menu-Item: 7300
diff --git a/debian/flash-kernel.install b/debian/flash-kernel.install
index a9f5a6c..e3e5258 100644
--- a/debian/flash-kernel.install
+++ b/debian/flash-kernel.install
@@ -1,2 +1,3 @@
flash-kernel usr/sbin
initramfs-tools usr/share
+bootscript usr/share/flash-kernel
diff --git a/flash-kernel b/flash-kernel
index 6b6161c..4d038f4 100755
--- a/flash-kernel
+++ b/flash-kernel
@@ -210,6 +210,18 @@ mkimage_initrd() {
echo "done." >&2
}
+mkimage_script() {
+ local baddr="$1"
+ local bdesc="$2"
+ local bdata="$3"
+ local bscript="$4"
+
+ printf "Generating u-boot script image... " >&2
+ mkimage -A arm -O linux -a "$baddr" -e "$baddr" -T script -C none \
+ -n "$bdesc" -d "$bdata" "$bscript" >&2 1>/dev/null
+ echo "done." >&2
+}
+
mkimage_multi() {
local maddr="$1"
local mdesc="$2"
@@ -297,15 +309,21 @@ Machine: Genesi EfikaMX nettop
Kernel-Flavors: mx5
U-Boot-Kernel-Address: 0x90008000
U-Boot-Initrd-Address: 0x0
+U-Boot-Script-Address: 0x0
+U-Boot-Script-Name: bootscr.mx5
Boot-Kernel-Path: /boot/uImage
Boot-Initrd-Path: /boot/uInitrd
+Boot-Script-Path: /boot/boot.scr
Machine: Genesi Efika Smartbook
Kernel-Flavors: mx5
U-Boot-Kernel-Address: 0x90008000
U-Boot-Initrd-Address: 0x0
+U-Boot-Script-Address: 0x0
+U-Boot-Script-Name: bootscr.mx5
Boot-Kernel-Path: /boot/uImage
Boot-Initrd-Path: /boot/uInitrd
+Boot-Script-Path: /boot/boot.scr
Machine: GLAN Tank
Kernel-Flavors: iop32x
@@ -486,10 +504,13 @@ mtd_kernel="$(get_machine_field "$machine" "Mtd-Kernel")" || :
mtd_initrd="$(get_machine_field "$machine" "Mtd-Initrd")" || :
ukaddr="$(get_machine_field "$machine" "U-Boot-Kernel-Address")" || :
uiaddr="$(get_machine_field "$machine" "U-Boot-Initrd-Address")" || :
+ubaddr="$(get_machine_field "$machine" "U-Boot-Script-Address")" || :
umaddr="$(get_machine_field "$machine" "U-Boot-Multi-Address")" || :
boot_kernel_path="$(get_machine_field "$machine" "Boot-Kernel-Path")" || :
boot_initrd_path="$(get_machine_field "$machine" "Boot-Initrd-Path")" || :
+boot_script_path="$(get_machine_field "$machine" "Boot-Script-Path")" || :
boot_multi_path="$(get_machine_field "$machine" "Boot-Multi-Path")" || :
+ubfile="$(get_machine_field "$machine" "U-Boot-Script-Name")" || :
if [ -n "$mtd_kernel" ] || [ -n "$mtd_initrd" ]; then
if [ ! -e "$PROC_MTD" ]; then
@@ -594,6 +615,23 @@ case "$machine" in
flash_initrd "$initrd" "$imtd" $ipad
rm -f "$tmpdir/uInitrd"
fi
+ if [ -n "$ubfile" ]; then
+ ubdir="/boot/flash-kernel/"
+ ubdesc="Debian U-Boot Boot Script"
+ if [ ! -d "$ubdir" ]; then
+ mkdir -p "$ubdir"
+ # XXX HACK: It needs better way of doing this
+ rootfs="\/dev\/sda2"
+ sed -e "s/@ROOTPARTITION@/$rootfs/" \
+ /usr/share/flash-kernel/bootscript/"$ubfile" \
+ >"$ubdir"/"$ubfile"
+ fi
+ if [ -e "$boot_script_path" ]; then
+ cp -a "$boot_script_path" "$boot_script_path".bak
+ fi
+ mkimage_script "$ubaddr" "$ubdesc" "$ubdir"/"$ubfile" \
+ "$boot_script_path"
+ fi
;;
"GLAN Tank")
rm -f /boot/initrd /boot/zImage
--
1.7.4.4
Bes regards
-- System Information:
Debian Release: wheezy/sid
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.38-2-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Reply to: