[PATCH v4 04/14] smegw01: Add altbootcmd

2023-04-26 Thread Fabio Estevam
From: Eduard Strehlau 

Add an altbootcmd script, which is convenient way to integrate with
swupdate and perform a roll back of the previous working version in the
case of update failure.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
Changes since v3:
- None

 configs/smegw01_defconfig | 2 +-
 include/configs/smegw01.h | 8 
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/configs/smegw01_defconfig b/configs/smegw01_defconfig
index 5d9d4194639d..418151a6de05 100644
--- a/configs/smegw01_defconfig
+++ b/configs/smegw01_defconfig
@@ -18,7 +18,7 @@ CONFIG_SYS_MEMTEST_END=0xa000
 CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_USE_BOOTCOMMAND=y
-CONFIG_BOOTCOMMAND="if run loadimage; then run mmcboot; fi; "
+CONFIG_BOOTCOMMAND="if test \"${ustate}\" = 1; then setenv upgrade_available 
1; saveenv; fi; if run loadimage; then run mmcboot; fi; "
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_MAXARGS=32
 CONFIG_SYS_PBSIZE=532
diff --git a/include/configs/smegw01.h b/include/configs/smegw01.h
index a356f095a68c..6ee4acc70d29 100644
--- a/include/configs/smegw01.h
+++ b/include/configs/smegw01.h
@@ -33,6 +33,7 @@
"mmcargs=setenv bootargs console=${console},${baudrate} " \
"root=/dev/mmcblk0p${mmcpart} rootwait rw " \
__stringify(EXTRA_BOOTPARAMS) "\0" \
+   "bootlimit=3\0" \
"loadimage=load mmc ${mmcdev}:${mmcpart} ${loadaddr} boot/${image}\0" \
"loadfdt=load mmc ${mmcdev}:${mmcpart} ${fdt_addr} boot/${fdtfile}\0" \
"mmcboot=echo Booting from mmc ...; " \
@@ -40,6 +41,13 @@
"if run loadfdt; then " \
"bootz ${loadaddr} - ${fdt_addr}; " \
"fi;\0" \
+   "altbootcmd=echo Performing rollback...; " \
+   "if test \"${mmcpart}\" = 1; then " \
+   "setenv mmcpart 2; " \
+   "else " \
+   "setenv mmcpart 1; " \
+   "fi; setenv bootcount 0; setenv upgrade_available; setenv 
ustate 3; saveenv; " \
+   "run bootcmd;\0"
 
 /* Physical Memory Map */
 #define PHYS_SDRAM MMDC0_ARB_BASE_ADDR
-- 
2.34.1



[PATCH v4 03/14] smegw01: Select bootcount support

2023-04-26 Thread Fabio Estevam
From: Eduard Strehlau 

Add automatic boot counter that increases after every
reset. After a power-on reset, it will be initialized with 1,
and each reboot will increment the value by 1. By default it is
disabled if bootlimit isn't set.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
Changes since v3:
- None

 configs/smegw01_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configs/smegw01_defconfig b/configs/smegw01_defconfig
index f15291f1dd04..5d9d4194639d 100644
--- a/configs/smegw01_defconfig
+++ b/configs/smegw01_defconfig
@@ -46,6 +46,8 @@ CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_BOUNCE_BUFFER=y
+CONFIG_BOOTCOUNT_LIMIT=y
+CONFIG_BOOTCOUNT_ENV=y
 CONFIG_DFU_MMC=y
 CONFIG_DM_I2C=y
 CONFIG_SUPPORT_EMMC_BOOT=y
-- 
2.34.1



[PATCH v4 02/14] smegw01: Select CONFIG_CMD_SQUASHFS

2023-04-26 Thread Fabio Estevam
From: Eduard Strehlau 

Select CONFIG_CMD_SQUASHFS so that the SquashFS U-Boot commands
are available.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
Changes since v3:
- None

 configs/smegw01_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/smegw01_defconfig b/configs/smegw01_defconfig
index 1e0b9aa5be11..f15291f1dd04 100644
--- a/configs/smegw01_defconfig
+++ b/configs/smegw01_defconfig
@@ -38,6 +38,7 @@ CONFIG_CMD_EXT2=y
 CONFIG_CMD_EXT4=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_CMD_FAT=y
+CONFIG_CMD_SQUASHFS=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_OF_CONTROL=y
 CONFIG_ENV_OVERWRITE=y
-- 
2.34.1



[PATCH v4 01/14] smegw01: Enable setting additional boot params

2023-04-26 Thread Fabio Estevam
From: Eduard Strehlau 

Introduce EXTRA_BOOTPARAMS to allow passing additional parameters
to kernel command line. This is useful for debugging purposes.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
Changes since v3:
- None

 include/configs/smegw01.h | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/include/configs/smegw01.h b/include/configs/smegw01.h
index 11031744bef8..a356f095a68c 100644
--- a/include/configs/smegw01.h
+++ b/include/configs/smegw01.h
@@ -17,6 +17,11 @@
 /* MMC Config*/
 #define CFG_SYS_FSL_ESDHC_ADDR 0
 
+/* default to no extra bootparams, we need an empty define for 
stringification*/
+#ifndef EXTRA_BOOTPARAMS
+#define EXTRA_BOOTPARAMS
+#endif
+
 #define CFG_EXTRA_ENV_SETTINGS \
"image=zImage\0" \
"console=ttymxc0\0" \
@@ -26,7 +31,8 @@
"mmcdev=0\0" \
"mmcpart=1\0" \
"mmcargs=setenv bootargs console=${console},${baudrate} " \
-   "root=/dev/mmcblk0p${mmcpart} rootwait rw\0" \
+   "root=/dev/mmcblk0p${mmcpart} rootwait rw " \
+   __stringify(EXTRA_BOOTPARAMS) "\0" \
"loadimage=load mmc ${mmcdev}:${mmcpart} ${loadaddr} boot/${image}\0" \
"loadfdt=load mmc ${mmcdev}:${mmcpart} ${fdt_addr} boot/${fdtfile}\0" \
"mmcboot=echo Booting from mmc ...; " \
-- 
2.34.1



[PATCH v3 13/13] smegw01: Fix fallback to altbootcmd

2023-04-24 Thread Fabio Estevam
From: Eduard Strehlau 

The bootcmd/altbootcmd mechanism is not invoked for bootmenus.
Manually compare bootcount and bootlimit to implement fallback on all
codepaths.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
Changes since v2:
- None

 configs/smegw01_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configs/smegw01_defconfig b/configs/smegw01_defconfig
index fe8152f33e..3d2713f528 100644
--- a/configs/smegw01_defconfig
+++ b/configs/smegw01_defconfig
@@ -23,7 +23,7 @@ CONFIG_AUTOBOOT_MENU_SHOW=y
 # CONFIG_CMD_BOOTEFI_BOOTMGR is not set
 CONFIG_BOOTMENU_DISABLE_UBOOT_CONSOLE=y
 CONFIG_USE_BOOTCOMMAND=y
-CONFIG_BOOTCOMMAND="if test \"${ustate}\" = 1; then setenv upgrade_available 
1; saveenv; fi; run mmcboot; "
+CONFIG_BOOTCOMMAND="if test \"${bootcount}\" -gt \"${bootlimit}\"; then run 
altbootcmd; else if test \"${ustate}\" = 1; then setenv upgrade_available 1; 
saveenv; fi; run mmcboot; fi;"
 CONFIG_USE_PREBOOT=y
 CONFIG_PREBOOT="run setup_boot_menu;"
 CONFIG_HUSH_PARSER=y
-- 
2.38.1



[PATCH v3 11/13] smegw01: Read the second MAC address

2023-04-24 Thread Fabio Estevam
From: Fabio Estevam 

Currently, only the first MAC address is read from the fuses.

The second MAC address is not read and Linux assigns a random one.

To prevent this behavior, read the second MAC address from the fuses
and store it into the eth1addr environment variable so that it
can be passed to Linux.

Signed-off-by: Fabio Estevam 
---
Changes since v2:
- Fixed typo in the Subject "smegw01".

 board/storopack/smegw01/smegw01.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/board/storopack/smegw01/smegw01.c 
b/board/storopack/smegw01/smegw01.c
index e786429476..605253ead3 100644
--- a/board/storopack/smegw01/smegw01.c
+++ b/board/storopack/smegw01/smegw01.c
@@ -82,6 +82,7 @@ int board_init(void)
 int board_late_init(void)
 {
struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR;
+   unsigned char eth1addr[6];
 
imx_iomux_v3_setup_multiple_pads(wdog_pads, ARRAY_SIZE(wdog_pads));
 
@@ -93,6 +94,11 @@ int board_late_init(void)
 */
clrsetbits_le16(>wcr, 0, 0x10);
 
+   /* Get the second MAC address */
+   imx_get_mac_from_fuse(1, eth1addr);
+   if (!env_get("eth1addr") && is_valid_ethaddr(eth1addr))
+   eth_env_set_enetaddr("eth1addr", eth1addr);
+
return 0;
 }
 
-- 
2.38.1



[PATCH v3 12/13] smegw01: Disable additional boot menu options

2023-04-24 Thread Fabio Estevam
From: Eduard Strehlau 

Defaults have changed, we do not want the bootmenu to contain EFI
options.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
Changes since v2:
- None

 configs/smegw01_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configs/smegw01_defconfig b/configs/smegw01_defconfig
index ea25b3b87c..fe8152f33e 100644
--- a/configs/smegw01_defconfig
+++ b/configs/smegw01_defconfig
@@ -19,6 +19,8 @@ CONFIG_SYS_MEMTEST_END=0xa000
 CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_AUTOBOOT_MENU_SHOW=y
+# CONFIG_BOOTSTD is not set
+# CONFIG_CMD_BOOTEFI_BOOTMGR is not set
 CONFIG_BOOTMENU_DISABLE_UBOOT_CONSOLE=y
 CONFIG_USE_BOOTCOMMAND=y
 CONFIG_BOOTCOMMAND="if test \"${ustate}\" = 1; then setenv upgrade_available 
1; saveenv; fi; run mmcboot; "
-- 
2.38.1



[PATCH v3 10/13] smegw01: Add lockdown U-Boot env support

2023-04-24 Thread Fabio Estevam
From: Eduard Strehlau 

Add lockdown U-Boot env support so that only certain U-Boot environment
variables are allowed to be modified.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
Changes since v2:
- None

 board/storopack/smegw01/Kconfig   |  7 +
 board/storopack/smegw01/smegw01.c | 17 +++
 configs/smegw01_defconfig | 11 ++-
 include/configs/smegw01.h | 48 +--
 4 files changed, 79 insertions(+), 4 deletions(-)

diff --git a/board/storopack/smegw01/Kconfig b/board/storopack/smegw01/Kconfig
index d8f24695d0..390214c285 100644
--- a/board/storopack/smegw01/Kconfig
+++ b/board/storopack/smegw01/Kconfig
@@ -12,4 +12,11 @@ config SYS_CONFIG_NAME
 config IMX_CONFIG
default "board/storopack/smegw01/imximage.cfg"
 
+config SYS_BOOT_LOCKED
+   bool "Lock boot process to EMMC"
+   default y
+   help
+ Say N here if you want to boot from eMMC and SD.
+ Say Y to boot from eMMC.
+
 endif
diff --git a/board/storopack/smegw01/smegw01.c 
b/board/storopack/smegw01/smegw01.c
index 9482f88773..e786429476 100644
--- a/board/storopack/smegw01/smegw01.c
+++ b/board/storopack/smegw01/smegw01.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -113,3 +114,19 @@ uint mmc_get_env_part(struct mmc *mmc)
 
return part;
 }
+
+enum env_location env_get_location(enum env_operation op, int prio)
+{
+   if (op == ENVOP_SAVE || op == ENVOP_ERASE)
+   return ENVL_MMC;
+
+   switch (prio) {
+   case 0:
+   return ENVL_NOWHERE;
+
+   case 1:
+   return ENVL_MMC;
+   }
+
+   return ENVL_UNKNOWN;
+}
diff --git a/configs/smegw01_defconfig b/configs/smegw01_defconfig
index 54cf1cfc1f..ea25b3b87c 100644
--- a/configs/smegw01_defconfig
+++ b/configs/smegw01_defconfig
@@ -7,6 +7,7 @@ CONFIG_ENV_OFFSET=0x10
 CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="imx7d-smegw01"
 CONFIG_TARGET_SMEGW01=y
+# CONFIG_SYS_BOOT_LOCKED is not set
 CONFIG_ENV_OFFSET_REDUND=0x11
 CONFIG_ARMV7_BOOT_SEC_DEFAULT=y
 # CONFIG_ARMV7_VIRT is not set
@@ -17,13 +18,18 @@ CONFIG_SYS_MEMTEST_START=0x8000
 CONFIG_SYS_MEMTEST_END=0xa000
 CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
+CONFIG_AUTOBOOT_MENU_SHOW=y
+CONFIG_BOOTMENU_DISABLE_UBOOT_CONSOLE=y
 CONFIG_USE_BOOTCOMMAND=y
-CONFIG_BOOTCOMMAND="if test \"${ustate}\" = 1; then setenv upgrade_available 
1; saveenv; fi; if run loadimage; then run mmcboot; else run altbootcmd; fi; "
+CONFIG_BOOTCOMMAND="if test \"${ustate}\" = 1; then setenv upgrade_available 
1; saveenv; fi; run mmcboot; "
+CONFIG_USE_PREBOOT=y
+CONFIG_PREBOOT="run setup_boot_menu;"
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_MAXARGS=32
 CONFIG_SYS_PBSIZE=532
 # CONFIG_CMD_BOOTD is not set
 CONFIG_CMD_BOOTZ=y
+CONFIG_CMD_BOOTMENU=y
 # CONFIG_CMD_IMI is not set
 # CONFIG_CMD_XIMG is not set
 CONFIG_CMD_MEMTEST=y
@@ -43,9 +49,12 @@ CONFIG_CMD_SQUASHFS=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_OF_CONTROL=y
 CONFIG_ENV_OVERWRITE=y
+CONFIG_ENV_IS_NOWHERE=y
 CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_SYS_MMC_ENV_DEV=1
+CONFIG_ENV_WRITEABLE_LIST=y
+CONFIG_ENV_ACCESS_IGNORE_FORCE=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_BOUNCE_BUFFER=y
 CONFIG_BOOTCOUNT_LIMIT=y
diff --git a/include/configs/smegw01.h b/include/configs/smegw01.h
index 8521883277..6f373973ab 100644
--- a/include/configs/smegw01.h
+++ b/include/configs/smegw01.h
@@ -22,6 +22,32 @@
 #define EXTRA_BOOTPARAMS
 #endif
 
+#ifdef CONFIG_SYS_BOOT_LOCKED
+#define EXTRA_ENV_FLAGS
+#define SETUP_BOOT_MENU "setup_boot_menu=setenv bootmenu_0 eMMC=run bootcmd\0"
+#else
+#define EXTRA_ENV_FLAGS "mmcdev:dw,"
+#define SETUP_BOOT_MENU "setup_boot_menu=" \
+   "if test \"${mmcdev}\" = 1; then " \
+   "setenv emmc_priority 0;" \
+   "setenv sd_priority 1;" \
+   "else " \
+   "setenv emmc_priority 1;" \
+   "setenv sd_priority 0;" \
+   "fi;" \
+   "setenv bootmenu_${emmc_priority} eMMC=run boot_emmc;" \
+   "setenv bootmenu_${sd_priority} SD=run boot_sd;\0"
+#endif
+
+#define CFG_ENV_FLAGS_LIST_STATIC \
+   "mmcpart:dw," \
+   "mmcpart_committed:dw," \
+   "ustate:dw," \
+   "bootcount:dw," \
+   "bootlimit:dw," \
+   "upgrade_available:dw," \
+   EXTRA_ENV_FLAGS
+
 #define CFG_EXTRA_ENV_SETTINGS \
"image=fitImage\0" \
"console=ttymxc0\0" \
@@ -40,13 +66,28 @@
  "fi;\0" \
"bootlimit=3\0" \
"fit_addr=0x8800\0" \
-   "loadimage=load mmc ${mmcdev}#rootfs-${mmcpart_committed}

[PATCH v3 09/13] smegw01: Switch to fitImage

2023-04-24 Thread Fabio Estevam
From: Eduard Strehlau 

Instead of loading the zImage kernel and the devicetree separately, switch
to the fitImage format, which is more convenient when working with secure
boot, for example.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
Changes since v2:
- None

 include/configs/smegw01.h | 14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/include/configs/smegw01.h b/include/configs/smegw01.h
index 8f68472f5b..8521883277 100644
--- a/include/configs/smegw01.h
+++ b/include/configs/smegw01.h
@@ -23,7 +23,7 @@
 #endif
 
 #define CFG_EXTRA_ENV_SETTINGS \
-   "image=zImage\0" \
+   "image=fitImage\0" \
"console=ttymxc0\0" \
"fdtfile=imx7d-smegw01.dtb\0" \
"fdt_addr=0x8300\0" \
@@ -39,8 +39,8 @@
"saveenv;" \
  "fi;\0" \
"bootlimit=3\0" \
-   "loadimage=load mmc ${mmcdev}#rootfs-${mmcpart_committed} ${loadaddr} 
boot/${image}\0" \
-   "loadfdt=load mmc ${mmcdev}#rootfs-${mmcpart_committed} ${fdt_addr} 
boot/${fdtfile}\0" \
+   "fit_addr=0x8800\0" \
+   "loadimage=load mmc ${mmcdev}#rootfs-${mmcpart_committed} ${fit_addr} 
boot/${image}\0" \
"loadpart=gpt setenv mmc ${mmcdev} rootfs-${mmcpart_committed}\0" \
"loadbootpart=mmc partconf 1 boot_part\0" \
"mmcboot=echo Booting from mmc ...; " \
@@ -48,12 +48,8 @@
"run loadpart; " \
"run loadbootpart; " \
"run mmcargs; " \
-   "if run loadfdt; then " \
-   "if bootz ${loadaddr} - ${fdt_addr}; then " \
-   "; " \
-   "else " \
-   "run altbootcmd; " \
-   "fi;" \
+   "if bootm ${fit_addr}; then " \
+   "; " \
"else " \
"run altbootcmd; " \
"fi;\0" \
-- 
2.38.1



[PATCH v3 08/13] smegw01: Change default boot device to eMMC

2023-04-24 Thread Fabio Estevam
From: Eduard Strehlau 

Let eMMC be the default boot medium.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
Changes since v2:
- None

 include/configs/smegw01.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/configs/smegw01.h b/include/configs/smegw01.h
index 71f2d9c8e8..8f68472f5b 100644
--- a/include/configs/smegw01.h
+++ b/include/configs/smegw01.h
@@ -28,7 +28,7 @@
"fdtfile=imx7d-smegw01.dtb\0" \
"fdt_addr=0x8300\0" \
"bootm_size=0x1000\0" \
-   "mmcdev=0\0" \
+   "mmcdev=1\0" \
"mmcpart=1\0" \
"mmcpart_committed=1\0" \
"mmcargs=setenv bootargs console=${console},${baudrate} " \
-- 
2.38.1



[PATCH v3 07/13] smegw01: Enable EMMC boot from multiple partitions

2023-04-24 Thread Fabio Estevam
From: Eduard Strehlau 

GPT Partition labels are used for determining the right
root filesystem to boot from.

The U-Boot environment is configured to reside in the eMMC hardware
boot partition we are currently booted from.

This should enable a dual copy approach for upgrading the bootloader.
One can overwrite the inactive hardware partition with new bootloader
and environment and afterwards switch the eMMC boot partition for an
atomic bootloader switch.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
Changes since v2:
- Use the same board_mmc_get_env_part() implementations as
board/purism/librem5/librem5.c.

Cc: Pali Rohár 

 board/storopack/smegw01/smegw01.c | 10 ++
 configs/smegw01_defconfig |  2 ++
 include/configs/smegw01.h | 12 
 3 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/board/storopack/smegw01/smegw01.c 
b/board/storopack/smegw01/smegw01.c
index e6bff80e5565..7d4de9326d6f 100644
--- a/board/storopack/smegw01/smegw01.c
+++ b/board/storopack/smegw01/smegw01.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -93,3 +94,12 @@ int board_late_init(void)
 
return 0;
 }
+
+uint board_mmc_get_env_part(struct mmc *mmc)
+{
+   uint part = EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config);
+
+   if (part == 7)
+   part = 0;
+   return part;
+}
diff --git a/configs/smegw01_defconfig b/configs/smegw01_defconfig
index b3580d5d6e54..54cf1cfc1f1b 100644
--- a/configs/smegw01_defconfig
+++ b/configs/smegw01_defconfig
@@ -30,6 +30,7 @@ CONFIG_CMD_MEMTEST=y
 CONFIG_CMD_UNZIP=y
 CONFIG_CMD_DFU=y
 CONFIG_CMD_GPIO=y
+CONFIG_CMD_GPT=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_PART=y
 CONFIG_CMD_DHCP=y
@@ -44,6 +45,7 @@ CONFIG_OF_CONTROL=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_SYS_MMC_ENV_DEV=1
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_BOUNCE_BUFFER=y
 CONFIG_BOOTCOUNT_LIMIT=y
diff --git a/include/configs/smegw01.h b/include/configs/smegw01.h
index 277c828d0e07..71f2d9c8e85c 100644
--- a/include/configs/smegw01.h
+++ b/include/configs/smegw01.h
@@ -32,17 +32,21 @@
"mmcpart=1\0" \
"mmcpart_committed=1\0" \
"mmcargs=setenv bootargs console=${console},${baudrate} " \
-   "root=/dev/mmcblk0p${mmcpart_committed} rootwait rw " \
-   __stringify(EXTRA_BOOTPARAMS) "\0" \
+   "root=/dev/mmcblk${mmcdev}p${gpt_partition_entry} rootwait rw " 
\
+   __stringify(EXTRA_BOOTPARAMS) " SM_ROOT_DEV=${mmcdev} 
SM_ROOT_PART=${gpt_partition_entry} SM_BOOT_PART=${boot_part}\0" \
"commit_mmc=if test \"${ustate}\" = 1 -a \"${mmcpart}\" != 
\"${mmcpart_committed}\"; then " \
  "setenv mmcpart_committed ${mmcpart};" \
"saveenv;" \
  "fi;\0" \
"bootlimit=3\0" \
-   "loadimage=load mmc ${mmcdev}:${mmcpart_committed} ${loadaddr} 
boot/${image}\0" \
-   "loadfdt=load mmc ${mmcdev}:${mmcpart_committed} ${fdt_addr} 
boot/${fdtfile}\0" \
+   "loadimage=load mmc ${mmcdev}#rootfs-${mmcpart_committed} ${loadaddr} 
boot/${image}\0" \
+   "loadfdt=load mmc ${mmcdev}#rootfs-${mmcpart_committed} ${fdt_addr} 
boot/${fdtfile}\0" \
+   "loadpart=gpt setenv mmc ${mmcdev} rootfs-${mmcpart_committed}\0" \
+   "loadbootpart=mmc partconf 1 boot_part\0" \
"mmcboot=echo Booting from mmc ...; " \
  "run commit_mmc; " \
+   "run loadpart; " \
+   "run loadbootpart; " \
"run mmcargs; " \
"if run loadfdt; then " \
"if bootz ${loadaddr} - ${fdt_addr}; then " \
-- 
2.34.1



[PATCH v3 06/13] smegw01: Only commit to new partition if update was successful

2023-04-24 Thread Fabio Estevam
From: Eduard Strehlau 

When performing rootfs update via swupdate, it is convenient to check the
'ustate' variable to decide whether the update succeeded or not.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
Changes since v2:
- None

 include/configs/smegw01.h | 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/include/configs/smegw01.h b/include/configs/smegw01.h
index 05edaac42f..277c828d0e 100644
--- a/include/configs/smegw01.h
+++ b/include/configs/smegw01.h
@@ -30,13 +30,19 @@
"bootm_size=0x1000\0" \
"mmcdev=0\0" \
"mmcpart=1\0" \
+   "mmcpart_committed=1\0" \
"mmcargs=setenv bootargs console=${console},${baudrate} " \
-   "root=/dev/mmcblk0p${mmcpart} rootwait rw " \
+   "root=/dev/mmcblk0p${mmcpart_committed} rootwait rw " \
__stringify(EXTRA_BOOTPARAMS) "\0" \
+   "commit_mmc=if test \"${ustate}\" = 1 -a \"${mmcpart}\" != 
\"${mmcpart_committed}\"; then " \
+ "setenv mmcpart_committed ${mmcpart};" \
+   "saveenv;" \
+ "fi;\0" \
"bootlimit=3\0" \
-   "loadimage=load mmc ${mmcdev}:${mmcpart} ${loadaddr} boot/${image}\0" \
-   "loadfdt=load mmc ${mmcdev}:${mmcpart} ${fdt_addr} boot/${fdtfile}\0" \
+   "loadimage=load mmc ${mmcdev}:${mmcpart_committed} ${loadaddr} 
boot/${image}\0" \
+   "loadfdt=load mmc ${mmcdev}:${mmcpart_committed} ${fdt_addr} 
boot/${fdtfile}\0" \
"mmcboot=echo Booting from mmc ...; " \
+ "run commit_mmc; " \
"run mmcargs; " \
"if run loadfdt; then " \
"if bootz ${loadaddr} - ${fdt_addr}; then " \
@@ -48,10 +54,12 @@
"run altbootcmd; " \
"fi;\0" \
"altbootcmd=echo Performing rollback...; " \
-   "if test \"${mmcpart}\" = 1; then " \
+   "if test \"${mmcpart_committed}\" = 1; then " \
"setenv mmcpart 2; " \
+   "setenv mmcpart_committed 2;" \
"else " \
"setenv mmcpart 1; " \
+   "setenv mmcpart_committed 1;" \
"fi; setenv bootcount 0; setenv upgrade_available; setenv 
ustate 3; saveenv; " \
"run bootcmd;\0"
 
-- 
2.38.1



[PATCH v3 05/13] smegw01: Run altbootcmd in the case of failure

2023-04-24 Thread Fabio Estevam
From: Eduard Strehlau 

Run the altbootcmd script if any step of bootcmd fails.

This ensures that always a valid image can be run.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
Changes since v2:
- None

 configs/smegw01_defconfig | 2 +-
 include/configs/smegw01.h | 8 +++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/configs/smegw01_defconfig b/configs/smegw01_defconfig
index 418151a6de..b3580d5d6e 100644
--- a/configs/smegw01_defconfig
+++ b/configs/smegw01_defconfig
@@ -18,7 +18,7 @@ CONFIG_SYS_MEMTEST_END=0xa000
 CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_USE_BOOTCOMMAND=y
-CONFIG_BOOTCOMMAND="if test \"${ustate}\" = 1; then setenv upgrade_available 
1; saveenv; fi; if run loadimage; then run mmcboot; fi; "
+CONFIG_BOOTCOMMAND="if test \"${ustate}\" = 1; then setenv upgrade_available 
1; saveenv; fi; if run loadimage; then run mmcboot; else run altbootcmd; fi; "
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_MAXARGS=32
 CONFIG_SYS_PBSIZE=532
diff --git a/include/configs/smegw01.h b/include/configs/smegw01.h
index 6ee4acc70d..05edaac42f 100644
--- a/include/configs/smegw01.h
+++ b/include/configs/smegw01.h
@@ -39,7 +39,13 @@
"mmcboot=echo Booting from mmc ...; " \
"run mmcargs; " \
"if run loadfdt; then " \
-   "bootz ${loadaddr} - ${fdt_addr}; " \
+   "if bootz ${loadaddr} - ${fdt_addr}; then " \
+   "; " \
+   "else " \
+   "run altbootcmd; " \
+   "fi;" \
+   "else " \
+   "run altbootcmd; " \
"fi;\0" \
"altbootcmd=echo Performing rollback...; " \
"if test \"${mmcpart}\" = 1; then " \
-- 
2.38.1



[PATCH v3 04/13] smegw01: Add altbootcmd

2023-04-24 Thread Fabio Estevam
From: Eduard Strehlau 

Add an altbootcmd script, which is convenient way to integrate with
swupdate and perform a roll back of the previous working version in the
case of update failure.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
Changes since v2:
- None

 configs/smegw01_defconfig | 2 +-
 include/configs/smegw01.h | 8 
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/configs/smegw01_defconfig b/configs/smegw01_defconfig
index 5d9d419463..418151a6de 100644
--- a/configs/smegw01_defconfig
+++ b/configs/smegw01_defconfig
@@ -18,7 +18,7 @@ CONFIG_SYS_MEMTEST_END=0xa000
 CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_USE_BOOTCOMMAND=y
-CONFIG_BOOTCOMMAND="if run loadimage; then run mmcboot; fi; "
+CONFIG_BOOTCOMMAND="if test \"${ustate}\" = 1; then setenv upgrade_available 
1; saveenv; fi; if run loadimage; then run mmcboot; fi; "
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_MAXARGS=32
 CONFIG_SYS_PBSIZE=532
diff --git a/include/configs/smegw01.h b/include/configs/smegw01.h
index a356f095a6..6ee4acc70d 100644
--- a/include/configs/smegw01.h
+++ b/include/configs/smegw01.h
@@ -33,6 +33,7 @@
"mmcargs=setenv bootargs console=${console},${baudrate} " \
"root=/dev/mmcblk0p${mmcpart} rootwait rw " \
__stringify(EXTRA_BOOTPARAMS) "\0" \
+   "bootlimit=3\0" \
"loadimage=load mmc ${mmcdev}:${mmcpart} ${loadaddr} boot/${image}\0" \
"loadfdt=load mmc ${mmcdev}:${mmcpart} ${fdt_addr} boot/${fdtfile}\0" \
"mmcboot=echo Booting from mmc ...; " \
@@ -40,6 +41,13 @@
"if run loadfdt; then " \
"bootz ${loadaddr} - ${fdt_addr}; " \
"fi;\0" \
+   "altbootcmd=echo Performing rollback...; " \
+   "if test \"${mmcpart}\" = 1; then " \
+   "setenv mmcpart 2; " \
+   "else " \
+   "setenv mmcpart 1; " \
+   "fi; setenv bootcount 0; setenv upgrade_available; setenv 
ustate 3; saveenv; " \
+   "run bootcmd;\0"
 
 /* Physical Memory Map */
 #define PHYS_SDRAM MMDC0_ARB_BASE_ADDR
-- 
2.38.1



[PATCH v3 03/13] smegw01: Select bootcount support

2023-04-24 Thread Fabio Estevam
From: Eduard Strehlau 

Add automatic boot counter that increases after every
reset. After a power-on reset, it will be initialized with 1,
and each reboot will increment the value by 1. By default it is
disabled if bootlimit isn't set.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
Changes since v2:
- None

 configs/smegw01_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configs/smegw01_defconfig b/configs/smegw01_defconfig
index f15291f1dd..5d9d419463 100644
--- a/configs/smegw01_defconfig
+++ b/configs/smegw01_defconfig
@@ -46,6 +46,8 @@ CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_BOUNCE_BUFFER=y
+CONFIG_BOOTCOUNT_LIMIT=y
+CONFIG_BOOTCOUNT_ENV=y
 CONFIG_DFU_MMC=y
 CONFIG_DM_I2C=y
 CONFIG_SUPPORT_EMMC_BOOT=y
-- 
2.38.1



[PATCH v3 02/13] smegw01: Select CONFIG_CMD_SQUASHFS

2023-04-24 Thread Fabio Estevam
From: Eduard Strehlau 

Select CONFIG_CMD_SQUASHFS so that the SquashFS U-Boot commands
are available.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
Changes since v2:
- None

 configs/smegw01_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/smegw01_defconfig b/configs/smegw01_defconfig
index 1e0b9aa5be..f15291f1dd 100644
--- a/configs/smegw01_defconfig
+++ b/configs/smegw01_defconfig
@@ -38,6 +38,7 @@ CONFIG_CMD_EXT2=y
 CONFIG_CMD_EXT4=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_CMD_FAT=y
+CONFIG_CMD_SQUASHFS=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_OF_CONTROL=y
 CONFIG_ENV_OVERWRITE=y
-- 
2.38.1



[PATCH v3 01/13] smegw01: Enable setting additional boot params

2023-04-24 Thread Fabio Estevam
From: Eduard Strehlau 

Introduce EXTRA_BOOTPARAMS to allow passing additional parameters
to kernel command line. This is useful for debugging purposes.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
Changes since v2:
- None

 include/configs/smegw01.h | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/include/configs/smegw01.h b/include/configs/smegw01.h
index 11031744be..a356f095a6 100644
--- a/include/configs/smegw01.h
+++ b/include/configs/smegw01.h
@@ -17,6 +17,11 @@
 /* MMC Config*/
 #define CFG_SYS_FSL_ESDHC_ADDR 0
 
+/* default to no extra bootparams, we need an empty define for 
stringification*/
+#ifndef EXTRA_BOOTPARAMS
+#define EXTRA_BOOTPARAMS
+#endif
+
 #define CFG_EXTRA_ENV_SETTINGS \
"image=zImage\0" \
"console=ttymxc0\0" \
@@ -26,7 +31,8 @@
"mmcdev=0\0" \
"mmcpart=1\0" \
"mmcargs=setenv bootargs console=${console},${baudrate} " \
-   "root=/dev/mmcblk0p${mmcpart} rootwait rw\0" \
+   "root=/dev/mmcblk0p${mmcpart} rootwait rw " \
+   __stringify(EXTRA_BOOTPARAMS) "\0" \
"loadimage=load mmc ${mmcdev}:${mmcpart} ${loadaddr} boot/${image}\0" \
"loadfdt=load mmc ${mmcdev}:${mmcpart} ${fdt_addr} boot/${fdtfile}\0" \
"mmcboot=echo Booting from mmc ...; " \
-- 
2.38.1



Re: [PATCH v2 7/7] smegw01: Enable EMMC boot from multiple partitions

2023-04-24 Thread Fabio Estevam
Hi Pali,

On Fri, Apr 21, 2023 at 3:11 PM Pali Rohár  wrote:

> This does not look to be correct. Return type of the function is uint
> but here you are trying to return negative number.
>
> I think that there is some layering or API issue. Caller of this
> function probably does not expect any failure and use returned value as
> partition number. But you are reading partition number from the source
> which may return failure (as the source does not have to contain it).
>
> I'm not sure what is the correct way how to handle these kind of error.
> I hope that this is something which you would know.

Thanks for your feedback.

Talked to Eduard and we prefer to go with a simpler implementation of
board_mmc_get_env_part(),
just like the one from board/purism/librem5/librem5.c.

The librem5 board is based on the imx8mq, which has the same esdhc
controller as the imx7d and
it works well in our case. Will send a v3.


[PATCH 13/13] smegw01: Fix fallback to altbootcmd

2023-04-21 Thread Fabio Estevam
From: Eduard Strehlau 

The bootcmd/altbootcmd mechanism is not invoked for bootmenus.
Manually compare bootcount and bootlimit to implement fallback on all
codepaths.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
Changes since v1:
- None

 configs/smegw01_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configs/smegw01_defconfig b/configs/smegw01_defconfig
index fe8152f33e..3d2713f528 100644
--- a/configs/smegw01_defconfig
+++ b/configs/smegw01_defconfig
@@ -23,7 +23,7 @@ CONFIG_AUTOBOOT_MENU_SHOW=y
 # CONFIG_CMD_BOOTEFI_BOOTMGR is not set
 CONFIG_BOOTMENU_DISABLE_UBOOT_CONSOLE=y
 CONFIG_USE_BOOTCOMMAND=y
-CONFIG_BOOTCOMMAND="if test \"${ustate}\" = 1; then setenv upgrade_available 
1; saveenv; fi; run mmcboot; "
+CONFIG_BOOTCOMMAND="if test \"${bootcount}\" -gt \"${bootlimit}\"; then run 
altbootcmd; else if test \"${ustate}\" = 1; then setenv upgrade_available 1; 
saveenv; fi; run mmcboot; fi;"
 CONFIG_USE_PREBOOT=y
 CONFIG_PREBOOT="run setup_boot_menu;"
 CONFIG_HUSH_PARSER=y
-- 
2.38.1



[PATCH v2 12/13] smegw01: Disable additional boot menu options

2023-04-21 Thread Fabio Estevam
From: Eduard Strehlau 

Defaults have changed, we do not want the bootmenu to contain EFI
options.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
Changes since v1:
- None

 configs/smegw01_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configs/smegw01_defconfig b/configs/smegw01_defconfig
index ea25b3b87c..fe8152f33e 100644
--- a/configs/smegw01_defconfig
+++ b/configs/smegw01_defconfig
@@ -19,6 +19,8 @@ CONFIG_SYS_MEMTEST_END=0xa000
 CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_AUTOBOOT_MENU_SHOW=y
+# CONFIG_BOOTSTD is not set
+# CONFIG_CMD_BOOTEFI_BOOTMGR is not set
 CONFIG_BOOTMENU_DISABLE_UBOOT_CONSOLE=y
 CONFIG_USE_BOOTCOMMAND=y
 CONFIG_BOOTCOMMAND="if test \"${ustate}\" = 1; then setenv upgrade_available 
1; saveenv; fi; run mmcboot; "
-- 
2.38.1



[PATCH v2 11/13] smegw01: Read the second MAC address

2023-04-21 Thread Fabio Estevam
From: Fabio Estevam 

Currently, only the first MAC address is read from the fuses.

The second MAC address is not read and Linux assigns a random one.

To prevent this behavior, read the second MAC address from the fuses
and store it into the eth1addr environment variable so that it
can be passed to Linux.

Signed-off-by: Fabio Estevam 
---
Changes since v1:
- Fixed typo in the Subject "smegw01".

 board/storopack/smegw01/smegw01.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/board/storopack/smegw01/smegw01.c 
b/board/storopack/smegw01/smegw01.c
index e786429476..605253ead3 100644
--- a/board/storopack/smegw01/smegw01.c
+++ b/board/storopack/smegw01/smegw01.c
@@ -82,6 +82,7 @@ int board_init(void)
 int board_late_init(void)
 {
struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR;
+   unsigned char eth1addr[6];
 
imx_iomux_v3_setup_multiple_pads(wdog_pads, ARRAY_SIZE(wdog_pads));
 
@@ -93,6 +94,11 @@ int board_late_init(void)
 */
clrsetbits_le16(>wcr, 0, 0x10);
 
+   /* Get the second MAC address */
+   imx_get_mac_from_fuse(1, eth1addr);
+   if (!env_get("eth1addr") && is_valid_ethaddr(eth1addr))
+   eth_env_set_enetaddr("eth1addr", eth1addr);
+
return 0;
 }
 
-- 
2.38.1



[PATCH v2 10/13] smegw01: Add lockdown U-Boot env support

2023-04-21 Thread Fabio Estevam
From: Eduard Strehlau 

Add lockdown U-Boot env support so that only certain U-Boot environment
variables are allowed to be modified.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
Changes since v1:
- None

 board/storopack/smegw01/Kconfig   |  7 +
 board/storopack/smegw01/smegw01.c | 17 +++
 configs/smegw01_defconfig | 11 ++-
 include/configs/smegw01.h | 48 +--
 4 files changed, 79 insertions(+), 4 deletions(-)

diff --git a/board/storopack/smegw01/Kconfig b/board/storopack/smegw01/Kconfig
index d8f24695d0..390214c285 100644
--- a/board/storopack/smegw01/Kconfig
+++ b/board/storopack/smegw01/Kconfig
@@ -12,4 +12,11 @@ config SYS_CONFIG_NAME
 config IMX_CONFIG
default "board/storopack/smegw01/imximage.cfg"
 
+config SYS_BOOT_LOCKED
+   bool "Lock boot process to EMMC"
+   default y
+   help
+ Say N here if you want to boot from eMMC and SD.
+ Say Y to boot from eMMC.
+
 endif
diff --git a/board/storopack/smegw01/smegw01.c 
b/board/storopack/smegw01/smegw01.c
index 9482f88773..e786429476 100644
--- a/board/storopack/smegw01/smegw01.c
+++ b/board/storopack/smegw01/smegw01.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -113,3 +114,19 @@ uint mmc_get_env_part(struct mmc *mmc)
 
return part;
 }
+
+enum env_location env_get_location(enum env_operation op, int prio)
+{
+   if (op == ENVOP_SAVE || op == ENVOP_ERASE)
+   return ENVL_MMC;
+
+   switch (prio) {
+   case 0:
+   return ENVL_NOWHERE;
+
+   case 1:
+   return ENVL_MMC;
+   }
+
+   return ENVL_UNKNOWN;
+}
diff --git a/configs/smegw01_defconfig b/configs/smegw01_defconfig
index 54cf1cfc1f..ea25b3b87c 100644
--- a/configs/smegw01_defconfig
+++ b/configs/smegw01_defconfig
@@ -7,6 +7,7 @@ CONFIG_ENV_OFFSET=0x10
 CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="imx7d-smegw01"
 CONFIG_TARGET_SMEGW01=y
+# CONFIG_SYS_BOOT_LOCKED is not set
 CONFIG_ENV_OFFSET_REDUND=0x11
 CONFIG_ARMV7_BOOT_SEC_DEFAULT=y
 # CONFIG_ARMV7_VIRT is not set
@@ -17,13 +18,18 @@ CONFIG_SYS_MEMTEST_START=0x8000
 CONFIG_SYS_MEMTEST_END=0xa000
 CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
+CONFIG_AUTOBOOT_MENU_SHOW=y
+CONFIG_BOOTMENU_DISABLE_UBOOT_CONSOLE=y
 CONFIG_USE_BOOTCOMMAND=y
-CONFIG_BOOTCOMMAND="if test \"${ustate}\" = 1; then setenv upgrade_available 
1; saveenv; fi; if run loadimage; then run mmcboot; else run altbootcmd; fi; "
+CONFIG_BOOTCOMMAND="if test \"${ustate}\" = 1; then setenv upgrade_available 
1; saveenv; fi; run mmcboot; "
+CONFIG_USE_PREBOOT=y
+CONFIG_PREBOOT="run setup_boot_menu;"
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_MAXARGS=32
 CONFIG_SYS_PBSIZE=532
 # CONFIG_CMD_BOOTD is not set
 CONFIG_CMD_BOOTZ=y
+CONFIG_CMD_BOOTMENU=y
 # CONFIG_CMD_IMI is not set
 # CONFIG_CMD_XIMG is not set
 CONFIG_CMD_MEMTEST=y
@@ -43,9 +49,12 @@ CONFIG_CMD_SQUASHFS=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_OF_CONTROL=y
 CONFIG_ENV_OVERWRITE=y
+CONFIG_ENV_IS_NOWHERE=y
 CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_SYS_MMC_ENV_DEV=1
+CONFIG_ENV_WRITEABLE_LIST=y
+CONFIG_ENV_ACCESS_IGNORE_FORCE=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_BOUNCE_BUFFER=y
 CONFIG_BOOTCOUNT_LIMIT=y
diff --git a/include/configs/smegw01.h b/include/configs/smegw01.h
index 8521883277..6f373973ab 100644
--- a/include/configs/smegw01.h
+++ b/include/configs/smegw01.h
@@ -22,6 +22,32 @@
 #define EXTRA_BOOTPARAMS
 #endif
 
+#ifdef CONFIG_SYS_BOOT_LOCKED
+#define EXTRA_ENV_FLAGS
+#define SETUP_BOOT_MENU "setup_boot_menu=setenv bootmenu_0 eMMC=run bootcmd\0"
+#else
+#define EXTRA_ENV_FLAGS "mmcdev:dw,"
+#define SETUP_BOOT_MENU "setup_boot_menu=" \
+   "if test \"${mmcdev}\" = 1; then " \
+   "setenv emmc_priority 0;" \
+   "setenv sd_priority 1;" \
+   "else " \
+   "setenv emmc_priority 1;" \
+   "setenv sd_priority 0;" \
+   "fi;" \
+   "setenv bootmenu_${emmc_priority} eMMC=run boot_emmc;" \
+   "setenv bootmenu_${sd_priority} SD=run boot_sd;\0"
+#endif
+
+#define CFG_ENV_FLAGS_LIST_STATIC \
+   "mmcpart:dw," \
+   "mmcpart_committed:dw," \
+   "ustate:dw," \
+   "bootcount:dw," \
+   "bootlimit:dw," \
+   "upgrade_available:dw," \
+   EXTRA_ENV_FLAGS
+
 #define CFG_EXTRA_ENV_SETTINGS \
"image=fitImage\0" \
"console=ttymxc0\0" \
@@ -40,13 +66,28 @@
  "fi;\0" \
"bootlimit=3\0" \
"fit_addr=0x8800\0" \
-   "loadimage=load mmc ${mmcdev}#rootfs-${mmcpart_committed}

[PATCH v2 09/13] smegw01: Switch to fitImage

2023-04-21 Thread Fabio Estevam
From: Eduard Strehlau 

Instead of loading the zImage kernel and the devicetree separately, switch
to the fitImage format, which is more convenient when working with secure
boot, for example.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
Changes since v1:
- None

 include/configs/smegw01.h | 14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/include/configs/smegw01.h b/include/configs/smegw01.h
index 8f68472f5b..8521883277 100644
--- a/include/configs/smegw01.h
+++ b/include/configs/smegw01.h
@@ -23,7 +23,7 @@
 #endif
 
 #define CFG_EXTRA_ENV_SETTINGS \
-   "image=zImage\0" \
+   "image=fitImage\0" \
"console=ttymxc0\0" \
"fdtfile=imx7d-smegw01.dtb\0" \
"fdt_addr=0x8300\0" \
@@ -39,8 +39,8 @@
"saveenv;" \
  "fi;\0" \
"bootlimit=3\0" \
-   "loadimage=load mmc ${mmcdev}#rootfs-${mmcpart_committed} ${loadaddr} 
boot/${image}\0" \
-   "loadfdt=load mmc ${mmcdev}#rootfs-${mmcpart_committed} ${fdt_addr} 
boot/${fdtfile}\0" \
+   "fit_addr=0x8800\0" \
+   "loadimage=load mmc ${mmcdev}#rootfs-${mmcpart_committed} ${fit_addr} 
boot/${image}\0" \
"loadpart=gpt setenv mmc ${mmcdev} rootfs-${mmcpart_committed}\0" \
"loadbootpart=mmc partconf 1 boot_part\0" \
"mmcboot=echo Booting from mmc ...; " \
@@ -48,12 +48,8 @@
"run loadpart; " \
"run loadbootpart; " \
"run mmcargs; " \
-   "if run loadfdt; then " \
-   "if bootz ${loadaddr} - ${fdt_addr}; then " \
-   "; " \
-   "else " \
-   "run altbootcmd; " \
-   "fi;" \
+   "if bootm ${fit_addr}; then " \
+   "; " \
"else " \
"run altbootcmd; " \
"fi;\0" \
-- 
2.38.1



[PATCH v2 08/13] smegw01: Change default boot device to eMMC

2023-04-21 Thread Fabio Estevam
From: Eduard Strehlau 

Let eMMC be the default boot medium.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
Changes since v1:
- None

 include/configs/smegw01.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/configs/smegw01.h b/include/configs/smegw01.h
index 71f2d9c8e8..8f68472f5b 100644
--- a/include/configs/smegw01.h
+++ b/include/configs/smegw01.h
@@ -28,7 +28,7 @@
"fdtfile=imx7d-smegw01.dtb\0" \
"fdt_addr=0x8300\0" \
"bootm_size=0x1000\0" \
-   "mmcdev=0\0" \
+   "mmcdev=1\0" \
"mmcpart=1\0" \
"mmcpart_committed=1\0" \
"mmcargs=setenv bootargs console=${console},${baudrate} " \
-- 
2.38.1



[PATCH v2 7/7] smegw01: Enable EMMC boot from multiple partitions

2023-04-21 Thread Fabio Estevam
From: Eduard Strehlau 

GPT Partition labels are used for determining the right
root filesystem to boot from.

The U-Boot environment is configured to reside in the eMMC hardware
boot partition we are currently booted from.

This should enable a dual copy approach for upgrading the bootloader.
One can overwrite the inactive hardware partition with new bootloader
and environment and afterwards switch the eMMC boot partition for an
atomic bootloader switch.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
Changes since v1:
- Remove custom mmc macro (Pali)
- Handle all the possible partition cases (Pali).

Cc: Pali Rohár 

 board/storopack/smegw01/smegw01.c | 32 +++
 configs/smegw01_defconfig |  2 ++
 include/configs/smegw01.h | 12 
 3 files changed, 42 insertions(+), 4 deletions(-)

diff --git a/board/storopack/smegw01/smegw01.c 
b/board/storopack/smegw01/smegw01.c
index e6bff80e5565..db6069a02722 100644
--- a/board/storopack/smegw01/smegw01.c
+++ b/board/storopack/smegw01/smegw01.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -93,3 +94,34 @@ int board_late_init(void)
 
return 0;
 }
+
+uint mmc_get_env_part(struct mmc *mmc)
+{
+   uint part;
+
+   if (mmc->part_config == MMCPART_NOAVAILABLE) {
+   part = 0;
+   } else {
+   switch (EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config)) {
+   case 0: /* Booting from this eMMC device is disabled */
+   printf("Error - Booting from this eMMC device is 
disabled\n");
+   printf("Hint: Use 'mmc partconf' command to choose boot 
partition\n");
+   return -ENODEV;
+   case 1: /* Boot partition 1 is used for booting */
+   part = 1;
+   break;
+   case 2: /* Boot partition 2 is used for booting */
+   part = 2;
+   break;
+   case 7: /* User area is used for booting */
+   part = 0;
+   break;
+   default: /* Other values are reserved / unsupported */
+   printf("Error - This eMMC device has configured 
Reserved boot option\n");
+   printf("Hint: Use 'mmc partconf' command to choose boot 
partition\n");
+   return -ENODEV;
+   }
+   }
+
+   return part;
+}
diff --git a/configs/smegw01_defconfig b/configs/smegw01_defconfig
index b3580d5d6e54..54cf1cfc1f1b 100644
--- a/configs/smegw01_defconfig
+++ b/configs/smegw01_defconfig
@@ -30,6 +30,7 @@ CONFIG_CMD_MEMTEST=y
 CONFIG_CMD_UNZIP=y
 CONFIG_CMD_DFU=y
 CONFIG_CMD_GPIO=y
+CONFIG_CMD_GPT=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_PART=y
 CONFIG_CMD_DHCP=y
@@ -44,6 +45,7 @@ CONFIG_OF_CONTROL=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_SYS_MMC_ENV_DEV=1
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_BOUNCE_BUFFER=y
 CONFIG_BOOTCOUNT_LIMIT=y
diff --git a/include/configs/smegw01.h b/include/configs/smegw01.h
index 277c828d0e07..71f2d9c8e85c 100644
--- a/include/configs/smegw01.h
+++ b/include/configs/smegw01.h
@@ -32,17 +32,21 @@
"mmcpart=1\0" \
"mmcpart_committed=1\0" \
"mmcargs=setenv bootargs console=${console},${baudrate} " \
-   "root=/dev/mmcblk0p${mmcpart_committed} rootwait rw " \
-   __stringify(EXTRA_BOOTPARAMS) "\0" \
+   "root=/dev/mmcblk${mmcdev}p${gpt_partition_entry} rootwait rw " 
\
+   __stringify(EXTRA_BOOTPARAMS) " SM_ROOT_DEV=${mmcdev} 
SM_ROOT_PART=${gpt_partition_entry} SM_BOOT_PART=${boot_part}\0" \
"commit_mmc=if test \"${ustate}\" = 1 -a \"${mmcpart}\" != 
\"${mmcpart_committed}\"; then " \
  "setenv mmcpart_committed ${mmcpart};" \
"saveenv;" \
  "fi;\0" \
"bootlimit=3\0" \
-   "loadimage=load mmc ${mmcdev}:${mmcpart_committed} ${loadaddr} 
boot/${image}\0" \
-   "loadfdt=load mmc ${mmcdev}:${mmcpart_committed} ${fdt_addr} 
boot/${fdtfile}\0" \
+   "loadimage=load mmc ${mmcdev}#rootfs-${mmcpart_committed} ${loadaddr} 
boot/${image}\0" \
+   "loadfdt=load mmc ${mmcdev}#rootfs-${mmcpart_committed} ${fdt_addr} 
boot/${fdtfile}\0" \
+   "loadpart=gpt setenv mmc ${mmcdev} rootfs-${mmcpart_committed}\0" \
+   "loadbootpart=mmc partconf 1 boot_part\0" \
"mmcboot=echo Booting from mmc ...; " \
  "run commit_mmc; " \
+   "run loadpart; " \
+   "run loadbootpart; " \
"run mmcargs; " \
"if run loadfdt; then " \
"if bootz ${loadaddr} - ${fdt_addr}; then " \
-- 
2.34.1



[PATCH v2 06/13] smegw01: Only commit to new partition if update was successful

2023-04-21 Thread Fabio Estevam
From: Eduard Strehlau 

When performing rootfs update via swupdate, it is convenient to check the
'ustate' variable to decide whether the update succeeded or not.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
Changes since v1:
- None

 include/configs/smegw01.h | 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/include/configs/smegw01.h b/include/configs/smegw01.h
index 05edaac42f..277c828d0e 100644
--- a/include/configs/smegw01.h
+++ b/include/configs/smegw01.h
@@ -30,13 +30,19 @@
"bootm_size=0x1000\0" \
"mmcdev=0\0" \
"mmcpart=1\0" \
+   "mmcpart_committed=1\0" \
"mmcargs=setenv bootargs console=${console},${baudrate} " \
-   "root=/dev/mmcblk0p${mmcpart} rootwait rw " \
+   "root=/dev/mmcblk0p${mmcpart_committed} rootwait rw " \
__stringify(EXTRA_BOOTPARAMS) "\0" \
+   "commit_mmc=if test \"${ustate}\" = 1 -a \"${mmcpart}\" != 
\"${mmcpart_committed}\"; then " \
+ "setenv mmcpart_committed ${mmcpart};" \
+   "saveenv;" \
+ "fi;\0" \
"bootlimit=3\0" \
-   "loadimage=load mmc ${mmcdev}:${mmcpart} ${loadaddr} boot/${image}\0" \
-   "loadfdt=load mmc ${mmcdev}:${mmcpart} ${fdt_addr} boot/${fdtfile}\0" \
+   "loadimage=load mmc ${mmcdev}:${mmcpart_committed} ${loadaddr} 
boot/${image}\0" \
+   "loadfdt=load mmc ${mmcdev}:${mmcpart_committed} ${fdt_addr} 
boot/${fdtfile}\0" \
"mmcboot=echo Booting from mmc ...; " \
+ "run commit_mmc; " \
"run mmcargs; " \
"if run loadfdt; then " \
"if bootz ${loadaddr} - ${fdt_addr}; then " \
@@ -48,10 +54,12 @@
"run altbootcmd; " \
"fi;\0" \
"altbootcmd=echo Performing rollback...; " \
-   "if test \"${mmcpart}\" = 1; then " \
+   "if test \"${mmcpart_committed}\" = 1; then " \
"setenv mmcpart 2; " \
+   "setenv mmcpart_committed 2;" \
"else " \
"setenv mmcpart 1; " \
+   "setenv mmcpart_committed 1;" \
"fi; setenv bootcount 0; setenv upgrade_available; setenv 
ustate 3; saveenv; " \
"run bootcmd;\0"
 
-- 
2.38.1



[PATCH v2 05/13] smegw01: Run altbootcmd in the case of failure

2023-04-21 Thread Fabio Estevam
From: Eduard Strehlau 

Run the altbootcmd script if any step of bootcmd fails.

This ensures that always a valid image can be run.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
Changes since v1:
- None

 configs/smegw01_defconfig | 2 +-
 include/configs/smegw01.h | 8 +++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/configs/smegw01_defconfig b/configs/smegw01_defconfig
index 418151a6de..b3580d5d6e 100644
--- a/configs/smegw01_defconfig
+++ b/configs/smegw01_defconfig
@@ -18,7 +18,7 @@ CONFIG_SYS_MEMTEST_END=0xa000
 CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_USE_BOOTCOMMAND=y
-CONFIG_BOOTCOMMAND="if test \"${ustate}\" = 1; then setenv upgrade_available 
1; saveenv; fi; if run loadimage; then run mmcboot; fi; "
+CONFIG_BOOTCOMMAND="if test \"${ustate}\" = 1; then setenv upgrade_available 
1; saveenv; fi; if run loadimage; then run mmcboot; else run altbootcmd; fi; "
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_MAXARGS=32
 CONFIG_SYS_PBSIZE=532
diff --git a/include/configs/smegw01.h b/include/configs/smegw01.h
index 6ee4acc70d..05edaac42f 100644
--- a/include/configs/smegw01.h
+++ b/include/configs/smegw01.h
@@ -39,7 +39,13 @@
"mmcboot=echo Booting from mmc ...; " \
"run mmcargs; " \
"if run loadfdt; then " \
-   "bootz ${loadaddr} - ${fdt_addr}; " \
+   "if bootz ${loadaddr} - ${fdt_addr}; then " \
+   "; " \
+   "else " \
+   "run altbootcmd; " \
+   "fi;" \
+   "else " \
+   "run altbootcmd; " \
"fi;\0" \
"altbootcmd=echo Performing rollback...; " \
"if test \"${mmcpart}\" = 1; then " \
-- 
2.38.1



[PATCH v2 04/13] smegw01: Add altbootcmd

2023-04-21 Thread Fabio Estevam
From: Eduard Strehlau 

Add an altbootcmd script, which is convenient way to integrate with
swupdate and perform a roll back of the previous working version in the
case of update failure.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
Changes since v1:
- None

 configs/smegw01_defconfig | 2 +-
 include/configs/smegw01.h | 8 
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/configs/smegw01_defconfig b/configs/smegw01_defconfig
index 5d9d419463..418151a6de 100644
--- a/configs/smegw01_defconfig
+++ b/configs/smegw01_defconfig
@@ -18,7 +18,7 @@ CONFIG_SYS_MEMTEST_END=0xa000
 CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_USE_BOOTCOMMAND=y
-CONFIG_BOOTCOMMAND="if run loadimage; then run mmcboot; fi; "
+CONFIG_BOOTCOMMAND="if test \"${ustate}\" = 1; then setenv upgrade_available 
1; saveenv; fi; if run loadimage; then run mmcboot; fi; "
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_MAXARGS=32
 CONFIG_SYS_PBSIZE=532
diff --git a/include/configs/smegw01.h b/include/configs/smegw01.h
index a356f095a6..6ee4acc70d 100644
--- a/include/configs/smegw01.h
+++ b/include/configs/smegw01.h
@@ -33,6 +33,7 @@
"mmcargs=setenv bootargs console=${console},${baudrate} " \
"root=/dev/mmcblk0p${mmcpart} rootwait rw " \
__stringify(EXTRA_BOOTPARAMS) "\0" \
+   "bootlimit=3\0" \
"loadimage=load mmc ${mmcdev}:${mmcpart} ${loadaddr} boot/${image}\0" \
"loadfdt=load mmc ${mmcdev}:${mmcpart} ${fdt_addr} boot/${fdtfile}\0" \
"mmcboot=echo Booting from mmc ...; " \
@@ -40,6 +41,13 @@
"if run loadfdt; then " \
"bootz ${loadaddr} - ${fdt_addr}; " \
"fi;\0" \
+   "altbootcmd=echo Performing rollback...; " \
+   "if test \"${mmcpart}\" = 1; then " \
+   "setenv mmcpart 2; " \
+   "else " \
+   "setenv mmcpart 1; " \
+   "fi; setenv bootcount 0; setenv upgrade_available; setenv 
ustate 3; saveenv; " \
+   "run bootcmd;\0"
 
 /* Physical Memory Map */
 #define PHYS_SDRAM MMDC0_ARB_BASE_ADDR
-- 
2.38.1



[PATCH v2 03/13] smegw01: Select bootcount support

2023-04-21 Thread Fabio Estevam
From: Eduard Strehlau 

Add automatic boot counter that increases after every
reset. After a power-on reset, it will be initialized with 1,
and each reboot will increment the value by 1. By default it is
disabled if bootlimit isn't set.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
Changes since v1:
- None

 configs/smegw01_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configs/smegw01_defconfig b/configs/smegw01_defconfig
index f15291f1dd..5d9d419463 100644
--- a/configs/smegw01_defconfig
+++ b/configs/smegw01_defconfig
@@ -46,6 +46,8 @@ CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_BOUNCE_BUFFER=y
+CONFIG_BOOTCOUNT_LIMIT=y
+CONFIG_BOOTCOUNT_ENV=y
 CONFIG_DFU_MMC=y
 CONFIG_DM_I2C=y
 CONFIG_SUPPORT_EMMC_BOOT=y
-- 
2.38.1



[PATCH v2 02/13] smegw01: Select CONFIG_CMD_SQUASHFS

2023-04-21 Thread Fabio Estevam
From: Eduard Strehlau 

Select CONFIG_CMD_SQUASHFS so that the SquashFS U-Boot commands
are available.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
Changes since v1:
- None

 configs/smegw01_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/smegw01_defconfig b/configs/smegw01_defconfig
index 1e0b9aa5be..f15291f1dd 100644
--- a/configs/smegw01_defconfig
+++ b/configs/smegw01_defconfig
@@ -38,6 +38,7 @@ CONFIG_CMD_EXT2=y
 CONFIG_CMD_EXT4=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_CMD_FAT=y
+CONFIG_CMD_SQUASHFS=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_OF_CONTROL=y
 CONFIG_ENV_OVERWRITE=y
-- 
2.38.1



[PATCH v2 01/13] smegw01: Enable setting additional boot params

2023-04-21 Thread Fabio Estevam
From: Eduard Strehlau 

Introduce EXTRA_BOOTPARAMS to allow passing additional parameters
to kernel command line. This is useful for debugging purposes.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
Changes since v1:
- None

 include/configs/smegw01.h | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/include/configs/smegw01.h b/include/configs/smegw01.h
index 11031744be..a356f095a6 100644
--- a/include/configs/smegw01.h
+++ b/include/configs/smegw01.h
@@ -17,6 +17,11 @@
 /* MMC Config*/
 #define CFG_SYS_FSL_ESDHC_ADDR 0
 
+/* default to no extra bootparams, we need an empty define for 
stringification*/
+#ifndef EXTRA_BOOTPARAMS
+#define EXTRA_BOOTPARAMS
+#endif
+
 #define CFG_EXTRA_ENV_SETTINGS \
"image=zImage\0" \
"console=ttymxc0\0" \
@@ -26,7 +31,8 @@
"mmcdev=0\0" \
"mmcpart=1\0" \
"mmcargs=setenv bootargs console=${console},${baudrate} " \
-   "root=/dev/mmcblk0p${mmcpart} rootwait rw\0" \
+   "root=/dev/mmcblk0p${mmcpart} rootwait rw " \
+   __stringify(EXTRA_BOOTPARAMS) "\0" \
"loadimage=load mmc ${mmcdev}:${mmcpart} ${loadaddr} boot/${image}\0" \
"loadfdt=load mmc ${mmcdev}:${mmcpart} ${fdt_addr} boot/${fdtfile}\0" \
"mmcboot=echo Booting from mmc ...; " \
-- 
2.38.1



[PATCH 13/13] smegw01: Fix fallback to altbootcmd

2023-04-18 Thread Fabio Estevam
From: Eduard Strehlau 

The bootcmd/altbootcmd mechanism is not invoked for bootmenus.
Manually compare bootcount and bootlimit to implement fallback on all
codepaths.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
 configs/smegw01_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configs/smegw01_defconfig b/configs/smegw01_defconfig
index fe8152f33e..3d2713f528 100644
--- a/configs/smegw01_defconfig
+++ b/configs/smegw01_defconfig
@@ -23,7 +23,7 @@ CONFIG_AUTOBOOT_MENU_SHOW=y
 # CONFIG_CMD_BOOTEFI_BOOTMGR is not set
 CONFIG_BOOTMENU_DISABLE_UBOOT_CONSOLE=y
 CONFIG_USE_BOOTCOMMAND=y
-CONFIG_BOOTCOMMAND="if test \"${ustate}\" = 1; then setenv upgrade_available 
1; saveenv; fi; run mmcboot; "
+CONFIG_BOOTCOMMAND="if test \"${bootcount}\" -gt \"${bootlimit}\"; then run 
altbootcmd; else if test \"${ustate}\" = 1; then setenv upgrade_available 1; 
saveenv; fi; run mmcboot; fi;"
 CONFIG_USE_PREBOOT=y
 CONFIG_PREBOOT="run setup_boot_menu;"
 CONFIG_HUSH_PARSER=y
-- 
2.38.1



[PATCH 12/13] smegw01: Disable additional boot menu options

2023-04-18 Thread Fabio Estevam
From: Eduard Strehlau 

Defaults have changed, we do not want the bootmenu to contain EFI
options.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
 configs/smegw01_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configs/smegw01_defconfig b/configs/smegw01_defconfig
index ea25b3b87c..fe8152f33e 100644
--- a/configs/smegw01_defconfig
+++ b/configs/smegw01_defconfig
@@ -19,6 +19,8 @@ CONFIG_SYS_MEMTEST_END=0xa000
 CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_AUTOBOOT_MENU_SHOW=y
+# CONFIG_BOOTSTD is not set
+# CONFIG_CMD_BOOTEFI_BOOTMGR is not set
 CONFIG_BOOTMENU_DISABLE_UBOOT_CONSOLE=y
 CONFIG_USE_BOOTCOMMAND=y
 CONFIG_BOOTCOMMAND="if test \"${ustate}\" = 1; then setenv upgrade_available 
1; saveenv; fi; run mmcboot; "
-- 
2.38.1



[PATCH 11/13] smegmac: Read the second MAC address

2023-04-18 Thread Fabio Estevam
From: Fabio Estevam 

Currently, only the first MAC address is read from the fuses.

The second MAC address is not read and Linux assigns a random one.

To prevent this behavior, read the second MAC address from the fuses
and store it into the eth1addr environment variable so that it
can be passed to Linux.

Signed-off-by: Fabio Estevam 
---
 board/storopack/smegw01/smegw01.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/board/storopack/smegw01/smegw01.c 
b/board/storopack/smegw01/smegw01.c
index e786429476..605253ead3 100644
--- a/board/storopack/smegw01/smegw01.c
+++ b/board/storopack/smegw01/smegw01.c
@@ -82,6 +82,7 @@ int board_init(void)
 int board_late_init(void)
 {
struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR;
+   unsigned char eth1addr[6];
 
imx_iomux_v3_setup_multiple_pads(wdog_pads, ARRAY_SIZE(wdog_pads));
 
@@ -93,6 +94,11 @@ int board_late_init(void)
 */
clrsetbits_le16(>wcr, 0, 0x10);
 
+   /* Get the second MAC address */
+   imx_get_mac_from_fuse(1, eth1addr);
+   if (!env_get("eth1addr") && is_valid_ethaddr(eth1addr))
+   eth_env_set_enetaddr("eth1addr", eth1addr);
+
return 0;
 }
 
-- 
2.38.1



[PATCH 10/13] smegw01: Add lockdown U-Boot env support

2023-04-18 Thread Fabio Estevam
From: Eduard Strehlau 

Add lockdown U-Boot env support so that only certain U-Boot environment
variables are allowed to be modified.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
 board/storopack/smegw01/Kconfig   |  7 +
 board/storopack/smegw01/smegw01.c | 17 +++
 configs/smegw01_defconfig | 11 ++-
 include/configs/smegw01.h | 48 +--
 4 files changed, 79 insertions(+), 4 deletions(-)

diff --git a/board/storopack/smegw01/Kconfig b/board/storopack/smegw01/Kconfig
index d8f24695d0..390214c285 100644
--- a/board/storopack/smegw01/Kconfig
+++ b/board/storopack/smegw01/Kconfig
@@ -12,4 +12,11 @@ config SYS_CONFIG_NAME
 config IMX_CONFIG
default "board/storopack/smegw01/imximage.cfg"
 
+config SYS_BOOT_LOCKED
+   bool "Lock boot process to EMMC"
+   default y
+   help
+ Say N here if you want to boot from eMMC and SD.
+ Say Y to boot from eMMC.
+
 endif
diff --git a/board/storopack/smegw01/smegw01.c 
b/board/storopack/smegw01/smegw01.c
index 9482f88773..e786429476 100644
--- a/board/storopack/smegw01/smegw01.c
+++ b/board/storopack/smegw01/smegw01.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -113,3 +114,19 @@ uint mmc_get_env_part(struct mmc *mmc)
 
return part;
 }
+
+enum env_location env_get_location(enum env_operation op, int prio)
+{
+   if (op == ENVOP_SAVE || op == ENVOP_ERASE)
+   return ENVL_MMC;
+
+   switch (prio) {
+   case 0:
+   return ENVL_NOWHERE;
+
+   case 1:
+   return ENVL_MMC;
+   }
+
+   return ENVL_UNKNOWN;
+}
diff --git a/configs/smegw01_defconfig b/configs/smegw01_defconfig
index 54cf1cfc1f..ea25b3b87c 100644
--- a/configs/smegw01_defconfig
+++ b/configs/smegw01_defconfig
@@ -7,6 +7,7 @@ CONFIG_ENV_OFFSET=0x10
 CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="imx7d-smegw01"
 CONFIG_TARGET_SMEGW01=y
+# CONFIG_SYS_BOOT_LOCKED is not set
 CONFIG_ENV_OFFSET_REDUND=0x11
 CONFIG_ARMV7_BOOT_SEC_DEFAULT=y
 # CONFIG_ARMV7_VIRT is not set
@@ -17,13 +18,18 @@ CONFIG_SYS_MEMTEST_START=0x8000
 CONFIG_SYS_MEMTEST_END=0xa000
 CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
+CONFIG_AUTOBOOT_MENU_SHOW=y
+CONFIG_BOOTMENU_DISABLE_UBOOT_CONSOLE=y
 CONFIG_USE_BOOTCOMMAND=y
-CONFIG_BOOTCOMMAND="if test \"${ustate}\" = 1; then setenv upgrade_available 
1; saveenv; fi; if run loadimage; then run mmcboot; else run altbootcmd; fi; "
+CONFIG_BOOTCOMMAND="if test \"${ustate}\" = 1; then setenv upgrade_available 
1; saveenv; fi; run mmcboot; "
+CONFIG_USE_PREBOOT=y
+CONFIG_PREBOOT="run setup_boot_menu;"
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_MAXARGS=32
 CONFIG_SYS_PBSIZE=532
 # CONFIG_CMD_BOOTD is not set
 CONFIG_CMD_BOOTZ=y
+CONFIG_CMD_BOOTMENU=y
 # CONFIG_CMD_IMI is not set
 # CONFIG_CMD_XIMG is not set
 CONFIG_CMD_MEMTEST=y
@@ -43,9 +49,12 @@ CONFIG_CMD_SQUASHFS=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_OF_CONTROL=y
 CONFIG_ENV_OVERWRITE=y
+CONFIG_ENV_IS_NOWHERE=y
 CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_SYS_MMC_ENV_DEV=1
+CONFIG_ENV_WRITEABLE_LIST=y
+CONFIG_ENV_ACCESS_IGNORE_FORCE=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_BOUNCE_BUFFER=y
 CONFIG_BOOTCOUNT_LIMIT=y
diff --git a/include/configs/smegw01.h b/include/configs/smegw01.h
index 8521883277..6f373973ab 100644
--- a/include/configs/smegw01.h
+++ b/include/configs/smegw01.h
@@ -22,6 +22,32 @@
 #define EXTRA_BOOTPARAMS
 #endif
 
+#ifdef CONFIG_SYS_BOOT_LOCKED
+#define EXTRA_ENV_FLAGS
+#define SETUP_BOOT_MENU "setup_boot_menu=setenv bootmenu_0 eMMC=run bootcmd\0"
+#else
+#define EXTRA_ENV_FLAGS "mmcdev:dw,"
+#define SETUP_BOOT_MENU "setup_boot_menu=" \
+   "if test \"${mmcdev}\" = 1; then " \
+   "setenv emmc_priority 0;" \
+   "setenv sd_priority 1;" \
+   "else " \
+   "setenv emmc_priority 1;" \
+   "setenv sd_priority 0;" \
+   "fi;" \
+   "setenv bootmenu_${emmc_priority} eMMC=run boot_emmc;" \
+   "setenv bootmenu_${sd_priority} SD=run boot_sd;\0"
+#endif
+
+#define CFG_ENV_FLAGS_LIST_STATIC \
+   "mmcpart:dw," \
+   "mmcpart_committed:dw," \
+   "ustate:dw," \
+   "bootcount:dw," \
+   "bootlimit:dw," \
+   "upgrade_available:dw," \
+   EXTRA_ENV_FLAGS
+
 #define CFG_EXTRA_ENV_SETTINGS \
"image=fitImage\0" \
"console=ttymxc0\0" \
@@ -40,13 +66,28 @@
  "fi;\0" \
"bootlimit=3\0" \
"fit_addr=0x8800\0" \
-   "loadimage=load mmc ${mmcdev}#rootfs-${mmcpart_committed} ${fit_addr} 
boot/${image}\0" 

[PATCH 09/13] smegw01: Switch to fitImage

2023-04-18 Thread Fabio Estevam
From: Eduard Strehlau 

Instead of loading the zImage kernel and the devicetree separately, switch
to the fitImage format, which is more convenient when working with secure
boot, for example.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
 include/configs/smegw01.h | 14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/include/configs/smegw01.h b/include/configs/smegw01.h
index 8f68472f5b..8521883277 100644
--- a/include/configs/smegw01.h
+++ b/include/configs/smegw01.h
@@ -23,7 +23,7 @@
 #endif
 
 #define CFG_EXTRA_ENV_SETTINGS \
-   "image=zImage\0" \
+   "image=fitImage\0" \
"console=ttymxc0\0" \
"fdtfile=imx7d-smegw01.dtb\0" \
"fdt_addr=0x8300\0" \
@@ -39,8 +39,8 @@
"saveenv;" \
  "fi;\0" \
"bootlimit=3\0" \
-   "loadimage=load mmc ${mmcdev}#rootfs-${mmcpart_committed} ${loadaddr} 
boot/${image}\0" \
-   "loadfdt=load mmc ${mmcdev}#rootfs-${mmcpart_committed} ${fdt_addr} 
boot/${fdtfile}\0" \
+   "fit_addr=0x8800\0" \
+   "loadimage=load mmc ${mmcdev}#rootfs-${mmcpart_committed} ${fit_addr} 
boot/${image}\0" \
"loadpart=gpt setenv mmc ${mmcdev} rootfs-${mmcpart_committed}\0" \
"loadbootpart=mmc partconf 1 boot_part\0" \
"mmcboot=echo Booting from mmc ...; " \
@@ -48,12 +48,8 @@
"run loadpart; " \
"run loadbootpart; " \
"run mmcargs; " \
-   "if run loadfdt; then " \
-   "if bootz ${loadaddr} - ${fdt_addr}; then " \
-   "; " \
-   "else " \
-   "run altbootcmd; " \
-   "fi;" \
+   "if bootm ${fit_addr}; then " \
+   "; " \
"else " \
"run altbootcmd; " \
"fi;\0" \
-- 
2.38.1



[PATCH 08/13] smegw01: Change default boot device to eMMC

2023-04-18 Thread Fabio Estevam
From: Eduard Strehlau 

Let eMMC be the default boot medium.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
 include/configs/smegw01.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/configs/smegw01.h b/include/configs/smegw01.h
index 71f2d9c8e8..8f68472f5b 100644
--- a/include/configs/smegw01.h
+++ b/include/configs/smegw01.h
@@ -28,7 +28,7 @@
"fdtfile=imx7d-smegw01.dtb\0" \
"fdt_addr=0x8300\0" \
"bootm_size=0x1000\0" \
-   "mmcdev=0\0" \
+   "mmcdev=1\0" \
"mmcpart=1\0" \
"mmcpart_committed=1\0" \
"mmcargs=setenv bootargs console=${console},${baudrate} " \
-- 
2.38.1



[PATCH 06/13] smegw01: Only commit to new partition if update was successful

2023-04-18 Thread Fabio Estevam
From: Eduard Strehlau 

When performing rootfs update via swupdate, it is convenient to check the
'ustate' variable to decide whether the update succeeded or not.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
 include/configs/smegw01.h | 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/include/configs/smegw01.h b/include/configs/smegw01.h
index 05edaac42f..277c828d0e 100644
--- a/include/configs/smegw01.h
+++ b/include/configs/smegw01.h
@@ -30,13 +30,19 @@
"bootm_size=0x1000\0" \
"mmcdev=0\0" \
"mmcpart=1\0" \
+   "mmcpart_committed=1\0" \
"mmcargs=setenv bootargs console=${console},${baudrate} " \
-   "root=/dev/mmcblk0p${mmcpart} rootwait rw " \
+   "root=/dev/mmcblk0p${mmcpart_committed} rootwait rw " \
__stringify(EXTRA_BOOTPARAMS) "\0" \
+   "commit_mmc=if test \"${ustate}\" = 1 -a \"${mmcpart}\" != 
\"${mmcpart_committed}\"; then " \
+ "setenv mmcpart_committed ${mmcpart};" \
+   "saveenv;" \
+ "fi;\0" \
"bootlimit=3\0" \
-   "loadimage=load mmc ${mmcdev}:${mmcpart} ${loadaddr} boot/${image}\0" \
-   "loadfdt=load mmc ${mmcdev}:${mmcpart} ${fdt_addr} boot/${fdtfile}\0" \
+   "loadimage=load mmc ${mmcdev}:${mmcpart_committed} ${loadaddr} 
boot/${image}\0" \
+   "loadfdt=load mmc ${mmcdev}:${mmcpart_committed} ${fdt_addr} 
boot/${fdtfile}\0" \
"mmcboot=echo Booting from mmc ...; " \
+ "run commit_mmc; " \
"run mmcargs; " \
"if run loadfdt; then " \
"if bootz ${loadaddr} - ${fdt_addr}; then " \
@@ -48,10 +54,12 @@
"run altbootcmd; " \
"fi;\0" \
"altbootcmd=echo Performing rollback...; " \
-   "if test \"${mmcpart}\" = 1; then " \
+   "if test \"${mmcpart_committed}\" = 1; then " \
"setenv mmcpart 2; " \
+   "setenv mmcpart_committed 2;" \
"else " \
"setenv mmcpart 1; " \
+   "setenv mmcpart_committed 1;" \
"fi; setenv bootcount 0; setenv upgrade_available; setenv 
ustate 3; saveenv; " \
"run bootcmd;\0"
 
-- 
2.38.1



[PATCH 07/13] smegw01: Enable EMMC boot from multiple partitions

2023-04-18 Thread Fabio Estevam
From: Eduard Strehlau 

GPT Partition labels are used for determining the right
root filesystem to boot from.

The U-Boot environment is configured to reside in the eMMC hardware
boot partition we are currently booted from.

This should enable a dual copy approach for upgrading the bootloader.
One can overwrite the inactive hardware partition with new bootloader
and environment and afterwards switch the eMMC boot partition for an
atomic bootloader switch.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
 board/storopack/smegw01/smegw01.c | 20 
 configs/smegw01_defconfig |  2 ++
 include/configs/smegw01.h | 12 
 3 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/board/storopack/smegw01/smegw01.c 
b/board/storopack/smegw01/smegw01.c
index e6bff80e55..9482f88773 100644
--- a/board/storopack/smegw01/smegw01.c
+++ b/board/storopack/smegw01/smegw01.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -93,3 +94,22 @@ int board_late_init(void)
 
return 0;
 }
+
+/* defined in JESD84-B50, PARTITION_CONFIG */
+#define BOOT_PARTITION_ENABLE_MASK (0x7)
+#define BOOT_PARTITION_ENABLE_SHIFT (0x3)
+
+uint mmc_get_env_part(struct mmc *mmc)
+{
+   uint part = (mmc->part_config >> BOOT_PARTITION_ENABLE_SHIFT) &
+   BOOT_PARTITION_ENABLE_MASK;
+   /* Default to Boot Partition 1 if not explicitly set. */
+   if (part != 1 && part != 2 && part != 7)
+   part = 1;
+
+   /* 7 in BOOT_PARTITION_ENABLE is equivalent to 0 in PARTITION_ACCESS. */
+   if (part == 7)
+   part = 0;
+
+   return part;
+}
diff --git a/configs/smegw01_defconfig b/configs/smegw01_defconfig
index b3580d5d6e..54cf1cfc1f 100644
--- a/configs/smegw01_defconfig
+++ b/configs/smegw01_defconfig
@@ -30,6 +30,7 @@ CONFIG_CMD_MEMTEST=y
 CONFIG_CMD_UNZIP=y
 CONFIG_CMD_DFU=y
 CONFIG_CMD_GPIO=y
+CONFIG_CMD_GPT=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_PART=y
 CONFIG_CMD_DHCP=y
@@ -44,6 +45,7 @@ CONFIG_OF_CONTROL=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_SYS_MMC_ENV_DEV=1
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_BOUNCE_BUFFER=y
 CONFIG_BOOTCOUNT_LIMIT=y
diff --git a/include/configs/smegw01.h b/include/configs/smegw01.h
index 277c828d0e..71f2d9c8e8 100644
--- a/include/configs/smegw01.h
+++ b/include/configs/smegw01.h
@@ -32,17 +32,21 @@
"mmcpart=1\0" \
"mmcpart_committed=1\0" \
"mmcargs=setenv bootargs console=${console},${baudrate} " \
-   "root=/dev/mmcblk0p${mmcpart_committed} rootwait rw " \
-   __stringify(EXTRA_BOOTPARAMS) "\0" \
+   "root=/dev/mmcblk${mmcdev}p${gpt_partition_entry} rootwait rw " 
\
+   __stringify(EXTRA_BOOTPARAMS) " SM_ROOT_DEV=${mmcdev} 
SM_ROOT_PART=${gpt_partition_entry} SM_BOOT_PART=${boot_part}\0" \
"commit_mmc=if test \"${ustate}\" = 1 -a \"${mmcpart}\" != 
\"${mmcpart_committed}\"; then " \
  "setenv mmcpart_committed ${mmcpart};" \
"saveenv;" \
  "fi;\0" \
"bootlimit=3\0" \
-   "loadimage=load mmc ${mmcdev}:${mmcpart_committed} ${loadaddr} 
boot/${image}\0" \
-   "loadfdt=load mmc ${mmcdev}:${mmcpart_committed} ${fdt_addr} 
boot/${fdtfile}\0" \
+   "loadimage=load mmc ${mmcdev}#rootfs-${mmcpart_committed} ${loadaddr} 
boot/${image}\0" \
+   "loadfdt=load mmc ${mmcdev}#rootfs-${mmcpart_committed} ${fdt_addr} 
boot/${fdtfile}\0" \
+   "loadpart=gpt setenv mmc ${mmcdev} rootfs-${mmcpart_committed}\0" \
+   "loadbootpart=mmc partconf 1 boot_part\0" \
"mmcboot=echo Booting from mmc ...; " \
  "run commit_mmc; " \
+   "run loadpart; " \
+   "run loadbootpart; " \
"run mmcargs; " \
"if run loadfdt; then " \
"if bootz ${loadaddr} - ${fdt_addr}; then " \
-- 
2.38.1



[PATCH 05/13] smegw01: Run altbootcmd in the case of failure

2023-04-18 Thread Fabio Estevam
From: Eduard Strehlau 

Run the altbootcmd script if any step of bootcmd fails.

This ensures that always a valid image can be run.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
 configs/smegw01_defconfig | 2 +-
 include/configs/smegw01.h | 8 +++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/configs/smegw01_defconfig b/configs/smegw01_defconfig
index 418151a6de..b3580d5d6e 100644
--- a/configs/smegw01_defconfig
+++ b/configs/smegw01_defconfig
@@ -18,7 +18,7 @@ CONFIG_SYS_MEMTEST_END=0xa000
 CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_USE_BOOTCOMMAND=y
-CONFIG_BOOTCOMMAND="if test \"${ustate}\" = 1; then setenv upgrade_available 
1; saveenv; fi; if run loadimage; then run mmcboot; fi; "
+CONFIG_BOOTCOMMAND="if test \"${ustate}\" = 1; then setenv upgrade_available 
1; saveenv; fi; if run loadimage; then run mmcboot; else run altbootcmd; fi; "
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_MAXARGS=32
 CONFIG_SYS_PBSIZE=532
diff --git a/include/configs/smegw01.h b/include/configs/smegw01.h
index 6ee4acc70d..05edaac42f 100644
--- a/include/configs/smegw01.h
+++ b/include/configs/smegw01.h
@@ -39,7 +39,13 @@
"mmcboot=echo Booting from mmc ...; " \
"run mmcargs; " \
"if run loadfdt; then " \
-   "bootz ${loadaddr} - ${fdt_addr}; " \
+   "if bootz ${loadaddr} - ${fdt_addr}; then " \
+   "; " \
+   "else " \
+   "run altbootcmd; " \
+   "fi;" \
+   "else " \
+   "run altbootcmd; " \
"fi;\0" \
"altbootcmd=echo Performing rollback...; " \
"if test \"${mmcpart}\" = 1; then " \
-- 
2.38.1



[PATCH 04/13] smegw01: Add altbootcmd

2023-04-18 Thread Fabio Estevam
From: Eduard Strehlau 

Add an altbootcmd script, which is convenient way to integrate with
swupdate and perform a roll back of the previous working version in the
case of update failure.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
 configs/smegw01_defconfig | 2 +-
 include/configs/smegw01.h | 8 
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/configs/smegw01_defconfig b/configs/smegw01_defconfig
index 5d9d419463..418151a6de 100644
--- a/configs/smegw01_defconfig
+++ b/configs/smegw01_defconfig
@@ -18,7 +18,7 @@ CONFIG_SYS_MEMTEST_END=0xa000
 CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_USE_BOOTCOMMAND=y
-CONFIG_BOOTCOMMAND="if run loadimage; then run mmcboot; fi; "
+CONFIG_BOOTCOMMAND="if test \"${ustate}\" = 1; then setenv upgrade_available 
1; saveenv; fi; if run loadimage; then run mmcboot; fi; "
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_MAXARGS=32
 CONFIG_SYS_PBSIZE=532
diff --git a/include/configs/smegw01.h b/include/configs/smegw01.h
index a356f095a6..6ee4acc70d 100644
--- a/include/configs/smegw01.h
+++ b/include/configs/smegw01.h
@@ -33,6 +33,7 @@
"mmcargs=setenv bootargs console=${console},${baudrate} " \
"root=/dev/mmcblk0p${mmcpart} rootwait rw " \
__stringify(EXTRA_BOOTPARAMS) "\0" \
+   "bootlimit=3\0" \
"loadimage=load mmc ${mmcdev}:${mmcpart} ${loadaddr} boot/${image}\0" \
"loadfdt=load mmc ${mmcdev}:${mmcpart} ${fdt_addr} boot/${fdtfile}\0" \
"mmcboot=echo Booting from mmc ...; " \
@@ -40,6 +41,13 @@
"if run loadfdt; then " \
"bootz ${loadaddr} - ${fdt_addr}; " \
"fi;\0" \
+   "altbootcmd=echo Performing rollback...; " \
+   "if test \"${mmcpart}\" = 1; then " \
+   "setenv mmcpart 2; " \
+   "else " \
+   "setenv mmcpart 1; " \
+   "fi; setenv bootcount 0; setenv upgrade_available; setenv 
ustate 3; saveenv; " \
+   "run bootcmd;\0"
 
 /* Physical Memory Map */
 #define PHYS_SDRAM MMDC0_ARB_BASE_ADDR
-- 
2.38.1



[PATCH 03/13] smegw01: Select bootcount support

2023-04-18 Thread Fabio Estevam
From: Eduard Strehlau 

Add automatic boot counter that increases after every
reset. After a power-on reset, it will be initialized with 1,
and each reboot will increment the value by 1. By default it is
disabled if bootlimit isn't set.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
 configs/smegw01_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configs/smegw01_defconfig b/configs/smegw01_defconfig
index f15291f1dd..5d9d419463 100644
--- a/configs/smegw01_defconfig
+++ b/configs/smegw01_defconfig
@@ -46,6 +46,8 @@ CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_BOUNCE_BUFFER=y
+CONFIG_BOOTCOUNT_LIMIT=y
+CONFIG_BOOTCOUNT_ENV=y
 CONFIG_DFU_MMC=y
 CONFIG_DM_I2C=y
 CONFIG_SUPPORT_EMMC_BOOT=y
-- 
2.38.1



[PATCH 02/13] smegw01: Select CONFIG_CMD_SQUASHFS

2023-04-18 Thread Fabio Estevam
From: Eduard Strehlau 

Select CONFIG_CMD_SQUASHFS so that the SquashFS U-Boot commands
are available.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
 configs/smegw01_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/smegw01_defconfig b/configs/smegw01_defconfig
index 1e0b9aa5be..f15291f1dd 100644
--- a/configs/smegw01_defconfig
+++ b/configs/smegw01_defconfig
@@ -38,6 +38,7 @@ CONFIG_CMD_EXT2=y
 CONFIG_CMD_EXT4=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_CMD_FAT=y
+CONFIG_CMD_SQUASHFS=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_OF_CONTROL=y
 CONFIG_ENV_OVERWRITE=y
-- 
2.38.1



[PATCH 01/13] smegw01: Enable setting additional boot params

2023-04-18 Thread Fabio Estevam
From: Eduard Strehlau 

Introduce EXTRA_BOOTPARAMS to allow passing additional parameters
to kernel command line. This is useful for debugging purposes.

Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
 include/configs/smegw01.h | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/include/configs/smegw01.h b/include/configs/smegw01.h
index 11031744be..a356f095a6 100644
--- a/include/configs/smegw01.h
+++ b/include/configs/smegw01.h
@@ -17,6 +17,11 @@
 /* MMC Config*/
 #define CFG_SYS_FSL_ESDHC_ADDR 0
 
+/* default to no extra bootparams, we need an empty define for 
stringification*/
+#ifndef EXTRA_BOOTPARAMS
+#define EXTRA_BOOTPARAMS
+#endif
+
 #define CFG_EXTRA_ENV_SETTINGS \
"image=zImage\0" \
"console=ttymxc0\0" \
@@ -26,7 +31,8 @@
"mmcdev=0\0" \
"mmcpart=1\0" \
"mmcargs=setenv bootargs console=${console},${baudrate} " \
-   "root=/dev/mmcblk0p${mmcpart} rootwait rw\0" \
+   "root=/dev/mmcblk0p${mmcpart} rootwait rw " \
+   __stringify(EXTRA_BOOTPARAMS) "\0" \
"loadimage=load mmc ${mmcdev}:${mmcpart} ${loadaddr} boot/${image}\0" \
"loadfdt=load mmc ${mmcdev}:${mmcpart} ${fdt_addr} boot/${fdtfile}\0" \
"mmcboot=echo Booting from mmc ...; " \
-- 
2.38.1



Re: [PATCH] usb: onboard-hub: Don't disable regulator in remove() callback

2023-04-18 Thread Fabio Estevam
Hi Patrice and Marek,

On Tue, Apr 18, 2023 at 4:22 AM Patrice CHOTARD
 wrote:

> > Isn't the regulator enable/disable refcounted ?
>
> There is no refcount on regulator that's why we let regulator enable.

There is a recent patch from Eugen that adds regulator refcount support:

https://lore.kernel.org/u-boot/20230331091549.149095-1-eugen.hris...@collabora.com/


[PATCH] pico-imx6ul: Convert to CONFIG_DM_SERIAL

2023-04-16 Thread Fabio Estevam
From: Fabio Estevam 

The conversion to CONFIG_DM_SERIAL is mandatory, so select
this option.

Signed-off-by: Fabio Estevam 
---
 configs/pico-imx6ul_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/pico-imx6ul_defconfig b/configs/pico-imx6ul_defconfig
index dcee179fcffb..4e60159a4624 100644
--- a/configs/pico-imx6ul_defconfig
+++ b/configs/pico-imx6ul_defconfig
@@ -76,6 +76,7 @@ CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_PFUZE100=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_USB=y
 CONFIG_USB_MAX_CONTROLLER_COUNT=2
-- 
2.34.1


[PATCH v4] ARM: dts: imx7d-sdb-u-boot: Fix usdhc1 UHS operation

2023-04-12 Thread Fabio Estevam
From: Fabio Estevam 

Commit 1a7904fdfa7d ("mmc: fsl_esdhc_imx: Use esdhc_soc_data
flags to set host caps") exposed the following SD card error:

U-Boot 2023.04-00652-g487e42f7bc5e (Apr 05 2023 - 22:14:21 -0300)

CPU:   Freescale i.MX7D rev1.0 1000 MHz (running at 792 MHz)
CPU:   Commercial temperature grade (0C to 95C) at 35C
Reset cause: POR
Model: Freescale i.MX7 SabreSD Board
Board: i.MX7D SABRESD in non-secure mode
DRAM:  1 GiB
Core:  100 devices, 19 uclasses, devicetree: separate
PMIC: PFUZE3000 DEV_ID=0x30 REV_ID=0x10
MMC:   FSL_SDHC: 0, FSL_SDHC: 1, FSL_SDHC: 2
Loading Environment from MMC... Card did not respond to voltage
select! : -110
*** Warning - No block device, using default environment

The reason of the problem, as explained by Ye Li:

"When UHS is enabled in defconfig, the usdhc1 node in imx7d-sdb.dts does
not configure pad for VSELECT, also the data pad should be set to
100Mhz/200Mhz pin states."

Apply these changes into u-boot.dtsi for now. When these changes
reach the Linux mainline imx7d-sdb, they can be dropped from u-boot.dtsi.

This fixes UHS mode on the imx7d-sdb board.

Suggested-by: Ye Li 
Signed-off-by: Fabio Estevam 
---
Changes since v3:
- Fixed a typo on the pinctrl_usdhc1 node.

 arch/arm/dts/imx7d-sdb-u-boot.dtsi | 51 ++
 1 file changed, 51 insertions(+)

diff --git a/arch/arm/dts/imx7d-sdb-u-boot.dtsi 
b/arch/arm/dts/imx7d-sdb-u-boot.dtsi
index b78358fa1397..913127b5e3c2 100644
--- a/arch/arm/dts/imx7d-sdb-u-boot.dtsi
+++ b/arch/arm/dts/imx7d-sdb-u-boot.dtsi
@@ -5,3 +5,54 @@
  {
dr_mode = "peripheral";
 };
+
+ {
+   pinctrl-names = "default", "state_100mhz", "state_200mhz";
+   pinctrl-0 = <_usdhc1>, <_usdhc1_gpio>;
+   pinctrl-1 = <_usdhc1_100mhz>, <_usdhc1_gpio>;
+   pinctrl-2 = <_usdhc1_200mhz>, <_usdhc1_gpio>;
+};
+
+_usdhc1 {
+   fsl,pins = <
+   MX7D_PAD_SD1_CMD__SD1_CMD   0x59
+   MX7D_PAD_SD1_CLK__SD1_CLK   0x19
+   MX7D_PAD_SD1_DATA0__SD1_DATA0   0x59
+   MX7D_PAD_SD1_DATA1__SD1_DATA1   0x59
+   MX7D_PAD_SD1_DATA2__SD1_DATA2   0x59
+   MX7D_PAD_SD1_DATA3__SD1_DATA3   0x59
+   >;
+};
+
+ {
+   pinctrl_usdhc1_gpio: usdhc1gpiogrp {
+   fsl,pins = <
+   MX7D_PAD_SD1_CD_B__GPIO5_IO00x59 /* CD */
+   MX7D_PAD_SD1_WP__GPIO5_IO1  0x59 /* WP */
+   MX7D_PAD_SD1_RESET_B__GPIO5_IO2 0x59 /* vmmc */
+   MX7D_PAD_GPIO1_IO08__SD1_VSELECT0x59 /* VSELECT 
*/
+   >;
+   };
+
+   pinctrl_usdhc1_100mhz: usdhc1100mhzgrp {
+   fsl,pins = <
+   MX7D_PAD_SD1_CMD__SD1_CMD   0x5a
+   MX7D_PAD_SD1_CLK__SD1_CLK   0x1a
+   MX7D_PAD_SD1_DATA0__SD1_DATA0   0x5a
+   MX7D_PAD_SD1_DATA1__SD1_DATA1   0x5a
+   MX7D_PAD_SD1_DATA2__SD1_DATA2   0x5a
+   MX7D_PAD_SD1_DATA3__SD1_DATA3   0x5a
+   >;
+   };
+
+   pinctrl_usdhc1_200mhz: usdhc1200mhzgrp {
+   fsl,pins = <
+   MX7D_PAD_SD1_CMD__SD1_CMD   0x5b
+   MX7D_PAD_SD1_CLK__SD1_CLK   0x1b
+   MX7D_PAD_SD1_DATA0__SD1_DATA0   0x5b
+   MX7D_PAD_SD1_DATA1__SD1_DATA1   0x5b
+   MX7D_PAD_SD1_DATA2__SD1_DATA2   0x5b
+   MX7D_PAD_SD1_DATA3__SD1_DATA3   0x5b
+   >;
+   };
+};
-- 
2.34.1



[PATCH v3] ARM: dts: imx7d-sdb-u-boot: Fix usdhc1 UHS operation

2023-04-12 Thread Fabio Estevam
From: Fabio Estevam 

Commit 1a7904fdfa7d ("mmc: fsl_esdhc_imx: Use esdhc_soc_data
flags to set host caps") exposed the following SD card error:

U-Boot 2023.04-00652-g487e42f7bc5e (Apr 05 2023 - 22:14:21 -0300)

CPU:   Freescale i.MX7D rev1.0 1000 MHz (running at 792 MHz)
CPU:   Commercial temperature grade (0C to 95C) at 35C
Reset cause: POR
Model: Freescale i.MX7 SabreSD Board
Board: i.MX7D SABRESD in non-secure mode
DRAM:  1 GiB
Core:  100 devices, 19 uclasses, devicetree: separate
PMIC: PFUZE3000 DEV_ID=0x30 REV_ID=0x10
MMC:   FSL_SDHC: 0, FSL_SDHC: 1, FSL_SDHC: 2
Loading Environment from MMC... Card did not respond to voltage
select! : -110
*** Warning - No block device, using default environment

The reason of the problem, as explained by Ye Li:

"When UHS is enabled in defconfig, the usdhc1 node in imx7d-sdb.dts does
not configure pad for VSELECT, also the data pad should be set to
100Mhz/200Mhz pin states."

Apply these changes into u-boot.dtsi for now. When these changes
reach the Linux mainline imx7d-sdb, they can be dropped from u-boot.dtsi.

This fixes UHS mode on the imx7d-sdb board.

Suggested-by: Ye Li 
Signed-off-by: Fabio Estevam 
---
Changes since v2:
- Fixed the devicetree instead of the imx sdhci driver (Ye Li).

 arch/arm/dts/imx7d-sdb-u-boot.dtsi | 51 ++
 1 file changed, 51 insertions(+)

diff --git a/arch/arm/dts/imx7d-sdb-u-boot.dtsi 
b/arch/arm/dts/imx7d-sdb-u-boot.dtsi
index b78358fa1397..913127b5e3c2 100644
--- a/arch/arm/dts/imx7d-sdb-u-boot.dtsi
+++ b/arch/arm/dts/imx7d-sdb-u-boot.dtsi
@@ -5,3 +5,54 @@
  {
dr_mode = "peripheral";
 };
+
+ {
+   pinctrl-names = "default", "state_100mhz", "state_200mhz";
+   pinctrl-0 = <_usdhc1>, <_usdhc1_gpio>;
+   pinctrl-1 = <_usdhc1_100mhz>, <_usdhc1_gpio>;
+   pinctrl-2 = <_usdhc1_200mhz>, <_usdhc1_gpio>;
+};
+
+_uart1 {
+   fsl,pins = <
+   MX7D_PAD_SD1_CMD__SD1_CMD   0x59
+   MX7D_PAD_SD1_CLK__SD1_CLK   0x19
+   MX7D_PAD_SD1_DATA0__SD1_DATA0   0x59
+   MX7D_PAD_SD1_DATA1__SD1_DATA1   0x59
+   MX7D_PAD_SD1_DATA2__SD1_DATA2   0x59
+   MX7D_PAD_SD1_DATA3__SD1_DATA3   0x59
+   >;
+};
+
+ {
+   pinctrl_usdhc1_gpio: usdhc1gpiogrp {
+   fsl,pins = <
+   MX7D_PAD_SD1_CD_B__GPIO5_IO00x59 /* CD */
+   MX7D_PAD_SD1_WP__GPIO5_IO1  0x59 /* WP */
+   MX7D_PAD_SD1_RESET_B__GPIO5_IO2 0x59 /* vmmc */
+   MX7D_PAD_GPIO1_IO08__SD1_VSELECT0x59 /* VSELECT 
*/
+   >;
+   };
+
+   pinctrl_usdhc1_100mhz: usdhc1100mhzgrp {
+   fsl,pins = <
+   MX7D_PAD_SD1_CMD__SD1_CMD   0x5a
+   MX7D_PAD_SD1_CLK__SD1_CLK   0x1a
+   MX7D_PAD_SD1_DATA0__SD1_DATA0   0x5a
+   MX7D_PAD_SD1_DATA1__SD1_DATA1   0x5a
+   MX7D_PAD_SD1_DATA2__SD1_DATA2   0x5a
+   MX7D_PAD_SD1_DATA3__SD1_DATA3   0x5a
+   >;
+   };
+
+   pinctrl_usdhc1_200mhz: usdhc1200mhzgrp {
+   fsl,pins = <
+   MX7D_PAD_SD1_CMD__SD1_CMD   0x5b
+   MX7D_PAD_SD1_CLK__SD1_CLK   0x1b
+   MX7D_PAD_SD1_DATA0__SD1_DATA0   0x5b
+   MX7D_PAD_SD1_DATA1__SD1_DATA1   0x5b
+   MX7D_PAD_SD1_DATA2__SD1_DATA2   0x5b
+   MX7D_PAD_SD1_DATA3__SD1_DATA3   0x5b
+   >;
+   };
+};
-- 
2.34.1



Re: [EXT] Re: [PATCH v2] mmc: fsl_esdhc: Do not set UHS_CAPS based on CONFIG_MMC_UHS_SUPPORT

2023-04-12 Thread Fabio Estevam
Hi Ye Li,

On Wed, Apr 12, 2023 at 6:51 AM Ye Li  wrote:

> Remove the UHS_CAPS is wrong, it will cause UHS-I mode not work.
> I just check the 7d sdb on upstream, it is due to imx7d-sdb.dts change.
> When UHS is enabled in defconfig, the usdhc1 node in imx7d-sdb.dts does not 
> configure pad for VSELECT, also
> the data pad should be set to 100Mhz/200Mhz pin states.
> You can try below changes:

Thanks for your suggestion! I tried it and it works.

I will submit a formal patch.

Thanks


[PATCH v2] mmc: fsl_esdhc: Do not set UHS_CAPS based on CONFIG_MMC_UHS_SUPPORT

2023-04-11 Thread Fabio Estevam
From: Fabio Estevam 

Since commit 1a7904fdfa7d ("mmc: fsl_esdhc_imx: Use esdhc_soc_data flags
to set host caps") the following SD card error is observed on an imx7d-sdb
board:

U-Boot 2023.04-00652-g487e42f7bc5e (Apr 05 2023 - 22:14:21 -0300)

CPU:   Freescale i.MX7D rev1.0 1000 MHz (running at 792 MHz)
CPU:   Commercial temperature grade (0C to 95C) at 35C
Reset cause: POR
Model: Freescale i.MX7 SabreSD Board
Board: i.MX7D SABRESD in non-secure mode
DRAM:  1 GiB
Core:  100 devices, 19 uclasses, devicetree: separate
PMIC: PFUZE3000 DEV_ID=0x30 REV_ID=0x10
MMC:   FSL_SDHC: 0, FSL_SDHC: 1, FSL_SDHC: 2
Loading Environment from MMC... Card did not respond to voltage select! : -110
*** Warning - No block device, using default environment

Setting UHS_CAPS only based on the CONFIG_MMC_UHS_SUPPORT config
option is not correct because UHS_CAPS has the following definition:

 #define UHS_CAPS (MMC_CAP(UHS_SDR12) | MMC_CAP(UHS_SDR25) | \
   MMC_CAP(UHS_SDR50) | MMC_CAP(UHS_SDR104) | \
   MMC_CAP(UHS_DDR50))

and the SD card may not necessarily support all these modes.

Remove the UHS_CAPS setting to fix the SD card regression.

Fixes: 1a7904fdfa7d ("mmc: fsl_esdhc_imx: Use esdhc_soc_data flags to set host 
caps")
Signed-off-by: Fabio Estevam 
---
Changes since v1:
- Remove setting UHS_CAPS completely.

 drivers/mmc/fsl_esdhc_imx.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/mmc/fsl_esdhc_imx.c b/drivers/mmc/fsl_esdhc_imx.c
index 66caf683f7..5e7d9f41b6 100644
--- a/drivers/mmc/fsl_esdhc_imx.c
+++ b/drivers/mmc/fsl_esdhc_imx.c
@@ -1258,13 +1258,6 @@ static int fsl_esdhc_init(struct fsl_esdhc_priv *priv,
esdhc_write32(>tuning_ctrl, val);
}
 
-   /*
-* UHS doesn't have explicit ESDHC flags, so if it's
-* not supported, disable it in config.
-*/
-   if (CONFIG_IS_ENABLED(MMC_UHS_SUPPORT))
-   cfg->host_caps |= UHS_CAPS;
-
if (CONFIG_IS_ENABLED(MMC_HS200_SUPPORT)) {
if (priv->flags & ESDHC_FLAG_HS200)
cfg->host_caps |= MMC_CAP(MMC_HS_200);
-- 
2.34.1



Re: [PATCH] mmc: fsl_esdhc: Fix enablement of UHS mode

2023-04-07 Thread Fabio Estevam
Hi Peng,

On Fri, Apr 7, 2023 at 12:21 AM Peng Fan  wrote:

> The supports_uhs is as below, so this condition check will never have
> UHS_CAPS set even MMC_UHS_SUPPORT selected. This seems not correct fix.

Thanks for your review.

Should we fix it like this instead?

--- a/drivers/mmc/fsl_esdhc_imx.c
+++ b/drivers/mmc/fsl_esdhc_imx.c
@@ -1258,13 +1258,6 @@ static int fsl_esdhc_init(struct fsl_esdhc_priv *priv,
esdhc_write32(>tuning_ctrl, val);
}

-   /*
-* UHS doesn't have explicit ESDHC flags, so if it's
-* not supported, disable it in config.
-*/
-   if (CONFIG_IS_ENABLED(MMC_UHS_SUPPORT))
-   cfg->host_caps |= UHS_CAPS;
-
if (CONFIG_IS_ENABLED(MMC_HS200_SUPPORT)) {
if (priv->flags & ESDHC_FLAG_HS200)
cfg->host_caps |= MMC_CAP(MMC_HS_200);


Setting UHS_CAPS based on CONFIG_MMC_UHS_SUPPORT=y does not look correct.

#define UHS_CAPS (MMC_CAP(UHS_SDR12) | MMC_CAP(UHS_SDR25) | \
  MMC_CAP(UHS_SDR50) | MMC_CAP(UHS_SDR104) | \
  MMC_CAP(UHS_DDR50))

The SD card may not support all these modes.

What do you think?


[PATCH] mmc: fsl_esdhc: Fix enablement of UHS mode

2023-04-06 Thread Fabio Estevam
From: Fabio Estevam 

Since commit 1a7904fdfa7d ("mmc: fsl_esdhc_imx: Use esdhc_soc_data flags
to set host caps") the following SD card error is observed on an imx7d-sdb
board:

U-Boot 2023.04-00652-g487e42f7bc5e (Apr 05 2023 - 22:14:21 -0300)

CPU:   Freescale i.MX7D rev1.0 1000 MHz (running at 792 MHz)
CPU:   Commercial temperature grade (0C to 95C) at 35C
Reset cause: POR
Model: Freescale i.MX7 SabreSD Board
Board: i.MX7D SABRESD in non-secure mode
DRAM:  1 GiB
Core:  100 devices, 19 uclasses, devicetree: separate
PMIC: PFUZE3000 DEV_ID=0x30 REV_ID=0x10
MMC:   FSL_SDHC: 0, FSL_SDHC: 1, FSL_SDHC: 2
Loading Environment from MMC... Card did not respond to voltage select! : -110
*** Warning - No block device, using default environment

Fix the problem by only asserting the UHS_CAPS when supports_uhs() is true
instead of doing it unconditionally, only based on the defconfig option.

Signed-off-by: Fabio Estevam 
---
 drivers/mmc/fsl_esdhc_imx.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/mmc/fsl_esdhc_imx.c b/drivers/mmc/fsl_esdhc_imx.c
index 66caf683f741..bfc94d2a5326 100644
--- a/drivers/mmc/fsl_esdhc_imx.c
+++ b/drivers/mmc/fsl_esdhc_imx.c
@@ -1258,11 +1258,7 @@ static int fsl_esdhc_init(struct fsl_esdhc_priv *priv,
esdhc_write32(>tuning_ctrl, val);
}
 
-   /*
-* UHS doesn't have explicit ESDHC flags, so if it's
-* not supported, disable it in config.
-*/
-   if (CONFIG_IS_ENABLED(MMC_UHS_SUPPORT))
+   if (CONFIG_IS_ENABLED(MMC_UHS_SUPPORT) && 
supports_uhs(cfg->host_caps))
cfg->host_caps |= UHS_CAPS;
 
if (CONFIG_IS_ENABLED(MMC_HS200_SUPPORT)) {
-- 
2.34.1



Re: imx7d-sabresd: Cannot access the SD card

2023-04-05 Thread Fabio Estevam
On Wed, Apr 5, 2023 at 10:21 PM Fabio Estevam  wrote:
>
> Hi Peng and Ye Li,
>
> The following SDHC error is seen when running top of tree U-Boot on an
> imx7d-sabresd board:
>
> U-Boot 2023.04-00652-g487e42f7bc5e (Apr 05 2023 - 22:14:21 -0300)
>
> CPU:   Freescale i.MX7D rev1.0 1000 MHz (running at 792 MHz)
> CPU:   Commercial temperature grade (0C to 95C) at 35C
> Reset cause: POR
> Model: Freescale i.MX7 SabreSD Board
> Board: i.MX7D SABRESD in non-secure mode
> DRAM:  1 GiB
> Core:  100 devices, 19 uclasses, devicetree: separate
> PMIC: PFUZE3000 DEV_ID=0x30 REV_ID=0x10
> MMC:   FSL_SDHC: 0, FSL_SDHC: 1, FSL_SDHC: 2
> Loading Environment from MMC... Card did not respond to voltage select! : -110
> *** Warning - No block device, using default environment

Reverting the commit below makes the SD card work again:

commit 1a7904fdfa7d1974410e9dc9b9bfe8aad7fb1311
Author: Adam Ford 
Date:   Wed Jan 12 07:53:56 2022 -0600

mmc: fsl_esdhc_imx: Use esdhc_soc_data flags to set host caps

The Linux driver automatically can detect and enable UHS, HS200, HS400
and HS400_ES automatically without extra flags being placed into the
device tree.

Right now, for U-Boot to use UHS, HS200 or HS400, the extra flags are
needed in the device tree.  Instead, go through the esdhc_soc_data
flags and enable the host caps where applicable to automatically
    enable higher speeds.

Suggested-by: Fabio Estevam 
Signed-off-by: Adam Ford 

Any suggestions?


imx7d-sabresd: Cannot access the SD card

2023-04-05 Thread Fabio Estevam
Hi Peng and Ye Li,

The following SDHC error is seen when running top of tree U-Boot on an
imx7d-sabresd board:

U-Boot 2023.04-00652-g487e42f7bc5e (Apr 05 2023 - 22:14:21 -0300)

CPU:   Freescale i.MX7D rev1.0 1000 MHz (running at 792 MHz)
CPU:   Commercial temperature grade (0C to 95C) at 35C
Reset cause: POR
Model: Freescale i.MX7 SabreSD Board
Board: i.MX7D SABRESD in non-secure mode
DRAM:  1 GiB
Core:  100 devices, 19 uclasses, devicetree: separate
PMIC: PFUZE3000 DEV_ID=0x30 REV_ID=0x10
MMC:   FSL_SDHC: 0, FSL_SDHC: 1, FSL_SDHC: 2
Loading Environment from MMC... Card did not respond to voltage select! : -110
*** Warning - No block device, using default environment

In:serial
Out:   serial
Err:   serial
SEC0:  RNG instantiated
Net:   eth0: ethernet@30be
Hit any key to stop autoboot:  0
=> saveenv
Saving Environment to MMC... Card did not respond to voltage select! : -110
No block device
Failed (1)

I cannot use the SD card anymore.

If I do the following change:

diff --git a/configs/mx7dsabresd_defconfig b/configs/mx7dsabresd_defconfig
index 26e68d30d267..4c81d1f167e9 100644
--- a/configs/mx7dsabresd_defconfig
+++ b/configs/mx7dsabresd_defconfig
@@ -49,9 +49,6 @@ CONFIG_DM_74X164=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_MXC=y
 CONFIG_SUPPORT_EMMC_BOOT=y
-CONFIG_MMC_IO_VOLTAGE=y
-CONFIG_MMC_UHS_SUPPORT=y
-CONFIG_MMC_HS200_SUPPORT=y
 CONFIG_FSL_USDHC=y
 CONFIG_PHYLIB=y
 CONFIG_PHY_BROADCOM=y

Then the SD card works again.

Any ideas on how this can be properly fixed?

Thanks


Re: [PATCH 2/2] thermal: imx_tmu: Move architecture code into driver

2023-04-04 Thread Fabio Estevam
On Tue, Apr 4, 2023 at 4:25 PM Marek Vasut  wrote:
>
> Stop polluting the architecture directory with driver specific code,
> move it into driver where it should be. Split the code slightly so
> the MX8MM/MX8MN fuse readout and programming and MX8MP fuse readout
> and programming are in their separate functions, and called in case
> of matching SoC.
>
> Signed-off-by: Marek Vasut 

Reviewed-by: Fabio Estevam 


Re: [PATCH 1/2] thermal: imx_tmu: Clean up all prints

2023-04-04 Thread Fabio Estevam
On Tue, Apr 4, 2023 at 4:25 PM Marek Vasut  wrote:
>
> Use dev_(dev, ...) for all printing and debug logging, since this
> already includes the device name. Drop device name where duplicate.
>
> Signed-off-by: Marek Vasut 

Reviewed-by: Fabio Estevam 


Re: [PATCH v2 0/5] board: verdin-imx8mp: ddr updates

2023-04-03 Thread Fabio Estevam
Hi Marcel,

On Mon, Apr 3, 2023 at 9:02 AM Marcel Ziswiler  wrote:
>
> From: Marcel Ziswiler 
>
>
> This series contains the following DDR updates:
>
> - update ddrc config for different lpddr4 memories
> - fix lpddr4 refresh timing
> - update lpddr4 configuration and training
> - compact slight different lpddr4 configuration
> - change prints in spl_dram_init function
>
> Changes in v2:
> - Use puts rather than printf in the SPL as suggested by Fabio. Thanks!

For the whole series:

Reviewed-by: Fabio Estevam 


Re: [PATCH 2/2] pico-imx6: Pass the mmc alias to fix boot regression

2023-04-03 Thread Fabio Estevam
Hi Tom and Stefano,

On Wed, Mar 29, 2023 at 7:25 PM  wrote:
>
> > Originally, the mmc aliases node was present in imx6qdl-pico.dtsi.
> >
> > After the sync with Linux in commit d0399a46e7cd ("imx6dl/imx6qdl:
> > synchronise device trees with linux"), the aliases node is gone as
> > the upstream version does not have it.
> >
> > This causes a boot regression in which the eMMC card cannot be found 
> > anymore.
> >
> > Fix it by passing the alias node in the u-boot.dtsi file to
> > restore the original behaviour where the eMMC (esdhc3) was
> > mapped to mmc0.
> >
> > Fixes: d0399a46e7cd ("imx6dl/imx6qdl: synchronise device trees with linux")
> > Signed-off-by: Fabio Estevam 
> Applied to u-boot-imx, next, thanks !

Since this one fixes a boot regression, could it be applied to 2023.04?

Thanks


Re: [PATCH v1 5/5] board: verdin-imx8mp: change prints in spl_dram_init function

2023-03-29 Thread Fabio Estevam
Hi Marcel,

The whole series looks good.

On Wed, Mar 29, 2023 at 8:24 AM Marcel Ziswiler  wrote:
>
> From: Emanuele Ghidoli 
>
> change prints to show which DDR configuration (single/dual rank) is used
>
> Signed-off-by: Emanuele Ghidoli 
> Signed-off-by: Marcel Ziswiler 
>
> ---
>
>  board/toradex/verdin-imx8mp/spl.c | 14 ++
>  1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/board/toradex/verdin-imx8mp/spl.c 
> b/board/toradex/verdin-imx8mp/spl.c
> index ab5bcbc0929..f43c6cc02f8 100644
> --- a/board/toradex/verdin-imx8mp/spl.c
> +++ b/board/toradex/verdin-imx8mp/spl.c
> @@ -35,11 +35,17 @@ void spl_dram_init(void)
> /*
>  * Try configuring for dual rank memory falling back to single rank
>  */
> -   if (ddr_init(_timing)) {
> -   printf("Dual rank failed, attempting single rank 
> configuration.\n");
> -   lpddr4_single_rank_training_patch();
> -   ddr_init(_timing);
> +   if (!ddr_init(_timing)) {
> +   printf("DDR configured as dual rank\n");

Just a minor suggestion:
puts() can be used instead of printf() as it uses less resources and
can help inside a memory constrained environment, such as SPL.


Re: [PATCH] imx6sx-udoo-neo-basic: Introduce the u-boot.dtsi

2023-03-22 Thread Fabio Estevam
Hi Tom,

On Wed, Mar 22, 2023 at 5:12 PM Tom Rini  wrote:

> Is this for master? If so, OK, we'll pick it up. If not, NAK, these are
> all bootph- properties now, and need to go upstream too.

Yes, this is for master as it is a regression.

Thanks.


[PATCH] imx6sx-udoo-neo-basic: Introduce the u-boot.dtsi

2023-03-22 Thread Fabio Estevam
From: Fabio Estevam 

After the conversion to DM_SERIAL in commit 01f372d8d62b ("udoo_neo:
Select DM_SERIAL and drop iomux board level init") the SPL log is gone
and the U-Boot proper log becomes incomplete:

Core:  80 devices, 18 uclasses, devicetree: separate
MMC:   FSL_SDHC: 1, FSL_SDHC: 2
Loading Environment from MMC... OK
In:serial@202
Out:   serial@202
Err:   serial@202
Net:   eth0: ethernet@2188000
Hit any key to stop autoboot:  0  

Introduce the u-boot.dtsi file that passes the u-boot,dm-pre-reloc
properties to the relevant nodes so that UART can be used early in SPL.

With this change, the complete SPL and U-Boot messages are seen again. 

Signed-off-by: Fabio Estevam 
---
 arch/arm/dts/imx6sx-udoo-neo-basic-u-boot.dtsi | 17 +
 1 file changed, 17 insertions(+)
 create mode 100644 arch/arm/dts/imx6sx-udoo-neo-basic-u-boot.dtsi

diff --git a/arch/arm/dts/imx6sx-udoo-neo-basic-u-boot.dtsi 
b/arch/arm/dts/imx6sx-udoo-neo-basic-u-boot.dtsi
new file mode 100644
index ..cb9e83fde6b7
--- /dev/null
+++ b/arch/arm/dts/imx6sx-udoo-neo-basic-u-boot.dtsi
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+ {
+   u-boot,dm-pre-reloc;
+};
+
+ {
+   u-boot,dm-pre-reloc;
+};
+
+_uart1 {
+   u-boot,dm-pre-reloc;
+};
+
+ {
+   u-boot,dm-pre-reloc;
+};
-- 
2.34.1



[PATCH 2/2] mx51evk: Remove unused mx51evk_video.c file

2023-03-14 Thread Fabio Estevam
From: Fabio Estevam 

Since commit 1fa43cad8625 ("video: Drop references to CONFIG_VIDEO et al")
the mx51evk_video.c is no longer used.

Remove the unused file.

Signed-off-by: Fabio Estevam 
---
 board/freescale/mx51evk/mx51evk_video.c | 98 -
 1 file changed, 98 deletions(-)
 delete mode 100644 board/freescale/mx51evk/mx51evk_video.c

diff --git a/board/freescale/mx51evk/mx51evk_video.c 
b/board/freescale/mx51evk/mx51evk_video.c
deleted file mode 100644
index 3715c5d738..00
--- a/board/freescale/mx51evk/mx51evk_video.c
+++ /dev/null
@@ -1,98 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (C) 2012 Freescale Semiconductor, Inc.
- * Fabio Estevam 
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#define MX51EVK_LCD_3V3IMX_GPIO_NR(4, 9)
-#define MX51EVK_LCD_5V IMX_GPIO_NR(4, 10)
-#define MX51EVK_LCD_BACKLIGHT  IMX_GPIO_NR(3, 4)
-
-static struct fb_videomode const claa_wvga = {
-   .name   = "CLAA07LC0ACW",
-   .refresh= 57,
-   .xres   = 800,
-   .yres   = 480,
-   .pixclock   = 37037,
-   .left_margin= 40,
-   .right_margin   = 60,
-   .upper_margin   = 10,
-   .lower_margin   = 10,
-   .hsync_len  = 20,
-   .vsync_len  = 10,
-   .sync   = 0,
-   .vmode  = FB_VMODE_NONINTERLACED
-};
-
-static struct fb_videomode const dvi = {
-   .name   = "DVI panel",
-   .refresh= 60,
-   .xres   = 1024,
-   .yres   = 768,
-   .pixclock   = 15385,
-   .left_margin= 220,
-   .right_margin   = 40,
-   .upper_margin   = 21,
-   .lower_margin   = 7,
-   .hsync_len  = 60,
-   .vsync_len  = 10,
-   .sync   = 0,
-   .vmode  = FB_VMODE_NONINTERLACED
-};
-
-void setup_iomux_lcd(void)
-{
-   /* DI2_PIN15 */
-   imx_iomux_v3_setup_pad(MX51_PAD_DI_GP4__DI2_PIN15);
-
-   /* Pad settings for DI2_DISP_CLK */
-   imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_DI2_DISP_CLK__DI2_DISP_CLK,
-   PAD_CTL_PKE | PAD_CTL_DSE_MAX | PAD_CTL_SRE_SLOW));
-
-   /* Turn on 3.3V voltage for LCD */
-   imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_CSI2_D12__GPIO4_9,
-   NO_PAD_CTRL));
-   gpio_direction_output(MX51EVK_LCD_3V3, 1);
-
-   /* Turn on 5V voltage for LCD */
-   imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_CSI2_D13__GPIO4_10,
-   NO_PAD_CTRL));
-   gpio_direction_output(MX51EVK_LCD_5V, 1);
-
-   /* Turn on GPIO backlight */
-   imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_DI1_D1_CS__GPIO3_4,
-   NO_PAD_CTRL));
-   gpio_direction_output(MX51EVK_LCD_BACKLIGHT, 1);
-}
-
-int board_video_skip(void)
-{
-   int ret;
-   char const *e = env_get("panel");
-
-   if (e) {
-   if (strcmp(e, "claa") == 0) {
-   ret = ipuv3_fb_init(_wvga, 1, IPU_PIX_FMT_RGB565);
-   if (ret)
-   printf("claa cannot be configured: %d\n", ret);
-   return ret;
-   }
-   }
-
-   /*
-* 'panel' env variable not found or has different value than 'claa'
-*  Defaulting to dvi output.
-*/
-   ret = ipuv3_fb_init(, 0, IPU_PIX_FMT_RGB24);
-   if (ret)
-   printf("dvi cannot be configured: %d\n", ret);
-   return ret;
-}
-- 
2.34.1



[PATCH 1/2] mx53loco: Remove unused mx53loco_video.c file

2023-03-14 Thread Fabio Estevam
From: Fabio Estevam 

Since commit 1fa43cad8625 ("video: Drop references to CONFIG_VIDEO et al")
the mx53loco_video.c is no longer used.

Remove the unused file.

Signed-off-by: Fabio Estevam 
---
 board/freescale/mx53loco/mx53loco_video.c | 114 --
 1 file changed, 114 deletions(-)
 delete mode 100644 board/freescale/mx53loco/mx53loco_video.c

diff --git a/board/freescale/mx53loco/mx53loco_video.c 
b/board/freescale/mx53loco/mx53loco_video.c
deleted file mode 100644
index ff3fc8ce3e..00
--- a/board/freescale/mx53loco/mx53loco_video.c
+++ /dev/null
@@ -1,114 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (C) 2012 Freescale Semiconductor, Inc.
- * Fabio Estevam 
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#define MX53LOCO_LCD_POWER IMX_GPIO_NR(3, 24)
-
-static struct fb_videomode const claa_wvga = {
-   .name   = "CLAA07LC0ACW",
-   .refresh= 57,
-   .xres   = 800,
-   .yres   = 480,
-   .pixclock   = 37037,
-   .left_margin= 40,
-   .right_margin   = 60,
-   .upper_margin   = 10,
-   .lower_margin   = 10,
-   .hsync_len  = 20,
-   .vsync_len  = 10,
-   .sync   = 0,
-   .vmode  = FB_VMODE_NONINTERLACED
-};
-
-static struct fb_videomode const seiko_wvga = {
-   .name   = "Seiko-43WVF1G",
-   .refresh= 60,
-   .xres   = 800,
-   .yres   = 480,
-   .pixclock   = 29851, /* picosecond (33.5 MHz) */
-   .left_margin= 89,
-   .right_margin   = 164,
-   .upper_margin   = 23,
-   .lower_margin   = 10,
-   .hsync_len  = 10,
-   .vsync_len  = 10,
-   .sync   = 0,
-};
-
-void setup_iomux_lcd(void)
-{
-   static const iomux_v3_cfg_t lcd_pads[] = {
-   MX53_PAD_DI0_DISP_CLK__IPU_DI0_DISP_CLK,
-   MX53_PAD_DI0_PIN15__IPU_DI0_PIN15,
-   MX53_PAD_DI0_PIN2__IPU_DI0_PIN2,
-   MX53_PAD_DI0_PIN3__IPU_DI0_PIN3,
-   MX53_PAD_DISP0_DAT0__IPU_DISP0_DAT_0,
-   MX53_PAD_DISP0_DAT1__IPU_DISP0_DAT_1,
-   MX53_PAD_DISP0_DAT2__IPU_DISP0_DAT_2,
-   MX53_PAD_DISP0_DAT3__IPU_DISP0_DAT_3,
-   MX53_PAD_DISP0_DAT4__IPU_DISP0_DAT_4,
-   MX53_PAD_DISP0_DAT5__IPU_DISP0_DAT_5,
-   MX53_PAD_DISP0_DAT6__IPU_DISP0_DAT_6,
-   MX53_PAD_DISP0_DAT7__IPU_DISP0_DAT_7,
-   MX53_PAD_DISP0_DAT8__IPU_DISP0_DAT_8,
-   MX53_PAD_DISP0_DAT9__IPU_DISP0_DAT_9,
-   MX53_PAD_DISP0_DAT10__IPU_DISP0_DAT_10,
-   MX53_PAD_DISP0_DAT11__IPU_DISP0_DAT_11,
-   MX53_PAD_DISP0_DAT12__IPU_DISP0_DAT_12,
-   MX53_PAD_DISP0_DAT13__IPU_DISP0_DAT_13,
-   MX53_PAD_DISP0_DAT14__IPU_DISP0_DAT_14,
-   MX53_PAD_DISP0_DAT15__IPU_DISP0_DAT_15,
-   MX53_PAD_DISP0_DAT16__IPU_DISP0_DAT_16,
-   MX53_PAD_DISP0_DAT17__IPU_DISP0_DAT_17,
-   MX53_PAD_DISP0_DAT18__IPU_DISP0_DAT_18,
-   MX53_PAD_DISP0_DAT19__IPU_DISP0_DAT_19,
-   MX53_PAD_DISP0_DAT20__IPU_DISP0_DAT_20,
-   MX53_PAD_DISP0_DAT21__IPU_DISP0_DAT_21,
-   MX53_PAD_DISP0_DAT22__IPU_DISP0_DAT_22,
-   MX53_PAD_DISP0_DAT23__IPU_DISP0_DAT_23,
-   };
-
-   imx_iomux_v3_setup_multiple_pads(lcd_pads, ARRAY_SIZE(lcd_pads));
-
-   /* Turn on GPIO backlight */
-   imx_iomux_v3_setup_pad(MX53_PAD_EIM_D24__GPIO3_24);
-   gpio_direction_output(MX53LOCO_LCD_POWER, 1);
-
-   /* Turn on display contrast */
-   imx_iomux_v3_setup_pad(MX53_PAD_GPIO_1__GPIO1_1);
-   gpio_direction_output(IMX_GPIO_NR(1, 1), 1);
-}
-
-int board_video_skip(void)
-{
-   int ret;
-   char const *e = env_get("panel");
-
-   if (e) {
-   if (strcmp(e, "seiko") == 0) {
-   ret = ipuv3_fb_init(_wvga, 0, IPU_PIX_FMT_RGB24);
-   if (ret)
-   printf("Seiko cannot be configured: %d\n", ret);
-   return ret;
-   }
-   }
-
-   /*
-* 'panel' env variable not found or has different value than 'seiko'
-*  Defaulting to claa lcd.
-*/
-   ret = ipuv3_fb_init(_wvga, 0, IPU_PIX_FMT_RGB565);
-   if (ret)
-   printf("CLAA cannot be configured: %d\n", ret);
-   return ret;
-}
-- 
2.34.1



Re: [PATCH 1/1] compulab: imx8mm-cl-iot-gate: Fix some function declarations in ddr.h

2023-03-13 Thread Fabio Estevam
On Mon, Mar 13, 2023 at 3:26 PM Ying-Chun Liu (PaulLiu)
 wrote:
>
> We have a few places here that the function declarations do not
> match their prototypes, correct them.
>
> Signed-off-by: Ying-Chun Liu (PaulLiu) 
> Cc: Tom Rini 
> Cc: Stefano Babic 
> Cc: Fabio Estevam 
> Cc: NXP i.MX U-Boot Team 

Reported-by: Tom Rini 
Reviewed-by: Fabio Estevam 


Re: [PATCH] README.mpc85xx-sd-spi-boot: Suggest the NXP boot format github repo

2023-03-09 Thread Fabio Estevam
Hi Leo,

On Wed, Mar 8, 2023 at 6:01 PM Leo Li  wrote:

> It mimics the branches on CodeAurora.  I will ask them to update the default 
> branch to master.

The default branch is master now, thanks.

Pali,

Is the patch good now?


Re: [PATCH] ARM: imx: Include on-SoM microSD in list of i.MX6 DHCOM boot devices

2023-03-06 Thread Fabio Estevam

On 05/03/2023 20:21, Marek Vasut wrote:

Add mmc1, which is mapped to optional on-SoM microSD socket,
to the list of distro boot command boot devices.

Signed-off-by: Marek Vasut 


Reviewed-by: Fabio Estevam 


Re: [PATCH] ARM: dts: imx: Add WDT bindings on DH i.MX6 DHSOM

2023-03-06 Thread Fabio Estevam

On 05/03/2023 17:49, Marek Vasut wrote:

Add WDT reboot bindings on DH i.MX6 DHSOM to permit the platform
to reboot via WDT in U-Boot. These are custom U-Boot bindings,
hence they are placed in -u-boot.dtsi .

Signed-off-by: Marek Vasut 


Reviewed-by: Fabio Estevam 


Re: [PATCH] ARM: imx: Convert DH i.MX6 DHSOM to DM_SERIAL

2023-03-06 Thread Fabio Estevam

On 05/03/2023 17:48, Marek Vasut wrote:

Enable CONFIG_DM_SERIAL on DH i.MX6 DHSOM to convert it to DM serial .

Signed-off-by: Marek Vasut 


Reviewed-by: Fabio Estevam 


Re: [PATCH v2 1/1] editorconfig: introduce .editorconfig

2023-03-02 Thread Fabio Estevam
Hi Dzmitry,

On Wed, Mar 1, 2023 at 7:44 AM Dzmitry Sankouski  wrote:
>
> Current process of sending patches includes running checkpatch.pl
> script for each patch, and fixing found style problems.
> EditorConfig may help to prevent some style related problems
> (like spaces vs tab indentation) on the fly.
>
> Reviewed-by: Simon Glass 

You missed giving your Signed-off-by tag.


Re: [PATCH 5/7] imx8image: Remove unused cont_img_count variable

2023-02-28 Thread Fabio Estevam
On Mon, Feb 27, 2023 at 7:08 PM Tom Rini  wrote:
>
> With clang-15, it is now reported that cont_img_count is unused. This is
> true as the code will increment / reset this counter, but never
> functionally use it. Remove it.
>
> Signed-off-by: Tom Rini 

Reviewed-by: Fabio Estevam 


Re: [PATCH 2/2] imx93_evk: enable ADC

2023-02-24 Thread Fabio Estevam
Hi Luca,

On Fri, Feb 24, 2023 at 4:59 AM Luca Ellero
 wrote:

> Hi Fabio,
> thank you for your reply.
> Ok, I will add a comment to the patch and fix DT node.
> Should I resend only this patch or both?

Please resend the whole series.

My suggestion:

1/3 - ADC driver
2/3 - Sync U-Boot imx93 evk dts with the one from linux-next 20230224
3/3 - Enable the ADC driver in the imx93 evk defconfig


Re: [PATCH 2/2] imx93_evk: enable ADC

2023-02-23 Thread Fabio Estevam
Hi Luca,

On Thu, Feb 23, 2023 at 9:52 AM Luca Ellero  wrote:

Please write a commit log.

> Signed-off-by: Luca Ellero 
> ---
>  arch/arm/dts/imx93-11x11-evk.dts  | 4 
>  configs/imx93_11x11_evk_defconfig | 1 +
>  2 files changed, 5 insertions(+)
>
> diff --git a/arch/arm/dts/imx93-11x11-evk.dts 
> b/arch/arm/dts/imx93-11x11-evk.dts
> index b3a5a3d71e..f7ffe7b3d2 100644
> --- a/arch/arm/dts/imx93-11x11-evk.dts
> +++ b/arch/arm/dts/imx93-11x11-evk.dts
> @@ -525,3 +525,7 @@
>   {
> status = "okay";
>  };
> +
> + {
> +   status = "okay";
> +};

The nodes should be kept in alphabetical order.

Actually, it would be better if you could sync imx93-11x11-evk.dts
with linux-next, which already contains the adc1 node:

https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/arch/arm64/boot/dts/freescale/imx93-11x11-evk.dts?h=next-20230223#n37

We want to keep U-Boot and Linux devicetree in sync as much as possible.

Thanks


Re: [PATCH 1/2] dm: adc: add iMX93 ADC support

2023-02-23 Thread Fabio Estevam
On Thu, Feb 23, 2023 at 9:52 AM Luca Ellero  wrote:
>
> This commit adds driver for iMX93 ADC.
>
> The driver is implemented using driver model and provides
> ADC uclass's methods for ADC single channel operations:
> - adc_start_channel()
> - adc_channel_data()
> - adc_stop()
>
> ADC features:
> - channels: 4
> - resolution: 12-bit
>
> Signed-off-by: Luca Ellero 

Reviewed-by: Fabio Estevam 


Re: [PATCH] dm: adc: add iMX93 ADC support

2023-02-21 Thread Fabio Estevam
Hi Luca,

On Tue, Feb 21, 2023 at 9:55 AM Luca Ellero  wrote:

> +int imx93_adc_channel_data(struct udevice *dev, int channel,

static int

> +int imx93_adc_start_channel(struct udevice *dev, int channel)

static int

> +int imx93_adc_stop(struct udevice *dev)

static int

> +int imx93_adc_probe(struct udevice *dev)

static int

> +int imx93_adc_of_to_plat(struct udevice *dev)

static int

Also, please add a user for this driver in a subsequent patch.

Otherwise it will never be built and would become dead code.


[PATCH 1/2] mx6sabreauto: Convert to DM_PMIC

2023-02-16 Thread Fabio Estevam
The usage of DM_PMIC is preferred, so convert to it.

This also brings the benefit of causing a significant amount
of code removal.

Signed-off-by: Fabio Estevam 
Reviewed-by: Peng Fan 
---
 board/freescale/mx6sabreauto/mx6sabreauto.c | 109 +++-
 configs/mx6sabreauto_defconfig  |  13 +--
 include/configs/mx6sabreauto.h  |   3 -
 3 files changed, 19 insertions(+), 106 deletions(-)

diff --git a/board/freescale/mx6sabreauto/mx6sabreauto.c 
b/board/freescale/mx6sabreauto/mx6sabreauto.c
index 9155dcfbd0..0ae86f42df 100644
--- a/board/freescale/mx6sabreauto/mx6sabreauto.c
+++ b/board/freescale/mx6sabreauto/mx6sabreauto.c
@@ -19,14 +19,12 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -49,23 +47,15 @@ DECLARE_GLOBAL_DATA_PTR;
 #define ENET_PAD_CTRL  (PAD_CTL_PUS_100K_UP |  \
PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS)
 
-#define I2C_PAD_CTRL   (PAD_CTL_PUS_100K_UP |  \
-   PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS |   \
-   PAD_CTL_ODE | PAD_CTL_SRE_FAST)
-
 #define GPMI_PAD_CTRL0 (PAD_CTL_PKE | PAD_CTL_PUE | PAD_CTL_PUS_100K_UP)
 #define GPMI_PAD_CTRL1 (PAD_CTL_DSE_40ohm | PAD_CTL_SPEED_MED | \
PAD_CTL_SRE_FAST)
 #define GPMI_PAD_CTRL2 (GPMI_PAD_CTRL0 | GPMI_PAD_CTRL1)
 
-#define PC MUX_PAD_CTRL(I2C_PAD_CTRL)
-
 #define WEIM_NOR_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE |  \
PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED |   \
PAD_CTL_DSE_40ohm   | PAD_CTL_SRE_FAST)
 
-#define I2C_PMIC   1
-
 int dram_init(void)
 {
gd->ram_size = imx_ddr_size();
@@ -78,70 +68,6 @@ static iomux_v3_cfg_t const uart4_pads[] = {
IOMUX_PADS(PAD_KEY_ROW0__UART4_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)),
 };
 
-
-/* I2C2 PMIC, iPod, Tuner, Codec, Touch, HDMI EDID, MIPI CSI2 card */
-static struct i2c_pads_info mx6q_i2c_pad_info1 = {
-   .scl = {
-   .i2c_mode = MX6Q_PAD_EIM_EB2__I2C2_SCL | PC,
-   .gpio_mode = MX6Q_PAD_EIM_EB2__GPIO2_IO30 | PC,
-   .gp = IMX_GPIO_NR(2, 30)
-   },
-   .sda = {
-   .i2c_mode = MX6Q_PAD_KEY_ROW3__I2C2_SDA | PC,
-   .gpio_mode = MX6Q_PAD_KEY_ROW3__GPIO4_IO13 | PC,
-   .gp = IMX_GPIO_NR(4, 13)
-   }
-};
-
-static struct i2c_pads_info mx6dl_i2c_pad_info1 = {
-   .scl = {
-   .i2c_mode = MX6DL_PAD_EIM_EB2__I2C2_SCL | PC,
-   .gpio_mode = MX6DL_PAD_EIM_EB2__GPIO2_IO30 | PC,
-   .gp = IMX_GPIO_NR(2, 30)
-   },
-   .sda = {
-   .i2c_mode = MX6DL_PAD_KEY_ROW3__I2C2_SDA | PC,
-   .gpio_mode = MX6DL_PAD_KEY_ROW3__GPIO4_IO13 | PC,
-   .gp = IMX_GPIO_NR(4, 13)
-   }
-};
-
-#ifndef CONFIG_SYS_FLASH_CFI
-/*
- * I2C3 MLB, Port Expanders (A, B, C), Video ADC, Light Sensor,
- * Compass Sensor, Accelerometer, Res Touch
- */
-static struct i2c_pads_info mx6q_i2c_pad_info2 = {
-   .scl = {
-   .i2c_mode = MX6Q_PAD_GPIO_3__I2C3_SCL | PC,
-   .gpio_mode = MX6Q_PAD_GPIO_3__GPIO1_IO03 | PC,
-   .gp = IMX_GPIO_NR(1, 3)
-   },
-   .sda = {
-   .i2c_mode = MX6Q_PAD_EIM_D18__I2C3_SDA | PC,
-   .gpio_mode = MX6Q_PAD_EIM_D18__GPIO3_IO18 | PC,
-   .gp = IMX_GPIO_NR(3, 18)
-   }
-};
-
-static struct i2c_pads_info mx6dl_i2c_pad_info2 = {
-   .scl = {
-   .i2c_mode = MX6DL_PAD_GPIO_3__I2C3_SCL | PC,
-   .gpio_mode = MX6DL_PAD_GPIO_3__GPIO1_IO03 | PC,
-   .gp = IMX_GPIO_NR(1, 3)
-   },
-   .sda = {
-   .i2c_mode = MX6DL_PAD_EIM_D18__I2C3_SDA | PC,
-   .gpio_mode = MX6DL_PAD_EIM_D18__GPIO3_IO18 | PC,
-   .gp = IMX_GPIO_NR(3, 18)
-   }
-};
-#endif
-
-static iomux_v3_cfg_t const i2c3_pads[] = {
-   IOMUX_PADS(PAD_EIM_A24__GPIO5_IO04  | MUX_PAD_CTRL(NO_PAD_CTRL)),
-};
-
 static iomux_v3_cfg_t const port_exp[] = {
IOMUX_PADS(PAD_SD2_DAT0__GPIO1_IO15 | MUX_PAD_CTRL(NO_PAD_CTRL)),
 };
@@ -516,21 +442,10 @@ int board_init(void)
/* address of boot parameters */
gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
 
-   /* I2C 2 and 3 setup - I2C 3 hw mux with EIM */
-   if (is_mx6dq() || is_mx6dqp())
-   setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, _i2c_pad_info1);
-   else
-   setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, _i2c_pad_info1);
/* I2C 3 Steer */
gpio_request(IMX_GPIO_NR(5, 4), "steer logic");
gpio_direction_output(IMX_GPIO_NR(5, 4), 1);
-   SETUP_IOMUX_PADS(i2c3_pads);
-#ifndef CONFIG_SYS_FLASH_CFI
-   if (is_mx6dq() || is_mx6dqp())
-   setup_i2c(2, CONFIG_SYS_I2C_SPEED, 0x7f, _i2c_pad_info2);
-   else
-   setup_i2c(2, CONFIG_SYS_I2C_SPEED, 0x7f, _i2c_pad_info2);
-#endif
+
 

