From: Jan Kiszka <jan.kiszka@siemens.com>
To: isar-users <isar-users@googlegroups.com>
Subject: [PATCH] u-boot-script: Add support for device tree overlays
Date: Sun, 9 Dec 2018 10:00:50 +0100 [thread overview]
Message-ID: <3bab30c1-2ed4-0fba-3507-a0a6faae8c4c@siemens.com> (raw)
This adds support to the u-boot script for loading device tree overlay
files into the main dtb before the kernel boots. The user just needs to
specify the files in the OVERLAYS variable in /etc/default/u-boot-script
or provide this information via sourceparams 'overlays' to
rootfs-u-boot.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
Developed for / tested against the AM65x (their downstream kernel uses
this). If someone knows a good test case for our in-tree targets, we
should add that. Maybe something for an RasPi?
meta/recipes-bsp/u-boot-script/files/u-boot-script | 5 +++++
.../recipes-bsp/u-boot-script/files/update-u-boot-script | 16 ++++++++++++++++
meta/scripts/lib/wic/plugins/source/rootfs-u-boot.py | 3 +++
3 files changed, 24 insertions(+)
diff --git a/meta/recipes-bsp/u-boot-script/files/u-boot-script b/meta/recipes-bsp/u-boot-script/files/u-boot-script
index ca31b6d..d053d72 100644
--- a/meta/recipes-bsp/u-boot-script/files/u-boot-script
+++ b/meta/recipes-bsp/u-boot-script/files/u-boot-script
@@ -5,6 +5,11 @@ ROOT_PARTITION="\${distro_bootpart}"
# Make sure to escape $ in u-boot variables, e.g. "\${console}".
KERNEL_ARGS=""
+# Space-separated list of device tree overlay files.
+# Can be absolute paths in root filesystem or relative ones under
+# /usr/lib/linux-image-<KERNEL_VERSION>
+OVERLAYS=""
+
# Set to "yes" or "1" to leave out initrd, even if present
NO_INITRD=""
diff --git a/meta/recipes-bsp/u-boot-script/files/update-u-boot-script b/meta/recipes-bsp/u-boot-script/files/update-u-boot-script
index c613b13..d006a23 100755
--- a/meta/recipes-bsp/u-boot-script/files/update-u-boot-script
+++ b/meta/recipes-bsp/u-boot-script/files/update-u-boot-script
@@ -37,6 +37,22 @@ yes|1)
INITRD_ADDR="\${ramdisk_addr_r}:\${filesize}"
esac
+if [ -n "${OVERLAYS}" ]; then
+ echo "fdt addr \${fdt_addr_r}" >> ${BOOT_CMD}
+ # grant 1 MB to combined device tree
+ echo "fdt resize 0x100000" >> ${BOOT_CMD}
+ echo "setexpr overlay_addr_r \${fdt_addr_r} + 0x100000" >> ${BOOT_CMD}
+ for OVERLAY in ${OVERLAYS}; do
+ if ! echo $OVERLAY | grep -q "^/"; then
+ OVERLAY_PATH=/usr/lib/linux-image-${KERNEL_VERSION}/
+ fi
+ echo "load \${devtype} \${devnum}:${ROOT_PARTITION}" \
+ "\${overlay_addr_r} ${OVERLAY_PATH}${OVERLAY}" \
+ >> ${BOOT_CMD}
+ echo "fdt apply \${overlay_addr_r}" >> ${BOOT_CMD}
+ done
+fi
+
BOOT="bootz"
if [ "$(uname -m)" = "aarch64" ]; then
BOOT="booti"
diff --git a/meta/scripts/lib/wic/plugins/source/rootfs-u-boot.py b/meta/scripts/lib/wic/plugins/source/rootfs-u-boot.py
index 0c7710e..37baea9 100644
--- a/meta/scripts/lib/wic/plugins/source/rootfs-u-boot.py
+++ b/meta/scripts/lib/wic/plugins/source/rootfs-u-boot.py
@@ -9,6 +9,7 @@
# u-boot-script to boot this rootfs.
# Recognized sourceparams:
# - no_initrd=yes (disables initrd loading)
+# - overlays=file.dtbo ... (overlay files)
# - script_prepend=cmd;... (prepends U-Boot command)
import glob
@@ -71,6 +72,8 @@ class RootfsUBootPlugin(RootfsPlugin):
(cr.rootdev, cr.ks.bootloader.append))
no_initrd = source_params.get('no_initrd') or ''
cfg.write('NO_INITRD="%s"\n' % no_initrd)
+ overlays = source_params.get('overlays') or ''
+ cfg.write('OVERLAYS="%s"\n' % overlays)
script_prepend = source_params.get('script_prepend') or ''
cfg.write('SCRIPT_PREPEND="%s"\n' % script_prepend)
--
2.16.4
next reply other threads:[~2018-12-09 9:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-09 9:00 Jan Kiszka [this message]
2018-12-11 8:11 ` Maxim Yu. Osipov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3bab30c1-2ed4-0fba-3507-a0a6faae8c4c@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=isar-users@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox