DistroKit Mailinglist
 help / color / mirror / Atom feed
From: Roland Hieber <rhi@pengutronix.de>
To: distrokit@pengutronix.de
Cc: Roland Hieber <rhi@pengutronix.de>
Subject: [DistroKit] [PATCH v3 03/14] rauc-udev: add a compatibility layer for mapping partitions
Date: Thu, 27 Apr 2023 12:01:23 +0200	[thread overview]
Message-ID: <20230427100134.2934937-4-rhi@pengutronix.de> (raw)
In-Reply-To: <20230427100134.2934937-1-rhi@pengutronix.de>

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 <rhi@pengutronix.de>
---
 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 08ce50601436..e123c5b9097a 100644
--- a/configs/ptxconfig
+++ b/configs/ptxconfig
@@ -3,6 +3,7 @@
 # PTXdist 2023.04.0
 #
 PTXCONF_DATAPARTITION=y
+PTXCONF_RAUC_UDEV=y
 
 #
 # ------------------------------------
@@ -693,7 +694,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 <rhi@pengutronix.de>
+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 <rhi@pengutronix.de>
+
+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 <rhi@pengutronix.de>
+#
+# 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 <rhi@pengutronix.de>")
+	@$(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




  parent reply	other threads:[~2023-04-27 10:01 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-27 10:01 [DistroKit] [PATCH v3 00/14] v7a: add redundant update support via RAUC Roland Hieber
2023-04-27 10:01 ` [DistroKit] [PATCH v3 01/14] platforms: revert to default systemd loglevel Roland Hieber
2023-04-27 10:01 ` [DistroKit] [PATCH v3 02/14] ptxconfig: enable more tools for debugging Roland Hieber
2023-04-27 10:01 ` Roland Hieber [this message]
2023-04-27 10:01 ` [DistroKit] [PATCH v3 04/14] v7a: barebox: include generic bootstate node in device tree Roland Hieber
2023-04-27 10:01 ` [DistroKit] [PATCH v3 05/14] v7a: add RAUC support for qemu-vexpress Roland Hieber
2023-04-27 10:01 ` [DistroKit] [PATCH v3 06/14] v7a: add RAUC support for beaglebone black Roland Hieber
2023-04-27 10:01 ` [DistroKit] [PATCH v3 07/14] v7a: add RAUC support for rpi3 Roland Hieber
2023-04-27 10:01 ` [DistroKit] [PATCH v3 08/14] v7a: add RAUC support for riotboard Roland Hieber
2023-04-27 10:01 ` [DistroKit] [PATCH v3 09/14] v7a: kernel: enable features necessary for RAUC Roland Hieber
2023-04-27 10:01 ` [DistroKit] [PATCH v3 10/14] rauc: add initial support Roland Hieber
2023-04-27 10:01 ` [DistroKit] [PATCH v3 11/14] v7a: enable RAUC bundle creation Roland Hieber
2023-04-27 10:01 ` [DistroKit] [PATCH v3 12/14] image-rauc: fork config from PTXdist 2023.04.0 Roland Hieber
2023-04-27 10:01 ` [DistroKit] [PATCH v3 13/14] image-rauc: use ext4 rootfs instead of tar.gz Roland Hieber
2023-04-27 10:01 ` [DistroKit] [PATCH v3 14/14] v7a: run: start with barebox by default Roland Hieber
2023-06-20 13:46 ` [DistroKit] [PATCH v3 00/14] v7a: add redundant update support via RAUC Robert Schwebel
2023-06-23 12:50   ` Roland Hieber

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=20230427100134.2934937-4-rhi@pengutronix.de \
    --to=rhi@pengutronix.de \
    --cc=distrokit@pengutronix.de \
    /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