[PATCH 2/2] mx6sabresd: Convert to DM_PMIC

2023-02-16 Thread Fabio Estevam
The usage of DM_PMIC is preferred, so convert to it.

This also brings the benefit of causing a significant amount
of code removal.

Signed-off-by: Fabio Estevam 
Reviewed-by: Peng Fan 
---
 board/freescale/mx6sabresd/mx6sabresd.c | 63 +
 configs/mx6sabresd_defconfig| 11 ++---
 include/configs/mx6sabresd.h|  3 --
 3 files changed, 17 insertions(+), 60 deletions(-)

diff --git a/board/freescale/mx6sabresd/mx6sabresd.c 
b/board/freescale/mx6sabresd/mx6sabresd.c
index 8c35230855..96a76b0581 100644
--- a/board/freescale/mx6sabresd/mx6sabresd.c
+++ b/board/freescale/mx6sabresd/mx6sabresd.c
@@ -17,7 +17,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -28,7 +27,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -49,14 +47,6 @@ DECLARE_GLOBAL_DATA_PTR;
 #define SPI_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_SPEED_MED | \
  PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST)
 
-#define I2C_PAD_CTRL  (PAD_CTL_PUS_100K_UP |   \
-   PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS |   \
-   PAD_CTL_ODE | PAD_CTL_SRE_FAST)
-
-#define I2C_PMIC   1
-
-#define I2C_PAD MUX_PAD_CTRL(I2C_PAD_CTRL)
-
 #define DISP0_PWR_EN   IMX_GPIO_NR(1, 21)
 
 #define KEY_VOL_UP IMX_GPIO_NR(1, 4)
