]> git.ozlabs.org Git - petitboot/commitdiff
utils/hooks: Add sample update-dtb hook.
authorJeremy Kerr <jk@ozlabs.org>
Fri, 21 Jun 2013 02:43:49 +0000 (10:43 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Mon, 24 Jun 2013 05:07:58 +0000 (13:07 +0800)
Provide an example for writing a pre-boot hook to update the dtb.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
utils/Makefile.am
utils/hooks/20-update-dtb-sample [new file with mode: 0644]

index c1ff586c404c78bc1de9451157140ac8129ccbac..6758d6812dbc5987a6d0db9baa4feeaeca1ae328 100644 (file)
@@ -31,6 +31,7 @@ dist_pkgdata_DATA = \
        kboot.conf.sample \
        bb-kexec-reboot \
        logrotate.conf \
-       hooks/01-create-default-dtb
+       hooks/01-create-default-dtb \
+       hooks/20-update-dtb-sample
 
 MAINTAINERCLEANFILES = Makefile.in
diff --git a/utils/hooks/20-update-dtb-sample b/utils/hooks/20-update-dtb-sample
new file mode 100644 (file)
index 0000000..44186a9
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/sh
+#
+# This is a sample boot hook to add a single property to the new kernel's
+# device tree.
+
+[ -z "$boot_dtb" ] && exit
+
+dtb_in=$boot_dtb
+dtb_out=$(mktemp)
+
+# Convert the dtb to dts, append our extra property, and convert back to dtb
+(
+       dtc -I dtb -O dts $dtb_in
+       echo '/ { petitboot,test = "test"; };'
+) | dtc -I dts -O dtb -o $dtb_out
+
+# If we have a good dtb (ie, the compile succeeded), replace the existing
+# dtb file.
+if [ $? = 0 ]
+then
+       mv $dtb_out $dtb_in
+fi