mx6sabresd: Fix U-Boot corruption after saving the environment
Subsystems (2)
Fabio Estevam
reviewerPATCH v2 1/3 mx6sabresd: Fix U-Boot corruption after saving the environment
From: Fabio Estevam <[email protected]>
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 selecting CONFIG_LTO so that the U-Boot proper size can be reduced.
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 = 0xc000 - 69 * 1024 CONFIG_BOARD_SIZE_LIMIT = 715766
---
Changes since v1:
- Select LTO. (Tom)
configs/mx6sabresd_defconfig | 3 +++ 1 file changed, 3 insertions(+)
configs/mx6sabresd_defconfig +3 -0
@@ -21,6 +21,9 @@ CONFIG_SPL_SERIAL=y CONFIG_SPL=y CONFIG_SPL_LIBDISK_SUPPORT=y CONFIG_PCI=y +CONFIG_LTO=y +CONFIG_HAS_BOARD_SIZE_LIMIT=y +CONFIG_BOARD_SIZE_LIMIT=715766 CONFIG_FIT=y CONFIG_SPL_FIT_PRINT=y CONFIG_SPL_LOAD_FIT=y
Signature · 1 line
2.34.1
Fabio Estevam
reviewerPATCH v2 2/3 mx6sabresd: Convert to watchdog driver model
From: Fabio Estevam <[email protected]>
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.
---
Changes since v1:
- None.
arch/arm/dts/imx6qdl-sabresd-u-boot.dtsi | 9 +++++++++ configs/mx6sabresd_defconfig | 3 +++ 2 files changed, 12 insertions(+)
arch/arm/dts/imx6qdl-sabresd-u-boot.dtsi +9 -0
@@ -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; +};
configs/mx6sabresd_defconfig +3 -0
@@ -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
Signature · 1 line
2.34.1
Re: [PATCH v2 2/3] mx6sabresd: Convert to watchdog driver model
Quoted 34 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
Commit
68dcbdd594d4("ARM: imx: Add weak defaultreset_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 <[email protected]>---
Changes since v1:
- None.arch/arm/dts/imx6qdl-sabresd-u-boot.dtsi | 9 +++++++++ configs/mx6sabresd_defconfig | 3 +++ 2 files changed, 12 insertions(+)arch/arm/dts/imx6qdl-sabresd-u-boot.dtsi +5
-0@@ -9,6 +9,11 @@ aliases { mmc1 = &usdhc3; }; + wdt-reboot { + compatible = "wdt-reboot"; + wdt = <&wdog2>; + bootph-pre-ram; + }; }; &usdhc3 {
arch/arm/dts/imx6qdl-sabresd-u-boot.dtsi line 29
Quoted 7 lines
arch/arm/dts/imx6qdl-sabresd-u-boot.dtsi +4
-0@@ -18,3 +23,7 @@ &pinctrl_usdhc3 { bootph-pre-ram; }; + +&wdog2 { + bootph-pre-ram; +};
Can all of this be upstreamed as well?
Signature · 1 line
Tom
Fabio Estevam
reviewerRe: [PATCH v2 2/3] mx6sabresd: Convert to watchdog driver model
Quoted 1 line · Tom Rini
Can all of this be upstreamed as well?
I can try it, but that would go into kernel 6.9 in the best case.
For now, let's keep it in u-boot.dtsi.
Re: [PATCH v2 2/3] mx6sabresd: Convert to watchdog driver model
Quoted 7 lines · Fabio Estevam
Quoted 1 line · Tom Rini
Can all of this be upstreamed as well?
I can try it, but that would go into kernel 6.9 in the best case.
For now, let's keep it in
u-boot.dtsi.
Yes, sorry, I'm not saying don't do this here, but can you please submit it so that long term this can be converted to OF_UPSTREAM and also not have a -u-boot.dtsi potentially.
Signature · 1 line
Tom
Fabio Estevam
reviewerPATCH v2 3/3 mx6sabresd: Remove board_phy_config()
In reply to Fabio EstevamFrom: Fabio Estevam <[email protected]>
With Ethernet DM in place, there is no longer the need for having the board_phy_config() anymore.
Remove it.
Confirmed that TFTP transfer still works fine without board_phy_config().
---
Changes since v1:
- Newly introduced.
board/freescale/mx6sabresd/mx6sabresd.c | 34 ------------------------- 1 file changed, 34 deletions(-)
board/freescale/mx6sabresd/mx6sabresd.c +0 -34
@@ -7,7 +7,6 @@#include <image.h> #include <init.h> -#include <net.h> #include <asm/arch/clock.h> #include <asm/arch/imx-regs.h> #include <asm/arch/iomux.h>
@@ -254,39 +253,6 @@ int board_mmc_init(struct bd_info *bis) }#endif -static int ar8031_phy_fixup (struct phy_device *phydev) -{ -unsigned short val; - -/* To enable AR8031 ouput a 125MHz clk from CLK_25M */ -phy_write (phydev,MDIO_DEVAD_NONE ,0xd ,0x7 ); -phy_write (phydev,MDIO_DEVAD_NONE ,0xe ,0x8016 ); -phy_write (phydev,MDIO_DEVAD_NONE ,0xd ,0x4007 ); - - val =phy_read (phydev,MDIO_DEVAD_NONE ,0xe ); - val &=0xffe3 ; - val |=0x18 ; -phy_write (phydev,MDIO_DEVAD_NONE ,0xe , val); - -/* introduce tx clock delay */ -phy_write (phydev,MDIO_DEVAD_NONE ,0x1d ,0x5 ); - val =phy_read (phydev,MDIO_DEVAD_NONE ,0x1e ); - val |=0x0100 ; -phy_write (phydev,MDIO_DEVAD_NONE ,0x1e , val); - -return 0 ; -} - -int board_phy_config (struct phy_device *phydev) -{ -ar8031_phy_fixup (phydev); - -if (phydev->drv->config) - phydev->drv->config (phydev); - -return 0 ; -} -#if defined(CONFIG_VIDEO_IPUV3 )static void disable_lvds (struct display_info_t const *dev) {
Signature · 1 line
2.34.1
Re: [PATCH v2 3/3] mx6sabresd: Remove board_phy_config()
Hello Fabio,
Quoted 71 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
With Ethernet DM in place, there is no longer the need for having the
board_phy_config()anymore.Remove it.
Confirmed that TFTP transfer still works fine without
board_phy_config().Signed-off-by Fabio Estevam <[email protected]>---
Changes since v1:
- Newly introduced.board/freescale/mx6sabresd/mx6sabresd.c | 34 ------------------------- 1 file changed, 34 deletions(-)board/freescale/mx6sabresd/mx6sabresd.c +0
-35@@ -7,7 +7,6 @@#include <image.h> #include <init.h> -#include <net.h> #include <asm/arch/clock.h> #include <asm/arch/imx-regs.h> #include <asm/arch/iomux.h> @@ -254,39 +253,6 @@ int board_mmc_init(struct bd_info *bis) }#endif -static int ar8031_phy_fixup (struct phy_device *phydev) -{ -unsigned short val; - -/* To enable AR8031 ouput a 125MHz clk from CLK_25M */ -phy_write (phydev,MDIO_DEVAD_NONE ,0xd ,0x7 ); -phy_write (phydev,MDIO_DEVAD_NONE ,0xe ,0x8016 ); -phy_write (phydev,MDIO_DEVAD_NONE ,0xd ,0x4007 ); - - val =phy_read (phydev,MDIO_DEVAD_NONE ,0xe ); - val &=0xffe3 ; - val |=0x18 ; -phy_write (phydev,MDIO_DEVAD_NONE ,0xe , val); - -/* introduce tx clock delay */ -phy_write (phydev,MDIO_DEVAD_NONE ,0x1d ,0x5 ); - val =phy_read (phydev,MDIO_DEVAD_NONE ,0x1e ); - val |=0x0100 ; -phy_write (phydev,MDIO_DEVAD_NONE ,0x1e , val); - -return 0 ; -} - -int board_phy_config (struct phy_device *phydev) -{ -ar8031_phy_fixup (phydev); - -if (phydev->drv->config) - phydev->drv->config (phydev); - -return 0 ; -} -#if defined(CONFIG_VIDEO_IPUV3 )static void disable_lvds (struct display_info_t const *dev) { --
Quoted 2 lines
2.34.1
Signature · 6 lines
Best regards - Freundliche Grüsse - Meilleures salutations Igor Opaniuk Senior Software Engineer, Embedded & Security E: [email protected] W: www.foundries.io
Quoted 14 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
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 selecting
CONFIG_LTOso that the U-Boot proper size can be reduced.Also, to prevent this same problem to happen in the future, use
CONFIG_BOARD_SIZE_LIMIT, which can detect the overlap in build-time.
Quoted 7 lines
CONFIG_BOARD_SIZE_LIMITis calculated as follows:
CONFIG_BOARD_SIZE_LIMIT=CONFIG_ENV_OFFSET- u-boot-img.dtb offsetCONFIG_BOARD_SIZE_LIMIT=0xc000- 69 * 1024CONFIG_BOARD_SIZE_LIMIT= 715766Signed-off-by Fabio Estevam <[email protected]>
Thanks!
Signature · 1 line
Tom
Quoted 44 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
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 selecting
CONFIG_LTOso that the U-Boot proper size can be reduced.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_LIMITis calculated as follows:
CONFIG_BOARD_SIZE_LIMIT=CONFIG_ENV_OFFSET- u-boot-img.dtb offsetCONFIG_BOARD_SIZE_LIMIT=0xc000- 69 * 1024CONFIG_BOARD_SIZE_LIMIT= 715766Signed-off-by Fabio Estevam <[email protected]>---
Changes since v1:
- Select LTO. (Tom)configs/mx6sabresd_defconfig | 3 +++ 1 file changed, 3 insertions(+)configs/mx6sabresd_defconfig +3
-1@@ -21,6 +21,9 @@ CONFIG_SPL_SERIAL=y CONFIG_SPL=y CONFIG_SPL_LIBDISK_SUPPORT=y CONFIG_PCI=y +CONFIG_LTO=y +CONFIG_HAS_BOARD_SIZE_LIMIT=y +CONFIG_BOARD_SIZE_LIMIT=715766 CONFIG_FIT=y CONFIG_SPL_FIT_PRINT=y CONFIG_SPL_LOAD_FIT=y --
Quoted 2 lines
2.34.1
btw, from my experience, the same issue will probably occur again in future, especially when the current U-Boot size is already close to the defined limit (yes, with this patch it will be reported during compile time, but still).
Have you considered adjusting the boot image layout instead (moving CONFIG_ENV_OFFSET, so unlikely
U-Boot image will overlap again) to tackle feature problems?
Signature · 6 lines
Best regards - Freundliche Grüsse - Meilleures salutations Igor Opaniuk Senior Software Engineer, Embedded & Security E: [email protected] W: www.foundries.io
Quoted 50 lines · Igor Opaniuk
Quoted 44 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
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 selecting
CONFIG_LTOso that the U-Boot proper size can be reduced.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_LIMITis calculated as follows:
CONFIG_BOARD_SIZE_LIMIT=CONFIG_ENV_OFFSET- u-boot-img.dtb offsetCONFIG_BOARD_SIZE_LIMIT=0xc000- 69 * 1024CONFIG_BOARD_SIZE_LIMIT= 715766Signed-off-by Fabio Estevam <[email protected]>---
Changes since v1:
- Select LTO. (Tom)configs/mx6sabresd_defconfig | 3 +++ 1 file changed, 3 insertions(+)configs/mx6sabresd_defconfig +3
-1@@ -21,6 +21,9 @@ CONFIG_SPL_SERIAL=y CONFIG_SPL=y CONFIG_SPL_LIBDISK_SUPPORT=y CONFIG_PCI=y +CONFIG_LTO=y +CONFIG_HAS_BOARD_SIZE_LIMIT=y +CONFIG_BOARD_SIZE_LIMIT=715766 CONFIG_FIT=y CONFIG_SPL_FIT_PRINT=y CONFIG_SPL_LOAD_FIT=y --Quoted 2 lines
2.34.1
Reviewed-by Igor Opaniuk <[email protected]>
Quoted 7 lines
btw, from my experience, the same issue will probably occur again in future, especially when the current U-Boot size is already close to the defined limit (yes, with this patch it will be reported during compile time, but still).
Have you considered adjusting the boot image layout instead (moving
CONFIG_ENV_OFFSET, so unlikely
U-Boot image will overlap again) to tackle feature problems?
I've just checked the previous patch version, where
you addressed that exactly with CONFIG_ENV_OFFSET change and following suggestions/objections from Tom, so sorry for the noise :)
Quoted 8 lines
--
Best regards - Freundliche Grüsse - Meilleures salutationsIgor Opaniuk
Senior Software Engineer, Embedded & Security
E: [email protected]
W: www.foundries.io
Signature · 6 lines
Best regards - Freundliche Grüsse - Meilleures salutations Igor Opaniuk Senior Software Engineer, Embedded & Security E: [email protected] W: www.foundries.io
Quoted 15 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
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 selecting
CONFIG_LTOso that the U-Boot proper size can be reduced.Also, to prevent this same problem to happen in the future, use
CONFIG_BOARD_SIZE_LIMIT, which can detect the overlap in build-time.
Quoted 7 lines
CONFIG_BOARD_SIZE_LIMITis calculated as follows:
CONFIG_BOARD_SIZE_LIMIT=CONFIG_ENV_OFFSET- u-boot-img.dtb offsetCONFIG_BOARD_SIZE_LIMIT=0xc000- 69 * 1024CONFIG_BOARD_SIZE_LIMIT= 715766Signed-off-by Fabio Estevam <[email protected]>
Applied all, thanks.