@@ -174,32 +164,6 @@ static void enable_lvds(struct display_info_t const *dev)
enable_backlight();
 }
 
-static struct i2c_pads_info mx6q_i2c_pad_info1 = {
-   .scl = {
-   .i2c_mode = MX6Q_PAD_KEY_COL3__I2C2_SCL | I2C_PAD,
-   .gpio_mode = MX6Q_PAD_KEY_COL3__GPIO4_IO12 | I2C_PAD,
-   .gp = IMX_GPIO_NR(4, 12)
-   },
-   .sda = {
-   .i2c_mode = MX6Q_PAD_KEY_ROW3__I2C2_SDA | I2C_PAD,
-   .gpio_mode = MX6Q_PAD_KEY_ROW3__GPIO4_IO13 | I2C_PAD,
-   .gp = IMX_GPIO_NR(4, 13)
-   }
-};
-
-static struct i2c_pads_info mx6dl_i2c_pad_info1 = {
-   .scl = {
-   .i2c_mode = MX6DL_PAD_KEY_COL3__I2C2_SCL | I2C_PAD,
-   .gpio_mode = MX6DL_PAD_KEY_COL3__GPIO4_IO12 | I2C_PAD,
-   .gp = IMX_GPIO_NR(4, 12)
-   },
-   .sda = {
-   .i2c_mode = MX6DL_PAD_KEY_ROW3__I2C2_SDA | I2C_PAD,
-   .gpio_mode = MX6DL_PAD_KEY_ROW3__GPIO4_IO13 | I2C_PAD,
-   .gp = IMX_GPIO_NR(4, 13)
-   }
-};
-
 static void setup_spi(void)
 {
SETUP_IOMUX_PADS(ecspi1_pads);
@@ -495,10 +459,7 @@ int board_init(void)
 #ifdef CONFIG_MXC_SPI
setup_spi();
 #endif
-   if (is_mx6dq() || is_mx6dqp())
-   setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, _i2c_pad_info1);
-   else
-   setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, _i2c_pad_info1);
+
 #if defined(CONFIG_VIDEO_IPUV3)
setup_display();
 #endif
@@ -511,29 +472,32 @@ int board_init(void)
 
 int power_init_board(void)
 {
-   struct pmic *p;
+   struct udevice *dev;
unsigned int reg;
int ret;
 
-   p = pfuze_common_init(I2C_PMIC);
-   if (!p)
-   return -ENODEV;
+   ret = pmic_get("pfuze100@8", );
+   if (ret == -ENODEV)
+   return 0;
+
+   if (ret != 0)
+   return ret;
 
-   ret = pfuze_mode_init(p, APS_PFM);
+   ret = pfuze_mode_init(dev, APS_PFM);
if (ret < 0)
return ret;
 
/* Increase VGEN3 from 2.5 to 2.8V */
-   pmic_reg_read(p, PFUZE100_VGEN3VOL, );
+   reg = pmic_reg_read(dev, PFUZE100_VGEN3VOL);
reg &= ~LDO_VOL_MASK;
reg |= LDOB_2_80V;
-   pmic_reg_write(p, PFUZE100_VGEN3VOL, reg);
+   pmic_reg_write(dev, PFUZE100_VGEN3VOL, reg);
 
/* Increase VGEN5 from 2.8 to 3V */
-   pmic_reg_read(p, PFUZE100_VGEN5VOL, );
+   reg = pmic_reg_read(dev, PFUZE100_VGEN5VOL);
reg &= ~LDO_VOL_MASK;
reg |= LDOB_3_00V;
-   pmic_reg_write(p, PFUZE100_VGEN5VOL, reg);
+   pmic_reg_write(dev, PFUZE100_VGEN5VOL, reg);
 
return 0;
 }
@@ -902,7 +866,6 @@ void board_init_f(ulong dummy)
ccgr_init();
gpr_init();
 
-   /* iomux and setup of i2c */
board_early_init_f();
 
/* setup GP timer */
diff --git a/configs/mx6sabresd_defconfig b/configs/mx6sabresd_defconfig
index 6905850083..0033a0e50a 100644
--- a/configs/mx6sabresd_defconfig
+++ b/configs/mx6sabresd_defconfig
@@ -11,9 +11,6 @@ CONFIG_ENV_SIZE=0x2000
 CONFIG_ENV_OFFSET=0xC
 CONFIG_MX6QDL=y
 CONFIG_TARGET_MX6SABRESD=y
-CONFIG_SYS_I2C_MXC_I2C1=y
-CONFIG_SYS_I2C_MXC_I2C2=y
-CONFIG_SYS_I2C_MXC_I2C3=y
 CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="imx6q-sabresd"
 CONFIG_SPL_TEXT_BASE=0x00908000
@@ -83,7 +80,6 @@ CONFIG_FASTBOOT_BUF_SIZE=0x1000
 CONFIG_FASTBOOT_FLASH=y
 CONFIG_FASTBOOT_FLASH_MMC_DEV=2
 CONFIG_DM_I2C=y
-CONFIG_SPL_SYS_I2C_LEGACY=y
 CONFIG_SYS_I2C_MXC=y
 CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_FSL_USDHC=y
@@ -101,11 +97,12 @@ CONFIG_PCI_SCAN_SHOW=y
 CONFIG_PCIE_IMX=y
 CONFIG_P

[PATCH] mx6sxsabreauto: Remove myself from MAINTAINERS

2023-02-15 Thread Fabio Estevam
I don't have access to the mx6sxsabreauto board, so remove myself
from the MAINTAINERS entry and add Peng instead.

Signed-off-by: Fabio Estevam 
---
 board/freescale/mx6sxsabreauto/MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/freescale/mx6sxsabreauto/MAINTAINERS 
b/board/freescale/mx6sxsabreauto/MAINTAINERS
index 692bbd9767..8dc62e5e3e 100644
--- a/board/freescale/mx6sxsabreauto/MAINTAINERS
+++ b/board/freescale/mx6sxsabreauto/MAINTAINERS
@@ -1,5 +1,5 @@
 MX6SXSABREAUTO BOARD
-M: Fabio Estevam 
+M: Peng Fan 
 S: Maintained
 F: board/freescale/mx6sxsabreauto/
 F: include/configs/mx6sxsabreauto.h
-- 
2.25.1



[PATCH 2/2] pico-imx6: Pass the mmc alias to fix boot regression

2023-02-15 Thread Fabio Estevam
Originally, the mmc aliases node was present in imx6qdl-pico.dtsi.

After the sync with Linux in commit d0399a46e7cd ("imx6dl/imx6qdl:
synchronise device trees with linux"), the aliases node is gone as
the upstream version does not have it.

This causes a boot regression in which the eMMC card cannot be found anymore.
   
Fix it by passing the alias node in the u-boot.dtsi file to
restore the original behaviour where the eMMC (esdhc3) was
mapped to mmc0.

Fixes: d0399a46e7cd ("imx6dl/imx6qdl: synchronise device trees with linux")
Signed-off-by: Fabio Estevam 
---
 arch/arm/dts/imx6dl-pico-u-boot.dtsi | 7 +++
 1 file changed, 7 insertions(+)
 create mode 100644 arch/arm/dts/imx6dl-pico-u-boot.dtsi

diff --git a/arch/arm/dts/imx6dl-pico-u-boot.dtsi 
b/arch/arm/dts/imx6dl-pico-u-boot.dtsi
new file mode 100644
index 00..e2ef9bcc14
--- /dev/null
+++ b/arch/arm/dts/imx6dl-pico-u-boot.dtsi
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0 OR MIT
+
+/ {
+   aliases {
+   mmc0 = 
+   };
+};
-- 
2.25.1



[PATCH 1/2] pico-imx6: Add DM_SERIAL support

2023-02-15 Thread Fabio Estevam
The conversion to DM_SERIAL is mandatory, so add support
for it.

Signed-off-by: Fabio Estevam 
---
 configs/pico-imx6_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/pico-imx6_defconfig b/configs/pico-imx6_defconfig
index a6ed013f8b..f79b7ec520 100644
--- a/configs/pico-imx6_defconfig
+++ b/configs/pico-imx6_defconfig
@@ -83,6 +83,7 @@ CONFIG_RGMII=y
 CONFIG_MII=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX6=y
+CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_USB=y
 CONFIG_USB_GADGET=y
-- 
2.25.1



[PATCH] udoo: Add DM_SERIAL support

2023-02-15 Thread Fabio Estevam
The conversion to DM_SERIAL is mandatory, so add support
for it.

Signed-off-by: Fabio Estevam 
---
 configs/udoo_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/udoo_defconfig b/configs/udoo_defconfig
index 0a3baec12e..20686298bd 100644
--- a/configs/udoo_defconfig
+++ b/configs/udoo_defconfig
@@ -55,5 +55,6 @@ CONFIG_MII=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX6=y
 CONFIG_DM_SCSI=y
+CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_DM_THERMAL=y
-- 
2.25.1



[PATCH] mx6sxsabresd: Add DM_SERIAL support

2023-02-15 Thread Fabio Estevam
The conversion to DM_SERIAL is mandatory, so add support
for it.

Signed-off-by: Fabio Estevam 
---
 configs/mx6sxsabresd_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/mx6sxsabresd_defconfig b/configs/mx6sxsabresd_defconfig
index c469084737..2e52e301ae 100644
--- a/configs/mx6sxsabresd_defconfig
+++ b/configs/mx6sxsabresd_defconfig
@@ -69,6 +69,7 @@ CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_PFUZE100=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
-- 
2.25.1



[PATCH] mx51evk: Add DM_SERIAL support

2023-02-15 Thread Fabio Estevam
The conversion to DM_SERIAL is mandatory, so add support
for it.

Signed-off-by: Fabio Estevam 
---
 configs/mx51evk_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/mx51evk_defconfig b/configs/mx51evk_defconfig
index b173648c8e..832f718410 100644
--- a/configs/mx51evk_defconfig
+++ b/configs/mx51evk_defconfig
@@ -57,6 +57,7 @@ CONFIG_DM_REGULATOR_GPIO=y
 CONFIG_POWER_FSL=y
 CONFIG_POWER_SPI=y
 CONFIG_RTC_MC13XXX=y
+CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_SPI=y
 CONFIG_MXC_SPI=y
-- 
2.25.1



[PATCH 2/2] mx53loco: Add DM_I2C support

2023-02-15 Thread Fabio Estevam
The conversion to DM_I2C is mandatory, so add support
for it.

Signed-off-by: Fabio Estevam 
---
 board/freescale/mx53loco/mx53loco.c | 36 ++---
 configs/mx53loco_defconfig  |  2 +-
 2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/board/freescale/mx53loco/mx53loco.c 
b/board/freescale/mx53loco/mx53loco.c
index d447ad840a..a2aed44fbb 100644
--- a/board/freescale/mx53loco/mx53loco.c
+++ b/board/freescale/mx53loco/mx53loco.c
@@ -27,6 +27,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #define MX53LOCO_LCD_POWER IMX_GPIO_NR(3, 24)
 
@@ -39,10 +41,16 @@ u32 get_board_rev(void)
struct fuse_bank *bank = >bank[0];
struct fuse_bank0_regs *fuse =
(struct fuse_bank0_regs *)bank->fuse_regs;
+   struct udevice *bus;
+   struct udevice *dev;
 
int rev = readl(>gp[6]);
 
-   if (!i2c_probe(CFG_SYS_DIALOG_PMIC_I2C_ADDR))
+   ret = uclass_get_device_by_seq(UCLASS_I2C, 0, );
+   if (ret)
+   return ret;
+
+   if (!dm_i2c_probe(bus, CFG_SYS_DIALOG_PMIC_I2C_ADDR, 0, ))
rev = 0;
 
return (get_cpu_rev() & ~(0xF << 8)) | (rev & 0xF) << 8;
@@ -62,26 +70,19 @@ static void setup_iomux_uart(void)
imx_iomux_v3_setup_multiple_pads(uart_pads, ARRAY_SIZE(uart_pads));
 }
 
