From: Zhihang Wei <wzh@ilbers.de>
To: Gourav Singh <gouravsingh@siemens.com>, isar-users@googlegroups.com
Subject: Re: [PATCH] target-bootstrapper-service: add runtime serial tty drop-in generation
Date: Wed, 1 Jul 2026 11:04:08 +0200 [thread overview]
Message-ID: <b0db2afd-d5eb-491b-80cc-07e467323ef9@ilbers.de> (raw)
In-Reply-To: <20260619103944.1303513-1-gouravsingh@siemens.com>
Applied to next, thanks.
Zhihang
On 6/19/26 12:39, 'Gourav Singh' via isar-users wrote:
> Extend the recipe to support dynamically detected serial consoles without
> taking over every getty instance.
>
> The existing loop still installs overrides for statically configured
> TARGET_BOOTSTRAPPER_TTY_SERVICES. In addition, a runtime oneshot service
> and helper script are installed to detect the first available serial tty
> (ttyACM*/ttyUSB*/ttyAMA*/ttyGS*) and create one matching
> serial-getty@<tty>.service.d override from a stored template.
>
> This keeps installer behavior on configured ttys, adds support for
> runtime-discovered serial devices, and preserves other consoles for
> normal login/debug access.
>
> Signed-off-by: Gourav Singh <gouravsingh@siemens.com>
> ---
> .../generate-target-bootstrapper-dropin.sh | 47 +++++++++++++++++++
> .../files/postinst.tmpl | 3 ++
> ...arget-bootstrapper-generate-dropin.service | 12 +++++
> .../target-bootstrapper-service.bb | 14 +++++-
> 4 files changed, 74 insertions(+), 2 deletions(-)
> create mode 100644 meta-isar/recipes-installer/target-bootstrapper-service/files/generate-target-bootstrapper-dropin.sh
> create mode 100644 meta-isar/recipes-installer/target-bootstrapper-service/files/target-bootstrapper-generate-dropin.service
>
> diff --git a/meta-isar/recipes-installer/target-bootstrapper-service/files/generate-target-bootstrapper-dropin.sh b/meta-isar/recipes-installer/target-bootstrapper-service/files/generate-target-bootstrapper-dropin.sh
> new file mode 100644
> index 00000000..50c3ba40
> --- /dev/null
> +++ b/meta-isar/recipes-installer/target-bootstrapper-service/files/generate-target-bootstrapper-dropin.sh
> @@ -0,0 +1,47 @@
> +#!/bin/sh
> +# This software is a part of Isar.
> +# Copyright (C) Siemens AG, 2026
> +#
> +# SPDX-License-Identifier: MIT
> +
> +set -e
> +
> +OVERRIDE_DIR="/usr/lib/systemd/system"
> +DROP_IN_SUFFIX="d/10-target-bootstrapper.override.conf"
> +
> +# Check if override template exists
> +if [ ! -f "/usr/lib/target-bootstrapper.override.conf" ]; then
> + exit 0
> +fi
> +
> +# Detect first available serial device (ttyACM*, ttyUSB*, ttyAMA*, etc.)
> +detect_first_serial_device() {
> + for pattern in ttyACM ttyUSB ttyAMA ttyGS; do
> + for dev in /dev/${pattern}*; do
> + if [ -c "$dev" ]; then
> + basename "$dev"
> + return 0
> + fi
> + done
> + done
> +}
> +
> +DETECTED_TTY=$(detect_first_serial_device 2>/dev/null)
> +
> +if [ -z "$DETECTED_TTY" ]; then
> + exit 0
> +fi
> +
> +# Map device name to getty service instance
> +# e.g. ttyACM0 -> serial-getty@ttyACM0.service
> +TTY_SERVICE="serial-getty@${DETECTED_TTY}.service"
> +DROP_IN_DIR="${OVERRIDE_DIR}/${TTY_SERVICE}.d"
> +
> +# Create drop-in directory and install override
> +mkdir -p "$DROP_IN_DIR"
> +cp "/usr/lib/target-bootstrapper.override.conf" "$DROP_IN_DIR/${DROP_IN_SUFFIX##*/}"
> +
> +# Reload systemd to pick up new drop-ins
> +systemctl daemon-reload || true
> +
> +exit 0
> diff --git a/meta-isar/recipes-installer/target-bootstrapper-service/files/postinst.tmpl b/meta-isar/recipes-installer/target-bootstrapper-service/files/postinst.tmpl
> index 7c24af17..57851956 100644
> --- a/meta-isar/recipes-installer/target-bootstrapper-service/files/postinst.tmpl
> +++ b/meta-isar/recipes-installer/target-bootstrapper-service/files/postinst.tmpl
> @@ -5,3 +5,6 @@ set -e
> for tty_service in ${TARGET_BOOTSTRAPPER_TTY_SERVICES}; do
> deb-systemd-helper enable ${tty_service} || true
> done
> +
> +# Enable the runtime detection service
> +deb-systemd-helper enable target-bootstrapper-generate-dropin.service || true
> diff --git a/meta-isar/recipes-installer/target-bootstrapper-service/files/target-bootstrapper-generate-dropin.service b/meta-isar/recipes-installer/target-bootstrapper-service/files/target-bootstrapper-generate-dropin.service
> new file mode 100644
> index 00000000..38457c8d
> --- /dev/null
> +++ b/meta-isar/recipes-installer/target-bootstrapper-service/files/target-bootstrapper-generate-dropin.service
> @@ -0,0 +1,12 @@
> +[Unit]
> +Description=Generate target-bootstrapper drop-in for detected serial devices
> +Before=serial-getty@.service getty@.service
> +After=dev-*.device
> +
> +[Service]
> +Type=oneshot
> +ExecStart=/usr/libexec/target-bootstrapper-service/generate-target-bootstrapper-dropin.sh
> +RemainAfterExit=yes
> +
> +[Install]
> +WantedBy=multi-user.target
> diff --git a/meta-isar/recipes-installer/target-bootstrapper-service/target-bootstrapper-service.bb b/meta-isar/recipes-installer/target-bootstrapper-service/target-bootstrapper-service.bb
> index e7a8b2a1..572cddcd 100644
> --- a/meta-isar/recipes-installer/target-bootstrapper-service/target-bootstrapper-service.bb
> +++ b/meta-isar/recipes-installer/target-bootstrapper-service/target-bootstrapper-service.bb
> @@ -25,6 +25,8 @@ inherit dpkg-raw
> SRC_URI = "\
> file://postinst.tmpl \
> file://target-bootstrapper.override.conf \
> + file://generate-target-bootstrapper-dropin.sh \
> + file://target-bootstrapper-generate-dropin.service \
> "
>
> TEMPLATE_FILES = "postinst.tmpl"
> @@ -33,11 +35,19 @@ TEMPLATE_VARS = "TARGET_BOOTSTRAPPER_TTY_SERVICES"
> DEPENDS += " target-bootstrapper"
> DEBIAN_DEPENDS = "target-bootstrapper"
>
> -do_install[cleandirs] = "${D}/usr/lib/systemd/system/"
> +do_install[cleandirs] = "${D}/usr/lib/systemd/system/ ${D}/usr/libexec"
> do_install() {
> for svc_name in ${TARGET_BOOTSTRAPPER_TTY_SERVICES}
> do
> - mkdir -p ${D}/usr/lib/systemd/system/${svc_name}.service.d/
> + install -d -m 0755 ${D}/usr/lib/systemd/system/${svc_name}.service.d/
> install -m 0644 ${WORKDIR}/target-bootstrapper.override.conf ${D}/usr/lib/systemd/system/${svc_name}.service.d/10-target-bootstrapper.override.conf
> done
> +
> + # Install script and service for runtime detection of serial devices
> + install -d -m 0755 ${D}/usr/libexec/${PN}/
> + install -m 0755 ${WORKDIR}/generate-target-bootstrapper-dropin.sh ${D}/usr/libexec/${PN}/
> + install -m 0644 ${WORKDIR}/target-bootstrapper-generate-dropin.service ${D}/usr/lib/systemd/system/
> +
> + # Install override template for runtime use by the detection script
> + install -m 0644 ${WORKDIR}/target-bootstrapper.override.conf ${D}/usr/lib/target-bootstrapper.override.conf
> }
--
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/isar-users/b0db2afd-d5eb-491b-80cc-07e467323ef9%40ilbers.de.
prev parent reply other threads:[~2026-07-01 9:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-19 10:39 'Gourav Singh' via isar-users
2026-07-01 9:04 ` Zhihang Wei [this message]
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=b0db2afd-d5eb-491b-80cc-07e467323ef9@ilbers.de \
--to=wzh@ilbers.de \
--cc=gouravsingh@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