From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6632915786870554624 X-Received: by 2002:a1c:9cc2:: with SMTP id f185mr129068wme.10.1544515896995; Tue, 11 Dec 2018 00:11:36 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a1c:41c5:: with SMTP id o188ls320735wma.3.gmail; Tue, 11 Dec 2018 00:11:36 -0800 (PST) X-Google-Smtp-Source: AFSGD/WQWWI8FRl0UhEGskrj9Nimx3X8E9xzNDt7sV+agPtUxmV3ui/YxeHfpiJcZpWitQXIz7GA X-Received: by 2002:a1c:3ad3:: with SMTP id h202mr132518wma.25.1544515896617; Tue, 11 Dec 2018 00:11:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544515896; cv=none; d=google.com; s=arc-20160816; b=ud43VMhNPl80C8nnbSa/3+HeUAGlQaaCqua10ZbokD0cGkru2NSMmURsJzYWDL1N9J /tFHIoHg7/jyoA+XEeLr8eDjZN+k5/Gzy9OojblqI/Y3mUAfiR4ffbFSIgIzdtAwVX9z +Lf+TSDOsMEqnlNPB5/ul5zEfIh3xlgi5iIPRIE0ZCtezzlOgTMRfld7tKHB/16zT/Wj /dmyVNA2TO/gyINafsQQOYMCJflAmaqyjHIru5H/z4fJMrKC9TcOPVvyZIKcTeappCU9 49kwa4Q+JUPCeb9NCNlGQC+TTMCK/bPQEtxxSKssLVYx5sJI6c2cZjppFbPwh0BYjlSy hEPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:organization:from:references:to:subject; bh=/QPUWUPFzkasjy8xF24zOWnDJrRvjKRTttBvqhnWQwk=; b=ZTXE/BBzGkazmxtg6k7Y/Qypan2Geh80LejjukMKaDJL6UQOe1PXtM81Sh+dBTVWBw RI/cwAE7x13ArVRknGvBQ63GJd8z+M/MYX7qnp3SW7e9Iw1/yLN82JJ9/4Zv3QLwJ8P9 ooi79OnTNfCKaIMOCkY4N63D0iEQWEk3UdIuAK+0OUSX8X/a8t1VIXaX9tptEPyRGILD 3JrzWom/wftx4Ye/wEJili/AVqF52/1CsGsorD+j5YHIasf2zNPPz2dpiwe+P1SDn2YV MermaFZNrIZmt8n2TalFbXBJ/GFVWEzG33h0GSWzC1oeVyb45sbfpQJ0x/dvJoqiG5x6 8BCw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: best guess record for domain of mosipov@ilbers.de designates 85.214.62.211 as permitted sender) smtp.mailfrom=mosipov@ilbers.de Return-Path: Received: from aqmola.ilbers.de (aqmola.ilbers.de. [85.214.62.211]) by gmr-mx.google.com with ESMTPS id 64si38166wma.1.2018.12.11.00.11.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Dec 2018 00:11:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of mosipov@ilbers.de designates 85.214.62.211 as permitted sender) client-ip=85.214.62.211; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: best guess record for domain of mosipov@ilbers.de designates 85.214.62.211 as permitted sender) smtp.mailfrom=mosipov@ilbers.de Received: from [192.168.50.180] (nat-ppp-217.71.235.199-satnet-spb.ru [217.71.235.199] (may be forged)) (authenticated bits=0) by aqmola.ilbers.de (8.14.4/8.14.4/Debian-4+deb7u1) with ESMTP id wBB8BX64017032 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Tue, 11 Dec 2018 09:11:35 +0100 Subject: Re: [PATCH] u-boot-script: Add support for device tree overlays To: Jan Kiszka , isar-users References: <3bab30c1-2ed4-0fba-3507-a0a6faae8c4c@siemens.com> From: "Maxim Yu. Osipov" Organization: ilbers GmbH Message-ID: Date: Tue, 11 Dec 2018 11:11:28 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: <3bab30c1-2ed4-0fba-3507-a0a6faae8c4c@siemens.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-TUID: M21+/HFlWllQ On 12/9/18 12:00 PM, Jan Kiszka wrote: > 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. Applied to the 'next', Thanks, Maxim. > 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) > > -- Maxim Osipov ilbers GmbH Maria-Merian-Str. 8 85521 Ottobrunn Germany +49 (151) 6517 6917 mosipov@ilbers.de http://ilbers.de/ Commercial register Munich, HRB 214197 General Manager: Baurzhan Ismagulov