From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6563939830724558848 X-Received: by 2002:adf:9d84:: with SMTP id p4-v6mr390753wre.32.1528309908916; Wed, 06 Jun 2018 11:31:48 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a5d:4985:: with SMTP id r5-v6ls2570664wrq.11.gmail; Wed, 06 Jun 2018 11:31:48 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKozjG1pYNzOMxOP6hlnkNrmQn3kn7lF1f65WAELvupOp9dYBaOuV7MJtq4qM2GHhe0aac2 X-Received: by 2002:adf:c7cf:: with SMTP id y15-v6mr391445wrg.20.1528309908370; Wed, 06 Jun 2018 11:31:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528309908; cv=none; d=google.com; s=arc-20160816; b=hTSxFSHZKVHbftuitEYfiWxizCuCSBsE3bEEaZ5O0E+/4pePr9lrxTWmcOR2VmGQDi 8Nr2K5cnUYKbFuocXZNmEVkTtp29pEknB1EvE1mG33ji9EDHWWu3gFDyh2Xq8+qc7bMM zLhccx3bRCn595mo7sDB6wt/GpOcEwiQmZeYewczJTLG5Fg8aAQyQHM+XlVSYULcy4u/ e5po91fjjxBklzUxRArV+MgGAkamK+me6PuCdU1h5nzaZfOzAx18Op+t9WKc0QM8rbsW kfz/Kx4jF8nxfAbQ5iDR60djtES+kl+JcU/8mbegVfyIWmfNeGENTOmjWmhf6OZuFUUa Z+3A== 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:autocrypt:openpgp:references:to:from :subject:arc-authentication-results; bh=2tC+eEVKsNhyzKG5G20C6bXOc/615AJ1zX5/MluF5To=; b=s3n5/KY9B9ni/uHTfNW71dwDjKW/zC0fIiwACyA2c4I03N7Xp0BBMvSPi1+gGns22D s3bj135njI0qtmX4NBJz7AFgEYb/7D2bJ26wEi/iGqguIDtTDXye2SYpUeBDH3NGmJgs SwzPfWjMKDZs4cnFtceDavl93WWEWkUdwnsz5qua2/TKU1adosrjLKjtuuC18gCgPQvu nQvFxhtitzSBE7WNJC9UDvVNSA+5xKUbwngQpcnBod7NHdHiIhlVFcR/MqGANf6+i6X4 V4mxmQKwI6lzysUcfQk/SvKpLgeT27HOAQhcwuy3ylg04hiDONAyxGlbIgUkyoE3bTTm zEPQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com Return-Path: Received: from david.siemens.de (david.siemens.de. [192.35.17.14]) by gmr-mx.google.com with ESMTPS id b8-v6si955704wrn.2.2018.06.06.11.31.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Jun 2018 11:31:48 -0700 (PDT) Received-SPF: pass (google.com: domain of jan.kiszka@siemens.com designates 192.35.17.14 as permitted sender) client-ip=192.35.17.14; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by david.siemens.de (8.15.2/8.15.2) with ESMTPS id w56IVlG4009412 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 6 Jun 2018 20:31:48 +0200 Received: from [139.25.68.37] (md1q0hnc.ad001.siemens.net [139.25.68.37] (may be forged)) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id w56IVlwO022335 for ; Wed, 6 Jun 2018 20:31:47 +0200 Subject: Re: [PATCH 4/5] Add u-boot script generator From: Jan Kiszka To: isar-users References: <7a07b823f595c4b49cb69f824436ff60efa98612.1528286332.git.jan.kiszka@siemens.com> Openpgp: preference=signencrypt Autocrypt: addr=jan.kiszka@siemens.com; prefer-encrypt=mutual; keydata= xsDhBEq0i8QRB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5 gz88SF5Tzq+0ywADBQf/YSkaYrEslPWiCA2wU6EW0yaqBQAobFsOMvsufJ6o2ntq5Ncq37VI 3KCT67eHPE9x+zPcENoZWsRrC9S9PCf1LOsi7ybZsR13AJqDFlRzJZ4klh9QwgwFZxUBzOdI vttwzG1QkzHx06RKZluFYpPF3DRduSMukdIJ2wmWCU+ohB+mYefe65JGjYQfHVs8mgYVFOPx bRea9VJACCMuspoZWpj43UdR1lLLyIUFYz+jqcPW7Hd/GTIw4N67pYl0dwPDmFd4ohJ5g4Zp q61toNysBGEuEm5GCcn0VmGtQpSYnR5cVm5b2yPz4bIuFOSuZUo/l7vitdY0iy0/wvKbBC+N K8JJBBgRAgAJBQJKtIvEAhsMAAoJEIrUrG965ecULvAAoKGvxs5T3IhyQT8I8sMsyAvCE4wH AJ46S16yab+OxNkvOeoOEX0EnHVHaA== Message-ID: Date: Wed, 6 Jun 2018 20:31:46 +0200 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 In-Reply-To: <7a07b823f595c4b49cb69f824436ff60efa98612.1528286332.git.jan.kiszka@siemens.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TUID: N8GqaPlIFiT0 On 2018-06-06 13:58, [ext] Jan Kiszka wrote: > From: Jan Kiszka > > In order to use upstream U-Boot default envs for booting Isar images, we > either need an extlinux script - can be provided by Debian u-boot-menu > from buster - or some boot.scr. The latter has the advantage of skipping > the interactive stage of a kernel selection, specifically when there is > only one kernel on an image, and allowing for injection of custom U-Boot > commands. BTW, there is also the Debian flash-kernel package with is apparently also able to generate some boot.scr, using a large device data base. My impression is that its enormous complexity is related to its history and the many legacy boards it supports. This rather simple tool should be sufficient when looking forward and focusing on the modern U-Boot distro interface. E.g., it's redundant to maintain the device tree name in the flash-kernel database - u-boot knows it already. > > This package generates the needed boot.scr, using the installed kernel > package and the rootfs parameters found in the target's /etc/fstab. It > is able to update itself when the kernel package is changed on the > target. Further kernel parameters and custom U-Boot commands can be > configured on the target via /etc/default/u-boot-script. This also > allows to opt-out from using an initramfs when the kernel does not need > one to boot properly. > > Furthermore, the package recipe can evaluate and bootloader --append=... > line from the WKS_FILE used for the target and inject those kernel > parameters into the deployed /etc/default/u-boot-script. > > Signed-off-by: Jan Kiszka > --- > meta/recipes-bsp/u-boot-script/files/u-boot-script | 9 ++++ > .../u-boot-script/files/update-u-boot-script | 58 ++++++++++++++++++++++ > .../u-boot-script/files/zz-u-boot-script | 3 ++ > .../recipes-bsp/u-boot-script/u-boot-script_1.0.bb | 53 ++++++++++++++++++++ > 4 files changed, 123 insertions(+) > create mode 100644 meta/recipes-bsp/u-boot-script/files/u-boot-script > create mode 100755 meta/recipes-bsp/u-boot-script/files/update-u-boot-script > create mode 100755 meta/recipes-bsp/u-boot-script/files/zz-u-boot-script > create mode 100644 meta/recipes-bsp/u-boot-script/u-boot-script_1.0.bb > > diff --git a/meta/recipes-bsp/u-boot-script/files/u-boot-script b/meta/recipes-bsp/u-boot-script/files/u-boot-script > new file mode 100644 > index 0000000..53cc613 > --- /dev/null > +++ b/meta/recipes-bsp/u-boot-script/files/u-boot-script > @@ -0,0 +1,9 @@ > +# Arguments to append to kernel command line. > +# Make sure to escape $ in u-boot variables, e.g. "\${console}". > +KERNEL_ARGS_APPEND="" > + > +# Set to "yes" or "1" to leave out initrd, even if present > +NO_INITRD="" > + > +# U-boot commands to prepend to boot script > +SCRIPT_PREPEND="" > 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 > new file mode 100755 > index 0000000..4ce74bb > --- /dev/null > +++ b/meta/recipes-bsp/u-boot-script/files/update-u-boot-script > @@ -0,0 +1,58 @@ > +#!/bin/sh > +# > +# Boot script generator for U-Boot > +# > +# This software is a part of ISAR. > +# Copyright (c) Siemens AG, 2018 > +# > +# SPDX-License-Identifier: MIT > + > +set -e > + > +if [ -f /etc/default/u-boot-script ]; then > + . /etc/default/u-boot-script > +fi > + > +ROOT_PART="\${distro_bootpart}" > + > +while read DEV MOUNT_POINT REST; do > + if echo ${DEV} | grep -q "^#"; then > + continue > + fi > + if [ "${MOUNT_POINT}" = "/" ]; then > + ROOT_DEV=${DEV} > + ROOT_PART=$(echo ${DEV} | sed 's/.*[^0-9]\([0-9]*\)$/\1/') > + fi > +done < /etc/fstab > + > +BOOT_CMD=$(mktemp) > + > +KERNEL_VERSION=$(linux-version list | linux-version sort --reverse | head -1) > + > +echo "${SCRIPT_PREPEND}" >> ${BOOT_CMD} > + > +echo "setenv bootargs root=${ROOT_DEV} ${KERNEL_ARGS_APPEND}" >> ${BOOT_CMD} > + > +echo "load \${devtype} \${devnum}:${ROOT_PART} \${fdt_addr_r}" \ > + "/usr/lib/linux-image-${KERNEL_VERSION}/\${fdtfile}" >> ${BOOT_CMD} > +echo "load \${devtype} \${devnum}:\${distro_bootpart} \${kernel_addr_r}" \ > + "/boot/vmlinuz-${KERNEL_VERSION}" >> ${BOOT_CMD} > + > +case "${NO_INITRD}" in > +yes|1) > + INITRD_ADDR="-" > + ;; > +*) > + RAMDISK_SIZE=$(printf %x \ > + $(stat -c %s /boot/initrd.img-${KERNEL_VERSION})) > + echo "load \${devtype} \${devnum}:\${distro_bootpart}" \ > + "\${ramdisk_addr_r} /boot/initrd.img-${KERNEL_VERSION}" \ > + >> ${BOOT_CMD} > + INITRD_ADDR="\${ramdisk_addr_r}:${RAMDISK_SIZE}" Ah, this can be done even simpler: There is ${filesize} in u-boot which is updated automatically by the last load. Will send an update. Jan -- Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux