From: Patrick Delaunay <patrick.delau...@foss.st.com>

For nor0 boot for the STMicroelectronics boards, the bootfs
is found in SD-Card = mmc0 for nor0 boot.

Introduce a new file configuration file stm32mp25_st_common.h
to manage this specific behavior for the STMicroelectronics
boards; change the boot order for nor0 boot and don't use
the default DISTRO order define in BOOT_TARGET_DEVICES:
mmc1, ubifs, mmc0, mmc2.

Signed-off-by: Patrick Delaunay <patrick.delau...@foss.st.com>
Signed-off-by: Patrice CHOTARD <patrice.chot...@foss.st.com>
Signed-off-by: Patrice Chotard <patrice.chot...@foss.st.com>
---

 board/st/stm32mp2/Kconfig             |  2 +-
 board/st/stm32mp2/MAINTAINERS         |  1 +
 include/configs/stm32mp25_st_common.h | 51 +++++++++++++++++++++++++++
 3 files changed, 53 insertions(+), 1 deletion(-)
 create mode 100644 include/configs/stm32mp25_st_common.h

diff --git a/board/st/stm32mp2/Kconfig b/board/st/stm32mp2/Kconfig
index 89039f068a2..f91e25f1f9a 100644
--- a/board/st/stm32mp2/Kconfig
+++ b/board/st/stm32mp2/Kconfig
@@ -7,7 +7,7 @@ config SYS_VENDOR
        default "st"
 
 config SYS_CONFIG_NAME
-       default "stm32mp25_common"
+       default "stm32mp25_st_common"
 
 source "board/st/common/Kconfig"
 endif
diff --git a/board/st/stm32mp2/MAINTAINERS b/board/st/stm32mp2/MAINTAINERS
index e6bea910f92..8f624811f99 100644
--- a/board/st/stm32mp2/MAINTAINERS
+++ b/board/st/stm32mp2/MAINTAINERS
@@ -7,3 +7,4 @@ F:      arch/arm/dts/stm32mp25*
 F:     board/st/stm32mp2/
 F:     configs/stm32mp25_defconfig
 F:     include/configs/stm32mp25_common.h
+F:     include/configs/stm32mp25_st_common.h
diff --git a/include/configs/stm32mp25_st_common.h 
b/include/configs/stm32mp25_st_common.h
new file mode 100644
index 00000000000..ab5a4a91644
--- /dev/null
+++ b/include/configs/stm32mp25_st_common.h
@@ -0,0 +1,51 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later OR BSD-3-Clause */
+/*
+ * Copyright (C) 2022, STMicroelectronics - All Rights Reserved
+ *
+ * Configuration settings for the STMicroelectonics STM32MP25x boards
+ */
+
+#ifndef __CONFIG_STM32MP25_ST_COMMON_H__
+#define __CONFIG_STM32MP25_ST_COMMON_H__
+
+#define STM32MP_BOARD_EXTRA_ENV \
+       "usb_pgood_delay=2000\0" \
+       "console=ttySTM0\0"
+
+#include <configs/stm32mp25_common.h>
+
+#ifdef CFG_EXTRA_ENV_SETTINGS
+/*
+ * default bootcmd for stm32mp25 STMicroelectronics boards:
+ * for serial/usb: execute the stm32prog command
+ * for mmc boot (eMMC, SD card), distro boot on the same mmc device
+ * for nand or spi-nand boot, distro boot with ubifs on UBI partition or
+ * sdcard
+ * for nor boot, distro boot on SD card = mmc0 ONLY !
+ */
+#define ST_STM32MP25_BOOTCMD "bootcmd_stm32mp=" \
+       "echo \"Boot over ${boot_device}${boot_instance}!\";" \
+       "if test ${boot_device} = serial || test ${boot_device} = usb;" \
+       "then stm32prog ${boot_device} ${boot_instance}; " \
+       "else " \
+               "run env_check;" \
+               "if test ${boot_device} = mmc;" \
+               "then env set boot_targets \"mmc${boot_instance}\"; fi;" \
+               "if test ${boot_device} = nand ||" \
+                 " test ${boot_device} = spi-nand ;" \
+               "then env set boot_targets ubifs0 mmc0; fi;" \
+               "if test ${boot_device} = nor;" \
+               "then env set boot_targets mmc0; fi;" \
+               "run distro_bootcmd;" \
+       "fi;\0"
+
+#undef CFG_EXTRA_ENV_SETTINGS
+#define CFG_EXTRA_ENV_SETTINGS \
+       STM32MP_MEM_LAYOUT \
+       ST_STM32MP25_BOOTCMD \
+       BOOTENV \
+       STM32MP_EXTRA \
+       STM32MP_BOARD_EXTRA_ENV
+
+#endif
+#endif
-- 
2.25.1

Reply via email to