Skip to contentSkip to conversation

board: phytec: phycore_am62x: Update environment for fitboot

PATCH Superseded Wadim Egorov 2 participants 8 messages Apr 28, 2025 – May 7, 2025

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 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.

---
 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 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.

---
 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 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.

---
 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 a0eacd1dfc3..df452804f98 100644
@@ -23,3 +23,6 @@ get_cmd=tftp
 spi_fdt_addr=0x700000
 spi_image_addr=0x800000
 spi_ramdisk_addr=0x1e00000
+
+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 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.

---
 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 d86e19d914f..c9d3c9f4bb8 100644
@@ -42,7 +42,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 3622e1a7cf2..22060e2634b 100644
@@ -46,7 +46,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 72936865132..40e92525ef2 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=0x180000
Signature · 1 line
2.34.1
#4 lore raw

PATCH 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.

---
 board/phytec/common/k3/board.c | 36 ++++++++++++++++++++++++++++++++--
 1 file changed, 34 insertions(+), 2 deletions(-)
board/phytec/common/k3/board.c +34 -2
index 828973a8e28..bddc818743a 100644
@@ -120,25 +120,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 +160,26 @@ 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);
+}
+
+#if IS_ENABLED(CONFIG_BOARD_LATE_INIT)
+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 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().

---
 board/phytec/common/k3/board.c | 44 ++++++++++++++++++----------------
 1 file changed, 24 insertions(+), 20 deletions(-)
board/phytec/common/k3/board.c +24 -20
index bddc818743a..26d87f58096 100644
@@ -175,31 +175,35 @@ static void boot_targets_setup(void)
 	env_set("boot_targets", boot_targets);
 }
 
+void setup_mac_from_eeprom(void)
+{
+	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;
+
+	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);
+		}
+	}
+}
+
 #if IS_ENABLED(CONFIG_BOARD_LATE_INIT)
 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;
-		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);
-			}
-		}
-	}
+	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 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 c9d3c9f4bb8..a1da27cf8ac 100644
@@ -74,7 +74,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
@@ -131,6 +130,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 22060e2634b..67c8bffd767 100644
@@ -79,7 +79,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
@@ -128,6 +127,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 40e92525ef2..c9f073f721c 100644
@@ -77,7 +77,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
@@ -133,6 +132,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