public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH 1/2] mx6sabresd: Fix U-Boot corruption after saving the environment
@ 2024-02-02  1:48 Fabio Estevam
  2024-02-02  1:48 ` [PATCH 2/2] mx6sabresd: Convert to watchdog driver model Fabio Estevam
  2024-02-02 13:51 ` [PATCH 1/2] mx6sabresd: Fix U-Boot corruption after saving the environment Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: Fabio Estevam @ 2024-02-02  1:48 UTC (permalink / raw)
  To: sbabic; +Cc: uboot-imx, u-boot, Fabio Estevam

From: Fabio Estevam <festevam@denx.de>

U-Boot binary has grown in such a way that it goes beyond the reserved
area for the environment variables.
    
Running "saveenv" and rebooting the board causes U-Boot to hang because
of this overlap.
    
Fix this problem by increasing the CONFIG_ENV_OFFSET.
    
Also, to prevent this same problem to happen in the future, use
CONFIG_BOARD_SIZE_LIMIT, which can detect the overlap in build-time.
    
CONFIG_BOARD_SIZE_LIMIT is calculated as follows:

CONFIG_BOARD_SIZE_LIMIT = CONFIG_ENV_OFFSET - u-boot-img.dtb offset
CONFIG_BOARD_SIZE_LIMIT = 0xd000 - 69 * 1024
CONFIG_BOARD_SIZE_LIMIT = 781312

Signed-off-by: Fabio Estevam <festevam@denx.de>
---
 configs/mx6sabresd_defconfig | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/configs/mx6sabresd_defconfig b/configs/mx6sabresd_defconfig
index a90efe4a7786..f19df607e7ae 100644
--- a/configs/mx6sabresd_defconfig
+++ b/configs/mx6sabresd_defconfig
@@ -9,7 +9,7 @@ CONFIG_SPL_LIBGENERIC_SUPPORT=y
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_SF_DEFAULT_SPEED=20000000
 CONFIG_ENV_SIZE=0x2000
-CONFIG_ENV_OFFSET=0xC0000
+CONFIG_ENV_OFFSET=0xd0000
 CONFIG_MX6QDL=y
 CONFIG_TARGET_MX6SABRESD=y
 CONFIG_DM_GPIO=y
@@ -24,6 +24,8 @@ CONFIG_PCI=y
 CONFIG_FIT=y
 CONFIG_SPL_FIT_PRINT=y
 CONFIG_SPL_LOAD_FIT=y
+CONFIG_HAS_BOARD_SIZE_LIMIT=y
+CONFIG_BOARD_SIZE_LIMIT=781312
 CONFIG_SUPPORT_RAW_INITRD=y
 CONFIG_USE_BOOTCOMMAND=y
 CONFIG_BOOTCOMMAND="run findfdt;mmc dev ${mmcdev};if mmc rescan; then if run loadbootscript; then run bootscript; else if run loadimage; then run mmcboot; else run netboot; fi; fi; else run netboot; fi"
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] mx6sabresd: Convert to watchdog driver model
  2024-02-02  1:48 [PATCH 1/2] mx6sabresd: Fix U-Boot corruption after saving the environment Fabio Estevam
@ 2024-02-02  1:48 ` Fabio Estevam
  2024-02-02 13:51 ` [PATCH 1/2] mx6sabresd: Fix U-Boot corruption after saving the environment Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Fabio Estevam @ 2024-02-02  1:48 UTC (permalink / raw)
  To: sbabic; +Cc: uboot-imx, u-boot, Fabio Estevam

From: Fabio Estevam <festevam@denx.de>

Commit 68dcbdd594d4 ("ARM: imx: Add weak default reset_cpu()") caused
the 'reset' command in U-Boot to not cause a board reset.

Fix it by switching to the watchdog driver model via sysreset, which
is the preferred method for implementing the watchdog reset.

