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 2/8] v7a: add RAUC support for qemu-vexpress
Date: Sun, 12 Feb 2023 23:14:43 +0100	[thread overview]
Message-ID: <20230212221449.1644628-3-rhi@pengutronix.de> (raw)
In-Reply-To: <20230212221449.1644628-1-rhi@pengutronix.de>

* Enable barebox bootchooser framework
* Add a redundant root partition to the genimage config. The current
  size of the rootfs is below 98 MiB, so we can add a second root
  partition to the image while keeping the overall image size the same.
* Add appropriate variables to the barebox defaultenv so the bootchooser
  can decide into which partition to boot
* Make the bootstate node in the device tree reusable for more platforms
* Map partitions in rauc-udev compatibility layer

Signed-off-by: Roland Hieber <rhi@pengutronix.de>
---
 .../init/bootsource                           |   2 +-
 .../nv/boot.default                           |   1 +
 .../nv/bootchooser.state_prefix               |   1 +
 .../nv/bootchooser.system0.boot               |   1 +
 .../nv/bootchooser.system1.boot               |   1 +
 .../nv/bootchooser.targets                    |   1 +
 configs/platform-v7a/barebox-vexpress.config  |   3 +-
 .../platform-v7a/barebox-vexpress.config.diff |   2 +
 .../config/images/vexpress.config             |   7 +-
 ...-bootstate-node-into-a-generic-templ.patch | 123 ++++++++++++++++++
 .../patches/barebox-2022.09.0/series          |   1 +
 .../lib/udev/rules.d/90-rauc-partitions.rules |   5 +
 12 files changed, 145 insertions(+), 3 deletions(-)
 create mode 100644 configs/platform-v7a/barebox-vexpress-defaultenv/nv/boot.default
 create mode 100644 configs/platform-v7a/barebox-vexpress-defaultenv/nv/bootchooser.state_prefix
 create mode 100644 configs/platform-v7a/barebox-vexpress-defaultenv/nv/bootchooser.system0.boot
 create mode 100644 configs/platform-v7a/barebox-vexpress-defaultenv/nv/bootchooser.system1.boot
 create mode 100644 configs/platform-v7a/barebox-vexpress-defaultenv/nv/bootchooser.targets
 create mode 100644 configs/platform-v7a/patches/barebox-2022.09.0/0101-arm-dts-refactor-bootstate-node-into-a-generic-templ.patch

diff --git a/configs/platform-v7a/barebox-vexpress-defaultenv/init/bootsource b/configs/platform-v7a/barebox-vexpress-defaultenv/init/bootsource
index b42659c5e78b..4432e021fb0f 100644
--- a/configs/platform-v7a/barebox-vexpress-defaultenv/init/bootsource
+++ b/configs/platform-v7a/barebox-vexpress-defaultenv/init/bootsource
@@ -4,4 +4,4 @@ if [ -n "$nv.boot.default" ]; then
 	exit
 fi
 
