From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Fri, 23 Jun 2023 14:48:18 +0200 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qCgD5-000aTz-Lz for lore@lore.pengutronix.de; Fri, 23 Jun 2023 14:48:18 +0200 Received: from localhost ([127.0.0.1] helo=metis.ext.pengutronix.de) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1qCgCu-0006cU-Kw; Fri, 23 Jun 2023 14:48:08 +0200 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qCgCm-0006KI-Ub; Fri, 23 Jun 2023 14:48:00 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1qCgCm-009VV6-BV; Fri, 23 Jun 2023 14:48:00 +0200 Received: from rhi by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1qCgCj-009fBW-7t; Fri, 23 Jun 2023 14:47:57 +0200 From: Roland Hieber To: distrokit@pengutronix.de Date: Fri, 23 Jun 2023 14:47:44 +0200 Message-Id: <20230623124755.2292833-4-rhi@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230623124755.2292833-1-rhi@pengutronix.de> References: <20230623124755.2292833-1-rhi@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [DistroKit] [PATCH 03/14] rauc-udev: add a compatibility layer for mapping partitions X-BeenThere: distrokit@pengutronix.de X-Mailman-Version: 2.1.29 Precedence: list List-Id: DistroKit Mailinglist List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roland Hieber Sender: "DistroKit" X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: distrokit-bounces@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false When we add RAUC support for different platforms later, we need a way to specify their respective root partitions in RAUC's system.conf; however, the names of the actual partitions can differ on different hardware platforms. Add a short udev rule that can add symlinks to the actual partitions based on the device tree compatible. This way we can refer to the partitions in system.conf using the symlinks on all boards that we want to support. This commit only adds a stub for now; we will add the code that creates the actual symlinks for each hardware in later commits. Signed-off-by: Roland Hieber --- configs/ptxconfig | 5 ++- projectroot/usr/lib/udev/of_base_compatible | 4 ++ .../lib/udev/rules.d/90-rauc-partitions.rules | 15 ++++++++ rules/rauc-udev.in | 10 +++++ rules/rauc-udev.make | 37 +++++++++++++++++++ 5 files changed, 70 insertions(+), 1 deletion(-) create mode 100755 projectroot/usr/lib/udev/of_base_compatible create mode 100644 projectroot/usr/lib/udev/rules.d/90-rauc-partitions.rules create mode 100644 rules/rauc-udev.in create mode 100644 rules/rauc-udev.make diff --git a/configs/ptxconfig b/configs/ptxconfig index 170c12408553..9f4fc06d5138 100644 --- a/configs/ptxconfig +++ b/configs/ptxconfig @@ -3,6 +3,7 @@ # PTXdist 2023.05.0 # PTXCONF_DATAPARTITION=y +PTXCONF_RAUC_UDEV=y # # ------------------------------------ @@ -700,7 +701,9 @@ PTXCONF_BUSYBOX_TEST=y # PTXCONF_BUSYBOX_TIMEOUT is not set PTXCONF_BUSYBOX_TOUCH=y PTXCONF_BUSYBOX_FEATURE_TOUCH_SUSV3=y -# PTXCONF_BUSYBOX_TR is not set +PTXCONF_BUSYBOX_TR=y +PTXCONF_BUSYBOX_FEATURE_TR_CLASSES=y +PTXCONF_BUSYBOX_FEATURE_TR_EQUIV=y PTXCONF_BUSYBOX_TRUE=y # PTXCONF_BUSYBOX_TRUNCATE is not set # PTXCONF_BUSYBOX_TSORT is not set diff --git a/projectroot/usr/lib/udev/of_base_compatible b/projectroot/usr/lib/udev/of_base_compatible new file mode 100755 index 000000000000..07c7f767ad90 --- /dev/null +++ b/projectroot/usr/lib/udev/of_base_compatible @@ -0,0 +1,4 @@ +#!/bin/sh +# SPDX-License-Identifier: 0-BSD +# SPDX-FileCopyrightText: 2021 Roland Hieber, Pengutronix +printf 'OF_BASE_COMPATIBLE="%s"\n' "$(tr '\0' ' ' < /sys/firmware/devicetree/base/compatible)" diff --git a/projectroot/usr/lib/udev/rules.d/90-rauc-partitions.rules b/projectroot/usr/lib/udev/rules.d/90-rauc-partitions.rules new file mode 100644 index 000000000000..c08f9b5633dc --- /dev/null +++ b/projectroot/usr/lib/udev/rules.d/90-rauc-partitions.rules @@ -0,0 +1,15 @@ +# SPDX-License-Identifier: 0-BSD +# SPDX-FileCopyrightText: 2021 Roland Hieber, Pengutronix + +ACTION=="remove", GOTO="rauc_partitions_end" +SUBSYSTEM!="block", GOTO="rauc_partitions_end" + +IMPORT{program}="of_base_compatible" + +# Add symlinks named /dev/disk/by-usage/{data,rootfs0,rootfs1} pointing +# to the correct partitions based on the device tree compatible + +# fallback for boards not yet supported by RAUC +KERNEL=="mmcblk0p3", SYMLINK+="disk/by-usage/data" + +LABEL="rauc_partitions_end" diff --git a/rules/rauc-udev.in b/rules/rauc-udev.in new file mode 100644 index 000000000000..f960c537f58f --- /dev/null +++ b/rules/rauc-udev.in @@ -0,0 +1,10 @@ +## SECTION=project_specific + +config RAUC_UDEV + tristate + prompt "rauc udev rules" + select BUSYBOX if RUNTIME + select BUSYBOX_TR if RUNTIME + select UDEV if RUNTIME + help + udev rules for cross-hardware-compatible partition symlinks diff --git a/rules/rauc-udev.make b/rules/rauc-udev.make new file mode 100644 index 000000000000..6a806fc43e34 --- /dev/null +++ b/rules/rauc-udev.make @@ -0,0 +1,37 @@ +# -*-makefile-*- +# +# Copyright (C) 2021 by Roland Hieber, Pengutronix +# +# For further information about the PTXdist project and license conditions +# see the README file. +# + +# +# We provide this package +# +PACKAGES-$(PTXCONF_RAUC_UDEV) += rauc-udev + +RAUC_UDEV_VERSION := 1 +RAUC_UDEV_LICENSE := 0-BSD + +# ---------------------------------------------------------------------------- +# Target-Install +# ---------------------------------------------------------------------------- + +$(STATEDIR)/rauc-udev.targetinstall: + @$(call targetinfo) + + @$(call install_init, rauc-udev) + @$(call install_fixup,rauc-udev,PRIORITY,optional) + @$(call install_fixup,rauc-udev,SECTION,base) + @$(call install_fixup,rauc-udev,AUTHOR,"Roland Hieber, Pengutronix ") + @$(call install_fixup,rauc-udev,DESCRIPTION,missing) + + @$(call install_alternative, rauc-udev, 0, 0, 0755, /usr/lib/udev/of_base_compatible) + @$(call install_alternative, rauc-udev, 0, 0, 0644, /usr/lib/udev/rules.d/90-rauc-partitions.rules) + + @$(call install_finish,rauc-udev) + + @$(call touch) + +# vim: syntax=make -- 2.39.2