Skip to contentSkip to conversation

board: phytec: phycore_am62x: Update environment for fitboot

PATCH In review Wadim Egorov 2 participants 8 messages May 8, 2025 – May 22, 2025

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/7 board: phytec: phycore_am62x: Update environment for fitboot

From: Nathan Morrisson <[email protected]>

Add fit_addr_r to the environment to allow us to boot from a FIT image.

---
v1: https://lists.denx.de/pipermail/u-boot/2025-April/588142.html
v2: No changes

---
 board/phytec/phycore_am62x/phycore_am62x.env | 1 +
 1 file changed, 1 insertion(+)
board/phytec/phycore_am62x/phycore_am62x.env +1 -0
index 5c48e856685..40787b0cbcb 100644
@@ -10,6 +10,7 @@ fdt_addr_r=0x88000000
 kernel_addr_r=0x82000000
 ramdisk_addr_r=0x88080000
 fdtoverlay_addr_r=0x89000000
+fit_addr_r=0x90000000
 
 fdtfile=CONFIG_DEFAULT_FDT_FILE
 mmcdev=1
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 2/7 board: phytec: phycore_am64x: Update environment for fitboot

From: Nathan Morrisson <[email protected]>

Add fit_addr_r to the environment to allow us to boot from a FIT image.

---
v1: https://lists.denx.de/pipermail/u-boot/2025-April/588142.html
v2: No changes

---
 board/phytec/phycore_am64x/phycore_am64x.env | 1 +
 1 file changed, 1 insertion(+)
board/phytec/phycore_am64x/phycore_am64x.env +1 -0
index d69dfe75674..d04a3be6864 100644
@@ -9,6 +9,7 @@ fdt_addr_r=0x88000000
 kernel_addr_r=0x82000000
 ramdisk_addr_r=0x88080000
 fdtoverlay_addr_r=0x89000000
+fit_addr_r=0x90000000
 
 fdtfile=CONFIG_DEFAULT_FDT_FILE
 mmcdev=1
Signature · 1 line
2.34.1
#2 lore raw

PATCH v2 3/7 board: phytec: phycore_am6xx: Set bootmeths & boot_targets environment

In reply to Wadim Egorov

As part of our migration to the standard boot process, configure the default values for the bootmeths and boot_targets environment variables.

---
v1: https://lists.denx.de/pipermail/u-boot/2025-April/588142.html
v2:
- Rebased on current master, fixing conflicts after 48db49b0977c ("Merge patch series "include: env: phytec: k3_net: Remove net_apply_extensions"")

---
 board/phytec/phycore_am62ax/phycore_am62ax.env | 3 +++
 board/phytec/phycore_am62x/phycore_am62x.env   | 3 +++
 board/phytec/phycore_am64x/phycore_am64x.env   | 3 +++
 3 files changed, 9 insertions(+)
board/phytec/phycore_am62ax/phycore_am62ax.env +3 -0
index 40787b0cbcb..797904013dc 100644
@@ -24,3 +24,6 @@ get_cmd=tftp
 spi_fdt_addr=0x700000
 spi_image_addr=0x800000
 spi_ramdisk_addr=0x2200000
+
+bootmeths=script efi extlinux pxe
+boot_targets=mmc1 mmc0 spi_flash dhcp
board/phytec/phycore_am62x/phycore_am62x.env +3 -0
index 40787b0cbcb..797904013dc 100644
@@ -24,3 +24,6 @@ get_cmd=tftp
 spi_fdt_addr=0x700000
 spi_image_addr=0x800000
 spi_ramdisk_addr=0x2200000
+
+bootmeths=script efi extlinux pxe
+boot_targets=mmc1 mmc0 spi_flash dhcp
board/phytec/phycore_am64x/phycore_am64x.env +3 -0
index d04a3be6864..36ab16e2f7a 100644
@@ -23,3 +23,6 @@ get_cmd=tftp
 spi_fdt_addr=0x700000
 spi_image_addr=0x800000
 spi_ramdisk_addr=0x2200000
+
+bootmeths=script efi extlinux pxe
+boot_targets=mmc1 mmc0 spi_flash dhcp
Signature · 1 line
2.34.1
#3 lore raw

PATCH v2 4/7 configs: phycore_am6xx: Default BOOTCOMMAND to standard boot

In reply to Wadim Egorov

Make the "bootflow scan -lb" command execute first and fallback to the legacy BSP boot scripts.

---
v1: https://lists.denx.de/pipermail/u-boot/2025-April/588142.html
v2: No changes

---
 configs/phycore_am62ax_a53_defconfig | 2 +-
 configs/phycore_am62x_a53_defconfig  | 2 +-
 configs/phycore_am64x_a53_defconfig  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
configs/phycore_am62ax_a53_defconfig +1 -1
index 94176929f9a..64bf89b14c2 100644
@@ -41,7 +41,7 @@ CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_LOAD_FIT_ADDRESS=0x81000000
 CONFIG_BOOTSTD_FULL=y
 CONFIG_OF_BOARD_SETUP=y
-CONFIG_BOOTCOMMAND="run ${boot}boot; bootflow scan -lb"
+CONFIG_BOOTCOMMAND="bootflow scan -lb; run ${boot}boot"
 CONFIG_DEFAULT_FDT_FILE="oftree"
 CONFIG_BOARD_LATE_INIT=y
 CONFIG_SPL_MAX_SIZE=0x58000
configs/phycore_am62x_a53_defconfig +1 -1
index c52a2f76200..e60ac1f363f 100644
@@ -44,7 +44,7 @@ CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_LOAD_FIT_ADDRESS=0x81000000
 CONFIG_BOOTSTD_FULL=y
 CONFIG_OF_BOARD_SETUP=y
-CONFIG_BOOTCOMMAND="run ${boot}boot; bootflow scan -lb"
+CONFIG_BOOTCOMMAND="bootflow scan -lb; run ${boot}boot"
 CONFIG_DEFAULT_FDT_FILE="oftree"
 CONFIG_BOARD_LATE_INIT=y
 CONFIG_SPL_MAX_SIZE=0x58000
configs/phycore_am64x_a53_defconfig +1 -1
index d4842939096..7b3d21e8ee2 100644
@@ -40,7 +40,7 @@ CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_LOAD_FIT_ADDRESS=0x81000000
 CONFIG_BOOTSTD_FULL=y
 CONFIG_OF_BOARD_SETUP=y
-CONFIG_BOOTCOMMAND="run ${boot}boot; bootflow scan -lb"
+CONFIG_BOOTCOMMAND="bootflow scan -lb; run ${boot}boot"
 CONFIG_DEFAULT_FDT_FILE="oftree"
 CONFIG_BOARD_LATE_INIT=y
 CONFIG_SPL_MAX_SIZE=0x180000
Signature · 1 line
2.34.1
#4 lore raw

PATCH v2 5/7 board: phytec: common: k3: Update boot_targets at runtime

In reply to Wadim Egorov

Factor out boot device detection from board_late_init() into a new boot_targets_setup() helper.

Adjust the boot_targets environment variable to favor the device we just booted from. If boot_targets is still at its default value, prepend the current boot device to the list; otherwise leave any user-customized order untouched.

---
v1: https://lists.denx.de/pipermail/u-boot/2025-April/588142.html
v2:
- Move boot_targets_setup() inside IS_ENABLED(CONFIG_BOARD_LATE_INIT) block to fix compile warning on R5 case:
warning: ‘boot_targets_setup’ defined but not used

---
 board/phytec/common/k3/board.c | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)
board/phytec/common/k3/board.c +33 -1
index 828973a8e28..755b9ecd407 100644
@@ -121,24 +121,37 @@ enum env_location env_get_location(enum env_operation op, int prio)
 }
 
 #if IS_ENABLED(CONFIG_BOARD_LATE_INIT)
-int board_late_init(void)
+/**
+ * Ensure the boot order favors the device we just booted from.
+ * If boot_targets is still at its default value, move the current
+ * boot device to the front of the list. Otherwise, leave any customized
+ * order untouched.
+ */
+static void boot_targets_setup(void)
 {
 	u32 boot_device = get_boot_device();
+	const char *boot_targets = NULL;
+	char boot_targets_default[100];
+	int ret;
 
 	switch (boot_device) {
 	case BOOT_DEVICE_MMC1:
 		env_set_ulong("mmcdev", 0);
 		env_set("boot", "mmc");
+		boot_targets = "mmc0 mmc1 spi_flash dhcp";
 		break;
 	case BOOT_DEVICE_MMC2:
 		env_set_ulong("mmcdev", 1);
 		env_set("boot", "mmc");
+		boot_targets = "mmc1 mmc0 spi_flash dhcp";
 		break;
 	case BOOT_DEVICE_SPI:
 		env_set("boot", "spi");
+		boot_targets = "spi_flash mmc0 mmc1 dhcp";
 		break;
 	case BOOT_DEVICE_ETHERNET:
 		env_set("boot", "net");
+		boot_targets = "dhcp mmc0 mmc1 spi_flash";
 		break;
 	case BOOT_DEVICE_UART:
 		env_set("boot", "uart");
@@ -148,6 +161,25 @@ int board_late_init(void)
 		break;
 	};
 
+	if (!boot_targets)
+		return;
+
+	ret = env_get_default_into("boot_targets", boot_targets_default, sizeof(boot_targets_default));
+	if (ret < 0)
+		boot_targets_default[0] = '\0';
+
+	if (strcmp(boot_targets_default, env_get("boot_targets"))) {
+		debug("boot_targets not default, don't change it\n");
+		return;
+	}
+
+	env_set("boot_targets", boot_targets);
+}
+
+int board_late_init(void)
+{
+	boot_targets_setup();
+
 	if (IS_ENABLED(CONFIG_PHYTEC_SOM_DETECTION_BLOCKS)) {
 		struct phytec_api3_element *block_element;
 		struct phytec_eeprom_data data;
Signature · 1 line
2.34.1
#5 lore raw

PATCH v2 6/7 board: phytec: common: k3: Factor out mac address setup

In reply to Wadim Egorov

Factor out the mac address setup into setup_mac_from_eeprom().

---
v1: https://lists.denx.de/pipermail/u-boot/2025-April/588142.html
v2:
- Move setup_mac_from_eeprom() inside IS_ENABLED(CONFIG_BOARD_LATE_INIT)

---
 board/phytec/common/k3/board.c | 44 ++++++++++++++++++----------------
 1 file changed, 24 insertions(+), 20 deletions(-)
board/phytec/common/k3/board.c +24 -20
index 755b9ecd407..d9aec16b090 100644
@@ -176,30 +176,34 @@ static void boot_targets_setup(void)
 	env_set("boot_targets", boot_targets);
 }
 
-int board_late_init(void)
+static void setup_mac_from_eeprom(void)
 {
-	boot_targets_setup();
+	struct phytec_api3_element *block_element;
+	struct phytec_eeprom_data data;
+	int ret;
+
+	ret = phytec_eeprom_data_setup(&data, 0, EEPROM_ADDR);
+	if (ret || !data.valid)
+		return;
 
-	if (IS_ENABLED(CONFIG_PHYTEC_SOM_DETECTION_BLOCKS)) {
-		struct phytec_api3_element *block_element;
-		struct phytec_eeprom_data data;
-		int ret;
-
-		ret = phytec_eeprom_data_setup(&data, 0, EEPROM_ADDR);
-		if (ret || !data.valid)
-			return 0;
-
-		PHYTEC_API3_FOREACH_BLOCK(block_element, &data) {
-			switch (block_element->block_type) {
-			case PHYTEC_API3_BLOCK_MAC:
-				phytec_blocks_add_mac_to_env(block_element);
-				break;
-			default:
-				debug("%s: Unknown block type %i\n", __func__,
-				      block_element->block_type);
-			}
+	PHYTEC_API3_FOREACH_BLOCK(block_element, &data) {
+		switch (block_element->block_type) {
+		case PHYTEC_API3_BLOCK_MAC:
+			phytec_blocks_add_mac_to_env(block_element);
+			break;
+		default:
+			debug("%s: Unknown block type %i\n", __func__,
+			      block_element->block_type);
 		}
 	}
+}
+
+int board_late_init(void)
+{
+	boot_targets_setup();
+
+	if (IS_ENABLED(CONFIG_PHYTEC_SOM_DETECTION_BLOCKS))
+		setup_mac_from_eeprom();
 
 #if IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT)
 	configure_capsule_updates();
Signature · 1 line
2.34.1
#6 lore raw

PATCH v2 7/7 configs: phycore_am6xx_a53_defconfig: Enable BOOTDEV_SPI_FLASH

In reply to Wadim Egorov

Enable standard boot with SPI Flash & sync after savedefconfig.

---
 configs/phycore_am62ax_a53_defconfig | 2 +-
 configs/phycore_am62x_a53_defconfig  | 2 +-
 configs/phycore_am64x_a53_defconfig  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
configs/phycore_am62ax_a53_defconfig +1 -1
index 64bf89b14c2..11aaec67e2e 100644
@@ -73,7 +73,6 @@ CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_MTD=y
 # CONFIG_CMD_POWEROFF is not set
-CONFIG_CMD_REMOTEPROC=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_USB_MASS_STORAGE=y
 CONFIG_CMD_CACHE=y
@@ -130,6 +129,7 @@ CONFIG_MMC_SDHCI_AM654=y
 CONFIG_MTD=y
 CONFIG_DM_MTD=y
 CONFIG_DM_SPI_FLASH=y
+CONFIG_BOOTDEV_SPI_FLASH=y
 CONFIG_SPI_FLASH_SFDP_SUPPORT=y
 # CONFIG_SPI_FLASH_SMART_HWCAPS is not set
 CONFIG_SPI_FLASH_SOFT_RESET=y
configs/phycore_am62x_a53_defconfig +1 -1
index e60ac1f363f..5f91ca647fd 100644
@@ -77,7 +77,6 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_MTD=y
-CONFIG_CMD_REMOTEPROC=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_EFIDEBUG=y
@@ -126,6 +125,7 @@ CONFIG_MMC_SDHCI_AM654=y
 CONFIG_MTD=y
 CONFIG_DM_MTD=y
 CONFIG_DM_SPI_FLASH=y
+CONFIG_BOOTDEV_SPI_FLASH=y
 CONFIG_SPI_FLASH_SFDP_SUPPORT=y
 # CONFIG_SPI_FLASH_SMART_HWCAPS is not set
 CONFIG_SPI_FLASH_SOFT_RESET=y
configs/phycore_am64x_a53_defconfig +1 -1
index 7b3d21e8ee2..8b508d011e0 100644
@@ -76,7 +76,6 @@ CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_MTD=y
-CONFIG_CMD_REMOTEPROC=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_EFIDEBUG=y
@@ -132,6 +131,7 @@ CONFIG_MMC_SDHCI_AM654=y
 CONFIG_MTD=y
 CONFIG_DM_MTD=y
 CONFIG_DM_SPI_FLASH=y
+CONFIG_BOOTDEV_SPI_FLASH=y
 CONFIG_SPI_FLASH_SFDP_SUPPORT=y
 # CONFIG_SPI_FLASH_SMART_HWCAPS is not set
 CONFIG_SPI_FLASH_SOFT_RESET=y
Signature · 1 line
2.34.1
#7 lore raw
In reply to Wadim Egorov
Quoted 3 lines · Wadim Egorov

Add fit_addr_r to the environment to allow us to boot from a FIT image.

Applied to u-boot/next, thanks!

[1/7] board: phytec: phycore_am62x: Update environment for fitboot

      commit: fdd2af2c13848dbec1210a3361c667476c328263
[2/7] board: phytec: phycore_am64x: Update environment for fitboot
      commit: 04c1a5b0d6029dd21f17fe649f9f11dd05f9e5b4
[3/7] board: phytec: phycore_am6xx: Set bootmeths & boot_targets environment
      commit: e423e35d0d0ee2871f87f5f00ecf80997feba7df
[4/7] configs: phycore_am6xx: Default BOOTCOMMAND to standard boot
      commit: 7fbadff8a7d62118896fe19881a9c744b9aa3a77
[5/7] board: phytec: common: k3: Update boot_targets at runtime
      commit: 5900a2db4b7688586dc4605f4bdccba16a2b103d
[6/7] board: phytec: common: k3: Factor out mac address setup
      commit: cd48860fec92b4373e2cf6c942df7b6290fb9acd
[7/7] configs: phycore_am6xx_a53_defconfig: Enable BOOTDEV_SPI_FLASH
      commit: 1385e4be42d913dea97fc4939c745a29f274766e
Signature · 1 line
Tom