Skip to contentSkip to conversation

Add RAUC boot logic for phycore_imx8mp

PATCH Superseded Leonard Anderweit 2 participants 9 messages Mar 11, 2024 Arm i.MX and Layerscape

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover Add RAUC boot logic for phycore_imx8mp

This series adds RAUC boot logic for the phycore_imx8mp.
The first patch converts the environment from a CFG_EXTRA_ENV_SETTINGS #define to a text environment for better readability and maintainability. The second patch moves the default bootcmd from the defconfig to the board environment.
The third patch enables the redundant environment on phycore_imx8mp. Patch 4 adds RAUC boot logic common to all phytec boards.
Patch 5 adds the RAUC boot logic to phycore_imx8mp.

Leonard Anderweit (5):
phycore_imx8mp: Move environment from include/config to board
phycore_imx8mp: Move default bootcmd to board env
configs: phycore-imx8mp_defconfig: Use redundant environment
include: env: Add phytec RAUC boot logic
board: phytec: phycore_imx8mp: Add RAUC boot logic to environment

 .../phytec/phycore_imx8mp/phycore_imx8mp.env  | 62 +++++++++++++++++++
 configs/phycore-imx8mp_defconfig              |  4 +-
 include/configs/phycore_imx8mp.h              | 43 -------------
 include/env/phytec/rauc.env                   | 52 ++++++++++++++++
 4 files changed, 116 insertions(+), 45 deletions(-)
 create mode 100644 board/phytec/phycore_imx8mp/phycore_imx8mp.env
 create mode 100644 include/env/phytec/rauc.env
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/5 phycore_imx8mp: Move environment from include/config to board

Move the environment into the board directory and convert it from a C header to a text file. Sort the variables alphabetically. No functional changes.

---
 .../phytec/phycore_imx8mp/phycore_imx8mp.env  | 45 +++++++++++++++++++
 include/configs/phycore_imx8mp.h              | 43 ------------------
 2 files changed, 45 insertions(+), 43 deletions(-)
 create mode 100644 board/phytec/phycore_imx8mp/phycore_imx8mp.env
board/phytec/phycore_imx8mp/phycore_imx8mp.env new file +45 -0
new file mode 100644
index 000000000000..6d15b7f3dc9f
@@ -0,0 +1,45 @@
+console=ttymxc0,115200
+dofastboot=0
+emmc_dev=2
+fastboot_raw_partition_all=0 4194304
+fastboot_raw_partition_bootloader=64 8128
+fdt_addr=0x48000000
+fdt_file=CONFIG_DEFAULT_FDT_FILE
+image=Image
+ip_dyn=yes
+loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}
+loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}
+mmcargs=
+	setenv bootargs console=${console}
+	root=/dev/mmcblk${mmcdev}p${mmcroot} rootwait rw
+mmcautodetect=yes
+mmcboot=
+	echo Booting from mmc ...;
+	run mmcargs;
+	if run loadfdt; then
+		booti ${loadaddr} - ${fdt_addr};
+	else
+		echo WARN: Cannot load the DT;
+	fi;
+mmcdev=CONFIG_SYS_MMC_ENV_DEV
+mmcpart=1
+mmcroot=2
+netargs=
+	setenv bootargs console=${console} root=/dev/nfs ip=dhcp
+	nfsroot=${serverip}:${nfsroot},v3,tcp
+netboot=
+	echo Booting from net ...;
+	run netargs;
+	if test ${ip_dyn} = yes; then
+		setenv get_cmd dhcp;
+	else
+		setenv get_cmd tftp;
+	fi;
+	${get_cmd} ${loadaddr} ${image};
+	if ${get_cmd} ${fdt_addr} ${fdt_file}; then
+		booti ${loadaddr} - ${fdt_addr};
+	else
+		echo WARN: Cannot load the DT;
+	fi;
+nfsroot=/nfs
+sd_dev=1
include/configs/phycore_imx8mp.h +0 -43

49 lines not on this page · raw message

Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/5 phycore_imx8mp: Move default bootcmd to board env

In reply to Leonard Anderweit

Move the default bootcmd from the defconfig to the board environment. No change in functionality.

