Bug#831003: support gzip'd kernel image
Package: flash-kernel
Version: 3.67
Tags: patch
flash-kernel currently always sets the compression type to "none" when
generating uImages. However, if the source vmlinuz file is gzip'd - as
is the case if you build the "Image.gz" kernel target - this will
prevent U-Boot from being able to boot it[1]. If the uImage is
generated with a compression type of "gzip", then it boots fine.
The attached patch checks the source image type and sets the
compression setting appropriately.
[1] At least, this is true on APM Mustang systems
diff -urpN flash-kernel-3.67/debian/changelog flash-kernel-3.68/debian/changelog
--- flash-kernel-3.67/debian/changelog 2016-06-20 00:20:31.000000000 -0600
+++ flash-kernel-3.68/debian/changelog 2016-07-13 09:33:53.714642651 -0600
@@ -1,3 +1,9 @@
+flash-kernel (3.68) UNRELEASED; urgency=medium
+
+ * Add support for gzip-compressed kernel images
+
+ -- dann frazier <dannf@debian.org> Wed, 13 Jul 2016 09:22:49 -0600
+
flash-kernel (3.67) unstable; urgency=medium
[ Vagrant Cascadian ]
diff -urpN flash-kernel-3.67/functions flash-kernel-3.68/functions
--- flash-kernel-3.67/functions 2016-04-01 21:01:45.000000000 -0600
+++ flash-kernel-3.68/functions 2016-07-13 09:25:43.520547829 -0600
@@ -409,15 +409,31 @@ get_kernel_cmdline_defaults() {
echo "$LINUX_KERNEL_CMDLINE_DEFAULTS"
}
+compress_type() {
+ local file="$1"
+ magic="$(od -x -N2 $file | head -1 | cut -d' ' -f2)"
+ case $magic in
+ 8b1f)
+ echo "gzip"
+ ;;
+ *)
+ echo "none"
+ ;;
+ esac
+}
+
mkimage_kernel() {
local kaddr="$1"
local epoint="$2"
local kdesc="$3"
local kdata="$4"
local uimage="$5"
+ local comp
+
+ comp="$(compress_type $kdata)"
printf "Generating kernel u-boot image... " >&2
- mkimage -A arm -O linux -T kernel -C none -a "$kaddr" -e "$epoint" \
+ mkimage -A arm -O linux -T kernel -C $comp -a "$kaddr" -e "$epoint" \
-n "$kdesc" -d "$kdata" "$uimage" >&2 1>/dev/null
echo "done." >&2
}
diff -urpN flash-kernel-3.67/test_functions flash-kernel-3.68/test_functions
--- flash-kernel-3.67/test_functions 2016-02-14 21:01:43.000000000 -0700
+++ flash-kernel-3.68/test_functions 2016-07-13 09:28:35.812630206 -0600
@@ -569,23 +569,40 @@ test_set_machine_id() {
}
add_test test_set_machine_id
-test_mkimage_kernel() {
+_test_mkimage_kernel() {
+ local kdata="$1"
+ local expected="$2"
(
mkimage() {
saved_args="$@"
}
. "$functions"
saved_args=""
- mkimage_kernel "0xdeadbeef" "0xbaddcafe" "desc" "input" "output" 2>/dev/null
- expected="-A arm -O linux -T kernel -C none -a 0xdeadbeef -e 0xbaddcafe -n desc -d input output"
+ mkimage_kernel "0xdeadbeef" "0xbaddcafe" "desc" "$kdata" "output" 2>/dev/null
if [ "$expected" != "$saved_args" ]; then
echo "Expected mkimage_kernel to be called with \"$expected\" but it was called with \"$saved_args\"" >&2
- exit 1
+ return 1
fi
)
}
+
+test_mkimage_kernel() {
+ local kdata="/dev/zero"
+ local expected="-A arm -O linux -T kernel -C none -a 0xdeadbeef -e 0xbaddcafe -n desc -d $kdata output"
+ _test_mkimage_kernel "$kdata" "$expected" || exit 1
+}
add_test test_mkimage_kernel
+test_mkimage_kernel_gzip() {
+ local kdata="$(mktemp)"
+ gzip < /dev/null > "$kdata"
+
+ local expected="-A arm -O linux -T kernel -C gzip -a 0xdeadbeef -e 0xbaddcafe -n desc -d $kdata output"
+ _test_mkimage_kernel "$kdata" "$expected" || exit 1
+ rm -f "$kdata"
+}
+add_test test_mkimage_kernel_gzip
+
test_mkimage_initrd() {
(
mkimage() {
Reply to: