summaryrefslogtreecommitdiff
path: root/include/env/phytec
diff options
context:
space:
mode:
Diffstat (limited to 'include/env/phytec')
-rw-r--r--include/env/phytec/k3_dfu.env3
-rw-r--r--include/env/phytec/k3_mmc.env24
-rw-r--r--include/env/phytec/k3_net.env21
-rw-r--r--include/env/phytec/k3_spi.env18
-rw-r--r--include/env/phytec/overlays.env38
-rw-r--r--include/env/phytec/rauc.env52
6 files changed, 156 insertions, 0 deletions
diff --git a/include/env/phytec/k3_dfu.env b/include/env/phytec/k3_dfu.env
new file mode 100644
index 00000000000..0cba87da99d
--- /dev/null
+++ b/include/env/phytec/k3_dfu.env
@@ -0,0 +1,3 @@
+dfu_alt_info_ram=
+ tispl.bin ram 0x80080000 0x200000;
+ u-boot.img ram 0x81000000 0x400000
diff --git a/include/env/phytec/k3_mmc.env b/include/env/phytec/k3_mmc.env
new file mode 100644
index 00000000000..3f67e312f65
--- /dev/null
+++ b/include/env/phytec/k3_mmc.env
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2024 PHYTEC Messtechnik GmbH
+ * Author: Daniel Schultz <d.schultz@phytec.de>
+ */
+
+/* Logic for TI K3 based SoCs to boot from a MMC device. */
+
+#include <env/phytec/overlays.env>
+#include <env/phytec/rauc.env>
+
+mmcargs=setenv bootargs console=${console} earlycon=${earlycon}
+ root=/dev/mmcblk${mmcdev}p${mmcroot} ${raucargs} rootwait rw
+ ${optargs}
+mmcloadimage=load mmc ${mmcdev}:${mmcpart} ${kernel_addr_r} Image
+mmcloadfdt=load mmc ${mmcdev}:${mmcpart} ${fdt_addr_r} ${fdtfile}
+mmcboot=if test ${doraucboot} = 1; then run raucinit; fi;
+ run mmcargs;
+ mmc dev ${mmcdev};
+ mmc rescan;
+ run mmcloadimage;
+ run mmcloadfdt;
+ run mmc_apply_overlays;
+ booti ${kernel_addr_r} - ${fdt_addr_r}
diff --git a/include/env/phytec/k3_net.env b/include/env/phytec/k3_net.env
new file mode 100644
index 00000000000..4d5c703cae9
--- /dev/null
+++ b/include/env/phytec/k3_net.env
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2024 PHYTEC Messtechnik GmbH
+ * Author: Daniel Schultz <d.schultz@phytec.de>
+ */
+
+/* Logic for TI K3 based SoCs to boot via network. */
+
+#include <env/phytec/overlays.env>
+
+netargs=setenv bootargs console=${console} root=/dev/nfs ip=dhcp rw
+ nfsroot=${serverip}:${nfsroot},vers=4,tcp ${optargs}
+netloadimage=${get_cmd} ${kernel_addr_r} ${serverip}:/Image
+netloadfdt=${get_cmd} ${fdt_addr_r} ${serverip}:/${fdtfile}
+netboot=run netargs;
+ setenv autoload no;
+ dhcp;
+ run netloadimage;
+ run netloadfdt;
+ run net_apply_overlays;
+ booti ${kernel_addr_r} - ${fdt_addr_r}
diff --git a/include/env/phytec/k3_spi.env b/include/env/phytec/k3_spi.env
new file mode 100644
index 00000000000..8e9cfce3b4c
--- /dev/null
+++ b/include/env/phytec/k3_spi.env
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2024 PHYTEC Messtechnik GmbH
+ * Author: Daniel Schultz <d.schultz@phytec.de>
+ */
+
+/* Logic for TI K3 based SoCs to boot from an OSPI/QSPI NOR flash. */
+
+spiargs=setenv bootargs console=${console} earlycon=${earlycon} ${optargs}
+spiloadimage=sf read ${kernel_addr_r} ${spi_image_addr} ${size_kern}
+spiloadfdt=sf read ${fdt_addr_r} ${spi_fdt_addr} ${size_fdt}
+spiloadramdisk=sf read ${ramdisk_addr_r} ${spi_ramdisk_addr} ${size_fs}
+spiboot=run spiargs;
+ sf probe;
+ run spiloadimage;
+ run spiloadfdt;
+ run spiloadramdisk;
+ booti ${kernel_addr_r} ${ramdisk_addr_r}:0x${size_fs} ${fdt_addr_r}
diff --git a/include/env/phytec/overlays.env b/include/env/phytec/overlays.env
new file mode 100644
index 00000000000..78721cde654
--- /dev/null
+++ b/include/env/phytec/overlays.env
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2024 PHYTEC Messtechnik GmbH
+ * Author: Benjamin Hahn <b.hahn@phytec.de>
+ */
+
+/* Logic to load and apply overlays. Load overlays from bootenv.txt into
+ * environment and apply those overlays.
+ * The variables bootenv_addr_r and fdtoverlay_addr_r are board specific.
+ * get_cmd can be either tftp or dhcp. */
+
+bootenv=bootenv.txt
+mmc_load_bootenv=load mmc ${mmcdev}:${mmcpart} ${bootenv_addr_r} ${bootenv}
+mmc_load_overlay=load mmc ${mmcdev}:${mmcpart} ${fdtoverlay_addr_r} ${overlay}
+mmc_apply_overlays=
+ fdt address ${fdt_addr_r};
+ if test ${no_overlays} = 0; then
+ for overlay in ${overlays};
+ do;
+ if run mmc_load_overlay; then
+ fdt resize ${filesize};
+ fdt apply ${fdtoverlay_addr_r};
+ fi;
+ done;
+ fi;
+net_load_bootenv=${get_cmd} ${bootenv_addr_r} ${bootenv}
+net_load_overlay=${get_cmd} ${fdtoverlay_addr_r} ${overlay}
+net_apply_overlays=
+ fdt address ${fdt_addr_r};
+ if test ${no_overlays} = 0; then
+ for overlay in ${overlays};
+ do;
+ if run net_load_overlay; then
+ fdt resize ${filesize};
+ fdt apply ${fdtoverlay_addr_r};
+ fi;
+ done;
+ fi;
diff --git a/include/env/phytec/rauc.env b/include/env/phytec/rauc.env
new file mode 100644
index 00000000000..89e17ff70ec
--- /dev/null
+++ b/include/env/phytec/rauc.env
@@ -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;