diff options
author | William Manley <will@williammanley.net> | 2018-01-09 19:40:07 +0000 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-01-16 22:54:53 +0000 |
commit | 720e2ec9bc401ec82deb64d5f493d5a2a41dd87d (patch) | |
tree | 392357aacda02e2e817263c2479ba697eb1f6562 /tests/test-no-initramfs.sh | |
parent | c5112c25e4519835c4cd53f4350c1b2f2a477746 (diff) | |
download | ostree-720e2ec9bc401ec82deb64d5f493d5a2a41dd87d.tar.gz |
Add support for devicetree files alongside the kernel and initramfs
Much like the (optional) initramfs at
`/usr/lib/ostree-boot/initramfs-<SHA256>` or
`/usr/lib/modules/$kver/initramfs` you can now optionally include a
flattened devicetree (.dtb) file alongside the kernel at
`/usr/lib/ostree-boot/devicetree-<SHA256>` or
`/usr/lib/modules/$kver/devicetree`.
This is useful for embedded ARM systems which need the devicetree file
loaded by the bootloader for the kernel to discover and initialise
hardware. See https://en.wikipedia.org/wiki/Device_tree for more
information.
This patch was mostly produced by copy-pasting code for initramfs handling
and renaming `s/initramfs/devicetree/g`. It's not beautiful, but it is
fairly straightforward.
It may be useful to extend device-tree support in a number ways in the
future. Device trees dependant on many details of the hardware they
support. This makes them unlike kernels, which may support many different
hardware variants as long as the instruction-set matches. This means that
a ostree tree created with a device-tree in this manner will only boot on
a single model of hardware. This is sufficient for my purposes, but may
not be for others'.
I've tested this on my NVidia Tegra TK1 device which has u-boot running
in syslinux-compatible mode.
Closes: #1411
Approved by: cgwalters
Diffstat (limited to 'tests/test-no-initramfs.sh')
-rwxr-xr-x | tests/test-no-initramfs.sh | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/tests/test-no-initramfs.sh b/tests/test-no-initramfs.sh index 7c23a3e7..52bb9d98 100755 --- a/tests/test-no-initramfs.sh +++ b/tests/test-no-initramfs.sh @@ -2,7 +2,7 @@ . $(dirname $0)/libtest.sh -echo "1..7" +echo "1..10" setup_os_repository "archive-z2" "uboot" @@ -20,11 +20,12 @@ echo "ok deployment with initramfs" pull_test_tree() { kernel_contents=$1 initramfs_contents=$2 + devicetree_contents=$3 - printf "TEST SETUP:\n kernel: %s\n initramfs: %s\n layout: %s\n" \ - "$kernel_contents" "$initramfs_contents" "$layout" + printf "TEST SETUP:\n kernel: %s\n initramfs: %s\n devicetree: %s\n layout: %s\n" \ + "$kernel_contents" "$initramfs_contents" "$devicetree_contents" "$layout" - rm -rf ${test_tmpdir}/osdata/usr/lib/modules/3.6.0/{initramfs.img,vmlinuz} \ + rm -rf ${test_tmpdir}/osdata/usr/lib/modules/3.6.0/{initramfs.img,vmlinuz,devicetree} \ ${test_tmpdir}/osdata/usr/lib/ostree-boot \ ${test_tmpdir}/osdata/boot if [ "$layout" = "/usr/lib/modules" ]; then @@ -32,14 +33,16 @@ pull_test_tree() { cd ${test_tmpdir}/osdata/usr/lib/modules/3.6.0 echo -n "$kernel_contents" > vmlinuz [ -n "$initramfs_contents" ] && echo -n "$initramfs_contents" > initramfs.img + [ -n "$devicetree_contents" ] && echo -n "$devicetree_contents" > devicetree elif [ "$layout" = "/usr/lib/ostree-boot" ] || [ "$layout" = "/boot" ]; then # "Legacy" layout mkdir -p "${test_tmpdir}/osdata/$layout" cd "${test_tmpdir}/osdata/$layout" - bootcsum=$(echo -n "$kernel_contents$initramfs_contents" \ + bootcsum=$(echo -n "$kernel_contents$initramfs_contents$devicetree_contents" \ | sha256sum | cut -f 1 -d ' ') echo -n "$kernel_contents" > vmlinuz-${bootcsum} [ -n "$initramfs_contents" ] && echo -n "$initramfs_contents" > initramfs-${bootcsum} + [ -n "$devicetree_contents" ] && echo -n "$devicetree_contents" > devicetree-${bootcsum} else exit 1 fi @@ -75,4 +78,13 @@ do assert_not_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'init=' echo "ok switching from no initramfs to initramfs enabled sysroot layout=$layout" + + pull_test_tree "the kernel" "" "my .dtb file" + ${CMD_PREFIX} ostree admin deploy --os=testos testos:testos/buildmaster/x86_64-runtime + + assert_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'init=' + assert_file_has_content sysroot/boot/"$(get_key_from_bootloader_conf sysroot/boot/loader/entries/ostree-testos-0.conf 'devicetree')" "my .dtb file" + assert_not_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'initrd' + + echo "ok switching from initramfs to no initramfs sysroot with devicetree layout=$layout" done |