]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
rockchip: odroid-go2: Use env from same storage FIT was loaded from
authorJonas Karlman <jonas@kwiboo.se>
Sun, 31 Aug 2025 16:49:30 +0000 (16:49 +0000)
committerTom Rini <trini@konsulko.com>
Sun, 2 Nov 2025 18:14:09 +0000 (12:14 -0600)
Change to dynamically select what storage media to use for the U-Boot
environment depending on from what storage media the FIT images was
loaded from, fall back to use env from nowhere.

  U-Boot SPL 2025.07 (Jul 13 2025 - 10:07:16 +0000)
  Trying to boot from MMC1
  ...
  Loading Environment from MMC... Reading from MMC(0)...

or

  U-Boot SPL 2025.07 (Jul 13 2025 - 10:07:16 +0000)
  Trying to boot from SPI
  ...
  Loading Environment from SPIFlash...

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Quentin Schulz <quentin.schulz@cherry.de>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
board/hardkernel/odroid_go2/Kconfig
board/hardkernel/odroid_go2/go2.c
configs/odroid-go2_defconfig

index dd6e366282e3fef867bced8db301ef3c50b2af98..6487335972b85b88a02fc57843cfc5f4d6eb9bbf 100644 (file)
@@ -13,6 +13,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        def_bool y
        select ADC
        select BOARD_TYPES
+       select ENV_IS_NOWHERE
        select SPL_ADC
 
 endif
index 9d9f3cee36a551660d4d5b3e75579b0441e65f83..ae32ea87af88afa9c58d8db95dd86622d0941c12 100644 (file)
@@ -7,7 +7,9 @@
 #include <adc.h>
 #include <asm/io.h>
 #include <dm.h>
+#include <dm/uclass-internal.h>
 #include <env.h>
+#include <env_internal.h>
 #include <stdlib.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -129,3 +131,35 @@ int board_fit_config_name_match(const char *name)
 
        return -EINVAL;
 }
+
+enum env_location env_get_location(enum env_operation op, int prio)
+{
+       const char *boot_device;
+       struct udevice *dev;
+       ofnode node;
+
+       if (prio)
+               return ENVL_UNKNOWN;
+
+       boot_device = ofnode_read_chosen_string("u-boot,spl-boot-device");
+       if (!boot_device) {
+               debug("%s: /chosen/u-boot,spl-boot-device not set\n", __func__);
+               return ENVL_NOWHERE;
+       }
+
+       debug("%s: booted from %s\n", __func__, boot_device);
+
+       node = ofnode_path(boot_device);
+       if (!ofnode_valid(node))
+               return ENVL_NOWHERE;
+
+       if (IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH) &&
+           !uclass_find_device_by_ofnode(UCLASS_SPI_FLASH, node, &dev))
+               return ENVL_SPI_FLASH;
+
+       if (IS_ENABLED(CONFIG_ENV_IS_IN_MMC) &&
+           !uclass_find_device_by_ofnode(UCLASS_MMC, node, &dev))
+               return ENVL_MMC;
+
+       return ENVL_NOWHERE;
+}
index 05d9f9c09dee4d5e7484e837cd54ee935c4aef71..185d0f1d7c5f5f30619fdcb972d8df5a238cce89 100644 (file)
@@ -65,6 +65,8 @@ CONFIG_OF_LIVE=y
 CONFIG_OF_LIST="rockchip/rk3326-odroid-go2 rockchip/rk3326-odroid-go2-v11 rockchip/rk3326-odroid-go3"
 CONFIG_OF_SPL_REMOVE_PROPS="interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents"
 CONFIG_ENV_IS_IN_MMC=y
+CONFIG_ENV_IS_IN_SPI_FLASH=y
+CONFIG_ENV_RELOC_GD_ENV_ADDR=y
 CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_REGMAP=y
 CONFIG_SPL_REGMAP=y