-#define I2C_PAD_CTRL   (PAD_CTL_SRE_FAST | PAD_CTL_DSE_HIGH | \
-PAD_CTL_PUS_100K_UP | PAD_CTL_ODE)
-
-static void setup_iomux_i2c(void)
-{
-   static const iomux_v3_cfg_t i2c1_pads[] = {
-   NEW_PAD_CTRL(MX53_PAD_CSI0_DAT8__I2C1_SDA, I2C_PAD_CTRL),
-   NEW_PAD_CTRL(MX53_PAD_CSI0_DAT9__I2C1_SCL, I2C_PAD_CTRL),
-   };
-
-   imx_iomux_v3_setup_multiple_pads(i2c1_pads, ARRAY_SIZE(i2c1_pads));
-}
-
 static int power_init(void)
 {
unsigned int val;
int ret;
struct pmic *p;
+   struct udevice *bus;
+   struct udevice *dev;
+
+   ret = uclass_get_device_by_seq(UCLASS_I2C, 0, );
+   if (ret)
+   return ret;
 
-   if (!i2c_probe(CFG_SYS_DIALOG_PMIC_I2C_ADDR)) {
+   if (!dm_i2c_probe(bus, CFG_SYS_DIALOG_PMIC_I2C_ADDR, 0, )) {
ret = pmic_dialog_init(I2C_PMIC);
if (ret)
return ret;
@@ -124,8 +125,8 @@ static int power_init(void)
return ret;
}
 
-   if (!i2c_probe(CFG_SYS_FSL_PMIC_I2C_ADDR)) {
-   ret = pmic_init(I2C_0);
+   if (!dm_i2c_probe(bus, CFG_SYS_FSL_PMIC_I2C_ADDR, 0, )) {
+   ret = pmic_init(0);
if (ret)
return ret;
 
@@ -225,7 +226,6 @@ int board_init(void)
gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
 
mxc_set_sata_internal_clock();
-   setup_iomux_i2c();
 
return 0;
 }
diff --git a/configs/mx53loco_defconfig b/configs/mx53loco_defconfig
index e332c930b9..f497ccf9e9 100644
--- a/configs/mx53loco_defconfig
+++ b/configs/mx53loco_defconfig
@@ -44,7 +44,7 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_USE_ETHPRIME=y
 CONFIG_ETHPRIME="FEC0"
 CONFIG_ARP_TIMEOUT=200
-CONFIG_SYS_I2C_LEGACY=y
+CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_MXC=y
 CONFIG_FSL_ESDHC_IMX=y
 CONFIG_MTD=y
-- 
2.25.1



[PATCH 1/2] mx53loco: Add DM_SERIAL support

2023-02-15 Thread Fabio Estevam
The conversion to DM_SERIAL is mandatory, so add support
for it.

Signed-off-by: Fabio Estevam 
---
 configs/mx53loco_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/mx53loco_defconfig b/configs/mx53loco_defconfig
index d5f2b7092d..e332c930b9 100644
--- a/configs/mx53loco_defconfig
+++ b/configs/mx53loco_defconfig
@@ -61,6 +61,7 @@ CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
 CONFIG_POWER_FSL=y
 CONFIG_POWER_I2C=y
+CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_USB=y
 CONFIG_USB_EHCI_MX5=y
-- 
2.25.1



Re: imx8mp EQOS regression in dwc_eth_qos,c

2023-02-15 Thread Fabio Estevam
Hi Elmar,

On Wed, Feb 15, 2023 at 3:02 AM Elmar Psilog  wrote:

> Marek, great! Can confirm that this patch (just to be sure attached
> complete below) does it's job.

Care to submit a formal patch to the list?

It would be great to have this problem fixed in 2023.04.


Re: imx8mp EQOS regression in dwc_eth_qos,c

2023-02-13 Thread Fabio Estevam
Adding Marek, who has sent some EQOS patches recently.

On Mon, Feb 13, 2023 at 6:02 PM Elmar Psilog  wrote:
>
> Hello,
> Think I found a regression in EQOS driver with fixed-phy. Maybe someone
> with a imx8mp board might check that use case to confirm? That would be
> great.
> While ethernet was working in v2022.04 a "ping" in v2023.01 returns
>
> ERROR: no/invalid  property!
> invalid speed 0 eqos_adjust_link() failed: -22 FAILED
>
> although devicetree/hardware kept unchanged.
> This happens because in file fixed.c in in function fixedphy_config()
> the call
>
>  val = ofnode_read_u32_default(node, "speed", 0);
>
> returns 0 instead of 1000 and also the duplex is not set. Found that  in
> file/function dwc_eth_qos.c / eqos_start() the line
>
> eqos->phy->node = eqos->phy_of_node;
>
> is responsible for losing the information. Don't know what magic happens
> here - so I can't fix it - I just followed the data. So all works well
> and even the parsing of old and new fixed-link devicetree works til that
> line. After that I don't get speed anymore. Maybe you can have a look at
> this?
>
> Thank you and best regards,
> Elmar
>
>
> DTS should be correct
>  {
>pinctrl-names = "default";
>pinctrl-0 = <_eqos>;
>phy-mode = "rgmii-id";
>status = "okay";
>
>// fixed-link = <0 1 1000 0 0>; // old - just for test
>fixed-link {
>  speed = <1000>;
>  full-duplex;
>};
> };


Re: imx8mp spi fail

2023-02-13 Thread Fabio Estevam
Hi Elmar,

On Mon, Feb 13, 2023 at 4:46 PM Elmar Psilog  wrote:
>
> Thank you so much, you made my day! Sorry, I didn't see the alias was
> used different.

Glad to know it is working.

> Although my credibility gambled away I think I found a real bug in EQOS
> driver with fixed-phy:
>
> In file fixed.c in in function fixedphy_config() the call
>
>  val = ofnode_read_u32_default(node, "speed", 0);
>
> returns 0 instead of 1000 and also the duplex is not set. I found that
> in file/function dwc_eth_qos.c / eqos_start() the line
>
> eqos->phy->node = eqos->phy_of_node;
>
> is reponsible for losing the info. Don't know what magic happens here -
> so I can't fix it - just followed the data. So all works well and even
> the parsing of old and new fixed-link devicetree works til that line.
> After that I don't get speed anymore. Can someone please confirm?

I don't have an imx8mp board to confirm.

Please open a new thread to discuss this new issue.


Re: [PATCH v3 79/95] power: wanderboard: Correct conditions for split config

2023-02-12 Thread Fabio Estevam
On Sun, Feb 12, 2023 at 8:47 PM Simon Glass  wrote:
>
> This currently causes a build error with wanderboard. Fix it by adding a

A typo here and in the Subject, it is "wandboard".


Re: imx8mp spi fail

2023-02-12 Thread Fabio Estevam
Hi Elmar,

On Sun, Feb 12, 2023 at 3:04 PM Elmar Psilog  wrote:
>
> Hello, kindly ask for help about SPI at an IMX8MP. I tried latest
> 2023.01. If you can please have a look and check it works on your side?
>
> sspi command returns: Invalid bus 0

Could you try passing an aliases entry in your dts like this?

aliases {
spi0 = 
};

Does this help?

> What am I doing wrong or is this a bug? Thanks ahead for any hint.

> dt: (tested with both types of cs-gpios)
>  {
>  pinctrl-names = "default";
>  pinctrl-0 = <_ecspi1>;
>  cs-gpios = <0>, < 9 GPIO_ACTIVE_LOW>;
> //  cs-gpios = < 9 GPIO_ACTIVE_LOW>;

This last format is the correct one.


Re: imx8mm USB Mass Storage fails through a HUB

2023-02-10 Thread Fabio Estevam
Hi Tim,

On Fri, Feb 10, 2023 at 10:26 AM Marcel Ziswiler
 wrote:

> The second USB port has a on-carrier USB hub both on Dahlia as well as the 
> Verdin Development board.
>
> Sorry, that I do not have any good suggestion other than maybe comparing with 
> our configuration/design.

The verdin board passes the OTG2 power domain node in devicetree.

I recall having issues detecting USB devices in some older Linux
releases without explicitly passing
the OTG power-domain node.

Does it help if you do it like this?

--- a/arch/arm/dts/imx8mm-venice-gw71xx.dtsi
+++ b/arch/arm/dts/imx8mm-venice-gw71xx.dtsi
@@ -158,6 +158,10 @@
status = "okay";
 };

+ {
+   power-domains = <_otg2>;
+};
+
  {


Re: [PATCH] doc: sl-mx8mm: Fix mistake in merge conflict resolution

2023-02-08 Thread Fabio Estevam

On 08/02/2023 13:20, Frieder Schrempf wrote:

From: Frieder Schrempf 

There was a conflict between the following two commits, that wasn't
resolved correctly. Fix this.

a93985ddfcc3 ("doc: sl-mx8mm: Update the NXP TF-A source reference")
f0f461287eff ("imx: Suggest the NXP ATF github repo")

Signed-off-by: Frieder Schrempf 
Cc: Heinrich Schuchardt 
Cc: Fabio Estevam 
Cc: Stefano Babic 


Reviewed-by: Fabio Estevam 


Re: [PATCH] board: gateworks: venice: enable XWAY PHY support

2023-02-07 Thread Fabio Estevam
On Tue, Feb 7, 2023 at 8:44 PM Tim Harvey  wrote:
>
> Enable XWAY PHY driver and remove board specific config from
> board_phy_config weak override.
>
> Signed-off-by: Tim Harvey 

Reviewed-by: Fabio Estevam 


[PATCH v2] imx8m: Select BINMAN via SoC level

2023-02-03 Thread Fabio Estevam
Since all imx8m boards have been converted to use binman, select
binman via SoC level rather than making the selection for each board.

Signed-off-by: Fabio Estevam 
Reviewed-by: Peng Fan 
---
Changes since v1:
- Rebased against u-boot-imx tree.
- Collected Peng Fan's Reviewed-by tag.

 arch/arm/mach-imx/imx8m/Kconfig | 35 +
 1 file changed, 1 insertion(+), 34 deletions(-)

diff --git a/arch/arm/mach-imx/imx8m/Kconfig b/arch/arm/mach-imx/imx8m/Kconfig
index 5e4836b02f..9845644ad6 100644
--- a/arch/arm/mach-imx/imx8m/Kconfig
+++ b/arch/arm/mach-imx/imx8m/Kconfig
@@ -2,6 +2,7 @@ if ARCH_IMX8M
 
 config IMX8M
bool
+   select BINMAN
select GICV3 if ARMV8_PSCI
select HAS_CAAM
select ROM_UNIFIED_SECTIONS
@@ -41,13 +42,11 @@ choice
 
 config TARGET_IMX8MQ_CM
bool "Ronetix iMX8MQ-CM SoM"
-   select BINMAN
select IMX8MQ
select IMX8M_LPDDR4
 
 config TARGET_IMX8MQ_EVK
bool "imx8mq_evk"
-   select BINMAN
select IMX8MQ
select IMX8M_LPDDR4
select FSL_CAAM
@@ -56,20 +55,17 @@ config TARGET_IMX8MQ_EVK
 
 config TARGET_IMX8MQ_PHANBELL
bool "imx8mq_phanbell"
-   select BINMAN
select IMX8MQ
select IMX8M_LPDDR4
 
 config TARGET_IMX8MM_DATA_MODUL_EDM_SBC
bool "Data Modul eDM SBC i.MX8M Mini"
-   select BINMAN
select IMX8MM
select IMX8M_LPDDR4
select SUPPORT_SPL
 
 config TARGET_IMX8MM_EVK
bool "imx8mm LPDDR4 EVK board"
-   select BINMAN
select IMX8MM
select SUPPORT_SPL
select IMX8M_LPDDR4
@@ -79,7 +75,6 @@ config TARGET_IMX8MM_EVK
 
 config TARGET_IMX8MM_ICORE_MX8MM
bool "Engicam i.Core MX8M Mini SOM"
-   select BINMAN
select IMX8MM
select SUPPORT_SPL
select IMX8M_LPDDR4
@@ -98,21 +93,18 @@ config TARGET_IMX8MM_ICORE_MX8MM
 
 config TARGET_IMX8MM_MX8MENLO
bool "Support i.MX8M Mini MX8Menlo board based on Toradex Verdin SoM"
-   select BINMAN
select IMX8MM
select SUPPORT_SPL
select IMX8M_LPDDR4
 
 config TARGET_IMX8MM_PHG
bool "i.MX8MM PHG board"
-   select BINMAN
select IMX8MM
select SUPPORT_SPL
select IMX8M_LPDDR4
 
 config TARGET_IMX8MM_VENICE
bool "Support Gateworks Venice iMX8M Mini module"
-   select BINMAN
select IMX8MM
select SUPPORT_SPL
select IMX8M_LPDDR4
@@ -121,7 +113,6 @@ config TARGET_IMX8MM_VENICE
 
 config TARGET_KONTRON_MX8MM
bool "Kontron Electronics N80xx"
-   select BINMAN
select IMX8MM
select SUPPORT_SPL
select IMX8M_LPDDR4
@@ -131,21 +122,18 @@ config TARGET_KONTRON_MX8MM
 
 config TARGET_IMX8MN_BSH_SMM_S2
bool "imx8mn-bsh-smm-s2"
-   select BINMAN
select IMX8MN
select SUPPORT_SPL
select IMX8M_DDR3L
 
 config TARGET_IMX8MN_BSH_SMM_S2PRO
bool "imx8mn-bsh-smm-s2pro"
-   select BINMAN
select IMX8MN
select SUPPORT_SPL
select IMX8M_DDR3L
 
 config TARGET_IMX8MN_EVK
bool "imx8mn LPDDR4 EVK board"
-   select BINMAN
select IMX8MN
select SUPPORT_SPL
select IMX8M_LPDDR4
@@ -154,7 +142,6 @@ config TARGET_IMX8MN_EVK
 
 config TARGET_IMX8MN_DDR4_EVK
bool "imx8mn DDR4 EVK board"
-   select BINMAN
select IMX8MN
select SUPPORT_SPL
select IMX8M_DDR4
@@ -163,7 +150,6 @@ config TARGET_IMX8MN_DDR4_EVK
 
 config TARGET_IMX8MN_VENICE
bool "Support Gateworks Venice iMX8M Nano module"
-   select BINMAN
select IMX8MN
select SUPPORT_SPL
select IMX8M_LPDDR4
@@ -172,14 +158,12 @@ config TARGET_IMX8MN_VENICE
 
 config TARGET_IMX8MP_DH_DHCOM_PDK2
bool "DH electronics DHCOM Premium Developer Kit (2) i.MX8M Plus"
-   select BINMAN
select IMX8MP
select IMX8M_LPDDR4
select SUPPORT_SPL
 
 config TARGET_IMX8MP_ICORE_MX8MP
bool "Engicam i.Core MX8M Plus SOM"
-   select BINMAN
select IMX8MP
select IMX8M_LPDDR4
select SUPPORT_SPL
@@ -193,7 +177,6 @@ config TARGET_IMX8MP_ICORE_MX8MP
 
 config TARGET_IMX8MP_EVK
bool "imx8mp LPDDR4 EVK board"
-   select BINMAN
select IMX8MP
select SUPPORT_SPL
select IMX8M_LPDDR4
@@ -203,7 +186,6 @@ config TARGET_IMX8MP_EVK
 
 config TARGET_IMX8MP_VENICE
bool "Support Gateworks Venice iMX8M Plus module"
-   select BINMAN
select IMX8MP
select SUPPORT_SPL
select IMX8M_LPDDR4
@@ -212,40 +194,34 @@ config TARGET_IMX8MP_VENICE
 
 config TARGET_PICO_IMX8MQ
bool "Support Technexion Pico iMX8MQ"
-   select BINMAN
select IMX8MQ
select IMX8M_LPDDR4
 
 config TARGET

Re: [PATCH 01/11] imx: implement get_effective_memsize

2023-01-31 Thread Fabio Estevam
Hi Peng,

On Mon, Nov 7, 2022 at 4:13 AM Peng Fan (OSS)  wrote:
>
> From: Peng Fan 
>
> To i.MX6/7 which has 2GB memory, the upper 4KB cut off, will cause the
> top 1MB not mapped as normal memory, because ARMV7-A use section
> mapping. So implement i.MX6/7 specific get_effective_memsize to fix the
> issue.
>
> Fixes: 777706bc("common/memsize.c: Fix get_effective_memsize() to check 
> for overflow")

This commit has been reverted in master for non-Power PC platforms:

commit d1f4b090dd17ee11373859f2c91af94bf254af7a
Author: Pali Rohár 
Date:   Sat Jan 7 22:55:26 2023 +0100

common/memsize.c: Check for overflow in get_effective_memsize()
only for mpc85xx

This reverts commit 777706bc ("common/memsize.c: Fix
get_effective_memsize() to check for overflow") for non-mpc85xx platforms.

The changes to this generic function, which is intended to help with
32bit platforms with large amounts of memory has unintended side effects
(which in turn lead to boot failures) on other platforms which were
previously functional.

For now do overflow check only for powerpc mpc85xx platform. It is needed
to prevent crashing of P1/P2 boards with 4GB DDR module in 32-bit mode.

Fixes: 777706bc ("common/memsize.c: Fix
get_effective_memsize() to check for overflow")
Signed-off-by: Pali Rohár 

Can this patch be discarded then?

I just noticed that Stefano applied it to u-boot-imx master-next branch.


Re: [RESEND PATCH] configs: imx8mn_bsh_smm_s2: remove console from bootargs

2023-01-29 Thread Fabio Estevam
On Sun, Jan 29, 2023 at 1:47 PM Dario Binacchi
 wrote:

> The patch re-added 'console=${console}':
> diff --cc include/configs/imx8mn_bsh_smm_s2.h
> index d09c2ab01610,84c19824bdca..c6b296281424
> --- a/include/configs/imx8mn_bsh_smm_s2.h
> +++ b/include/configs/imx8mn_bsh_smm_s2.h
> @@@ -14,11 -14,8 +14,9 @@@
>   #include 
>
>   #define NANDARGS \
> -   "mtdids=" CONFIG_MTDIDS_DEFAULT "\0" \
> -   "mtdparts=" CONFIG_MTDPARTS_DEFAULT "\0" \
> -   "nandargs=setenv bootargs " \
> +   "nandargs=setenv bootargs console=${console} " \
> "${optargs} " \
>  +  "mtdparts=${mtdparts} " \
> "root=${nandroot} " \
> "rootfstype=${nandrootfstype}\0" \
> "nandroot=ubi0:root rw ubi.mtd=nandrootfs\0" \
>
> that I already removed in the commit:
> bede82f75075 ("configs: imx8mn_bsh_smm_s2: remove console from bootargs").
> This is why I decided to add the fix tag.

Understood.

It would be nice to have such an explanation in the commit log.


Re: [RESEND PATCH v2] arm: dts: imx8mn-u-boot: fix DDR3 only support

2023-01-28 Thread Fabio Estevam
On Sat, Jan 28, 2023 at 1:04 PM Dario Binacchi
 wrote:
>
> In case the CONFIG_IMX8M_LPDDR4 and CONFIG_IMX8M_DDR4 options are both
> disabled (i. e. BSH boards), binmain fails because DDR4 bin files are
> missing.
>
> Fixes: 93c4c0e4dd1e75 ("arm: dts: imx8mn-u-boot: Create common 
> imx8mn-u-boot.dtsi")
> Signed-off-by: Dario Binacchi 
> Reviewed-by: Michael Trimarchi 

Reviewed-by: Fabio Estevam 


Re: [RESEND PATCH] configs: imx8mn_bsh_smm_s2: remove console from bootargs

2023-01-28 Thread Fabio Estevam
Hi Dario,

On Sat, Jan 28, 2023 at 1:09 PM Dario Binacchi
 wrote:
>
> The Linux kernel device tree already specifies the device to be used for
> boot console output with a stdout-path property under /chosen.
>
> Fixes: 36b661dc919da ("Merge branch 'next'")

The patch looks good, but I don't understand why this needs a Fixes tag.

Reviewed-by: Fabio Estevam 


Re: [PATCH] Revert "config: tools only: add VIDEO to build bmp_logo"

2023-01-25 Thread Fabio Estevam
Hi Rasmus,

On Wed, Jan 25, 2023 at 11:59 AM Rasmus Villemoes
 wrote:

> So I also got curious about that part, because when I build
> tools-only_defconfig with older U-Boot releases I don't get a bmp_logo
> tool built.
>
> I think I figured that out (but only after it's been revealed that this
> was about Fedora's packaging of u-boot-tools). Fedora seems to do
>
> %make_build HOSTCC="gcc $RPM_OPT_FLAGS" CROSS_COMPILE=""
> tools-only_defconfig O=builds/
>
> %make_build HOSTCC="gcc $RPM_OPT_FLAGS" CROSS_COMPILE="" tools-all O=builds/
>
> so unlike the Yocto case, the build target is tools-all and not
> cross_tools. Hence the top Makefile sets HOST_TOOLS_ALL=y, which in
> tools/Makefile then hits
>
> ifneq ($(HOST_TOOLS_ALL),)
> CONFIG_ARCH_KIRKWOOD = y
> ...
> endif
>
> and that block used to, until 1dc6517649f2, contain
>
> CONFIG_LCD_LOGO = y
>
> with the corresponding
>
> hostprogs-$(CONFIG_LCD_LOGO) += bmp_logo
>
> further down.
>
> IOW, it wasn't really tools-only_defconfig per se that used to cause
> bmp_logo to get built, it was the tools-all target.

Thanks for the in-depth investigation, appreciated it.


Re: [PATCH 41/41] imx9: support i.MX93 9x9 QSB board

2023-01-23 Thread Fabio Estevam
Hi

On Mon, Jan 23, 2023 at 5:30 AM Peng Fan (OSS)  wrote:
>
> From: Peng Fan 
>
> Support i.MX93 9x9 Quick Start Board, UART/SD/MMC/I2C supported.
>
> Boot Log as below:
> U-Boot SPL 2023.01-rc3-00069-g7c3dea52355-dirty (Dec 14 2022 - 11:46:43 +0800)
> SOC: 0xa0009300
> LC: 0x40010
> M33 prepare ok

The last three lines above are too noisy. Please move them to debug level.

> Normal Boot
> Trying to boot from BOOTROM
> Boot Stage: Primary boot
> image offset 0x8000, pagesize 0x200, ivt offset 0x0
> Load image from 0x42000 by ROM_API
> NOTICE:  BL31: v2.6(release):v2.6-277-g5234dfb98
> NOTICE:  BL31: Built : 10:11:35, Dec  9 2022
>
> U-Boot 2023.01-rc3-00069-g7c3dea52355-dirty (Dec 14 2022 - 11:46:43 +0800)
>
> CPU:   i.MX93(52) rev1.0 1700 MHz (running at 1692 MHz)
> CPU:   Consumer temperature grade (0C to 95C) at 33C
> Reset cause: POR  (0x1)
> Model: NXP i.MX93 9x9 Quick Start Board
> DRAM:  2 GiB
> Core:  51 devices, 18 uclasses, devicetree: separate
> MMC:   FSL_SDHC: 0, FSL_SDHC: 1, FSL_SDHC: 2
> Loading Environment from MMC... OK
> In:serial@4438
> Out:   serial@4438
> Err:   serial@4438
>
> BuildInfo:
>   - ELE firmware version 0.0.8-80d3db4b

What does ELE firmware mean?

Please add a doc/board/nxp/imx93_qsb.rst with instructions on how to
build U-Boot + all required firmware for this board.

> +/* Link Definitions */
> +
> +#define CFG_SYS_INIT_RAM_ADDR  0x8000
> +#define CFG_SYS_INIT_RAM_SIZE  0x20
> +
> +#define CFG_SYS_SDRAM_BASE 0x8000
> +#define PHYS_SDRAM 0x8000
> +#define PHYS_SDRAM_SIZE0x8000 /* 2GB DDR */
> +
> +/* Using ULP WDOG for reset */
> +#define WDOG_BASE_ADDR WDG3_BASE_ADDR

This should be retrieved from the device tree.


Re: [PATCH] Revert "config: tools only: add VIDEO to build bmp_logo"

2023-01-19 Thread Fabio Estevam
On Thu, Jan 19, 2023 at 8:18 AM Peter Robinson  wrote:

> Did you read the original thread?

I only read your commit log and it is not clear if it is a regression
and which commit caused the problem.
It lacks a Fixes tag too.

> > - What is the exact problem you are trying to solve? How can we reproduce 
> > it?
>
> Building that tool with the tools only option.

When I try to build U-Boot 2023.01 u-boot-tools-native in OpenEmbedded
it works fine.

It fails when trying to build it for the target since commit
1cfba53ca46c ("config: tools only: add VIDEO to build
bmp_logo").

> > - Is it a regression? What is the commit that caused the problem you
> > are trying to solve?

What about this part?

Tom, Otavio? Any suggestions, please?


<    3   4   5   6   7   8   9   10   11   12   >