-global.boot.default="disk0.0 net"
+global.boot.default="bootchooser net"
diff --git a/configs/platform-v7a/barebox-vexpress-defaultenv/nv/boot.default b/configs/platform-v7a/barebox-vexpress-defaultenv/nv/boot.default
new file mode 100644
index 000000000000..d7d9a373c50b
--- /dev/null
+++ b/configs/platform-v7a/barebox-vexpress-defaultenv/nv/boot.default
@@ -0,0 +1 @@
+bootchooser net
diff --git a/configs/platform-v7a/barebox-vexpress-defaultenv/nv/bootchooser.state_prefix b/configs/platform-v7a/barebox-vexpress-defaultenv/nv/bootchooser.state_prefix
new file mode 100644
index 000000000000..6246412a5c27
--- /dev/null
+++ b/configs/platform-v7a/barebox-vexpress-defaultenv/nv/bootchooser.state_prefix
@@ -0,0 +1 @@
+state.bootstate
diff --git a/configs/platform-v7a/barebox-vexpress-defaultenv/nv/bootchooser.system0.boot b/configs/platform-v7a/barebox-vexpress-defaultenv/nv/bootchooser.system0.boot
new file mode 100644
index 000000000000..961e29fe981b
--- /dev/null
+++ b/configs/platform-v7a/barebox-vexpress-defaultenv/nv/bootchooser.system0.boot
@@ -0,0 +1 @@
+disk0.0
diff --git a/configs/platform-v7a/barebox-vexpress-defaultenv/nv/bootchooser.system1.boot b/configs/platform-v7a/barebox-vexpress-defaultenv/nv/bootchooser.system1.boot
new file mode 100644
index 000000000000..5676f868b380
--- /dev/null
+++ b/configs/platform-v7a/barebox-vexpress-defaultenv/nv/bootchooser.system1.boot
@@ -0,0 +1 @@
+disk0.1
diff --git a/configs/platform-v7a/barebox-vexpress-defaultenv/nv/bootchooser.targets b/configs/platform-v7a/barebox-vexpress-defaultenv/nv/bootchooser.targets
new file mode 100644
index 000000000000..f0fb14eeaad2
--- /dev/null
+++ b/configs/platform-v7a/barebox-vexpress-defaultenv/nv/bootchooser.targets
@@ -0,0 +1 @@
+system0 system1
diff --git a/configs/platform-v7a/barebox-vexpress.config b/configs/platform-v7a/barebox-vexpress.config
index 9503d59b04af..443d2c2d82f2 100644
--- a/configs/platform-v7a/barebox-vexpress.config
+++ b/configs/platform-v7a/barebox-vexpress.config
@@ -188,7 +188,7 @@ CONFIG_BTHREAD=y
 CONFIG_STATE=y
 # CONFIG_STATE_CRYPTO is not set
 # CONFIG_STATE_BACKWARD_COMPATIBLE is not set
-# CONFIG_BOOTCHOOSER is not set
+CONFIG_BOOTCHOOSER=y
 CONFIG_RESET_SOURCE=y
 # CONFIG_MACHINE_ID is not set
 # CONFIG_SYSTEMD_OF_WATCHDOG is not set
@@ -277,6 +277,7 @@ CONFIG_CMD_GO=y
 # CONFIG_CMD_LOADY is not set
 CONFIG_CMD_RESET=y
 CONFIG_CMD_UIMAGE=y
+CONFIG_CMD_BOOTCHOOSER=y
 # end of Boot
 
 #
diff --git a/configs/platform-v7a/barebox-vexpress.config.diff b/configs/platform-v7a/barebox-vexpress.config.diff
index c9c2cc471980..8811f82ccd04 100644
--- a/configs/platform-v7a/barebox-vexpress.config.diff
+++ b/configs/platform-v7a/barebox-vexpress.config.diff
@@ -8,8 +8,10 @@ CONFIG_ARCH_VEXPRESS=y
 # CONFIG_ARM_SECURE_MONITOR is undefined
 # CONFIG_ARM_SMCCC is undefined
 # CONFIG_ARM_USE_COMPRESSED_DTB is undefined
+CONFIG_BOOTCHOOSER=y
 # CONFIG_CFI_BUFFER_WRITE is not set
 # CONFIG_CLOCKSOURCE_BCM283X is undefined
+CONFIG_CMD_BOOTCHOOSER=y
 # CONFIG_CMD_GPIO is undefined
 # CONFIG_CMD_SMC is undefined
 CONFIG_CONSOLE_ACTIVATE_ALL=y
