From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6632915786870554624 X-Received: by 2002:a50:a5f1:: with SMTP id b46mr1424583edc.12.1544346051908; Sun, 09 Dec 2018 01:00:51 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a50:89cf:: with SMTP id h15ls1773059edh.7.gmail; Sun, 09 Dec 2018 01:00:51 -0800 (PST) X-Google-Smtp-Source: AFSGD/WqL12x7mTBJGK8/u4EgeSsys/u4wuoH5BwW5akgTjxW0bPL5SXigf37LzgC7XaBQDNHfQB X-Received: by 2002:a50:a5f1:: with SMTP id b46mr1424580edc.12.1544346051377; Sun, 09 Dec 2018 01:00:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544346051; cv=none; d=google.com; s=arc-20160816; b=HV42ApUhzTeylSGn65u6+/P+SpDyzM5kx2TNGNybn40Ep9w3x8pq0Y826GBM16jtC6 O6Kq7Xaurj0I2ALQi34z14439mJlXkxgCIPNVW4SjFFjOuaB6l7UDn+3Bw2S5G9VR6FN fX432XNStGqhhaxPEvfR4TnQjLRb2mp6yT3zWkCjPDmxsRK+eDepTDfvReeqVcZuTVzq TJBY133HujTF9yg/O6vr+1Qm/PMF5g/LN+XKlDe98v4iSWEsWlry7aJLyyGm6dgs9t8h spGpPFNpbjjeExXaProF2sKtTA/N/HCFFgoao9tPC258+syn0cvbM1DAfgalthCnKZ8T O1hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:mime-version:user-agent :date:message-id:subject:from:to; bh=QsV64auG7gOl31S2CrJWUCIMDsJ+pt79dGpoiBMch8M=; b=AuXA6EgWVxy17ZPDYG6jqRAWhHPTGUr4ZjZpiiC27H7PQsYg33gKM1T0zrSpCyVzOW 1jJurEZabTQh7mLVnWQrijCxez6rhh/erb8JCtJluueYVgn+BEk7V40PxZxNc+A1yZTY 2nc/zxB3/kFEzGcE2hxHbqBkAEVbQq91yn6eMvBjUw5E8yOra+jp+vLgzD93r2RfVy3N zZKLg6bY5Odl9BQ8NjEGqAS1sg8sZVONGusEEWRMwdpnesdn8ZKEiureHbOlXJEgv4wa aGngVLjZapuRXlIOCLx34VvLmBOvDmHLNmclDqtQhFo10IaDT4ExzEQAQ3vt5LVC4xqo FWEA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 194.138.37.39 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com Return-Path: Received: from lizzard.sbs.de (lizzard.sbs.de. [194.138.37.39]) by gmr-mx.google.com with ESMTPS id i17si260454edg.2.2018.12.09.01.00.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Dec 2018 01:00:51 -0800 (PST) Received-SPF: pass (google.com: domain of jan.kiszka@siemens.com designates 194.138.37.39 as permitted sender) client-ip=194.138.37.39; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 194.138.37.39 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com Received: from mail1.sbs.de (mail1.sbs.de [192.129.41.35]) by lizzard.sbs.de (8.15.2/8.15.2) with ESMTPS id wB990oYv030878 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 9 Dec 2018 10:00:50 +0100 Received: from [167.87.3.160] ([167.87.3.160]) by mail1.sbs.de (8.15.2/8.15.2) with ESMTP id wB990oU2006249 for ; Sun, 9 Dec 2018 10:00:50 +0100 To: isar-users From: Jan Kiszka Subject: [PATCH] u-boot-script: Add support for device tree overlays Message-ID: <3bab30c1-2ed4-0fba-3507-a0a6faae8c4c@siemens.com> Date: Sun, 9 Dec 2018 10:00:50 +0100 User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TUID: D+LruLkwYLNi 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 --- 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- +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