[PATCH 00/13] 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

From: Wadim Egorov w.egorov@phytec.de
Enable CONFIG_OF_BOARD_SETUP to fixup kernel device tree with mtd partitions.
Signed-off-by: Wadim Egorov w.egorov@phytec.de Signed-off-by: Daniel Schultz d.schultz@phytec.de --- configs/phycore_am64x_a53_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/phycore_am64x_a53_defconfig b/configs/phycore_am64x_a53_defconfig index 1af72e8bb32..5651a25c5dd 100644 --- a/configs/phycore_am64x_a53_defconfig +++ b/configs/phycore_am64x_a53_defconfig @@ -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

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.
Signed-off-by: Daniel Schultz d.schultz@phytec.de --- include/env/phytec/k3_mmc.env | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/env/phytec/k3_mmc.env b/include/env/phytec/k3_mmc.env index 3d3595ceb7e..2bce4f77d2d 100644 --- a/include/env/phytec/k3_mmc.env +++ b/include/env/phytec/k3_mmc.env @@ -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}

Initialize the environment for booting an RAUC image when 'doraucboot' is set to 1.
Signed-off-by: Daniel Schultz d.schultz@phytec.de --- include/env/phytec/k3_mmc.env | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/include/env/phytec/k3_mmc.env b/include/env/phytec/k3_mmc.env index 2bce4f77d2d..ad8d3a8b764 100644 --- a/include/env/phytec/k3_mmc.env +++ b/include/env/phytec/k3_mmc.env @@ -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;

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.
Signed-off-by: Daniel Schultz d.schultz@phytec.de --- include/env/phytec/k3_net.env | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 include/env/phytec/k3_net.env
diff --git a/include/env/phytec/k3_net.env b/include/env/phytec/k3_net.env new file mode 100644 index 00000000000..377e406688d --- /dev/null +++ b/include/env/phytec/k3_net.env @@ -0,0 +1,22 @@ +/* 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 +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}

This boot logic allows to boot a Kernel image, Device-Tree blob and a initramfs from an external OSPI/QSPI NOR flash.
Signed-off-by: Daniel Schultz d.schultz@phytec.de --- include/env/phytec/k3_spi.env | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 include/env/phytec/k3_spi.env
diff --git a/include/env/phytec/k3_spi.env b/include/env/phytec/k3_spi.env new file mode 100644 index 00000000000..97d3a157058 --- /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} +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}

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.
Signed-off-by: Daniel Schultz d.schultz@phytec.de --- board/phytec/phycore_am62x/phycore_am62x.env | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/board/phytec/phycore_am62x/phycore_am62x.env b/board/phytec/phycore_am62x/phycore_am62x.env index 046bbd22f25..711ca3040c4 100644 --- a/board/phytec/phycore_am62x/phycore_am62x.env +++ b/board/phytec/phycore_am62x/phycore_am62x.env @@ -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

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.
Signed-off-by: Daniel Schultz d.schultz@phytec.de --- board/phytec/phycore_am64x/phycore_am64x.env | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/board/phytec/phycore_am64x/phycore_am64x.env b/board/phytec/phycore_am64x/phycore_am64x.env index 18f0fa5b4c3..3032b518e0b 100644 --- a/board/phytec/phycore_am64x/phycore_am64x.env +++ b/board/phytec/phycore_am64x/phycore_am64x.env @@ -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

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.
Signed-off-by: Daniel Schultz d.schultz@phytec.de --- configs/phycore_am62x_a53_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configs/phycore_am62x_a53_defconfig b/configs/phycore_am62x_a53_defconfig index 39161b722b1..7bbd8011fa8 100644 --- a/configs/phycore_am62x_a53_defconfig +++ b/configs/phycore_am62x_a53_defconfig @@ -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

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.
Signed-off-by: Daniel Schultz d.schultz@phytec.de --- configs/phycore_am64x_a53_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configs/phycore_am64x_a53_defconfig b/configs/phycore_am64x_a53_defconfig index 5651a25c5dd..e1699ad4420 100644 --- a/configs/phycore_am64x_a53_defconfig +++ b/configs/phycore_am64x_a53_defconfig @@ -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

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.
Signed-off-by: Daniel Schultz d.schultz@phytec.de --- configs/phycore_am62x_a53_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configs/phycore_am62x_a53_defconfig b/configs/phycore_am62x_a53_defconfig index 7bbd8011fa8..07a1fff1f3d 100644 --- a/configs/phycore_am62x_a53_defconfig +++ b/configs/phycore_am62x_a53_defconfig @@ -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

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.
Signed-off-by: Daniel Schultz d.schultz@phytec.de --- configs/phycore_am62x_r5_usbdfu_defconfig | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 configs/phycore_am62x_r5_usbdfu_defconfig
diff --git a/configs/phycore_am62x_r5_usbdfu_defconfig b/configs/phycore_am62x_r5_usbdfu_defconfig new file mode 100644 index 00000000000..237f5d344ce --- /dev/null +++ b/configs/phycore_am62x_r5_usbdfu_defconfig @@ -0,0 +1,2 @@ +#include <configs/phycore_am62x_r5_defconfig> +#include <configs/am62x_r5_usbdfu.config>

The environment should have a size of 0x20000 instead 0x2000. Update to have the same environment size for all PHYTEC K3 products.
Signed-off-by: Daniel Schultz d.schultz@phytec.de --- configs/phycore_am62x_a53_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configs/phycore_am62x_a53_defconfig b/configs/phycore_am62x_a53_defconfig index 07a1fff1f3d..246b8743da0 100644 --- a/configs/phycore_am62x_a53_defconfig +++ b/configs/phycore_am62x_a53_defconfig @@ -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"

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.
Signed-off-by: Daniel Schultz d.schultz@phytec.de --- configs/phycore_am62x_a53_defconfig | 2 +- configs/phycore_am62x_r5_usbdfu_defconfig | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/configs/phycore_am62x_a53_defconfig b/configs/phycore_am62x_a53_defconfig index 246b8743da0..5a1aa52c1ba 100644 --- a/configs/phycore_am62x_a53_defconfig +++ b/configs/phycore_am62x_a53_defconfig @@ -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 diff --git a/configs/phycore_am62x_r5_usbdfu_defconfig b/configs/phycore_am62x_r5_usbdfu_defconfig index 237f5d344ce..1c05950dddf 100644 --- a/configs/phycore_am62x_r5_usbdfu_defconfig +++ b/configs/phycore_am62x_r5_usbdfu_defconfig @@ -1,2 +1,3 @@ #include <configs/phycore_am62x_r5_defconfig> #include <configs/am62x_r5_usbdfu.config> +CONFIG_USB_GADGET_MANUFACTURER="PHYTEC"

On Fri, 30 Aug 2024 02:09:27 -0700, Daniel Schultz wrote:
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!
participants (2)
-
Daniel Schultz
-
Tom Rini