diff --git a/configs/platform-v7a/config/images/vexpress.config b/configs/platform-v7a/config/images/vexpress.config
index d51a58be2893..3aa64a4299ce 100644
--- a/configs/platform-v7a/config/images/vexpress.config
+++ b/configs/platform-v7a/config/images/vexpress.config
@@ -6,7 +6,12 @@ image @IMAGE@ {
 	partition root-A {
 		image = root.ext2
 		partition-type = 0x83
-		size = 192M
+		size = 96M
+	}
+	partition root-B {
+		image = root.ext2
+		partition-type = 0x83
+		size = 96M
 	}
 	partition data {
 		partition-type = 0x83
diff --git a/configs/platform-v7a/patches/barebox-2022.09.0/0101-arm-dts-refactor-bootstate-node-into-a-generic-templ.patch b/configs/platform-v7a/patches/barebox-2022.09.0/0101-arm-dts-refactor-bootstate-node-into-a-generic-templ.patch
new file mode 100644
index 000000000000..a735d0449de3
--- /dev/null
+++ b/configs/platform-v7a/patches/barebox-2022.09.0/0101-arm-dts-refactor-bootstate-node-into-a-generic-templ.patch
@@ -0,0 +1,123 @@
+From: Roland Hieber <rhi@pengutronix.de>
+Date: Mon, 25 Jan 2021 00:24:21 +0100
+Subject: [PATCH] arm: dts: refactor bootstate node into a generic template
+
+The existing bootstate node can be used as-is for other A/B redundancy
+setups with the bootchooser framework too. Refactor it into an include
+file which can be simply re-used in other device trees.
+
+Signed-off-by: Roland Hieber <rhi@pengutronix.de>
+---
+ arch/arm/dts/generic-bootstate.dtsi | 44 +++++++++++++++++++++++++++++++++++++
+ arch/arm/dts/vexpress-v2p-ca9.dts   | 44 +++----------------------------------
+ 2 files changed, 47 insertions(+), 41 deletions(-)
+ create mode 100644 arch/arm/dts/generic-bootstate.dtsi
+
+diff --git a/arch/arm/dts/generic-bootstate.dtsi b/arch/arm/dts/generic-bootstate.dtsi
+new file mode 100644
+index 000000000000..5cf9d1640d5c
+--- /dev/null
++++ b/arch/arm/dts/generic-bootstate.dtsi
+@@ -0,0 +1,44 @@
++&bootstate {
++	#address-cells = <1>;
++	#size-cells = <1>;
++
++	system0 {
++		#address-cells = <1>;
++		#size-cells = <1>;
++
++		remaining_attempts@0 {
++			reg = <0x0 0x4>;
++			type = "uint32";
++			default = <3>;
++		};
++
++		priority@4 {
++			reg = <0x4 0x4>;
++			type = "uint32";
++			default = <20>;
++		};
++	};
++
++	system1 {
++		#address-cells = <1>;
++		#size-cells = <1>;
++
++		remaining_attempts@8 {
++			reg = <0x8 0x4>;
++			type = "uint32";
++			default = <3>;
++		};
++
++		priority@c {
++			reg = <0xc 0x4>;
++			type = "uint32";
++			default = <10>;
++		};
++	};
++
++	last_chosen@10 {
++		reg = <0x10 0x4>;
++		type = "uint32";
++	};
++};
++
+diff --git a/arch/arm/dts/vexpress-v2p-ca9.dts b/arch/arm/dts/vexpress-v2p-ca9.dts
+index a43628e7ce15..b7962c363a7b 100644
+--- a/arch/arm/dts/vexpress-v2p-ca9.dts
++++ b/arch/arm/dts/vexpress-v2p-ca9.dts
+@@ -25,50 +25,12 @@
+ 		#address-cells = <1>;
+ 		#size-cells = <1>;
+ 
+-		bootstate {
+-			#address-cells = <1>;
+-			#size-cells = <1>;
+-
+-			system0 { /* the node's name here must match the subnode's name in the 'bootstate' node */
+-				#address-cells = <1>;
+-				#size-cells = <1>;
+-
+-				remaining_attempts@0 {
+-					reg = <0x0 0x4>;
+-					type = "uint32";
+-					default = <3>;
+-				};
+-				priority@4 {
+-					reg = <0x4 0x4>;
+-					type = "uint32";
+-					default = <20>;
+-				};
+-			};
+-
+-			system1 { /* the node's name here must match the subnode's name in the 'bootstate' node */
+-				#address-cells = <1>;
+-				#size-cells = <1>;
+-
+-				remaining_attempts@8 {
+-					reg = <0x8 0x4>;
+-					type = "uint32";
+-					default = <3>;
+-				};
+-				priority@c {
+-					reg = <0xC 0x4>;
+-					type = "uint32";
+-					default = <20>;
+-				};
+-			};
+-
+-			last_chosen@10 {
+-				reg = <0x10 0x4>;
+-				type = "uint32";
+-			};
+-		};
++		bootstate: bootstate {};
+ 	};
+ };
+ 
++#include "generic-bootstate.dtsi"
++
+ &{/bus@40000000/motherboard-bus@40000000/flash@0,00000000} {
+ 	partitions {
+ 		compatible = "fixed-partitions";
diff --git a/configs/platform-v7a/patches/barebox-2022.09.0/series b/configs/platform-v7a/patches/barebox-2022.09.0/series
index 26c8a02e7caa..5ae996252bb9 100644
--- a/configs/platform-v7a/patches/barebox-2022.09.0/series
+++ b/configs/platform-v7a/patches/barebox-2022.09.0/series
@@ -1,3 +1,4 @@
 0001-mci-core-act-upon-broken-cd-device-tree-property.patch
 0002-mci-core-add-broken_cd-device-parameter.patch
 0003-mci-core-fixup-broken-cd-information-into-kernel-DT.patch
+0101-arm-dts-refactor-bootstate-node-into-a-generic-templ.patch
diff --git a/projectroot/usr/lib/udev/rules.d/90-rauc-partitions.rules b/projectroot/usr/lib/udev/rules.d/90-rauc-partitions.rules
index 0300e8b9daad..32731f8e983a 100644
--- a/projectroot/usr/lib/udev/rules.d/90-rauc-partitions.rules
+++ b/projectroot/usr/lib/udev/rules.d/90-rauc-partitions.rules
@@ -8,5 +8,10 @@ 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
+ENV{OF_BASE_COMPATIBLE}!="*arm,vexpress,v2p-ca9*", GOTO="qemu_vexpress_end"
+KERNEL=="mmcblk0p1", SYMLINK+="disk/by-usage/rootfs0"
+KERNEL=="mmcblk0p2", SYMLINK+="disk/by-usage/rootfs1"
+KERNEL=="mmcblk0p3", SYMLINK+="disk/by-usage/data"
+LABEL="qemu_vexpress_end"
 
 LABEL="rauc_partitions_end"
-- 
2.30.2




  parent reply	other threads:[~2023-02-12 22:15 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-12 22:14 [DistroKit] [PATCH 0/8] v7a: add redundant update support via RAUC Roland Hieber
2023-02-12 22:14 ` [DistroKit] [PATCH 1/8] rauc-udev: add a compatibility layer for mapping partitions Roland Hieber
2023-02-13  9:43   ` Michael Olbrich
2023-03-02  9:33     ` Roland Hieber
2023-02-12 22:14 ` Roland Hieber [this message]
2023-03-08  9:33   ` [DistroKit] [PATCH 2/8] v7a: add RAUC support for qemu-vexpress Roland Hieber
2023-02-12 22:14 ` [DistroKit] [PATCH 3/8] v7a: add RAUC support for beaglebone black Roland Hieber
2023-02-12 22:14 ` [DistroKit] [PATCH 4/8] v7a: add RAUC support for rpi3 Roland Hieber
2023-02-12 22:14 ` [DistroKit] [PATCH 5/8] v7a: add RAUC support for riotboard Roland Hieber
2023-02-12 22:14 ` [DistroKit] [PATCH 6/8] v7a: kernel: enable features necessary for RAUC Roland Hieber
2023-02-13  7:33   ` Jan Lübbe
2023-02-12 22:14 ` [DistroKit] [PATCH 7/8] rauc: add initial support Roland Hieber
2023-02-13  7:37   ` Jan Lübbe
2023-03-02  9:41     ` Roland Hieber
2023-03-02 10:34       ` Jan Lübbe
2023-03-02 16:09         ` Michael Olbrich
2023-03-08  9:45           ` Roland Hieber
2023-02-12 22:14 ` [DistroKit] [PATCH 8/8] v7a: enable RAUC bundle creation Roland Hieber
2023-02-13  7:42   ` Jan Lübbe
2023-04-25 18:38     ` Roland Hieber
2023-02-13  7:48 ` [DistroKit] [PATCH 0/8] v7a: add redundant update support via RAUC Marco Felsch
2023-02-13  9:35   ` Roland Hieber
2023-03-07 12:04 ` Ahmad Fatoum
2023-03-08 10:11   ` 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=20230212221449.1644628-3-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