From d0bc2ac2bda96b4bdc0827b364f84e1046ee0f00 Mon Sep 17 00:00:00 2001 From: Wadim Egorov Date: Fri, 30 Aug 2024 02:09:28 -0700 Subject: [PATCH 01/13] configs: phycore_am64x_a53_defconfig: Enable CONFIG_OF_BOARD_SETUP Enable CONFIG_OF_BOARD_SETUP to fixup kernel device tree with mtd partitions. Signed-off-by: Wadim Egorov Signed-off-by: Daniel Schultz --- 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 From 80c4f6f9f28109bcaed850b76a2036c57e0e6225 Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Fri, 30 Aug 2024 02:09:29 -0700 Subject: [PATCH 02/13] include: env: phytec: k3_mmc: Rename variables 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 --- 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} From 8cafb21215c15b41361b4c7356cc5bcdc34aa26b Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Fri, 30 Aug 2024 02:09:30 -0700 Subject: [PATCH 03/13] include: env: phytec: Add raucinit to k3_mmc environment Initialize the environment for booting an RAUC image when 'doraucboot' is set to 1. Signed-off-by: Daniel Schultz --- 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 +#include 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; From d87842cd3dec760cc54a0cdcb38b7c2e4f2f62a7 Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Fri, 30 Aug 2024 02:09:31 -0700 Subject: [PATCH 04/13] include: net: phytec: Add K3 network boot logic 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 --- 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 + */ + +/* Logic for TI K3 based SoCs to boot via network. */ + +#include + +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} From 92ff68b298c62718a16dba22504ec7b60a0de06d Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Fri, 30 Aug 2024 02:09:32 -0700 Subject: [PATCH 05/13] include: env: phytec: Add K3 boot logic for OSPI/QSPI flashes 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 --- 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 + */ + +/* 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} From a48cbaeecbfa9ed8e3cd0ec5e1249786d8e4ed5f Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Fri, 30 Aug 2024 02:09:33 -0700 Subject: [PATCH 06/13] board: phytec: phycore_am62x: Add Network/SPI Boot 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 --- 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 #include +#include +#include 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 From 11b8fa00953b678fe68de0297c58de5d048159bc Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Fri, 30 Aug 2024 02:09:34 -0700 Subject: [PATCH 07/13] board: phytec: phycore_am64x: Add Network/SPI Boot 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 --- 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 +#include +#include 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 From 9624465384cfca23d78015f3b423e476f49e02f2 Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Fri, 30 Aug 2024 02:09:35 -0700 Subject: [PATCH 08/13] configs: phycore_am62x_a53_defconfig: Make BOOTCMD generic 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 --- 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 From 8b4a72f513070e518a7747d3caffc4b410a5eb75 Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Fri, 30 Aug 2024 02:09:36 -0700 Subject: [PATCH 09/13] configs: phycore_am64x_a53_defconfig: Make BOOTCMD generic 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 --- 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 From 529ddb60532aefb9b49fd2b5edc03e78777dbd03 Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Fri, 30 Aug 2024 02:09:37 -0700 Subject: [PATCH 10/13] configs: phycore_am62x_a53_defconfig: Merge am62x_a53_usbdfu.config 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 --- 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 From 4d197fab9b82ad50383f50b0316137590b80f040 Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Fri, 30 Aug 2024 02:09:38 -0700 Subject: [PATCH 11/13] configs: Add phycore_am62x_r5_usbdfu_defconfig 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 --- 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 +#include From 1bd194f1ffc3df7e3bf3e937c666305a8b0acad4 Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Fri, 30 Aug 2024 02:09:39 -0700 Subject: [PATCH 12/13] configs: phycore_am62x_a53_defconfig: Fix CONFIG_ENV_SIZE 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 --- 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" From ef7a3f16a27b3d98ce5a4146a21ab58c8f1b2280 Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Fri, 30 Aug 2024 02:09:40 -0700 Subject: [PATCH 13/13] configs: phycore_am62x_*_defconfig: Set PHYTEC as Manufacturer 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 --- 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 #include +CONFIG_USB_GADGET_MANUFACTURER="PHYTEC"