---
 board/phytec/phycore_imx8mp/phycore_imx8mp.env | 12 ++++++++++++
 configs/phycore-imx8mp_defconfig               |  2 --
 2 files changed, 12 insertions(+), 2 deletions(-)
board/phytec/phycore_imx8mp/phycore_imx8mp.env +12 -0
index 6d15b7f3dc9f..73202c3b129a 100644
@@ -1,3 +1,15 @@
+bootcmd=
+	if test ${dofastboot} = 1; then
+		fastboot 0;
+	fi;
+	mmc dev ${mmcdev};
+	if mmc rescan; then
+		if run loadimage; then
+			run mmcboot;
+		else
+			run netboot;
+		fi;
+	fi;
 console=ttymxc0,115200
 dofastboot=0
 emmc_dev=2
configs/phycore-imx8mp_defconfig +0 -2
index b3a7bbd79bb6..fd492eba3c10 100644
@@ -25,8 +25,6 @@ CONFIG_FIT=y
 CONFIG_FIT_EXTERNAL_OFFSET=0x3000
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_OF_SYSTEM_SETUP=y
-CONFIG_USE_BOOTCOMMAND=y
-CONFIG_BOOTCOMMAND="if test ${dofastboot} = 1; then fastboot 0; fi; mmc dev ${mmcdev}; if mmc rescan; then if run loadimage; then run mmcboot; else run netboot; fi; fi;"
 CONFIG_DEFAULT_FDT_FILE="oftree"
 CONFIG_SYS_CBSIZE=2048
 CONFIG_SYS_PBSIZE=2074
Signature · 1 line
2.25.1
#3 lore raw

PATCH 3/5 configs: phycore-imx8mp_defconfig: Use redundant environment

In reply to Leonard Anderweit

Add support for the redundant environment.

---
 configs/phycore-imx8mp_defconfig | 2 ++
 1 file changed, 2 insertions(+)
configs/phycore-imx8mp_defconfig +2 -0
index fd492eba3c10..6c67f14b5559 100644
@@ -19,6 +19,7 @@ CONFIG_SPL_SERIAL=y
 CONFIG_SPL_DRIVERS_MISC=y
 CONFIG_SPL_STACK=0x960000
 CONFIG_SPL=y
+CONFIG_ENV_OFFSET_REDUND=0x3e0000
 CONFIG_SPL_IMX_ROMAPI_LOADADDR=0x48000000
 CONFIG_SYS_LOAD_ADDR=0x40480000
 CONFIG_FIT=y
@@ -77,6 +78,7 @@ CONFIG_OF_CONTROL=y
 CONFIG_SPL_OF_CONTROL=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_ENV_IS_IN_MMC=y
+CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_SYS_MMC_ENV_DEV=2
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
Signature · 1 line
2.25.1
reviewer
#4 lore raw

Re: [PATCH 3/5] configs: phycore-imx8mp_defconfig: Use redundant environment

Hi Leonard,

Quoted 4 lines · Leonard Anderweit

Add support for the redundant environment.

Please rebase this series against U-Boot next branch and resend.

There is an error while applying this patch against next.

Thanks

#5 lore raw

Re: [PATCH 3/5] configs: phycore-imx8mp_defconfig: Use redundant environment

Hi Fabio,

Am Montag, dem 11.03.2024 um 11:05 -0300 schrieb Fabio Estevam:

Quoted 10 lines

Hi Leonard,

Quoted 4 lines · Leonard Anderweit

Add support for the redundant environment.

Please rebase this series against U-Boot next branch and resend.

This series is based on the latest master branch.

Quoted 2 lines

There is an error while applying this patch against next.

I also got an error while applying this to next. To apply cleanly this series requires the commit 19f657600781 (configs: Resync with savedefconfig) which is on master but not on next.

If this missing commit is intended I'll resend this series based on next.

Regards,
Leonard

Quoted 2 lines

Thanks

reviewer
#6 lore raw

Re: [PATCH 3/5] configs: phycore-imx8mp_defconfig: Use redundant environment

Hi Leonard,

Quoted 6 lines · Leonard Anderweit

I also got an error while applying this to next. To apply cleanly this series requires the commit 19f657600781 (configs: Resync with savedefconfig) which is on master but not on next.

