diff mbox series

[U-Boot] board/BuR: invalidate ${dtbaddr} before cfgscr

Message ID 1558020259-6064-1-git-send-email-oe5hpm@oevsv.at
State Accepted
Commit 0ea4fc4dcf90ef0281ee413892ba3281de3f54c8
Delegated to: Tom Rini
Headers show
Series [U-Boot] board/BuR: invalidate ${dtbaddr} before cfgscr | expand

Commit Message

Hannes Schmelzer May 16, 2019, 3:24 p.m. UTC
From: Hannes Schmelzer <hannes.schmelzer@br-automation.com>

The first memory location of ${dtbaddr} may be still valid after a warm
restart of the machine and 'fdt addr ${dtbaddr}' doesn't recognize that
the cfgscript didn't run properly and fallback mechanism with copying
the internal fdt ${fdtcontroladdr} to ${dtbaddr} doesn't catch this.

To get sure that we have proper failsafe behaviour we simply zero the
first memory location of ${dtbaddr} for getting sure that the fdt is
invalid if cfgscript didn't run.

Signed-off-by: Hannes Schmelzer <hannes.schmelzer@br-automation.com>

Signed-off-by: Hannes Schmelzer <oe5hpm@oevsv.at>
---

 include/configs/brppt1.h | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Comments

Tom Rini May 29, 2019, 5:16 p.m. UTC | #1
On Thu, May 16, 2019 at 05:24:19PM +0200, Hannes Schmelzer wrote:

> From: Hannes Schmelzer <hannes.schmelzer@br-automation.com>
> 
> The first memory location of ${dtbaddr} may be still valid after a warm
> restart of the machine and 'fdt addr ${dtbaddr}' doesn't recognize that
> the cfgscript didn't run properly and fallback mechanism with copying
> the internal fdt ${fdtcontroladdr} to ${dtbaddr} doesn't catch this.
> 
> To get sure that we have proper failsafe behaviour we simply zero the
> first memory location of ${dtbaddr} for getting sure that the fdt is
> invalid if cfgscript didn't run.
> 
> Signed-off-by: Hannes Schmelzer <hannes.schmelzer@br-automation.com>
> 
> Signed-off-by: Hannes Schmelzer <oe5hpm@oevsv.at>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/include/configs/brppt1.h b/include/configs/brppt1.h
index 51af93a..82f3f1a 100644
--- a/include/configs/brppt1.h
+++ b/include/configs/brppt1.h
@@ -66,7 +66,8 @@ 
 #define NANDTGTS \
 "mtdids=" CONFIG_MTDIDS_DEFAULT "\0" \
 "mtdparts=" CONFIG_MTDPARTS_DEFAULT "\0" \
-"cfgscr=nand read ${cfgaddr} cfgscr && source ${cfgaddr}\0" \
+"cfgscr=mw ${dtbaddr} 0; nand read ${cfgaddr} cfgscr && source ${cfgaddr};" \
+" fdt addr ${dtbaddr} || cp ${fdtcontroladdr} ${dtbaddr} 4000\0" \
 "nandargs=setenv bootargs console=${console} ${optargs} ${optargs_rot} " \
 	"root=mtd6 rootfstype=jffs2 b_mode=${b_mode}\0" \
 "b_nand=nand read ${loadaddr} kernel; nand read ${dtbaddr} dtb; " \
@@ -104,7 +105,9 @@ 
 #ifdef CONFIG_ENV_IS_IN_MMC
 #define MMCTGTS \
 MMCSPI_TGTS \
-"cfgscr=mmc dev 1; mmc read ${cfgaddr} 200 80; source ${cfgaddr}\0"
+"cfgscr=mw ${dtbaddr} 0;" \
+" mmc dev 1; mmc read ${cfgaddr} 200 80; source ${cfgaddr};" \
+" fdt addr ${dtbaddr} || cp ${fdtcontroladdr} ${dtbaddr} 4000\0"
 #else
 #define MMCTGTS ""
 #endif /* CONFIG_MMC */
@@ -112,7 +115,9 @@  MMCSPI_TGTS \
 #ifdef CONFIG_SPI
 #define SPITGTS \
 MMCSPI_TGTS \
-"cfgscr=sf probe; sf read ${cfgaddr} 0xC0000 10000; source ${cfgaddr}\0"
+"cfgscr=mw ${dtbaddr} 0;" \
+" sf probe; sf read ${cfgaddr} 0xC0000 10000; source ${cfgaddr};" \
+" fdt addr ${dtbaddr} || cp ${fdtcontroladdr} ${dtbaddr} 4000\0"
 #else
 #define SPITGTS ""
 #endif /* CONFIG_SPI */