From: Jan Kiszka <jan.kiszka@siemens.com>
To: isar-users <isar-users@googlegroups.com>
Subject: Re: [PATCH 4/5] Add u-boot script generator
Date: Wed, 6 Jun 2018 20:31:46 +0200 [thread overview]
Message-ID: <b96f7af1-a25b-e335-7f2c-92ba98bfe185@siemens.com> (raw)
In-Reply-To: <7a07b823f595c4b49cb69f824436ff60efa98612.1528286332.git.jan.kiszka@siemens.com>
On 2018-06-06 13:58, [ext] Jan Kiszka wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
>
> 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 <jan.kiszka@siemens.com>
> ---
> 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
next prev parent reply other threads:[~2018-06-06 18:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-06 11:58 [PATCH 0/5] Enable U-Boot-based images, add Banana Pi demo Jan Kiszka
2018-06-06 11:58 ` [PATCH 1/5] Add DISTRO and DISTRO_ARCH as OVERRIDES suffixes Jan Kiszka
2018-06-06 11:58 ` [PATCH 2/5] buildchroot: Break up wic build deps into common and arch-specific ones Jan Kiszka
2018-06-06 11:58 ` [PATCH 3/5] Set up target image fstab prior to installing any packages Jan Kiszka
2018-06-07 6:38 ` Claudius Heine
2018-06-06 11:58 ` [PATCH 4/5] Add u-boot script generator Jan Kiszka
2018-06-06 18:31 ` Jan Kiszka [this message]
2018-06-06 18:48 ` Jan Kiszka
2018-06-06 11:58 ` [PATCH 5/5] Add Banana Pi SD-card image Jan Kiszka
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=b96f7af1-a25b-e335-7f2c-92ba98bfe185@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