From b90921faa3ba5ef8608667c3afb61fdbd21a2fe4 Mon Sep 17 00:00:00 2001
From: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
Date: Mon, 27 Apr 2026 15:20:15 +0300
Subject: [PATCH 25/29] configs: airoha: disable ENV_IS_IN_MTD to avoid boot panic

Booting image generated with

  make an7581_evb_defconfig

will results in

  U-Boot 2026.04-00924-gfb815bd8793b (Apr 27 2026 - 15:08:30 +0300)

  CPU:   Airoha AN7581
  DRAM:  512 MiB
  Core:  35 devices, 19 uclasses, devicetree: separate
  MMC:   mmc@1fa0e000: 0
  Loading Environment from MMC... *** Warning - No block device, using default environment

  Loading Environment from MTD... *** Warning - get_mtd_device_nm() failed, using default environment

  BUG at drivers/mtd/mtdcore.c:898/__put_mtd_device()!
  BUG!
  resetting ...

This happens because no any mtd partition defined in dts/mtdparts.
Disabling of ENV_IS_IN_MTD fixes an issue.

Fix the same for en7523 & an7583 as well.

Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
---
 configs/an7583_evb_defconfig | 1 +
 configs/en7523_evb_defconfig | 3 +--
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/configs/an7583_evb_defconfig b/configs/an7583_evb_defconfig
index e1d3c3b428a..ca0422abcdb 100644
--- a/configs/an7583_evb_defconfig
+++ b/configs/an7583_evb_defconfig
@@ -42,6 +42,7 @@ CONFIG_CMD_LOG=y
 CONFIG_CMD_UBI=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_ENV_IS_IN_MMC=y
+# CONFIG_ENV_IS_IN_MTD is not set
 CONFIG_ENV_IS_IN_UBI=y
 CONFIG_ENV_REDUNDANT=y
 CONFIG_ENV_UBI_PART="ubi"
diff --git a/configs/en7523_evb_defconfig b/configs/en7523_evb_defconfig
index dd809c5f949..c539ba71994 100644
--- a/configs/en7523_evb_defconfig
+++ b/configs/en7523_evb_defconfig
@@ -5,7 +5,6 @@ CONFIG_TEXT_BASE=0x81E00000
 CONFIG_SYS_MALLOC_F_LEN=0x4000
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_ENV_SIZE=0x4000
-CONFIG_ENV_OFFSET=0x7c000
 CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="airoha/en7523-evb"
 CONFIG_SYS_LOAD_ADDR=0x81800000
@@ -38,13 +37,13 @@ CONFIG_CMD_LOG=y
 CONFIG_CMD_UBI=y
 CONFIG_OF_UPSTREAM=y
 CONFIG_ENV_OVERWRITE=y
+# CONFIG_ENV_IS_IN_MTD is not set
 CONFIG_ENV_IS_IN_UBI=y
 CONFIG_ENV_REDUNDANT=y
 CONFIG_ENV_UBI_PART="ubi"
 CONFIG_ENV_UBI_VOLUME="ubootenv"
 CONFIG_ENV_UBI_VOLUME_REDUND="ubootenv2"
 CONFIG_ENV_RELOC_GD_ENV_ADDR=y
-CONFIG_ENV_MTD_DEV="spi-nand0"
 CONFIG_ENV_USE_DEFAULT_ENV_TEXT_FILE=y
 CONFIG_ENV_DEFAULT_ENV_TEXT_FILE="defenvs/en7523_rfb_env"
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
-- 
2.53.0

