From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Sun, 12 Feb 2023 23:15:08 +0100 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 1pRKcn-005arx-K0 for lore@lore.pengutronix.de; Sun, 12 Feb 2023 23:15:08 +0100 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 1pRKck-0006pA-Gd; Sun, 12 Feb 2023 23:15:06 +0100 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 1pRKcb-0006o0-HW; Sun, 12 Feb 2023 23:14:57 +0100 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 1pRKcZ-004WUn-Jj; Sun, 12 Feb 2023 23:14:56 +0100 Received: from rhi by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pRKcZ-006uAe-U4; Sun, 12 Feb 2023 23:14:55 +0100 From: Roland Hieber To: distrokit@pengutronix.de Date: Sun, 12 Feb 2023 23:14:45 +0100 Message-Id: <20230212221449.1644628-5-rhi@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230212221449.1644628-1-rhi@pengutronix.de> References: <20230212221449.1644628-1-rhi@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [DistroKit] [PATCH 4/8] v7a: add RAUC support for rpi3 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 * Enable barebox bootchooser framework * Add a redundant root partition to the genimage config. The state and environment partitions can live in the first 4 MiB of the SD card, so move the the boot partition by the same amount. * Add appropriate variables to the barebox defaultenv so the bootchooser can decide into which partition to boot * Add a state partition to the device tree * Map partitions in rauc-udev compatibility layer Signed-off-by: Roland Hieber --- .../barebox-rpi2-defaultenv/init/bootsource | 5 +- .../barebox-rpi2-defaultenv/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-rpi2.config | 3 +- configs/platform-v7a/barebox-rpi2.config.diff | 2 + .../platform-v7a/config/images/rpi2.config | 5 ++ ...ts-bcm2837-rpi-3-b-add-state-support.patch | 59 +++++++++++++++++++ .../patches/barebox-2022.09.0/series | 1 + .../lib/udev/rules.d/90-rauc-partitions.rules | 6 ++ 12 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 configs/platform-v7a/barebox-rpi2-defaultenv/nv/boot.default create mode 100644 configs/platform-v7a/barebox-rpi2-defaultenv/nv/bootchooser.state_prefix create mode 100644 configs/platform-v7a/barebox-rpi2-defaultenv/nv/bootchooser.system0.boot create mode 100644 configs/platform-v7a/barebox-rpi2-defaultenv/nv/bootchooser.system1.boot create mode 100644 configs/platform-v7a/barebox-rpi2-defaultenv/nv/bootchooser.targets create mode 100644 configs/platform-v7a/patches/barebox-2022.09.0/0103-arm-dts-bcm2837-rpi-3-b-add-state-support.patch diff --git a/configs/platform-v7a/barebox-rpi2-defaultenv/init/bootsource b/configs/platform-v7a/barebox-rpi2-defaultenv/init/bootsource index 4de71635720a..50f505f6266b 100644 --- a/configs/platform-v7a/barebox-rpi2-defaultenv/init/bootsource +++ b/configs/platform-v7a/barebox-rpi2-defaultenv/init/bootsource @@ -6,8 +6,7 @@ fi if [ $bootsource = mmc ]; then global.boot.default="bootchooser net" -elif [ $bootsource = net ]; then - global.boot.default="net bootchooser" else - global.boot.default="disk0.1 net" + global.boot.default="net bootchooser" fi + diff --git a/configs/platform-v7a/barebox-rpi2-defaultenv/nv/boot.default b/configs/platform-v7a/barebox-rpi2-defaultenv/nv/boot.default new file mode 100644 index 000000000000..d7d9a373c50b --- /dev/null +++ b/configs/platform-v7a/barebox-rpi2-defaultenv/nv/boot.default @@ -0,0 +1 @@ +bootchooser net diff --git a/configs/platform-v7a/barebox-rpi2-defaultenv/nv/bootchooser.state_prefix b/configs/platform-v7a/barebox-rpi2-defaultenv/nv/bootchooser.state_prefix new file mode 100644 index 000000000000..6246412a5c27 --- /dev/null +++ b/configs/platform-v7a/barebox-rpi2-defaultenv/nv/bootchooser.state_prefix @@ -0,0 +1 @@ +state.bootstate diff --git a/configs/platform-v7a/barebox-rpi2-defaultenv/nv/bootchooser.system0.boot b/configs/platform-v7a/barebox-rpi2-defaultenv/nv/bootchooser.system0.boot new file mode 100644 index 000000000000..5676f868b380 --- /dev/null +++ b/configs/platform-v7a/barebox-rpi2-defaultenv/nv/bootchooser.system0.boot @@ -0,0 +1 @@ +disk0.1 diff --git a/configs/platform-v7a/barebox-rpi2-defaultenv/nv/bootchooser.system1.boot b/configs/platform-v7a/barebox-rpi2-defaultenv/nv/bootchooser.system1.boot new file mode 100644 index 000000000000..1851d291c58c --- /dev/null +++ b/configs/platform-v7a/barebox-rpi2-defaultenv/nv/bootchooser.system1.boot @@ -0,0 +1 @@ +disk0.2 diff --git a/configs/platform-v7a/barebox-rpi2-defaultenv/nv/bootchooser.targets b/configs/platform-v7a/barebox-rpi2-defaultenv/nv/bootchooser.targets new file mode 100644 index 000000000000..f0fb14eeaad2 --- /dev/null +++ b/configs/platform-v7a/barebox-rpi2-defaultenv/nv/bootchooser.targets @@ -0,0 +1 @@ +system0 system1 diff --git a/configs/platform-v7a/barebox-rpi2.config b/configs/platform-v7a/barebox-rpi2.config index 4788ff19a692..c8c92385382f 100644 --- a/configs/platform-v7a/barebox-rpi2.config +++ b/configs/platform-v7a/barebox-rpi2.config @@ -208,7 +208,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 @@ -290,6 +290,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-rpi2.config.diff b/configs/platform-v7a/barebox-rpi2.config.diff index 534b657b7448..a65fef755868 100644 --- a/configs/platform-v7a/barebox-rpi2.config.diff +++ b/configs/platform-v7a/barebox-rpi2.config.diff @@ -1,5 +1,7 @@ 44749ac3167836cbc7b473f78c4e9fea CONFIG_ARM_ASM_UNIFIED=y +CONFIG_BOOTCHOOSER=y +CONFIG_CMD_BOOTCHOOSER=y # CONFIG_CMD_NVMEM is not set # CONFIG_CMD_USBGADGET is undefined CONFIG_DRIVER_SERIAL_NS16550=y diff --git a/configs/platform-v7a/config/images/rpi2.config b/configs/platform-v7a/config/images/rpi2.config index 3dc404d36379..80f004e03bde 100644 --- a/configs/platform-v7a/config/images/rpi2.config +++ b/configs/platform-v7a/config/images/rpi2.config @@ -13,6 +13,7 @@ image @IMAGE@ { disk-signature = 0xbedf7893 } partition boot { + offset = 4M image = rpi2-boot.vfat partition-type = 0xc bootable = true @@ -21,6 +22,10 @@ image @IMAGE@ { image = root.ext2 partition-type = 0x83 } + partition root-B { + image = root.ext2 + partition-type = 0x83 + } partition data { partition-type = 0x83 size = 512M diff --git a/configs/platform-v7a/patches/barebox-2022.09.0/0103-arm-dts-bcm2837-rpi-3-b-add-state-support.patch b/configs/platform-v7a/patches/barebox-2022.09.0/0103-arm-dts-bcm2837-rpi-3-b-add-state-support.patch new file mode 100644 index 000000000000..ec49b669e995 --- /dev/null +++ b/configs/platform-v7a/patches/barebox-2022.09.0/0103-arm-dts-bcm2837-rpi-3-b-add-state-support.patch @@ -0,0 +1,59 @@ +From: Enrico Joerns +Date: Thu, 5 Jan 2017 17:46:36 +0100 +Subject: [PATCH] arm: dts: bcm2837-rpi-3-b: add state support + +Signed-off-by: Enrico Joerns +--- + arch/arm/dts/bcm2837-rpi-3.dts | 36 ++++++++++++++++++++++++++++++++++++ + 1 file changed, 36 insertions(+) + +diff --git a/arch/arm/dts/bcm2837-rpi-3.dts b/arch/arm/dts/bcm2837-rpi-3.dts +index e82d518fa551..086397ba35f5 100644 +--- a/arch/arm/dts/bcm2837-rpi-3.dts ++++ b/arch/arm/dts/bcm2837-rpi-3.dts +@@ -1,5 +1,26 @@ + #include + ++/ { ++ aliases { ++ state = &state; ++ }; ++ ++ state: state { ++ magic = <0x11fb08ef>; ++ compatible = "barebox,state"; ++ backend-type = "raw"; ++ backend = <&statepart>; ++ backend-stridesize = <0x80>; ++ backend-storage-type = "direct"; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ bootstate: bootstate {}; ++ }; ++}; ++ ++#include "generic-bootstate.dtsi" ++ + &{/memory@0} { + reg = <0x0 0x0>; + }; +@@ -7,3 +28,18 @@ + &sdhci { + status = "disabled"; + }; ++ ++&sdhost { ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ statepart: partition@100000 { ++ label = "barebox-state"; ++ reg = <0x100000 0x100000>; ++ }; ++ ++ partition@200000 { ++ label = "barebox-environment"; ++ reg = <0x200000 0x100000>; ++ }; ++}; diff --git a/configs/platform-v7a/patches/barebox-2022.09.0/series b/configs/platform-v7a/patches/barebox-2022.09.0/series index 14a2ac07a71f..24a6b4c9896b 100644 --- a/configs/platform-v7a/patches/barebox-2022.09.0/series +++ b/configs/platform-v7a/patches/barebox-2022.09.0/series @@ -3,3 +3,4 @@ 0003-mci-core-fixup-broken-cd-information-into-kernel-DT.patch 0101-arm-dts-refactor-bootstate-node-into-a-generic-templ.patch 0102-arm-dts-boneblack-add-beaglebone-black-state-entry.patch +0103-arm-dts-bcm2837-rpi-3-b-add-state-support.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 11b4e1c86a3c..87575bc15273 100644 --- a/projectroot/usr/lib/udev/rules.d/90-rauc-partitions.rules +++ b/projectroot/usr/lib/udev/rules.d/90-rauc-partitions.rules @@ -20,4 +20,10 @@ KERNEL=="mmcblk0p3", SYMLINK+="disk/by-usage/rootfs1" KERNEL=="mmcblk0p4", SYMLINK+="disk/by-usage/data" LABEL="beaglebone_black_end" +ENV{OF_BASE_COMPATIBLE}!="*raspberrypi,3-model-b*", GOTO="rpi3_end" +KERNEL=="mmcblk0p2", SYMLINK+="disk/by-usage/rootfs0" +KERNEL=="mmcblk0p3", SYMLINK+="disk/by-usage/rootfs1" +KERNEL=="mmcblk0p4", SYMLINK+="disk/by-usage/data" +LABEL="rpi3_end" + LABEL="rauc_partitions_end" -- 2.30.2