* [PATCH 0/5] Enable U-Boot-based images, add Banana Pi demo
@ 2018-06-06 11:58 Jan Kiszka
2018-06-06 11:58 ` [PATCH 1/5] Add DISTRO and DISTRO_ARCH as OVERRIDES suffixes Jan Kiszka
` (4 more replies)
0 siblings, 5 replies; 9+ messages in thread
From: Jan Kiszka @ 2018-06-06 11:58 UTC (permalink / raw)
To: isar-users
This provides missing bits to build SD-card (or also eMMC) images for
boards that use U-Boot as bootloader. The images can be described via
well-known wks files.
For U-Boot, we rely on scan_dev_for_scripts from the default
environment. The reason to generate our own boot script is documented in
the related patch. While that generator may start its life inside Isar,
I could imagine selling it also to Debian as a seperate package.
As an example, I've added the necessary configs to build a basic image
for a Banana Pi board.
This is surely not the smoothest solution. E.g., I dislike that we still
need those ugly ROOTFS_TYPE and ROOTFS_DEV variables - the information
is encoded in the wks file already. But those files are evaluated by wic
only AFTER we build the rootfs. So, extracting that information from wks
would require logic like in u-boot-script_1.0.bb, i.e. a certain level
wic duplication so that we can continue to generate /etc/fstab ahead of
the package installation. Better suggestions welcome.
We should probably also convert BUILDCHROOT_PREINSTALL_WIC to
WIC_FILE_DEPENDS* as indicated in patch 2. But I didn't study the
implications in details yet.
Looking forward to comments and tests!
Jan
Jan Kiszka (5):
Add DISTRO and DISTRO_ARCH as OVERRIDES suffixes
buildchroot: Break up wic build deps into common and arch-specific
ones
Set up target image fstab prior to installing any packages
Add u-boot script generator
Add Banana Pi SD-card image
.../conf/distro/debian-stretch-backports.list | 1 +
meta-isar/conf/local.conf.sample | 1 +
meta-isar/conf/multiconfig/bananapi-stretch.conf | 24 +++++++++
.../conf/multiconfig/preferences.bananapi.conf | 7 +++
.../images/files/debian-configscript.sh | 14 ------
.../images/files/raspbian-configscript.sh | 14 ------
meta-isar/recipes-core/images/isar-image-base.bb | 18 +++++--
meta-isar/scripts/lib/wic/canned-wks/bananapi.wks | 5 ++
meta/classes/isar-bootstrap-helper.bbclass | 5 +-
meta/conf/isar-bitbake.conf | 2 +
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 ++++++++++++++++++++
meta/recipes-devtools/buildchroot/buildchroot.bb | 22 ++++++--
15 files changed, 197 insertions(+), 39 deletions(-)
create mode 100644 meta-isar/conf/distro/debian-stretch-backports.list
create mode 100644 meta-isar/conf/multiconfig/bananapi-stretch.conf
create mode 100644 meta-isar/conf/multiconfig/preferences.bananapi.conf
create mode 100644 meta-isar/scripts/lib/wic/canned-wks/bananapi.wks
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
--
2.13.7
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/5] Add DISTRO and DISTRO_ARCH as OVERRIDES suffixes
2018-06-06 11:58 [PATCH 0/5] Enable U-Boot-based images, add Banana Pi demo Jan Kiszka
@ 2018-06-06 11:58 ` Jan Kiszka
2018-06-06 11:58 ` [PATCH 2/5] buildchroot: Break up wic build deps into common and arch-specific ones Jan Kiszka
` (3 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Jan Kiszka @ 2018-06-06 11:58 UTC (permalink / raw)
To: isar-users
From: Jan Kiszka <jan.kiszka@siemens.com>
By default, bitbake offers MACHINE, TARGET_OS and TARGET_ARCH. But we
are using DISTRO and DISTRO_ARCH in Isar. Adding them will allow to let
variables depend on these parameters as well.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
meta/conf/isar-bitbake.conf | 2 ++
1 file changed, 2 insertions(+)
diff --git a/meta/conf/isar-bitbake.conf b/meta/conf/isar-bitbake.conf
index 8a1d86b..ead7798 100644
--- a/meta/conf/isar-bitbake.conf
+++ b/meta/conf/isar-bitbake.conf
@@ -24,6 +24,8 @@ SSTATE_DIR ?= "${TMPDIR}/sstate-cache"
BUILDCHROOT_DIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/buildchroot/rootfs"
CACHE = "${TMPDIR}/cache"
+OVERRIDES_append = ":${DISTRO}:${DISTRO_ARCH}"
+
BB_HASHBASE_WHITELIST ?= "TMPDIR FILE PATH PWD BB_TASKHASH BBPATH BBSERVER DL_DIR \
SSTATE_DIR THISDIR FILESEXTRAPATHS FILE_DIRNAME HOME LOGNAME SHELL TERM \
USER FILESPATH STAGING_DIR_HOST STAGING_DIR_TARGET COREBASE PRSERV_HOST \
--
2.13.7
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/5] buildchroot: Break up wic build deps into common and arch-specific ones
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 ` Jan Kiszka
2018-06-06 11:58 ` [PATCH 3/5] Set up target image fstab prior to installing any packages Jan Kiszka
` (2 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Jan Kiszka @ 2018-06-06 11:58 UTC (permalink / raw)
To: isar-users
From: Jan Kiszka <jan.kiszka@siemens.com>
wic is currently not usable on non-x86 archs because of naturally
unresolvable dependencies on x86 grub-efi packages. Fix this by
factoring our a common dependency core and a set of arch-specific ones.
This should also allow to build EFI images for armhf and arm64
(Tianocore firmware or U-boot in EFI mode). But primarily, it allows to
build non-EFI images on non-x86 archs via wic.
Note that we should probably consider replacing the Isar-proprietary
BUILDCHROOT_PREINSTALL_WIC variable with the OE standard
WIC_FILE_DEPENDS*.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
meta/recipes-devtools/buildchroot/buildchroot.bb | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/meta/recipes-devtools/buildchroot/buildchroot.bb b/meta/recipes-devtools/buildchroot/buildchroot.bb
index cec42c3..e405509 100644
--- a/meta/recipes-devtools/buildchroot/buildchroot.bb
+++ b/meta/recipes-devtools/buildchroot/buildchroot.bb
@@ -32,15 +32,27 @@ BUILDCHROOT_PREINSTALL_WIC = " \
parted \
gdisk \
util-linux \
- syslinux \
- syslinux-common \
dosfstools \
mtools \
e2fsprogs \
- grub-efi-amd64-bin \
- grub-efi-ia32-bin \
python3"
+BUILDCHROOT_PREINSTALL_WIC_append_amd64 = " \
+ syslinux \
+ syslinux-common \
+ grub-efi-amd64-bin"
+
+BUILDCHROOT_PREINSTALL_WIC_append_armhf = " \
+ grub-efi-arm-bin"
+
+BUILDCHROOT_PREINSTALL_WIC_append_arm64 = " \
+ grub-efi-arm64-bin"
+
+BUILDCHROOT_PREINSTALL_WIC_append_i386 = " \
+ syslinux \
+ syslinux-common \
+ grub-efi-ia32-bin"
+
python () {
if d.getVar('IMAGE_TYPE', True) == 'wic-img':
d.appendVar('BUILDCHROOT_PREINSTALL',
--
2.13.7
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 3/5] Set up target image fstab prior to installing any packages
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 ` 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 11:58 ` [PATCH 5/5] Add Banana Pi SD-card image Jan Kiszka
4 siblings, 1 reply; 9+ messages in thread
From: Jan Kiszka @ 2018-06-06 11:58 UTC (permalink / raw)
To: isar-users
From: Jan Kiszka <jan.kiszka@siemens.com>
Package postinst hooks may need the fstab or may want to modify it,
including customization packages or the upcoming u-boot-script
generator. So extract the already identical setup pattern from the
distro config scripts, generate the fstab prior to calling
setup_root_file_system and let the latter inject the file before
starting the package installation. By specifying "-" as fstab file, we
can skip the injection for the buildchroot which does not need it.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
.../recipes-core/images/files/debian-configscript.sh | 14 --------------
.../recipes-core/images/files/raspbian-configscript.sh | 14 --------------
meta-isar/recipes-core/images/isar-image-base.bb | 18 ++++++++++++++----
meta/classes/isar-bootstrap-helper.bbclass | 5 +++--
meta/recipes-devtools/buildchroot/buildchroot.bb | 2 +-
5 files changed, 18 insertions(+), 35 deletions(-)
diff --git a/meta-isar/recipes-core/images/files/debian-configscript.sh b/meta-isar/recipes-core/images/files/debian-configscript.sh
index 136918c..bcd5507 100755
--- a/meta-isar/recipes-core/images/files/debian-configscript.sh
+++ b/meta-isar/recipes-core/images/files/debian-configscript.sh
@@ -7,20 +7,6 @@ set -e
readonly MACHINE_SERIAL="$1"
readonly BAUDRATE_TTY="$2"
-readonly ROOTFS_DEV="$3"
-readonly ROOTFS_TYPE="$4"
-
-cat > /etc/fstab << EOF
-# Begin /etc/fstab
-/dev/$ROOTFS_DEV / $ROOTFS_TYPE defaults 1 1
-proc /proc proc nosuid,noexec,nodev 0 0
-sysfs /sys sysfs nosuid,noexec,nodev 0 0
-devpts /dev/pts devpts gid=5,mode=620 0 0
-tmpfs /run tmpfs defaults 0 0
-devtmpfs /dev devtmpfs mode=0755,nosuid 0 0
-
-# End /etc/fstab
-EOF
# Create console device
if [ ! -e /dev/console ]; then
diff --git a/meta-isar/recipes-core/images/files/raspbian-configscript.sh b/meta-isar/recipes-core/images/files/raspbian-configscript.sh
index 04ea571..3631c26 100644
--- a/meta-isar/recipes-core/images/files/raspbian-configscript.sh
+++ b/meta-isar/recipes-core/images/files/raspbian-configscript.sh
@@ -7,20 +7,6 @@ set -e
readonly MACHINE_SERIAL="$1"
readonly BAUDRATE_TTY="$2"
-readonly ROOTFS_DEV="$3"
-readonly ROOTFS_TYPE="$4"
-
-cat > /etc/fstab << EOF
-# Begin /etc/fstab
-/dev/$ROOTFS_DEV / $ROOTFS_TYPE defaults 1 1
-proc /proc proc nosuid,noexec,nodev 0 0
-sysfs /sys sysfs nosuid,noexec,nodev 0 0
-devpts /dev/pts devpts gid=5,mode=620 0 0
-tmpfs /run tmpfs defaults 0 0
-devtmpfs /dev devtmpfs mode=0755,nosuid 0 0
-
-# End /etc/fstab
-EOF
# Enable tty conditionally, systemd does not have the file but its own magic
if [ -f /etc/inittab ]; then
diff --git a/meta-isar/recipes-core/images/isar-image-base.bb b/meta-isar/recipes-core/images/isar-image-base.bb
index f91dfb0..bf90e30 100644
--- a/meta-isar/recipes-core/images/isar-image-base.bb
+++ b/meta-isar/recipes-core/images/isar-image-base.bb
@@ -28,15 +28,25 @@ do_rootfs[root_cleandirs] = "${IMAGE_ROOTFS} \
${IMAGE_ROOTFS}/isar-apt"
do_rootfs() {
- setup_root_file_system "${IMAGE_ROOTFS}" "clean" \
+ cat > ${WORKDIR}/fstab << EOF
+# Begin /etc/fstab
+/dev/${ROOTFS_DEV} / ${ROOTFS_TYPE} defaults 1 1
+proc /proc proc nosuid,noexec,nodev 0 0
+sysfs /sys sysfs nosuid,noexec,nodev 0 0
+devpts /dev/pts devpts gid=5,mode=620 0 0
+tmpfs /run tmpfs defaults 0 0
+devtmpfs /dev devtmpfs mode=0755,nosuid 0 0
+
+# End /etc/fstab
+EOF
+
+ setup_root_file_system "${IMAGE_ROOTFS}" "clean" "${WORKDIR}/fstab" \
${IMAGE_PREINSTALL} ${IMAGE_INSTALL}
# Configure root filesystem
sudo install -m 755 "${WORKDIR}/${DISTRO_CONFIG_SCRIPT}" "${IMAGE_ROOTFS}"
sudo chroot ${IMAGE_ROOTFS} /${DISTRO_CONFIG_SCRIPT} ${MACHINE_SERIAL} \
- ${BAUDRATE_TTY} \
- ${ROOTFS_DEV} \
- ${ROOTFS_TYPE}
+ ${BAUDRATE_TTY}
# Cleanup
sudo rm "${IMAGE_ROOTFS}/${DISTRO_CONFIG_SCRIPT}"
diff --git a/meta/classes/isar-bootstrap-helper.bbclass b/meta/classes/isar-bootstrap-helper.bbclass
index a3f1686..5d4dca0 100644
--- a/meta/classes/isar-bootstrap-helper.bbclass
+++ b/meta/classes/isar-bootstrap-helper.bbclass
@@ -17,8 +17,8 @@ def reverse_bb_array(d, varname):
setup_root_file_system() {
ROOTFSDIR="$1"
CLEAN="$2"
- shift
- shift
+ FSTAB="$3"
+ shift 3
PACKAGES="$@"
APT_ARGS="install --yes -o Debug::pkgProblemResolver=yes"
CLEAN_FILES="${ROOTFSDIR}/etc/hostname ${ROOTFSDIR}/etc/resolv.conf"
@@ -26,6 +26,7 @@ setup_root_file_system() {
sudo cp -Trpfx \
"${DEPLOY_DIR_IMAGE}/isar-bootstrap-${DISTRO}-${DISTRO_ARCH}/" \
"$ROOTFSDIR"
+ [ "${FSTAB}" != "-" ] && cat ${FSTAB} | sudo tee "$ROOTFSDIR/etc/fstab"
echo "deb [trusted=yes] file:///isar-apt ${DEBDISTRONAME} main" | \
sudo tee "$ROOTFSDIR/etc/apt/sources.list.d/isar-apt.list" >/dev/null
diff --git a/meta/recipes-devtools/buildchroot/buildchroot.bb b/meta/recipes-devtools/buildchroot/buildchroot.bb
index e405509..10142b7 100644
--- a/meta/recipes-devtools/buildchroot/buildchroot.bb
+++ b/meta/recipes-devtools/buildchroot/buildchroot.bb
@@ -69,7 +69,7 @@ do_build[root_cleandirs] = "${BUILDCHROOT_DIR} \
do_build[depends] = "isar-apt:do_cache_config isar-bootstrap:do_deploy"
do_build() {
- setup_root_file_system "${BUILDCHROOT_DIR}" "noclean" \
+ setup_root_file_system "${BUILDCHROOT_DIR}" "noclean" "-" \
${BUILDCHROOT_PREINSTALL}
# Install package builder script
--
2.13.7
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 4/5] Add u-boot script generator
2018-06-06 11:58 [PATCH 0/5] Enable U-Boot-based images, add Banana Pi demo Jan Kiszka
` (2 preceding siblings ...)
2018-06-06 11:58 ` [PATCH 3/5] Set up target image fstab prior to installing any packages Jan Kiszka
@ 2018-06-06 11:58 ` Jan Kiszka
2018-06-06 18:31 ` Jan Kiszka
2018-06-06 18:48 ` Jan Kiszka
2018-06-06 11:58 ` [PATCH 5/5] Add Banana Pi SD-card image Jan Kiszka
4 siblings, 2 replies; 9+ messages in thread
From: Jan Kiszka @ 2018-06-06 11:58 UTC (permalink / raw)
To: isar-users
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.
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}"
+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
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 5/5] Add Banana Pi SD-card image
2018-06-06 11:58 [PATCH 0/5] Enable U-Boot-based images, add Banana Pi demo Jan Kiszka
` (3 preceding siblings ...)
2018-06-06 11:58 ` [PATCH 4/5] Add u-boot script generator Jan Kiszka
@ 2018-06-06 11:58 ` Jan Kiszka
4 siblings, 0 replies; 9+ messages in thread
From: Jan Kiszka @ 2018-06-06 11:58 UTC (permalink / raw)
To: isar-users
From: Jan Kiszka <jan.kiszka@siemens.com>
This generates a bootable SD-card image for the LeMaker Banana Pi board.
As the 4.9 stretch kernel does not work on the board, we need to pull
4.16 from backports. That also gives us a chance to document by example
how multiple external repos and apt preferences can be used with Isar.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
.../conf/distro/debian-stretch-backports.list | 1 +
meta-isar/conf/local.conf.sample | 1 +
meta-isar/conf/multiconfig/bananapi-stretch.conf | 24 ++++++++++++++++++++++
.../conf/multiconfig/preferences.bananapi.conf | 7 +++++++
meta-isar/scripts/lib/wic/canned-wks/bananapi.wks | 5 +++++
5 files changed, 38 insertions(+)
create mode 100644 meta-isar/conf/distro/debian-stretch-backports.list
create mode 100644 meta-isar/conf/multiconfig/bananapi-stretch.conf
create mode 100644 meta-isar/conf/multiconfig/preferences.bananapi.conf
create mode 100644 meta-isar/scripts/lib/wic/canned-wks/bananapi.wks
diff --git a/meta-isar/conf/distro/debian-stretch-backports.list b/meta-isar/conf/distro/debian-stretch-backports.list
new file mode 100644
index 0000000..727a835
--- /dev/null
+++ b/meta-isar/conf/distro/debian-stretch-backports.list
@@ -0,0 +1 @@
+deb http://ftp.de.debian.org/debian stretch-backports main
diff --git a/meta-isar/conf/local.conf.sample b/meta-isar/conf/local.conf.sample
index 390cc4c..16ef488 100644
--- a/meta-isar/conf/local.conf.sample
+++ b/meta-isar/conf/local.conf.sample
@@ -46,6 +46,7 @@ BBMULTICONFIG = " \
qemui386-stretch \
qemuamd64-jessie \
qemuamd64-stretch \
+ bananapi-stretch \
rpi-jessie \
"
diff --git a/meta-isar/conf/multiconfig/bananapi-stretch.conf b/meta-isar/conf/multiconfig/bananapi-stretch.conf
new file mode 100644
index 0000000..a78300a
--- /dev/null
+++ b/meta-isar/conf/multiconfig/bananapi-stretch.conf
@@ -0,0 +1,24 @@
+# This software is a part of ISAR.
+# Copyright (c) Siemens AG, 2018
+#
+# SPDX-License-Identifier: MIT
+
+MACHINE ?= "bananapi"
+
+DISTRO ?= "debian-stretch"
+DISTRO_ARCH ?= "armhf"
+
+KERNEL_NAME ?= "armmp"
+
+IMAGE_PREINSTALL += "init"
+
+DISTRO_APT_SOURCES_append = " conf/distro/debian-stretch-backports.list"
+DISTRO_APT_PREFERENCES += "conf/multiconfig/preferences.bananapi.conf"
+
+IMAGE_INSTALL += "u-boot-script"
+BUILDCHROOT_PREINSTALL_WIC_append = " u-boot-sunxi"
+
+IMAGE_TYPE ?= "wic-img"
+WKS_FILE ?= "bananapi"
+
+ROOTFS_DEV ?= "mmcblk0p1"
diff --git a/meta-isar/conf/multiconfig/preferences.bananapi.conf b/meta-isar/conf/multiconfig/preferences.bananapi.conf
new file mode 100644
index 0000000..9f5c196
--- /dev/null
+++ b/meta-isar/conf/multiconfig/preferences.bananapi.conf
@@ -0,0 +1,7 @@
+Package: linux-image* linux-headers* linux-kbuild*
+Pin: release n=stretch-backports
+Pin-Priority: 501
+
+Package: *
+Pin: release n=stretch-backports
+Pin-Priority: -1
diff --git a/meta-isar/scripts/lib/wic/canned-wks/bananapi.wks b/meta-isar/scripts/lib/wic/canned-wks/bananapi.wks
new file mode 100644
index 0000000..d60868a
--- /dev/null
+++ b/meta-isar/scripts/lib/wic/canned-wks/bananapi.wks
@@ -0,0 +1,5 @@
+part u-boot --source rawcopy --sourceparams="file=/usr/lib/u-boot/Bananapi/u-boot-sunxi-with-spl.bin" --ondisk mmcblk --no-table --align 8
+
+part / --source rootfs --ondisk mmcblk --fstype=ext4 --label platform --align 1024
+
+bootloader --append="rootwait"
--
2.13.7
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 4/5] Add u-boot script generator
2018-06-06 11:58 ` [PATCH 4/5] Add u-boot script generator Jan Kiszka
@ 2018-06-06 18:31 ` Jan Kiszka
2018-06-06 18:48 ` Jan Kiszka
1 sibling, 0 replies; 9+ messages in thread
From: Jan Kiszka @ 2018-06-06 18:31 UTC (permalink / raw)
To: isar-users
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 4/5] Add u-boot script generator
2018-06-06 11:58 ` [PATCH 4/5] Add u-boot script generator Jan Kiszka
2018-06-06 18:31 ` Jan Kiszka
@ 2018-06-06 18:48 ` Jan Kiszka
1 sibling, 0 replies; 9+ messages in thread
From: Jan Kiszka @ 2018-06-06 18:48 UTC (permalink / raw)
To: isar-users
On 2018-06-06 13:58, [ext] Jan Kiszka wrote:
[...]
> +
> +echo "bootz \${kernel_addr_r} ${INITRD_ADDR} \${fdt_addr_r}" >> ${BOOT_CMD}
Another reason for v2: ARM64 will need "booti" here.
Jan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/5] Set up target image fstab prior to installing any packages
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
0 siblings, 0 replies; 9+ messages in thread
From: Claudius Heine @ 2018-06-07 6:38 UTC (permalink / raw)
To: [ext] Jan Kiszka, isar-users
Hi,
On 2018-06-06 13:58, [ext] Jan Kiszka wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
>
> Package postinst hooks may need the fstab or may want to modify it,
> including customization packages or the upcoming u-boot-script
> generator. So extract the already identical setup pattern from the
> distro config scripts, generate the fstab prior to calling
> setup_root_file_system and let the latter inject the file before
> starting the package installation. By specifying "-" as fstab file, we
> can skip the injection for the buildchroot which does not need it.
>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
> .../recipes-core/images/files/debian-configscript.sh | 14 --------------
> .../recipes-core/images/files/raspbian-configscript.sh | 14 --------------
> meta-isar/recipes-core/images/isar-image-base.bb | 18 ++++++++++++++----
> meta/classes/isar-bootstrap-helper.bbclass | 5 +++--
> meta/recipes-devtools/buildchroot/buildchroot.bb | 2 +-
> 5 files changed, 18 insertions(+), 35 deletions(-)
>
> diff --git a/meta-isar/recipes-core/images/files/debian-configscript.sh b/meta-isar/recipes-core/images/files/debian-configscript.sh
> index 136918c..bcd5507 100755
> --- a/meta-isar/recipes-core/images/files/debian-configscript.sh
> +++ b/meta-isar/recipes-core/images/files/debian-configscript.sh
> @@ -7,20 +7,6 @@ set -e
>
> readonly MACHINE_SERIAL="$1"
> readonly BAUDRATE_TTY="$2"
> -readonly ROOTFS_DEV="$3"
> -readonly ROOTFS_TYPE="$4"
> -
> -cat > /etc/fstab << EOF
> -# Begin /etc/fstab
> -/dev/$ROOTFS_DEV / $ROOTFS_TYPE defaults 1 1
> -proc /proc proc nosuid,noexec,nodev 0 0
> -sysfs /sys sysfs nosuid,noexec,nodev 0 0
> -devpts /dev/pts devpts gid=5,mode=620 0 0
> -tmpfs /run tmpfs defaults 0 0
> -devtmpfs /dev devtmpfs mode=0755,nosuid 0 0
> -
> -# End /etc/fstab
> -EOF
>
> # Create console device
> if [ ! -e /dev/console ]; then
> diff --git a/meta-isar/recipes-core/images/files/raspbian-configscript.sh b/meta-isar/recipes-core/images/files/raspbian-configscript.sh
> index 04ea571..3631c26 100644
> --- a/meta-isar/recipes-core/images/files/raspbian-configscript.sh
> +++ b/meta-isar/recipes-core/images/files/raspbian-configscript.sh
> @@ -7,20 +7,6 @@ set -e
>
> readonly MACHINE_SERIAL="$1"
> readonly BAUDRATE_TTY="$2"
> -readonly ROOTFS_DEV="$3"
> -readonly ROOTFS_TYPE="$4"
> -
> -cat > /etc/fstab << EOF
> -# Begin /etc/fstab
> -/dev/$ROOTFS_DEV / $ROOTFS_TYPE defaults 1 1
> -proc /proc proc nosuid,noexec,nodev 0 0
> -sysfs /sys sysfs nosuid,noexec,nodev 0 0
> -devpts /dev/pts devpts gid=5,mode=620 0 0
> -tmpfs /run tmpfs defaults 0 0
> -devtmpfs /dev devtmpfs mode=0755,nosuid 0 0
> -
> -# End /etc/fstab
> -EOF
>
> # Enable tty conditionally, systemd does not have the file but its own magic
> if [ -f /etc/inittab ]; then
> diff --git a/meta-isar/recipes-core/images/isar-image-base.bb b/meta-isar/recipes-core/images/isar-image-base.bb
> index f91dfb0..bf90e30 100644
> --- a/meta-isar/recipes-core/images/isar-image-base.bb
> +++ b/meta-isar/recipes-core/images/isar-image-base.bb
> @@ -28,15 +28,25 @@ do_rootfs[root_cleandirs] = "${IMAGE_ROOTFS} \
> ${IMAGE_ROOTFS}/isar-apt"
>
> do_rootfs() {
> - setup_root_file_system "${IMAGE_ROOTFS}" "clean" \
> + cat > ${WORKDIR}/fstab << EOF
> +# Begin /etc/fstab
> +/dev/${ROOTFS_DEV} / ${ROOTFS_TYPE} defaults 1 1
> +proc /proc proc nosuid,noexec,nodev 0 0
> +sysfs /sys sysfs nosuid,noexec,nodev 0 0
> +devpts /dev/pts devpts gid=5,mode=620 0 0
> +tmpfs /run tmpfs defaults 0 0
> +devtmpfs /dev devtmpfs mode=0755,nosuid 0 0
> +
> +# End /etc/fstab
> +EOF
> +
> + setup_root_file_system "${IMAGE_ROOTFS}" "clean" "${WORKDIR}/fstab" \
> ${IMAGE_PREINSTALL} ${IMAGE_INSTALL}
>
> # Configure root filesystem
> sudo install -m 755 "${WORKDIR}/${DISTRO_CONFIG_SCRIPT}" "${IMAGE_ROOTFS}"
> sudo chroot ${IMAGE_ROOTFS} /${DISTRO_CONFIG_SCRIPT} ${MACHINE_SERIAL} \
> - ${BAUDRATE_TTY} \
> - ${ROOTFS_DEV} \
> - ${ROOTFS_TYPE}
> + ${BAUDRATE_TTY}
>
> # Cleanup
> sudo rm "${IMAGE_ROOTFS}/${DISTRO_CONFIG_SCRIPT}"
> diff --git a/meta/classes/isar-bootstrap-helper.bbclass b/meta/classes/isar-bootstrap-helper.bbclass
> index a3f1686..5d4dca0 100644
> --- a/meta/classes/isar-bootstrap-helper.bbclass
> +++ b/meta/classes/isar-bootstrap-helper.bbclass
> @@ -17,8 +17,8 @@ def reverse_bb_array(d, varname):
> setup_root_file_system() {
> ROOTFSDIR="$1"
> CLEAN="$2"
> - shift
> - shift
> + FSTAB="$3"
> + shift 3
If that starts getting this complex with the second optional parameter,
maybe we should look into using getopt or just the normal shell 'case'
loop over the options. I would prefer that instead of introducing more
and more '-' positional parameter.
With 'clean' and 'noclean' we could sort of get away with it because we
always specify 'noclean' in those places instead of just '-'. It wasn't
ideal, but since it was the only one it was sort of ok. Now since we are
expanding this we should really switch to something easier to use and
understand.
Claudius
> PACKAGES="$@"
> APT_ARGS="install --yes -o Debug::pkgProblemResolver=yes"
> CLEAN_FILES="${ROOTFSDIR}/etc/hostname ${ROOTFSDIR}/etc/resolv.conf"
> @@ -26,6 +26,7 @@ setup_root_file_system() {
> sudo cp -Trpfx \
> "${DEPLOY_DIR_IMAGE}/isar-bootstrap-${DISTRO}-${DISTRO_ARCH}/" \
> "$ROOTFSDIR"
> + [ "${FSTAB}" != "-" ] && cat ${FSTAB} | sudo tee "$ROOTFSDIR/etc/fstab"
>
> echo "deb [trusted=yes] file:///isar-apt ${DEBDISTRONAME} main" | \
> sudo tee "$ROOTFSDIR/etc/apt/sources.list.d/isar-apt.list" >/dev/null
> diff --git a/meta/recipes-devtools/buildchroot/buildchroot.bb b/meta/recipes-devtools/buildchroot/buildchroot.bb
> index e405509..10142b7 100644
> --- a/meta/recipes-devtools/buildchroot/buildchroot.bb
> +++ b/meta/recipes-devtools/buildchroot/buildchroot.bb
> @@ -69,7 +69,7 @@ do_build[root_cleandirs] = "${BUILDCHROOT_DIR} \
> do_build[depends] = "isar-apt:do_cache_config isar-bootstrap:do_deploy"
>
> do_build() {
> - setup_root_file_system "${BUILDCHROOT_DIR}" "noclean" \
> + setup_root_file_system "${BUILDCHROOT_DIR}" "noclean" "-" \
> ${BUILDCHROOT_PREINSTALL}
>
> # Install package builder script
>
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-54 Fax: (+49)-8142-66989-80 Email: ch@denx.de
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2018-06-07 6:38 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2018-06-06 18:48 ` Jan Kiszka
2018-06-06 11:58 ` [PATCH 5/5] Add Banana Pi SD-card image Jan Kiszka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox