diff -Nru flash-kernel-3.98ubuntu5/bootscript/all/bootscr.rpi flash-kernel-3.98ubuntu5.1/bootscript/all/bootscr.rpi --- flash-kernel-3.98ubuntu5/bootscript/all/bootscr.rpi 2019-10-10 09:41:43.000000000 +0000 +++ flash-kernel-3.98ubuntu5.1/bootscript/all/bootscr.rpi 2019-11-07 14:02:26.000000000 +0000 @@ -1,52 +1,65 @@ # Ubuntu Classic RPi U-Boot script (for armhf and arm64) -# These values *must* be set in the global environment, not the hush -# interpreter's environment (they're already in the global environment -# which oddly takes precedence over hush vars) -setenv fdt_addr_r 0x03000000 -setenv kernel_addr_r 0x01000000 -setenv ramdisk_addr_r 0x03100000 - -# Load the flattened device tree and extract the bootargs from the /chosen -# path into the ${bootargs} variable -fdt addr ${fdt_addr_r} -fdt get value bootargs /chosen bootargs +# Expects to be called with the following environment variables set: +# +# devtype e.g. mmc/scsi etc +# devnum The device number of the given type +# distro_bootpart The partition containing the boot files +# (introduced in u-boot mainline 2016.01) +# prefix Prefix within the boot partiion to the boot files +# kernel_addr_r Address to load the kernel to +# fdt_addr_r Address to load the FDT to +# ramdisk_addr_r Address to load the initrd to. -# Store the gzip header (1f 8b) in the kernel area for comparison to the -# header of the image we load. Load "vmlinuz" into the portion of memory for -# the RAM disk (because we want to uncompress to the kernel area if it's -# compressed) and compare the word at the start -mw.w ${kernel_addr_r} 0x8b1f # little endian -load ${devtype} ${devnum}:${distro_bootpart} ${ramdisk_addr_r} vmlinuz -kernel_size=${filesize} -if cmp.w ${kernel_addr_r} ${ramdisk_addr_r} 1; then - # It's a gzip compressed image (NOTE: *not* a self-extracting gzip - # compressed kernel, just a kernel image that has been gzip'd). This is - # how all kernels *should* be shipped on Ubuntu for RPi in future, - # regardless of architecture. - # - # Decompress the image into the kernel area, and set us up to use booti - # to launch it - echo "Decompressing kernel..." - unzip ${ramdisk_addr_r} ${kernel_addr_r} - kernel_size=${filesize} - try_boot="booti" +# Take fdt addr from the prior stage boot loader, if available +if test -n "$fdt_addr"; then + setexpr fdt_addr sub "^0x" "" # work-around missing 0x prefix + setenv fdt_addr 0x${fdt_addr} + fdt addr ${fdt_addr} + fdt move ${fdt_addr} ${fdt_addr_r} # implicitly sets fdt active else - # The kernel *might* be a self-extracting image (former case on armhf) or - # an uncompressed image (former case on arm64). Copy the data into the - # kernel area then attempt to launch first with "bootz" (will fail on arm64 - # with an unknown command, on armhf with compressed image will succeed) - # then "booti" (will succeed with uncompressed image) - echo "Copying kernel..." - cp.b ${ramdisk_addr_r} ${kernel_addr_r} ${kernel_size} - try_boot="bootz booti" + fdt addr ${fdt_addr_r} fi +fdt get value bootargs /chosen bootargs + +setenv bootargs "@@LINUX_KERNEL_CMDLINE_DEFAULTS@@ ${bootargs} @@LINUX_KERNEL_CMDLINE@@" +@@UBOOT_ENV_EXTRA@@ + +@@UBOOT_PREBOOT_EXTRA@@ + +if test -z "${fk_image_locations}"; then + setenv fk_image_locations ${prefix} +fi + +for pathprefix in ${fk_image_locations}; do + # Store the gzip header (1f 8b) in the kernel area for comparison to the + # header of the image we load. Load "vmlinuz" into the portion of memory for + # the RAM disk (because we want to uncompress to the kernel area if it's + # compressed) and compare the word at the start + mw.w ${kernel_addr_r} 0x8b1f # little endian + if test -e ${devtype} ${devnum}:${partition} ${pathprefix}vmlinuz; then + load ${devtype} ${devnum}:${distro_bootpart} ${ramdisk_addr_r} ${pathprefix}vmlinuz + kernel_size=${filesize} + if cmp.w ${kernel_addr_r} ${ramdisk_addr_r} 1; then + # gzip compressed image (NOTE: *not* a self-extracting gzip compressed + # kernel, just a kernel image that has been gzip'd) + echo "Decompressing kernel..." + unzip ${ramdisk_addr_r} ${kernel_addr_r} + setenv kernel_size ${filesize} + setenv try_boot "booti" + else + # Possibly self-extracting or uncompressed; copy data into the kernel area + # and attempt launch with bootz then booti + echo "Copying kernel..." + cp.b ${ramdisk_addr_r} ${kernel_addr_r} ${kernel_size} + setenv try_boot "bootz booti" + fi -# Load the initramfs into the initramfs area, storing the filesize in the -# variable expected by $boot_ubuntu -load mmc 0:1 ${ramdisk_addr_r} initrd.img -ramdisk_size=${filesize} -for cmd in ${try_boot}; do - echo "Trying boot command: ${cmd}..." - ${cmd} ${kernel_addr_r} ${ramdisk_addr_r}:${ramdisk_size} ${fdt_addr_r} + load ${devtype} ${devnum}:${distro_bootpart} ${ramdisk_addr_r} ${pathprefix}initrd.img + setenv ramdisk_size ${filesize} + for cmd in ${try_boot}; do + echo "Booting Ubuntu (with ${cmd}) from ${devtype} ${devnum}:${partition}..." + ${cmd} ${kernel_addr_r} ${ramdisk_addr_r}:${ramdisk_size} ${fdt_addr_r} + done + fi done diff -Nru flash-kernel-3.98ubuntu5/db/all.db flash-kernel-3.98ubuntu5.1/db/all.db --- flash-kernel-3.98ubuntu5/db/all.db 2019-10-10 12:04:59.000000000 +0000 +++ flash-kernel-3.98ubuntu5.1/db/all.db 2019-11-07 14:02:26.000000000 +0000 @@ -1359,7 +1359,7 @@ Boot-Script-Path: preEnv.txt Required-Packages: u-boot-tools Bootloader-sets-root: yes -DTB-Kernel-Version: 3.11 +DTB-Append-From: 3.11 DTB-Id: omap4-panda-es.dtb Machine: QCT APQ8064 CDP @@ -1618,68 +1618,59 @@ Required-Packages: u-boot-tools Boot-Script-Path: /boot/boot.scr -# Raspberry Pi 2 (BCM2709) Machine: BCM2709 Machine: Raspberry Pi 2 Model B Machine: Raspberry Pi 2 Model B Rev 1.1 Machine: Raspberry Pi 2 Model B Rev 1.2 +Method: pi +Kernel-Flavors: raspi2 DTB-Id: bcm2709-rpi-2-b.dtb U-Boot-Script-Name: bootscr.rpi Required-Packages: u-boot-tools -Boot-DTB-Path: /boot/firmware/bcm2709-rpi-2-b.dtb -Boot-Kernel-Path: /boot/firmware/vmlinuz -Boot-Initrd-Path: /boot/firmware/initrd.img -Boot-Script-Path: /boot/firmware/boot.scr -# XXX we should copy the entire overlay dtbs dir too -# Raspberry Pi 3 (BCM2710) Machine: BCM2710 Machine: Raspberry Pi 3 Model B Machine: Raspberry Pi 3 Model B Rev 1.2 +Method: pi +Kernel-Flavors: raspi2 DTB-Id: bcm2710-rpi-3-b.dtb U-Boot-Script-Name: bootscr.rpi Required-Packages: u-boot-tools -Boot-DTB-Path: /boot/firmware/bcm2710-rpi-3-b.dtb -Boot-Kernel-Path: /boot/firmware/vmlinuz -Boot-Initrd-Path: /boot/firmware/initrd.img -Boot-Script-Path: /boot/firmware/boot.scr -# XXX we should copy the entire overlay dtbs dir too -# Raspberry Pi 3 B+ +Machine: Raspberry Pi 3 Model A+ +Machine: Raspberry Pi 3 Model A Plus +Machine: Raspberry Pi 3 Model A Plus Rev 1.0 +Method: pi +Kernel-Flavors: raspi2 +DTB-Id: bcm2710-rpi-3-b-plus.dtb +U-Boot-Script-Name: bootscr.rpi +Required-Packages: u-boot-tools +# XXX when a 3A+ specific dtb is added to linux-raspi2, use it here + Machine: Raspberry Pi 3 Model B+ Machine: Raspberry Pi 3 Model B Plus Machine: Raspberry Pi 3 Model B Plus Rev 1.3 +Method: pi +Kernel-Flavors: raspi2 DTB-Id: bcm2710-rpi-3-b-plus.dtb U-Boot-Script-Name: bootscr.rpi Required-Packages: u-boot-tools -Boot-DTB-Path: /boot/firmware/bcm2710-rpi-3-b-plus.dtb -Boot-Kernel-Path: /boot/firmware/vmlinuz -Boot-Initrd-Path: /boot/firmware/initrd.img -Boot-Script-Path: /boot/firmware/boot.scr -# XXX we should copy the entire overlay dtbs dir too -# Raspberry Pi Compute Module 3 and 3+ Machine: Raspberry Pi Compute Module 3 Rev 1.0 Machine: Raspberry Pi Compute Module 3 Plus Rev 1.0 +Method: pi +Kernel-Flavors: raspi2 DTB-Id: bcm2710-rpi-cm3.dtb U-Boot-Script-Name: bootscr.rpi Required-Packages: u-boot-tools -Boot-DTB-Path: /boot/firmware/bcm2710-rpi-cm3.dtb -Boot-Kernel-Path: /boot/firmware/vmlinuz -Boot-Initrd-Path: /boot/firmware/initrd.img -Boot-Script-Path: /boot/firmware/boot.scr -# XXX we should copy the entire overlay dtbs dir too Machine: Raspberry Pi 4 Model B Machine: Raspberry Pi 4 Model B Rev 1.1 +Method: pi +Kernel-Flavors: raspi2 DTB-Id: bcm2711-rpi-4-b.dtb U-Boot-Script-Name: bootscr.rpi Required-Packages: u-boot-tools -Boot-DTB-Path: /boot/firmware/bcm2711-rpi-4-b.dtb -Boot-Kernel-Path: /boot/firmware/vmlinuz -Boot-Initrd-Path: /boot/firmware/initrd.img -Boot-Script-Path: /boot/firmware/boot.scr -# XXX we should copy the entire overlay dtbs dir too Machine: Rockchip RK3288 Tinker Board Kernel-Flavors: armmp armmp-lpae @@ -1702,7 +1693,7 @@ U-Boot-Script-Address: 0x80001000 U-Boot-Script-Name: bootscr.exynos5 DTB-Id: exynos5440-ssdk5440.dtb -DTB-Kernel-Version: 3.11 +DTB-Append-From: 3.11 Boot-Kernel-Path: /boot/uImage Boot-Initrd-Path: /boot/uInitrd Boot-Script-Path: /boot/boot.scr @@ -1716,7 +1707,7 @@ U-Boot-Script-Address: 0x80001000 U-Boot-Script-Name: bootscr.exynos5 DTB-Id: exynos5440-sd5v1.dtb -DTB-Kernel-Version: 3.11 +DTB-Append-From: 3.11 Boot-Kernel-Path: /boot/uImage Boot-Initrd-Path: /boot/uInitrd Boot-Script-Path: /boot/boot.scr @@ -1923,7 +1914,7 @@ Boot-Script-Path: preEnv.txt Required-Packages: u-boot-tools Bootloader-sets-root: yes -DTB-Kernel-Version: 3.12 +DTB-Append-From: 3.12 DTB-Id: imx6q-wandboard.dtb Machine: Wandboard i.MX6 Quad Board rev B1 diff -Nru flash-kernel-3.98ubuntu5/debian/changelog flash-kernel-3.98ubuntu5.1/debian/changelog --- flash-kernel-3.98ubuntu5/debian/changelog 2019-10-10 12:04:59.000000000 +0000 +++ flash-kernel-3.98ubuntu5.1/debian/changelog 2019-11-07 14:02:26.000000000 +0000 @@ -1,3 +1,19 @@ +flash-kernel (3.98ubuntu5.1) eoan; urgency=medium + + * Backport changes from 3.98ubuntu6 to eoan + * Remove redundant DTB-Kernel-Version field + * Remove redundant copying of boot dtb + * Fix mkimage_kernel tests + * Add "pi" value for the "Method" field which copies all dtbs and overlays + to the boot partition and provides defaults for the boot paths of the + kernel, initrd, and u-boot script. This fixes upgrades to support the Pi 4 + on Bionic (LP: #1850678) + * Update pi bootscript to support all flash-kernel vars, including + calculated devtype and partition for future USB boot support + * Add entry for Raspberry Pi 3A+ (LP: #1841955) + + -- Dave Jones Thu, 07 Nov 2019 14:02:26 +0000 + flash-kernel (3.98ubuntu5) eoan; urgency=medium * Fix AARCH64 qcom laptop names, to those accepted upstream and in the diff -Nru flash-kernel-3.98ubuntu5/debian/control flash-kernel-3.98ubuntu5.1/debian/control --- flash-kernel-3.98ubuntu5/debian/control 2019-10-10 09:41:43.000000000 +0000 +++ flash-kernel-3.98ubuntu5.1/debian/control 2019-11-07 14:02:26.000000000 +0000 @@ -19,7 +19,8 @@ initramfs-tools (>= 0.92f), linux-base (>= 3.2), mtd-utils, - ucf + ucf, + awk Recommends: u-boot-tools Description: utility to make certain embedded devices bootable flash-kernel is a script which will put the kernel and initramfs in diff -Nru flash-kernel-3.98ubuntu5/functions flash-kernel-3.98ubuntu5.1/functions --- flash-kernel-3.98ubuntu5/functions 2019-10-10 09:41:43.000000000 +0000 +++ flash-kernel-3.98ubuntu5.1/functions 2019-11-07 14:02:26.000000000 +0000 @@ -21,6 +21,7 @@ BOOTSCRIPTS_DIR="${FK_CHECKOUT:-/etc/flash-kernel}/bootscript" FK_ETC_MACHINE="${FK_ETC_MACHINE:-/etc/flash-kernel/machine}" +FK_DEFAULTS="${FK_DEFAULTS:-/etc/default/flash-kernel}" PROC_CPUINFO="${FK_PROC_CPUINFO:-/proc/cpuinfo}" PROC_DTMODEL="${FK_PROC_DTMODEL:-/proc/device-tree/model}" PROC_MTD="/proc/mtd" @@ -441,11 +442,11 @@ } get_kernel_cmdline() { - . /etc/default/flash-kernel + . ${FK_DEFAULTS} echo "$LINUX_KERNEL_CMDLINE" } get_kernel_cmdline_defaults() { - . /etc/default/flash-kernel + . ${FK_DEFAULTS} echo "$LINUX_KERNEL_CMDLINE_DEFAULTS" } @@ -502,7 +503,7 @@ -e "/@@UBOOT_ENV_EXTRA@@/{ s/@@UBOOT_ENV_EXTRA@@//g r $ubootenv - }" < $sdata > $tdata \ + }" \ -e "/@@UBOOT_PREBOOT_EXTRA@@/{ s/@@UBOOT_PREBOOT_EXTRA@@//g r $preboot @@ -527,7 +528,7 @@ # Return a nonempty string *unless* NO_CREATE_DOT_BAK_FILES is set. get_dot_bak_preference() { - . /etc/default/flash-kernel + . ${FK_DEFAULTS} case $(echo "$NO_CREATE_DOT_BAK_FILES" | tr '[:upper:]' '[:lower:]') in true|yes|1) ;; *) echo yes ;; @@ -536,7 +537,7 @@ # Return a nonempty string *unless* MTD_BACKUP_DIR is "none". get_mtd_backup_dir() { - . /etc/default/flash-kernel + . ${FK_DEFAULTS} case "${MTD_BACKUP_DIR:=/var/backups/flash-kernel}" in none) echo "";; *) echo "${MTD_BACKUP_DIR}";; @@ -585,7 +586,6 @@ fi } -# XXX needs testsuite coverage abootimg_get_image_size() { local abootimg="$1" @@ -596,7 +596,6 @@ linux-version compare "$kvers" ge "$dtb_append_from" } -# XXX needs testsuite coverage android_flash() { local device="$1" @@ -659,6 +658,30 @@ echo $dtb } +unique_filenames() { + awk ' + { + file=$0; + sub("^.*/", "", file); + if (!(file in files)) files[file]=$0; + } + END { + for (file in files) print files[file]; + }' +} + +find_all_dtbs() { + # NOTE: The following assumes that "find" processes and outputs + # filenames in the same order as starting points ($paths) are specified + paths="/etc/flash-kernel/dtbs /usr/lib/linux-image-$kvers /lib/firmware/$kvers/device-tree/" + find $paths -name "*.dtb" 2>/dev/null | unique_filenames +} + +find_all_overlays() { + paths="/etc/flash-kernel/dtbs /usr/lib/linux-image-$kvers /lib/firmware/$kvers/device-tree/" + find $paths -name "*.dtbo" 2>/dev/null | unique_filenames +} + handle_dtb() { if [ "x$dtb_name" = "x" ]; then return @@ -856,7 +879,6 @@ method="$(get_machine_field "$machine" "Method")" || method="generic" mtd_kernel="$(get_machine_field "$machine" "Mtd-Kernel")" || : mtd_initrd="$(get_machine_field "$machine" "Mtd-Initrd")" || : -dtb_kver="$(get_machine_field "$machine" "DTB-Kernel-Version")" || : dtb_append="$(get_machine_field "$machine" "DTB-Append")" || : dtb_append_from="$(get_machine_field "$machine" "DTB-Append-From")" || : ukaddr="$(get_machine_field "$machine" "U-Boot-Kernel-Address")" || : @@ -962,17 +984,6 @@ gen_kernel "$kernel" "$tmpdir/kernel" "$machine_id" kernel="$tmpdir/kernel" fi - if [ -n "$dtb_kver" ]; then - if dpkg --compare-versions "$kvers" ge "$dtb_kver" >/dev/null; then - dtb="$(find /lib/firmware/$kvers/device-tree/ -name $dtb_name)" - if [ ! -f "$dtb" ] ; then - error "Couldn't find $dtb" - fi - append_dtb "$kernel" "$dtb" "$tmpdir/kernel.dtb" - mv "$tmpdir/kernel.dtb" "$tmpdir/kernel" - kernel="$tmpdir/kernel" - fi - fi if [ -n "$ukaddr" ]; then if [ -n "$ukepoint" ]; then mkimage_kernel "$ukaddr" "$ukepoint" "$desc" "$kernel" \ @@ -1012,14 +1023,6 @@ flash_kernel "$tmpdir/uImage" "$kmtd" "" rm -f "$tmpdir/uImage" fi - if [ -n "$dtb_name" ] && [ -n "$boot_dtb_path" ]; then - dtb="$(find /lib/firmware/$kvers/device-tree/ -name $dtb_name)" - if [ -f "$dtb" ]; then - cp "$dtb" "$tmpdir/$dtb_name" - dtb_path="$boot_mnt_dir/$boot_dtb_path" - backup_and_install "$tmpdir/$dtb_name" "$dtb_path" - fi - fi if [ -n "$boot_multi_path" ]; then backup_and_install "$tmpdir/uImage" "$boot_multi_path" fi @@ -1091,6 +1094,37 @@ backup_and_install "$dtb" "$boot_dtb_path" fi ;; + "pi") + boot_dir="/boot/firmware" + boot_kernel_path=${boot_kernel_path:-$boot_dir/vmlinuz} + boot_initrd_path=${boot_initrd_path:-$boot_dir/initrd.img} + boot_script_path=${boot_script_path:-$boot_dir/boot.scr} + cp "$kfile" "$tmpdir/vmlinuz" + backup_and_install "$tmpdir/vmlinuz" "$boot_kernel_path" + cp "$ifile" "$tmpdir/initrd.img" + backup_and_install "$tmpdir/initrd.img" "$boot_initrd_path" + boot_script="$tmpdir/boot.scr" + for script in $usname ; do + echo "\n#\n# flash-kernel: $script\n#\n" >> "$boot_script" + cat "$BOOTSCRIPTS_DIR/$script" >> "$boot_script" + done + mkimage_script "$usaddr" "boot script" "$boot_script" "$tmpdir/boot.scr" + backup_and_install "$boot_script" "$boot_dir/boot.scr" + find_all_dtbs | { + while read dtb; do + dtb_name=$(basename $dtb) + cp "$dtb" "$tmpdir/$dtb_name" + backup_and_install "$tmpdir/$dtb_name" "$boot_dir/$dtb_name" + done + } + find_all_overlays | { + while read overlay; do + overlay_name=$(basename $overlay) + cp "$overlay" "$tmpdir/$overlay_name" + backup_and_install "$tmpdir/$overlay_name" "$boot_dir/overlays/$overlay_name" + done + } + ;; "symlink") rm -f /boot/initrd /boot/zImage ln -s "$(basename "$ifile")" /boot/initrd diff -Nru flash-kernel-3.98ubuntu5/README flash-kernel-3.98ubuntu5.1/README --- flash-kernel-3.98ubuntu5/README 2019-10-10 09:41:43.000000000 +0000 +++ flash-kernel-3.98ubuntu5.1/README 2019-11-07 14:02:26.000000000 +0000 @@ -193,8 +193,6 @@ kernel, initrd and U-Boot script; Boot-Kernel-Path, Boot-Initrd-Path and Boot-Script-Path are then taken relative to this boot device -* DTB-Kernel-Version: (optional) minimal kernel version for DTB concatenation - Configuration - - - - - - - diff -Nru flash-kernel-3.98ubuntu5/test_db flash-kernel-3.98ubuntu5.1/test_db --- flash-kernel-3.98ubuntu5/test_db 2019-10-10 09:41:43.000000000 +0000 +++ flash-kernel-3.98ubuntu5.1/test_db 2019-11-07 14:02:26.000000000 +0000 @@ -22,7 +22,7 @@ MACHINE_DB="$(cat "${FK_CHECKOUT:-$FK_DIR}/db/"*.db)" test_no_unknown_fields() { - local expected='Android-Boot-Device Android-Skip-Initrd Boot-Device Boot-DTB-Path Boot-Initrd-Path Boot-Kernel-Path Bootloader-Sets-Incorrect-Root Bootloader-sets-root Boot-Multi-Path Boot-Script-Path DTB-Append DTB-Append-From DTB-Id DTB-Kernel-Version Kernel-Flavors Machine Machine-Id Method Mtd-Initrd Mtd-Kernel Optional-Packages Required-Packages U-Boot-Initrd-Address U-Boot-Kernel-Address U-Boot-Kernel-Entry-Point U-Boot-Multi-Address U-Boot-Script-Address U-Boot-Script-Name' + local expected='Android-Boot-Device Android-Skip-Initrd Boot-Device Boot-DTB-Path Boot-Initrd-Path Boot-Kernel-Path Bootloader-Sets-Incorrect-Root Bootloader-sets-root Boot-Multi-Path Boot-Script-Path DTB-Append DTB-Append-From DTB-Id Kernel-Flavors Machine Machine-Id Method Mtd-Initrd Mtd-Kernel Optional-Packages Required-Packages U-Boot-Initrd-Address U-Boot-Kernel-Address U-Boot-Kernel-Entry-Point U-Boot-Multi-Address U-Boot-Script-Address U-Boot-Script-Name' expected="$(echo "$expected" | sed 's/ /\n/g' | sort -u | xargs)" local fields="$(echo "$MACHINE_DB" | sed -n '/^[^#]*:/s/:.*//p' | sort -u | xargs)" if [ "$fields" != "$expected" ]; then diff -Nru flash-kernel-3.98ubuntu5/test_functions flash-kernel-3.98ubuntu5.1/test_functions --- flash-kernel-3.98ubuntu5/test_functions 2019-10-10 09:41:43.000000000 +0000 +++ flash-kernel-3.98ubuntu5.1/test_functions 2019-11-07 14:02:26.000000000 +0000 @@ -571,29 +571,28 @@ . "$functions" saved_args="" mkarch="arm" - 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 - return 1 + exit 1 fi ) } test_mkimage_kernel() { local kdata="/dev/zero" - local expected="-A arm -O linux -T kernel -C none -a 0xdeadbeef -e 0xdeadbeef -n desc -d $kdata output" - _test_mkimage_kernel "$kdata" "$expected" || exit 1 + local expected="-A arm -O linux -T kernel -C none -a 0xdeadbeef -e 0xbaddcafe -n desc -d $kdata output" + _test_mkimage_kernel "$kdata" "$expected" } add_test test_mkimage_kernel test_mkimage_kernel_gzip() { - local kdata="$(mktemp)" + get_tempfile + local kdata="$last_tempfile" gzip < /dev/null > "$kdata" - local expected="-A arm -O linux -T kernel -C gzip -a 0xdeadbeef -e 0xdeadbeef -n desc -d $kdata output" - _test_mkimage_kernel "$kdata" "$expected" || exit 1 - rm -f "$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" } add_test test_mkimage_kernel_gzip @@ -615,6 +614,60 @@ } add_test test_mkimage_initrd +test_mkimage_script() { + get_tempfile + mock_fk_defaults="$last_tempfile" + cat >"$mock_fk_defaults" <"$mock_script" </dev/null + expected="-A arm -O linux -T script -C none -a 0xdeadbeef -e 0xdeadbeef -n desc -d $tmpdir/$(basename $mock_script).out script" + expected_script="$(printf "setenv bootargs foo bar baz quux\n\nfoo\nbar\n\nbaz\nend")" + if [ "$expected" != "$saved_args" ]; then + echo "Expected mkimage_script to be called with \"$expected\" but it was called with \"$saved_args\"" >&2 + exit 1 + fi + if [ "$generated_script" != "$expected_script" ]; then + echo "The script generated by mkimage_script did not match the expected output" >&2 + exit 1 + fi + ) +} +add_test test_mkimage_script + test_mkimage_multi() { ( mkimage() { @@ -707,6 +760,123 @@ } add_test test_dtb_append_from +test_abootimg_get_image_size() { + abootimg_output=" + +Android Boot Image Info: + +* file name = boot.img + +* image size = 8388608 bytes (8.00 MB) + page size = 2048 bytes + +* Boot Name = \"\" + +* kernel size = 3002744 bytes (2.86 MB) + ramdisk size = 1639626 bytes (1.56 MB) + +* load addresses: + kernel: 0x10008000 + ramdisk: 0x11000000 + tags: 0x10000100 + +* cmdline = mem=448M@0M nvmem=64M@448M vmalloc=320M video=tegrafb console=tty0 usbcore.old_scheme_first=1 quiet splash elevator=noop tegraboot=sdmmc cmdpart=1:7168:10240,2:17408:16384,3:35840:614400,4:4004864:27096064 + +* id = 0x07571070 0x13950a6a 0x185c996f 0x9ab7b64d 0xcccd09bd 0x00000000 0x00000000 0x00000000 +" + ( + . "$functions" + size=$(abootimg_get_image_size "$abootimg_output") + if [ "$size" -ne 8388608 ]; then + echo "Expected 8388608 but got $size" >&2 + exit 1 + fi + ) +} +add_test test_abootimg_get_image_size + +test_android_flash() { + ( + abootimg() { + saved_args="$@" + } + . "$functions" + saved_args="" + kfile="vmlinuz" + ifile="initrd.img" + android_flash /dev/some-dev 2>/dev/null + expected="-u /dev/some-dev -k vmlinuz -r initrd.img" + if [ "$expected" != "$saved_args" ]; then + echo "Expected abootimg to be called with \"$expected\" but it was called with \"$saved_args\"" >&2 + exit 1 + fi + saved_args="" + android_skip_initrd=1 android_flash /dev/some-dev 2>/dev/null + expected="-u /dev/some-dev -k vmlinuz" + if [ "$expected" != "$saved_args" ]; then + echo "Expected abootimg to be called with \"$expected\" but it was called with \"$saved_args\"" >&2 + exit 1 + fi + ) +} +add_test test_android_flash + +test_find_all_dtbs() { + kvers="3.14" + get_tempfile + mock_find_output="$last_tempfile" + cat >"$mock_find_output" <&2 + exit 1 + fi + ) +} +add_test test_find_all_dtbs + +test_find_all_overlays() { + kvers="3.14" + get_tempfile + mock_find_output="$last_tempfile" + cat >"$mock_find_output" <&2 + exit 1 + fi + ) +} +add_test test_find_all_overlays + test_main # vim:syntax=sh