From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6563939830724558848 X-Received: by 2002:adf:de03:: with SMTP id b3-v6mr223722wrm.4.1528286335140; Wed, 06 Jun 2018 04:58:55 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a1c:ed14:: with SMTP id l20-v6ls292408wmh.3.gmail; Wed, 06 Jun 2018 04:58:54 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIKHB3cvKPzleVYI2a9H9Jt/CgSsFfqTPmL2aIdeFD4pMN/Ea2ITp22DS9DlgZz7EE+tN87 X-Received: by 2002:a1c:5b0b:: with SMTP id p11-v6mr194519wmb.11.1528286334579; Wed, 06 Jun 2018 04:58:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528286334; cv=none; d=google.com; s=arc-20160816; b=PR7bJYsqhEUd2m9tQQy9yuQvGj3I+dy3uVPWqrSBW0zNq5hWdGjzowitI5Eg2N1Cpa DQRKgopwntkMcHvCfG4N/6XWZLz+Zmi3geVkcHwa8iWhax95jsT4YtDfs5kQL4HJ7ffr 3gyIJpNnVpbG6acYIyd1jfXxBN6avZAtmkuZybh7/936Pgs3LMqMn6iowl4wwPbUYosH jOOlGhowmU5ZZ3u6C39RdwwSTiPs0UwesF9HhXh3CQ2F2AjQCvuXf5r+KYj8vTQgfbo3 svGwBIMdxNMBgRG903CTGF6ESTjUmTkXctu7wisqYhsYiTCH8UlGkc4ZJ79hRClFyo10 TEeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:references:in-reply-to:message-id:date :subject:to:from:arc-authentication-results; bh=QIjTGEHAZuIlJ6fTq4p3zYKh3/GATxsRJJwVcW2WQ/w=; b=J7ehIxpkmY2DVReErdTqxwhB6bZPpu6mcTYwBZw20SspT6OAKS+9ov6oo9KVZLxiX8 VyOzyKIY9+fNSwV9ZtwX4NrIwLCULlM9TbpbvE/9OWmTtiovg49HYkUI5O5kU/P/dRrk E51gafwvC/abg+6fP2BTbxkbp7rBlt4aHJTvmSYl8NRfVFpIUycAjP0hNX/X+Bc+yy5z s/QDaw+cSbbeDvSSKZUVUMVldbERDxieCqFsIFGoQRM9fzygKMhMgBxN9+iPY7Jd5ObA qdv0AEDVTABk5jn7NMgduG4PY74fzg1+R1QRyLsUh5ji5Vy8OXZRoDVX8nobghqidMQW Ly8g== 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 r7-v6si64030wmc.0.2018.06.06.04.58.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Jun 2018 04:58:54 -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 mail1.siemens.de (mail1.siemens.de [139.23.33.14]) by david.siemens.de (8.15.2/8.15.2) with ESMTPS id w56BwsiJ001477 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 6 Jun 2018 13:58:54 +0200 Received: from md1f2u6c.ad001.siemens.net (md1q0hnc.ad001.siemens.net [139.25.68.37] (may be forged)) by mail1.siemens.de (8.15.2/8.15.2) with ESMTP id w56Bwr2A002525 for ; Wed, 6 Jun 2018 13:58:54 +0200 From: Jan Kiszka To: isar-users Subject: [PATCH 4/5] Add u-boot script generator Date: Wed, 6 Jun 2018 13:58:51 +0200 Message-Id: <7a07b823f595c4b49cb69f824436ff60efa98612.1528286332.git.jan.kiszka@siemens.com> X-Mailer: git-send-email 2.13.7 In-Reply-To: References: In-Reply-To: References: X-TUID: EWS7ntXz2g0k 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. 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}" +esac + +echo "bootz \${kernel_addr_r} ${INITRD_ADDR} \${fdt_addr_r}" >> ${BOOT_CMD} + +mkimage -T script -A invalid -C none -d ${BOOT_CMD} /boot/boot.scr > /dev/null + +rm ${BOOT_CMD} diff --git a/meta/recipes-bsp/u-boot-script/files/zz-u-boot-script b/meta/recipes-bsp/u-boot-script/files/zz-u-boot-script new file mode 100755 index 0000000..cf4cc5a --- /dev/null +++ b/meta/recipes-bsp/u-boot-script/files/zz-u-boot-script @@ -0,0 +1,3 @@ +#!/bin/sh + +update-u-boot-script diff --git a/meta/recipes-bsp/u-boot-script/u-boot-script_1.0.bb b/meta/recipes-bsp/u-boot-script/u-boot-script_1.0.bb new file mode 100644 index 0000000..490c306 --- /dev/null +++ b/meta/recipes-bsp/u-boot-script/u-boot-script_1.0.bb @@ -0,0 +1,53 @@ +# Boot script generator for U-Boot +# +# This software is a part of ISAR. +# Copyright (c) Siemens AG, 2018 +# +# SPDX-License-Identifier: MIT + +inherit dpkg-raw + +DESCRIPTION = "Boot script generator for U-Boot" + +SRC_URI = " \ + file://update-u-boot-script \ + file://u-boot-script \ + file://zz-u-boot-script" + +DEBIAN_DEPENDS = "u-boot-tools, linux-image-${KERNEL_NAME}" + +do_install() { + # Find WKS_FILE specified for the current target. + WKS_DIRS=$(dirname $(which wic))/lib/wic/canned-wks + for LAYER in ${BBLAYERS}; do + WKS_DIRS="${WKS_DIRS} ${LAYER}/scripts/lib/wic/canned-wks" + done + for DIR in ${WKS_DIRS}; do + if [ -f ${DIR}/${WKS_FILE}.wks ]; then + WKS_PATH=${DIR}/${WKS_FILE}.wks + break + fi + done + + # Transfer --append parameters from a bootloader entry in the wks file + # to the packaged /etc/default/u-boot-script. + if [ -n ${WKS_PATH} ]; then + APPEND=$(grep "^bootloader " ${WKS_PATH} | \ + sed 's/.* --append=\([^ $]*\).*/\1/') + sed -i 's|\(^KERNEL_ARGS_APPEND=\).*|\1'${APPEND}'|' \ + ${WORKDIR}/u-boot-script + fi + + sudo rm -rf ${D}/etc ${D}/usr + + install -v -d ${D}/usr/sbin + install -v -m 755 ${WORKDIR}/update-u-boot-script ${D}/usr/sbin/ + + install -v -d ${D}/etc/default + install -v -m 644 ${WORKDIR}/u-boot-script ${D}/etc/default/ + + install -v -d ${D}/etc/kernel/postinst.d + install -v -m 755 ${WORKDIR}/zz-u-boot-script ${D}/etc/kernel/postinst.d + + sudo chown -R root:root ${D}/etc ${D}/usr +} -- 2.13.7