summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWeijie Gao <weijie.gao@mediatek.com>2019-05-16 17:19:13 +0800
committerTom Rini <trini@konsulko.com>2019-07-07 17:38:17 -0400
commit84b2416b6a0531a9ad46a4e445e558f183c50171 (patch)
tree7c5fa38150ac70d43bb03a536b899d2a2f04a474
parent3c1ead908128436b7df61b8ffd5642a924418bb6 (diff)
board_r: move initr_watchdog to be called after initr_serial
The initr_watchdog is currently placed before initr_serial. The initr_watchdog calls printf and printf finally calls ops->putc of a serial driver. However, gd->cur_serial_dev points to a udevice allocated in board_f. The gd->cur_serial_dev->driver->ops->putc points the the code region before relocation. Some serial drivers call WATCHDOG_RESET() in ops->putc. When DM is enabled for watchdog, watchdog_reset() is called. watchdog_reset() calls get_timer to get current timer. On some platforms the timer driver is also a DM driver. initr_watchdog is placed right after initr_dm, which means the timer driver hasn't been initialized. So dm_timer_init() is called. To create a new udevice, calloc is called. However start from ops->putc, u-boot execution flow is redirected into the memory region before relocation (board_f). In board_f, dlmalloc hasn't been initialized. The call to calloc will fail, and this will cause DM to print out an error message, and it will call printf again, causing recursive error outputs. This patch places initr_watchdog after initr_serial to solve this issue. Cc: Stefan Roese <sr@denx.de> Reviewed-by: Ryder Lee <ryder.lee@mediatek.com> Signed-off-by: Weijie Gao <weijie.gao@mediatek.com> Reviewed-by: Stefan Roese <sr@denx.de> Tested-by: Frank Wunderlich <frank-w@public-files.de> Tested-by: Suniel Mahesh <sunil.m@techveda.org>
-rw-r--r--common/board_r.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/common/board_r.c b/common/board_r.c
index 150e8cd424..df24021f2c 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -678,9 +678,6 @@ static init_fnc_t init_sequence_r[] = {
#ifdef CONFIG_DM
initr_dm,
#endif
-#if defined(CONFIG_WDT)
- initr_watchdog,
-#endif
#if defined(CONFIG_ARM) || defined(CONFIG_NDS32) || defined(CONFIG_RISCV) || \
defined(CONFIG_SANDBOX)
board_init, /* Setup chipselects */
@@ -700,6 +697,9 @@ static init_fnc_t init_sequence_r[] = {
stdio_init_tables,
initr_serial,
initr_announce,
+#if defined(CONFIG_WDT)
+ initr_watchdog,
+#endif
INIT_FUNC_WATCHDOG_RESET
#ifdef CONFIG_NEEDS_MANUAL_RELOC
initr_manual_reloc_cmdtable,