From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6599936908158042112 X-Received: by 2002:adf:dd8e:: with SMTP id x14-v6mr1824234wrl.19.1536667558931; Tue, 11 Sep 2018 05:05:58 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:adf:b6ae:: with SMTP id j46-v6ls5718683wre.4.gmail; Tue, 11 Sep 2018 05:05:58 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYzkjtsSq/xU55jopmhZ3ANFpewAKzCKcI37coI3tgH7vOzM8M7XsArUuyPWgwaFNn+JneA X-Received: by 2002:adf:fa46:: with SMTP id y6-v6mr1802146wrr.9.1536667558449; Tue, 11 Sep 2018 05:05:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536667558; cv=none; d=google.com; s=arc-20160816; b=lgsZTStZeqWLGdHK5rdU2FSTS19bmRX2AjPrxlsVnDsZxAjbFjxDvenYPfIZlXXy1Q K+FUCG+RImrOJn6ScC1adtOMOpVXGuEbewcWdUDkUTOqraetzBbOkUcMWit7wULVDnDz Og4nxH02GDN9vzZAxHiYtSYV1i3o4ko7Sb+z11WWPBl94zC+IivlpIWWKsmoaMnVonxU o694y0y/M9RI8EN2qndXTNUIVwy0yfBMRXO8uKGH/w8wyLvP9xdRTw2m94ro+/BdGZlv iTL411RfhSB+lAO3KpRZPvN74nHDtzkxs+JmmhcXQRyuAlZn765lgR2Rd+Nac4Ttf8Ie w6ew== 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; bh=mVYXjLO5at6aszJ1+8T6uryGeuppre62pFEaeMH0LCM=; b=KemMeR6pBITTcwhMbrgeZXdVH2ZG7qCJUjXSFdMRNBHeaQpR8e7U5eLe6nLCrYCYtA bPT/sz+na3bYp6WDkQTeI5idfJ0umgiBxWqGl3WrJhuAYVPkjb3KZ+cPV7GxGhAxzhl0 kUkaz/DOzqi3ZNPOrArLuszcyxKGLmw5Ae59b/LOdR1D+XqmCGTfUlZZsD0oZhdlIF+v 72zhhPw4VtlEf0MtCnpMDgISJv+o9iJ/AdzTW/bS04tCxlYfIX4nrZRO4bLC4aciSqB+ jFqXZLwG86eGzA+SfedpixWey7xZK5aq5PbRXk4EBWqlPvCY+OYeKNtU6xYz3Ko7iFh/ 7ziA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 194.138.37.40 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com Return-Path: Received: from gecko.sbs.de (gecko.sbs.de. [194.138.37.40]) by gmr-mx.google.com with ESMTPS id x7-v6si25891wmh.0.2018.09.11.05.05.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Sep 2018 05:05:58 -0700 (PDT) Received-SPF: pass (google.com: domain of jan.kiszka@siemens.com designates 194.138.37.40 as permitted sender) client-ip=194.138.37.40; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 194.138.37.40 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com Received: from mail1.sbs.de (mail1.sbs.de [192.129.41.35]) by gecko.sbs.de (8.15.2/8.15.2) with ESMTPS id w8BC5vYx017957 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 11 Sep 2018 14:05:57 +0200 Received: from md1f2u6c.ad001.siemens.net (md1q0hnc.ad001.siemens.net [139.25.68.37] (may be forged)) by mail1.sbs.de (8.15.2/8.15.2) with ESMTP id w8BC5vIP000884 for ; Tue, 11 Sep 2018 14:05:57 +0200 From: Jan Kiszka To: isar-users Subject: [PATCH 05/16] u-boot-script: Become independent of target /etc/fstab Date: Tue, 11 Sep 2018 14:05:45 +0200 Message-Id: X-Mailer: git-send-email 2.16.4 In-Reply-To: References: In-Reply-To: References: X-TUID: l0ijNucSycpw From: Jan Kiszka It's a bit hacky to rely on that file during image creation, specifically as imagers such as wic may change them. So far we used the side channel ROOTFS_DEV which needs to be maintained separately from the commonly used source: the wks file of the target. This changes the interface of /etc/default/u-boot-script slightly and reworks how its recipe fills that config file: - ROOT_PARTITION variable is added, saving the root partition number - KERNEL_ARGS replaces KERNEL_ARGS_APPEND and is supposed to include root= from now on - do_install derives both the root partition number as well as the root device from the wks file, when available - in all other (special) cases, u-boot-script should be set by a customization package Signed-off-by: Jan Kiszka --- meta/recipes-bsp/u-boot-script/files/u-boot-script | 7 ++- .../u-boot-script/files/update-u-boot-script | 12 +---- .../recipes-bsp/u-boot-script/u-boot-script_1.0.bb | 55 ++++++++++++++++++---- 3 files changed, 52 insertions(+), 22 deletions(-) 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 53cc613..ca31b6d 100644 --- a/meta/recipes-bsp/u-boot-script/files/u-boot-script +++ b/meta/recipes-bsp/u-boot-script/files/u-boot-script @@ -1,6 +1,9 @@ -# Arguments to append to kernel command line. +# Root filesystem partition number +ROOT_PARTITION="\${distro_bootpart}" + +# Arguments for the kernel command line. # Make sure to escape $ in u-boot variables, e.g. "\${console}". -KERNEL_ARGS_APPEND="" +KERNEL_ARGS="" # 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 c12c3ed..c613b13 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 @@ -13,23 +13,15 @@ if [ -f /etc/default/u-boot-script ]; then . /etc/default/u-boot-script fi -ROOT_DEV=$(egrep '^[^# ]+[ ]+/[ ]' /etc/fstab | awk '{print $1}') \ - || true - -ROOT_PART="\${distro_bootpart}" -if [ -n "${ROOT_DEV}" ]; then - ROOT_PART=$(echo ${ROOT_DEV} | sed 's/.*[^0-9]\([0-9]*\)$/\1/') -fi - 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 "setenv bootargs ${KERNEL_ARGS}" >> ${BOOT_CMD} -echo "load \${devtype} \${devnum}:${ROOT_PART} \${fdt_addr_r}" \ +echo "load \${devtype} \${devnum}:${ROOT_PARTITION} \${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} 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 index da8dca5..8d1ad25 100644 --- 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 @@ -16,6 +16,50 @@ SRC_URI = " \ DEBIAN_DEPENDS = "u-boot-tools, linux-image-${KERNEL_NAME}" +# Extract the following information from the wks file and add it to the +# packaged /etc/default/u-boot-script: +# - --append parameters from a bootloader entry +# - root partition number +# - disk name the root partition is located on + +init_config_from_wks() { + # Filter out the bootloader line, then grap the argument of --append. + # The argument may be quoted, respect that but remove the quotes prior + # to assigning the target variable. Will be re-added later. + KERNEL_ARGS=$(grep "^bootloader " $1 | \ + sed -e 's/.* --append[= ]\(".*"\|[^ $]*\).*/\1/' \ + -e 's/\"\(.*\)\"/\1/') + + COUNT=0 + while read COMMAND MNT OPTIONS; do + if [ "${COMMAND}" != part ] || + echo "${OPTIONS}" | grep -q "\--no-table"; then + continue + fi + COUNT=$(expr ${COUNT} + 1) + if [ "${MNT}" = "/" ]; then + ROOT_PARTITION=${COUNT} + break + fi + done < $1 + if [ -n "${ROOT_PARTITION}" ]; then + # filter out parameter of --ondisk or --ondrive + ROOT=$(echo ${OPTIONS} | \ + sed 's/.*--on\(disk\|drive\)[ ]\+\([^ ]\+\) .*/\2/') + # anything found? + if [ "${ROOT}" != "${OPTIONS}" ]; then + # special case: append 'p' to mmcblkN + ROOT=$(echo ${ROOT} | sed 's/^\(mmcblk[0-9]\+\)/\1p/') + + KERNEL_ARGS="\"root=/dev/${ROOT}${ROOT_PARTITION} ${KERNEL_ARGS}\"" + fi + fi + + sed -i -e 's|\(^ROOT_PARTITION=\).*|\1\"'"${ROOT_PARTITION}"'\"|' \ + -e 's|\(^KERNEL_ARGS=\).*|\1'"${KERNEL_ARGS}"'|' \ + ${WORKDIR}/u-boot-script +} + do_install() { # Find WKS_FILE specified for the current target. WKS_DIRS=$(dirname $(which wic))/lib/wic/canned-wks @@ -24,20 +68,11 @@ do_install() { done for DIR in ${WKS_DIRS}; do if [ -f ${DIR}/${WKS_FILE}.wks ]; then - WKS_PATH=${DIR}/${WKS_FILE}.wks + init_config_from_wks ${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 -- 2.16.4