[PATCH] cmd: go: Flush cache before jumping to app/image

Stefan Roese sr at denx.de
Wed Feb 12 13:21:51 CET 2020

It has been noticed on MT7628/88 platforms, that booting the RAM image
does not work reliably. Sometimes it works and sometimes not. Debugging
showed that this "might" be a cache related issue as very strange
errors occured (output corrupted etc).

This patch adds a cache flush for the complete SDRAM area to the go cmd
before jumping to the entry point. The complete area is flushed as we
don't know at this point, how big the area of the "application" really

Signed-off-by: Stefan Roese <sr at denx.de>
Cc: Daniel Schwierzeck <daniel.schwierzeck at gmail.com>
Cc: Mauro Condarelli <mc5686 at mclink.it>
Cc: Weijie Gao <weijie.gao at mediatek.com>
 cmd/boot.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/cmd/boot.c b/cmd/boot.c
index 9150fce80b..968522face 100644
--- a/cmd/boot.c
+++ b/cmd/boot.c
@@ -9,10 +9,13 @@
 #include <common.h>
 #include <command.h>
+#include <cpu_func.h>
 #include <net.h>
 /* Allow ports to override the default behavior */
 unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc,
@@ -33,6 +36,13 @@ static int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	printf ("## Starting application at 0x%08lX ...\n", addr);
+	/*
+	 * Flush cache before jumping to application. Let's flush the
+	 * whole SDRAM area, since we don't know the size of the image
+	 * that was loaded.
+	 */
+	flush_cache(gd->bd->bi_memstart, gd->bd->bi_memsize);
 	 * pass address parameter as argv[0] (aka command name),
 	 * and all remaining args

More information about the U-Boot mailing list