If this missing commit is intended I'll resend this series based on next.

At this point, the master branch is open only for bug fixes.

This series is targeted at the next branch, so please send a v2 based on next and I will apply it.

#7 lore raw

PATCH 4/5 include: env: Add phytec RAUC boot logic

In reply to Leonard Anderweit

Add logic for booting systems with the RAUC update mechanism. This can be reused by other phytec boards.

---
 include/env/phytec/rauc.env | 52 +++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 include/env/phytec/rauc.env
include/env/phytec/rauc.env new file +52 -0
new file mode 100644
index 000000000000..89e17ff70ec6
@@ -0,0 +1,52 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+/* Logic to select a boot partition based on environment variables and switch
+ * to the other if the boot fails. */
+
+doraucboot=0
+
+raucbootpart0=1
+raucrootpart0=5
+raucbootpart1=2
+raucrootpart1=6
+
+raucinit=
+	echo Booting RAUC A/B system;
+	test -n "${BOOT_ORDER}" || env set BOOT_ORDER "system0 system1";
+	test -n "${BOOT_system0_LEFT}" || env set BOOT_system0_LEFT 3;
+	test -n "${BOOT_system1_LEFT}" || env set BOOT_system1_LEFT 3;
+	env set raucstatus;
+	for BOOT_SLOT in "${BOOT_ORDER}"; do
+		if test "x${raucstatus}" != "x"; then
+			echo Skipping remaing slots!;
+		elif test "x${BOOT_SLOT}" = "xsystem0"; then
+			if test ${BOOT_system0_LEFT} -gt 0; then
+				echo Found valid slot A, ${BOOT_system0_LEFT} attempts remaining;
+				setexpr BOOT_system0_LEFT ${BOOT_system0_LEFT} - 1;
+				env set mmcpart ${raucbootpart0};
+				env set mmcroot ${raucrootpart0};
+				env set raucargs rauc.slot=system0;
+				env set raucstatus success;
+			fi;
+		elif test "x${BOOT_SLOT}" = "xsystem1"; then
+			if test ${BOOT_system1_LEFT} -gt 0; then
+				echo Found valid slot B, ${BOOT_system1_LEFT} attempts remaining;
+				setexpr BOOT_system1_LEFT ${BOOT_system1_LEFT} - 1;
+				env set mmcpart ${raucbootpart1};
+				env set mmcroot ${raucrootpart1};
+				env set raucargs rauc.slot=system1;
+				env set raucstatus success;
+			fi;
+		fi;
+	done;
+	if test -n "${raucstatus}"; then
+		env delete raucstatus;
+		env save;
+	else
+		echo WARN: No valid slot found;
+		env set BOOT_system0_LEFT 3;
+		env set BOOT_system1_LEFT 3;
+		env delete raucstatus;
+		env save;
+		reset;
+	fi;
Signature · 1 line
2.25.1
#8 lore raw

PATCH 5/5 board: phytec: phycore_imx8mp: Add RAUC boot logic to environment

In reply to Leonard Anderweit

Add RAUC boot logic to the environment. This is the first board to utilize this environment.

---
 board/phytec/phycore_imx8mp/phycore_imx8mp.env | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
board/phytec/phycore_imx8mp/phycore_imx8mp.env +6 -1
index 73202c3b129a..d58d25476f6b 100644
@@ -1,9 +1,14 @@
+#include <env/phytec/rauc.env>
+
 bootcmd=
 	if test ${dofastboot} = 1; then
 		fastboot 0;
 	fi;
 	mmc dev ${mmcdev};
 	if mmc rescan; then
+		if test ${doraucboot} = 1; then
+			run raucinit;
+		fi;
 		if run loadimage; then
 			run mmcboot;
 		else
@@ -23,7 +28,7 @@ loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}
 loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}
 mmcargs=
 	setenv bootargs console=${console}
-	root=/dev/mmcblk${mmcdev}p${mmcroot} rootwait rw
+	root=/dev/mmcblk${mmcdev}p${mmcroot} ${raucargs} rootwait rw
 mmcautodetect=yes
 mmcboot=
 	echo Booting from mmc ...;
Signature · 1 line
2.25.1