From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Sat, 04 Nov 2023 01:35:38 +0100 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) 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 1qz4dW-000NQl-Ss for lore@lore.pengutronix.de; Sat, 04 Nov 2023 01:35:38 +0100 Received: from localhost ([127.0.0.1] helo=metis.whiteo.stw.pengutronix.de) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1qz4dV-0001ik-LL; Sat, 04 Nov 2023 01:35:37 +0100 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qz4dQ-0001bj-3i; Sat, 04 Nov 2023 01:35:32 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qz4dP-006RQI-N9; Sat, 04 Nov 2023 01:35:31 +0100 Received: from rhi by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1qz4dP-0072BE-28; Sat, 04 Nov 2023 01:35:31 +0100 From: Roland Hieber To: distrokit@pengutronix.de Date: Sat, 4 Nov 2023 01:35:24 +0100 Message-Id: <20231104003525.1673736-4-rhi@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231104003525.1673736-1-rhi@pengutronix.de> References: <20231104003525.1673736-1-rhi@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [DistroKit] [PATCH 3/4] v8a: add RAUC support for rock3a 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false * Add a state partition to the genimage configuration (offset is not needed for the root partition since genimage can calculate that based on the size of the previous partition and the alignment; and the barebox-state partition is autodetected based on the partition GUID) * Add a device tree fragment to barebox containing the state backend * Add appropriate variables to the barebox defaultenv so the bootchooser can decide into which partition to boot * Map boot device (SD card) in rauc-udev compatibility layer Signed-off-by: Roland Hieber --- .../barebox-common-defaultenv/init/bootsource | 6 +- configs/platform-v8a/barebox.config | 2 +- .../platform-v8a/config/images/rock3a.config | 6 +- configs/platform-v8a/dts/bootstate.dtsi | 72 +++++++++++++++++++ .../lib/udev/rules.d/90-rauc-partitions.rules | 1 + 5 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 configs/platform-v8a/dts/bootstate.dtsi diff --git a/configs/platform-v8a/barebox-common-defaultenv/init/bootsource b/configs/platform-v8a/barebox-common-defaultenv/init/bootsource index db1915321531..fe63bbbe099b 100644 --- a/configs/platform-v8a/barebox-common-defaultenv/init/bootsource +++ b/configs/platform-v8a/barebox-common-defaultenv/init/bootsource @@ -7,10 +7,14 @@ fi if [ "$bootsource" = mmc ]; then detect mmc$bootsource_instance - global.boot.default="mmc$bootsource_instance net" + global.boot.default="bootchooser net" fi if [ "${global.model}" = "Radxa ROCK3 Model A" ]; then + global bootchooser.state_prefix="state.bootstate" + global bootchooser.targets="system0 system1" + global bootchooser.system0.boot="mmc1.root-A" + global bootchooser.system1.boot="mmc1.root-B" if [ "$bootsource" = "spi-nor" ]; then usbgadget -A '/dev/mmc1(sd)' global.autoboot=abort diff --git a/configs/platform-v8a/barebox.config b/configs/platform-v8a/barebox.config index 9ac64ad8a7f4..8b0cb4647239 100644 --- a/configs/platform-v8a/barebox.config +++ b/configs/platform-v8a/barebox.config @@ -238,7 +238,7 @@ CONFIG_BOOTCHOOSER=y CONFIG_RESET_SOURCE=y # CONFIG_MACHINE_ID is not set # CONFIG_SYSTEMD_OF_WATCHDOG is not set -CONFIG_EXTERNAL_DTS_FRAGMENTS="" +CONFIG_EXTERNAL_DTS_FRAGMENTS="${PTXDIST_PLATFORMCONFIGDIR}/dts/bootstate.dtsi" # # OP-TEE loading diff --git a/configs/platform-v8a/config/images/rock3a.config b/configs/platform-v8a/config/images/rock3a.config index 4b53e32ced3d..19e8a306861a 100644 --- a/configs/platform-v8a/config/images/rock3a.config +++ b/configs/platform-v8a/config/images/rock3a.config @@ -21,8 +21,12 @@ image @IMAGE@ { in-partition-table = false image = /dev/null } + partition barebox-state { + size = 1M + partition-type-uuid = 4778ed65-bf42-45fa-9c5b-287a1dc4aab1 # barebox-state + image = /dev/null + } partition root-A { - offset = 5M image = "root.ext2" partition-type-uuid = b921b045-1df0-41c3-af44-4c6f280d3fae # root-arm64 } diff --git a/configs/platform-v8a/dts/bootstate.dtsi b/configs/platform-v8a/dts/bootstate.dtsi new file mode 100644 index 000000000000..d5dee2cea8c1 --- /dev/null +++ b/configs/platform-v8a/dts/bootstate.dtsi @@ -0,0 +1,72 @@ +/** Radxa ROCK3 Model A *******************************************************/ +#ifdef rk3568_rock_3a_dts +/ { + aliases { + state = &state_sd; + }; + + state_sd: state { + #address-cells = <1>; + #size-cells = <1>; + compatible = "barebox,state"; + magic = <0xde3e5c14>; + backend = <&sdmmc0>; // via GPT Type UUID + backend-type = "raw"; + backend-storage-type = "direct"; + backend-stridesize = <0x40>; + }; +}; + +#endif + +/** Generic bootstate node for all platforms **********************************/ +/ { + state: state { + bootstate: bootstate {}; + }; +}; + +&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/projectroot/usr/lib/udev/rules.d/90-rauc-partitions.rules b/projectroot/usr/lib/udev/rules.d/90-rauc-partitions.rules index 64f1aab46ac0..2da28ae5df16 100644 --- a/projectroot/usr/lib/udev/rules.d/90-rauc-partitions.rules +++ b/projectroot/usr/lib/udev/rules.d/90-rauc-partitions.rules @@ -15,6 +15,7 @@ ENV{OF_BASE_COMPATIBLE}=="*lxa,stm32mp157c-mc1*", ENV{ID_PATH}=="platform-soc-am ENV{OF_BASE_COMPATIBLE}=="*ti,am335x-bone-black*", ENV{ID_PATH}=="platform-48060000.mmc", TAG+="boot_disk" ENV{OF_BASE_COMPATIBLE}=="*raspberrypi,3-model-b*", ENV{ID_PATH}=="platform-3f202000.mmc", TAG+="boot_disk" ENV{OF_BASE_COMPATIBLE}=="*riot,imx6s-riotboard*", ENV{ID_PATH}=="platform-2198000.mmc", TAG+="boot_disk" +ENV{OF_BASE_COMPATIBLE}=="*radxa,rock3a*", ENV{ID_PATH}=="platform-fe2b0000.mmc", TAG+="boot_disk" # second part: create /dev/disk/by-usage/ symlinks ENV{DEVTYPE}!="partition", GOTO="rauc_partitions_end" -- 2.39.2