Signed-off-by: Fabio Estevam <festevam@denx.de>
---
 arch/arm/dts/imx6qdl-sabresd-u-boot.dtsi | 9 +++++++++
 configs/mx6sabresd_defconfig             | 3 +++
 2 files changed, 12 insertions(+)

diff --git a/arch/arm/dts/imx6qdl-sabresd-u-boot.dtsi b/arch/arm/dts/imx6qdl-sabresd-u-boot.dtsi
index 5c4101b76da2..9e9c4422f00e 100644
--- a/arch/arm/dts/imx6qdl-sabresd-u-boot.dtsi
+++ b/arch/arm/dts/imx6qdl-sabresd-u-boot.dtsi
@@ -9,6 +9,11 @@
 	aliases {
 		mmc1 = &usdhc3;
 	};
+	wdt-reboot {
+		compatible = "wdt-reboot";
+		wdt = <&wdog2>;
+		bootph-pre-ram;
+	};
 };
 
 &usdhc3 {
@@ -18,3 +23,7 @@
 &pinctrl_usdhc3 {
 	bootph-pre-ram;
 };
+
+&wdog2 {
+	bootph-pre-ram;
+};
diff --git a/configs/mx6sabresd_defconfig b/configs/mx6sabresd_defconfig
index f19df607e7ae..69685f12eb10 100644
--- a/configs/mx6sabresd_defconfig
+++ b/configs/mx6sabresd_defconfig
@@ -103,6 +103,8 @@ CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
 CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
+CONFIG_SYSRESET=y
+CONFIG_SYSRESET_WATCHDOG=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
 CONFIG_MXC_SPI=y
@@ -129,3 +131,4 @@ CONFIG_IMX_HDMI=y
 CONFIG_SPLASH_SCREEN=y
 CONFIG_SPLASH_SCREEN_ALIGN=y
 CONFIG_BMP_16BPP=y
+CONFIG_IMX_WATCHDOG=y
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] mx6sabresd: Fix U-Boot corruption after saving the environment
  2024-02-02  1:48 [PATCH 1/2] mx6sabresd: Fix U-Boot corruption after saving the environment Fabio Estevam
  2024-02-02  1:48 ` [PATCH 2/2] mx6sabresd: Convert to watchdog driver model Fabio Estevam
@ 2024-02-02 13:51 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2024-02-02 13:51 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: sbabic, uboot-imx, u-boot, Fabio Estevam

[-- Attachment #1: Type: text/plain, Size: 1038 bytes --]

On Thu, Feb 01, 2024 at 10:48:48PM -0300, Fabio Estevam wrote:

> From: Fabio Estevam <festevam@denx.de>
> 
> U-Boot binary has grown in such a way that it goes beyond the reserved
> area for the environment variables.
>     
> Running "saveenv" and rebooting the board causes U-Boot to hang because
> of this overlap.
>     
> Fix this problem by increasing the CONFIG_ENV_OFFSET.
>     
> Also, to prevent this same problem to happen in the future, use
> CONFIG_BOARD_SIZE_LIMIT, which can detect the overlap in build-time.
>     
> CONFIG_BOARD_SIZE_LIMIT is calculated as follows:
> 
> CONFIG_BOARD_SIZE_LIMIT = CONFIG_ENV_OFFSET - u-boot-img.dtb offset
> CONFIG_BOARD_SIZE_LIMIT = 0xd000 - 69 * 1024
> CONFIG_BOARD_SIZE_LIMIT = 781312
> 
> Signed-off-by: Fabio Estevam <festevam@denx.de>
> ---
>  configs/mx6sabresd_defconfig | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

I don't like when we have to move the environment like this, can we trim
things down instead? Perhaps LTO?

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-02-02 13:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-02  1:48 [PATCH 1/2] mx6sabresd: Fix U-Boot corruption after saving the environment Fabio Estevam
2024-02-02  1:48 ` [PATCH 2/2] mx6sabresd: Convert to watchdog driver model Fabio Estevam
2024-02-02 13:51 ` [PATCH 1/2] mx6sabresd: Fix U-Boot corruption after saving the environment Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox