From: Jan Kiszka <jan.kiszka@siemens.com>
To: isar-users <isar-users@googlegroups.com>
Subject: [PATCH 05/16] u-boot-script: Become independent of target /etc/fstab
Date: Tue, 11 Sep 2018 14:05:45 +0200 [thread overview]
Message-ID: <c4debfe041015e7a19ba58ac6bde2531744a88d7.1536667556.git.jan.kiszka@siemens.com> (raw)
In-Reply-To: <cover.1536667556.git.jan.kiszka@siemens.com>
In-Reply-To: <cover.1536667556.git.jan.kiszka@siemens.com>
From: Jan Kiszka <jan.kiszka@siemens.com>
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=<rootdev> 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 <jan.kiszka@siemens.com>
---
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
next prev parent reply other threads:[~2018-09-11 12:05 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-11 12:05 [PATCH 00/16] Cleanups, linux-custom fix, auto-expansion helper Jan Kiszka
2018-09-11 12:05 ` [PATCH 01/16] meta-isar: Adjust kernel params in sdimage-efi.wks Jan Kiszka
2018-09-11 12:05 ` [PATCH 02/16] meta-isar: Reduce grub timeout to 3 seconds Jan Kiszka
2018-09-11 12:05 ` [PATCH 03/16] meta-isar: Fix bananapi root disk specification Jan Kiszka
2018-09-12 8:57 ` Henning Schild
2018-09-12 8:59 ` Henning Schild
2018-09-11 12:05 ` [PATCH 04/16] meta-isar: Remove "=" after wic parameters Jan Kiszka
2018-09-11 12:05 ` Jan Kiszka [this message]
2018-09-11 12:05 ` [PATCH 06/16] isar-image-base: Disable rootfs check by default Jan Kiszka
2018-09-11 12:05 ` [PATCH 07/16] isar-image-base: Use generic parameters for rootfs entry in fstab Jan Kiszka
2018-09-11 12:05 ` [PATCH 08/16] meta: Remove ROOTFS_TYPE Jan Kiszka
2018-09-11 12:05 ` [PATCH 09/16] start_vm: Rename QEMU_ROOTFS_DEV to QEMU_DISK_ARGS Jan Kiszka
2018-09-11 12:05 ` [PATCH 10/16] start_vm: Rename ROOTFS_DEV to QEMU_ROOTFS_DEV Jan Kiszka
2018-09-11 12:05 ` [PATCH 11/16] RECIPE-API-CHANGELOG: Add ROOTFS_DEV/TYPE removal Jan Kiszka
2018-09-11 12:05 ` [PATCH 12/16] meta: Add expand-on-first-boot support package Jan Kiszka
2018-09-12 13:46 ` Henning Schild
2018-09-13 8:33 ` Jan Kiszka
2018-09-13 9:30 ` Henning Schild
2018-09-13 13:17 ` Jan Kiszka
2018-09-11 12:05 ` [PATCH 13/16] image: Limit ROOTFS_EXTRA to non-wic image type Jan Kiszka
2018-09-11 12:05 ` [PATCH 14/16] linux-custom: Simplify and clarify KERNEL_NAME-to-recipe matching Jan Kiszka
2018-09-11 12:05 ` [PATCH 15/16] meta-isar: Move init preinstallation into distro conf Jan Kiszka
2018-09-11 12:05 ` [PATCH 16/16] meta: Add enable-fsck helper recipe Jan Kiszka
2018-09-25 11:27 ` [PATCH 00/16] Cleanups, linux-custom fix, auto-expansion helper Maxim Yu. Osipov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c4debfe041015e7a19ba58ac6bde2531744a88d7.1536667556.git.jan.kiszka@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=isar-users@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox