Skip to contentSkip to conversation

phycore-am62/4: Add more boot sources

PATCH In review Daniel Schultz 2 participants 15 messages Aug 30, 2024 – Sep 10, 2024

lore
Share & tools
lore
#0 lore raw

cover phycore-am62/4: Add more boot sources

This patch stack extends the phyCORE-AM62x/AM64x U-Boot by following boot sources:

- Load U-Boot with USB DFU
- Load a Linux and initramfs from OSPI/QSPI NOR flash
- Load a Linux and rootfs from Network

Moreover, it adds required changes to the environment to boot an A/B system with RAUC and includes some minor fixes.

Daniel Schultz (12):
include: env: phytec: k3_mmc: Rename variables
include: env: phytec: Add raucinit to k3_mmc environment
include: net: phytec: Add K3 network boot logic
include: env: phytec: Add K3 boot logic for OSPI/QSPI flashes
board: phytec: phycore_am62x: Add Network/SPI Boot
board: phytec: phycore_am64x: Add Network/SPI Boot
configs: phycore_am62x_a53_defconfig: Make BOOTCMD generic
configs: phycore_am64x_a53_defconfig: Make BOOTCMD generic
configs: phycore_am62x_a53_defconfig: Merge am62x_a53_usbdfu.config
configs: Add phycore_am62x_r5_usbdfu_defconfig
configs: phycore_am62x_a53_defconfig: Fix CONFIG_ENV_SIZE
configs: phycore_am62x_*_defconfig: Set PHYTEC as Manufacturer

Wadim Egorov (1):
configs: phycore_am64x_a53_defconfig: Enable CONFIG_OF_BOARD_SETUP

 board/phytec/phycore_am62x/phycore_am62x.env |  8 +++++++
 board/phytec/phycore_am64x/phycore_am64x.env |  8 +++++++
 configs/phycore_am62x_a53_defconfig          |  8 +++----
 configs/phycore_am62x_r5_usbdfu_defconfig    |  3 +++
 configs/phycore_am64x_a53_defconfig          |  3 ++-
 include/env/phytec/k3_mmc.env                | 16 +++++++-------
 include/env/phytec/k3_net.env                | 22 ++++++++++++++++++++
 include/env/phytec/k3_spi.env                | 18 ++++++++++++++++
 8 files changed, 74 insertions(+), 12 deletions(-)
 create mode 100644 configs/phycore_am62x_r5_usbdfu_defconfig
 create mode 100644 include/env/phytec/k3_net.env
 create mode 100644 include/env/phytec/k3_spi.env
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/13 configs: phycore_am64x_a53_defconfig: Enable CONFIG_OF_BOARD_SETUP

From: Wadim Egorov <[email protected]>

Enable CONFIG_OF_BOARD_SETUP to fixup kernel device tree with mtd partitions.

---
 configs/phycore_am64x_a53_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/phycore_am64x_a53_defconfig +1 -0
index 1af72e8bb32..5651a25c5dd 100644
@@ -37,6 +37,7 @@ CONFIG_SPL_SPI=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_LOAD_FIT_ADDRESS=0x81000000
 CONFIG_BOOTSTD_FULL=y
+CONFIG_OF_BOARD_SETUP=y
 CONFIG_BOOTCOMMAND="run mmcboot; bootflow scan -lb"
 CONFIG_DEFAULT_FDT_FILE="oftree"
 CONFIG_BOARD_LATE_INIT=y
Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/13 include: env: phytec: k3_mmc: Rename variables

In reply to Daniel Schultz

Add a mmc prefix to 'loadimage' and 'loadfdt' because we need similar variables for other boot sources. This will prevent name clashes and allows to implement similar boot logic.

Also switch from loadaddr to kernel_addr_r.

---
 include/env/phytec/k3_mmc.env | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
include/env/phytec/k3_mmc.env +5 -5
index 3d3595ceb7e..2bce4f77d2d 100644
@@ -10,12 +10,12 @@
 
 mmcargs=setenv bootargs console=${console} earlycon=${earlycon}
 	root=/dev/mmcblk${mmcdev}p${mmcroot} rootwait rw
-loadimage=load mmc ${mmcdev}:${mmcpart} ${loadaddr} Image
-loadfdt=load mmc ${mmcdev}:${mmcpart} ${fdt_addr_r} ${fdtfile}
+mmcloadimage=load mmc ${mmcdev}:${mmcpart} ${kernel_addr_r} Image
+mmcloadfdt=load mmc ${mmcdev}:${mmcpart} ${fdt_addr_r} ${fdtfile}
 mmcboot=run mmcargs;
 	mmc dev ${mmcdev};
 	mmc rescan;
-	run loadimage;
-	run loadfdt;
+	run mmcloadimage;
+	run mmcloadfdt;
 	run mmc_apply_overlays;
-	booti ${loadaddr} - ${fdt_addr_r}
+	booti ${kernel_addr_r} - ${fdt_addr_r}
Signature · 1 line
2.25.1
#3 lore raw

PATCH 3/13 include: env: phytec: Add raucinit to k3_mmc environment

In reply to Daniel Schultz

Initialize the environment for booting an RAUC image when 'doraucboot' is set to 1.

---
 include/env/phytec/k3_mmc.env | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
include/env/phytec/k3_mmc.env +4 -2
index 2bce4f77d2d..ad8d3a8b764 100644
@@ -7,12 +7,14 @@
 /* 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} rootwait rw
+	root=/dev/mmcblk${mmcdev}p${mmcroot} ${raucargs} rootwait rw
 mmcloadimage=load mmc ${mmcdev}:${mmcpart} ${kernel_addr_r} Image
 mmcloadfdt=load mmc ${mmcdev}:${mmcpart} ${fdt_addr_r} ${fdtfile}
-mmcboot=run mmcargs;
+mmcboot=if test ${doraucboot} = 1; then run raucinit; fi;
+	run mmcargs;
 	mmc dev ${mmcdev};
 	mmc rescan;
 	run mmcloadimage;
Signature · 1 line
2.25.1
#4 lore raw

PATCH 4/13 include: net: phytec: Add K3 network boot logic

In reply to Daniel Schultz

This boot logic allows to boot a Kernel image, Device-Tree blob and overlays via tftp/dhcp (configurable with 'net_fetch_cmd'). Additionally, it loads a rootfs via NFS.

---
 include/env/phytec/k3_net.env | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 include/env/phytec/k3_net.env
include/env/phytec/k3_net.env new file +22 -0
new file mode 100644
index 00000000000..377e406688d
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2024 PHYTEC Messtechnik GmbH
+ * Author: Daniel Schultz <[email protected]>
+ */
+
+/* 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
+netloadimage=${net_fetch_cmd} ${kernel_addr_r} ${serverip}:/Image
+netloadfdt=${net_fetch_cmd} ${fdt_addr_r} ${serverip}:/${fdtfile}
+netboot=run netargs;
+	setenv autoload no;
+	dhcp;
+	run netloadimage;
+	run netloadfdt;
+	run net_apply_overlays;
+	run net_apply_extensions;
+	booti ${kernel_addr_r} - ${fdt_addr_r}
Signature · 1 line
2.25.1
#5 lore raw

PATCH 5/13 include: env: phytec: Add K3 boot logic for OSPI/QSPI flashes

In reply to Daniel Schultz

This boot logic allows to boot a Kernel image, Device-Tree blob and a initramfs from an external OSPI/QSPI NOR flash.

---
 include/env/phytec/k3_spi.env | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 include/env/phytec/k3_spi.env
include/env/phytec/k3_spi.env new file +18 -0
new file mode 100644
index 00000000000..97d3a157058
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2024 PHYTEC Messtechnik GmbH
+ * Author: Daniel Schultz <[email protected]>
+ */
+
+/* Logic for TI K3 based SoCs to boot from an OSPI/QSPI NOR flash. */
+
+spiargs=setenv bootargs console=${console} earlycon=${earlycon}
+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}
Signature · 1 line
2.25.1
#6 lore raw

PATCH 6/13 board: phytec: phycore_am62x: Add Network/SPI Boot

In reply to Daniel Schultz

Include the boot logic to boot via Network or from a OSPI/QSPI NOR flash. Moreover, set all required variables to both boot methods to the environment.

---
 board/phytec/phycore_am62x/phycore_am62x.env | 8 ++++++++
 1 file changed, 8 insertions(+)
board/phytec/phycore_am62x/phycore_am62x.env +8 -0
index 046bbd22f25..711ca3040c4 100644
@@ -1,5 +1,7 @@
 #include <env/ti/k3_dfu.env>
 #include <env/phytec/k3_mmc.env>
+#include <env/phytec/k3_net.env>
+#include <env/phytec/k3_spi.env>
 
 fdtaddr=0x88000000
 loadaddr=0x82000000
@@ -15,3 +17,9 @@ mmcroot=2
 mmcpart=1
 console=ttyS2,115200n8
 earlycon=ns16550a,mmio32,0x02800000
+
+get_cmd=tftp
+
+spi_fdt_addr=0x700000
+spi_image_addr=0x800000
+spi_ramdisk_addr=0x1e00000
Signature · 1 line
2.25.1
#7 lore raw

PATCH 7/13 board: phytec: phycore_am64x: Add Network/SPI Boot

In reply to Daniel Schultz

Include the boot logic to boot via Network or from a OSPI/QSPI NOR flash. Moreover, set all required variables to both boot methods to the environment.

Note: The phyBOARD-Electra AM64x is not able to load the U-Boot via Network. However, it's still possible to load the kernel.

---
 board/phytec/phycore_am64x/phycore_am64x.env | 8 ++++++++
 1 file changed, 8 insertions(+)
board/phytec/phycore_am64x/phycore_am64x.env +8 -0
index 18f0fa5b4c3..3032b518e0b 100644
@@ -1,4 +1,6 @@
 #include <env/phytec/k3_mmc.env>
+#include <env/phytec/k3_net.env>
+#include <env/phytec/k3_spi.env>
 
 fdtaddr=0x88000000
 loadaddr=0x82000000
@@ -14,3 +16,9 @@ mmcroot=2
 mmcpart=1
 console=ttyS2,115200n8
 earlycon=ns16550a,mmio32,0x02800000
+
+get_cmd=tftp
+
+spi_fdt_addr=0x700000
+spi_image_addr=0x800000
+spi_ramdisk_addr=0x1e00000
Signature · 1 line
2.25.1
#8 lore raw

PATCH 8/13 configs: phycore_am62x_a53_defconfig: Make BOOTCMD generic

In reply to Daniel Schultz

The phyCORE-AM62x board code sets an environment variable 'boot' with the device U-Boot booted from. Use this variable in CONFIG_BOOTCOMMAND to boot Linux from the same boot device by default.

---
 configs/phycore_am62x_a53_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configs/phycore_am62x_a53_defconfig +1 -1
index 39161b722b1..7bbd8011fa8 100644
@@ -40,7 +40,7 @@ CONFIG_SPL_LOAD_FIT_ADDRESS=0x81000000
 CONFIG_BOOTSTD_FULL=y
 CONFIG_SYS_BOOTM_LEN=0x800000
 CONFIG_OF_BOARD_SETUP=y
-CONFIG_BOOTCOMMAND="run mmcboot; bootflow scan -lb"
+CONFIG_BOOTCOMMAND="run ${boot}boot; bootflow scan -lb"
 CONFIG_DEFAULT_FDT_FILE="oftree"
 CONFIG_BOARD_LATE_INIT=y
 CONFIG_SPL_MAX_SIZE=0x58000
Signature · 1 line
2.25.1
#9 lore raw

PATCH 9/13 configs: phycore_am64x_a53_defconfig: Make BOOTCMD generic

In reply to Daniel Schultz

The phyCORE-AM64x board code sets an environment variable 'boot' with the device U-Boot booted from. Use this variable in CONFIG_BOOTCOMMAND to boot Linux from the same boot device by default.

---
 configs/phycore_am64x_a53_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configs/phycore_am64x_a53_defconfig +1 -1
index 5651a25c5dd..e1699ad4420 100644
@@ -38,7 +38,7 @@ CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_LOAD_FIT_ADDRESS=0x81000000
 CONFIG_BOOTSTD_FULL=y
 CONFIG_OF_BOARD_SETUP=y
-CONFIG_BOOTCOMMAND="run mmcboot; bootflow scan -lb"
+CONFIG_BOOTCOMMAND="run ${boot}boot; bootflow scan -lb"
 CONFIG_DEFAULT_FDT_FILE="oftree"
 CONFIG_BOARD_LATE_INIT=y
 CONFIG_SPL_MAX_SIZE=0x180000
Signature · 1 line
2.25.1
#10 lore raw

PATCH 10/13 configs: phycore_am62x_a53_defconfig: Merge am62x_a53_usbdfu.config

In reply to Daniel Schultz

Merge the am62x_a53_usbdfu.config into the phyCORE-AM62x A53 defconfig to properly support USB DFU boot.

This config was made with the following command:

    make ARCH=arm CROSS_COMPILE=aarch64-linux-gnu- \
        phycore_am62x_a53_defconfig am62x_a53_usbdfu.config

However, CONFIG_USB_GADGET_MANUFACTURER was not merged to keep Phytec as manufacturer.

---
 configs/phycore_am62x_a53_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configs/phycore_am62x_a53_defconfig +1 -1
index 7bbd8011fa8..07a1fff1f3d 100644
@@ -92,7 +92,7 @@ CONFIG_SPL_CLK=y
 CONFIG_CLK_TI_SCI=y
 CONFIG_DFU_MMC=y
 CONFIG_DFU_RAM=y
-CONFIG_SYS_DFU_DATA_BUF_SIZE=0x5000
+CONFIG_SYS_DFU_DATA_BUF_SIZE=0x40000
 CONFIG_SYS_DFU_MAX_FILE_SIZE=0x800000
 CONFIG_DMA_CHANNELS=y
 CONFIG_TI_K3_NAVSS_UDMA=y
Signature · 1 line
2.25.1
#11 lore raw

PATCH 11/13 configs: Add phycore_am62x_r5_usbdfu_defconfig

In reply to Daniel Schultz

This config includes the phycore_am62x_r5_defconfig file as well as the am62x_r5_usbdfu.config fragment. We need another defconfig because the AM62x has not enough internal SRAM to support all boot sources. The normal phycore_am62x_r5_defconfig should allow to boot from MMC and OSPI while this new defconfig allows to boot from USB.

---
 configs/phycore_am62x_r5_usbdfu_defconfig | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 configs/phycore_am62x_r5_usbdfu_defconfig
configs/phycore_am62x_r5_usbdfu_defconfig new file +2 -0
new file mode 100644
index 00000000000..237f5d344ce
@@ -0,0 +1,2 @@
+#include <configs/phycore_am62x_r5_defconfig>
+#include <configs/am62x_r5_usbdfu.config>
Signature · 1 line
2.25.1
#12 lore raw

PATCH 12/13 configs: phycore_am62x_a53_defconfig: Fix CONFIG_ENV_SIZE

In reply to Daniel Schultz

The environment should have a size of 0x20000 instead 0x2000. Update to have the same environment size for all PHYTEC K3 products.

---
 configs/phycore_am62x_a53_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configs/phycore_am62x_a53_defconfig +1 -1
index 07a1fff1f3d..246b8743da0 100644
@@ -12,7 +12,7 @@ CONFIG_TARGET_PHYCORE_AM62X_A53=y
 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x80b80000
 CONFIG_SF_DEFAULT_SPEED=25000000
-CONFIG_ENV_SIZE=0x2000
+CONFIG_ENV_SIZE=0x20000
 CONFIG_ENV_OFFSET=0x680000
 CONFIG_SPL_DM_SPI=y
 CONFIG_DEFAULT_DEVICE_TREE="ti/k3-am625-phyboard-lyra-rdk"
Signature · 1 line
2.25.1
#13 lore raw

PATCH 13/13 configs: phycore_am62x_*_defconfig: Set PHYTEC as Manufacturer

In reply to Daniel Schultz

Commit 371b379edbf3 ("configs: Make USB_GADGET_MANUFACTURER consistent over all PHYTEC boards") made the USB_GADGET_MANUFACTURER value consistent over all PHYTEC boards.

Update the phyCORE-AM62x defconfigs to make this config consistent as well.

---
 configs/phycore_am62x_a53_defconfig       | 2 +-
 configs/phycore_am62x_r5_usbdfu_defconfig | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
configs/phycore_am62x_a53_defconfig +1 -1
index 246b8743da0..5a1aa52c1ba 100644
@@ -151,7 +151,7 @@ CONFIG_SPL_USB_DWC3_AM62=y
 CONFIG_USB_DWC3_AM62=y
 CONFIG_USB_GADGET=y
 CONFIG_SPL_USB_GADGET=y
-CONFIG_USB_GADGET_MANUFACTURER="Phytec"
+CONFIG_USB_GADGET_MANUFACTURER="PHYTEC"
 CONFIG_USB_GADGET_VENDOR_NUM=0x0451
 CONFIG_USB_GADGET_PRODUCT_NUM=0x6165
 CONFIG_USB_GADGET_DOWNLOAD=y
configs/phycore_am62x_r5_usbdfu_defconfig +1 -0
index 237f5d344ce..1c05950dddf 100644
@@ -1,2 +1,3 @@
 #include <configs/phycore_am62x_r5_defconfig>
 #include <configs/am62x_r5_usbdfu.config>
+CONFIG_USB_GADGET_MANUFACTURER="PHYTEC"
Signature · 1 line
2.25.1
#14 lore raw
In reply to Daniel Schultz
Quoted 8 lines · Daniel Schultz

This patch stack extends the phyCORE-AM62x/AM64x U-Boot by following boot sources:

- Load U-Boot with USB DFU
- Load a Linux and initramfs from OSPI/QSPI NOR flash
- Load a Linux and rootfs from Network

[...]

Applied to u-boot/next, thanks!

Signature · 1 line
Tom