From b279f5170a807a87a5726bcbeb0bc98937102eee Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 15 Jul 2023 21:38:46 -0600 Subject: [PATCH] bdinfo: Show the RAM top and approximate stack pointer These are useful pieces of information when debugging. The RAM top shows where U-Boot started allocating memory from, before it relocated. The stack pointer can be checked to ensure it is in the correct region. Signed-off-by: Simon Glass Reviewed-by: Nikhil M Jain Reviewed-by: Bin Meng Tested-by: Nikhil M Jain --- cmd/Kconfig | 8 ++++++++ cmd/bdinfo.c | 5 +++++ test/cmd/bdinfo.c | 7 +++++++ 3 files changed, 20 insertions(+) diff --git a/cmd/Kconfig b/cmd/Kconfig index fd76972..ecfd575 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -135,6 +135,14 @@ config CMD_BDI help Print board info +config CMD_BDINFO_EXTRA + bool "bdinfo extra features" + default y if SANDBOX || X86 + help + Show additional information about the board. This uses a little more + code space but provides more options, particularly those useful for + bringup, development and debugging. + config CMD_CONFIG bool "config" default SANDBOX diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c index dab73f1..44e6d6a 100644 --- a/cmd/bdinfo.c +++ b/cmd/bdinfo.c @@ -173,6 +173,11 @@ int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) } print_serial(gd->cur_serial_dev); + if (IS_ENABLED(CONFIG_CMD_BDINFO_EXTRA)) { + bdinfo_print_num_ll("stack ptr", (ulong)&bd); + bdinfo_print_num_ll("ram_top ptr", (ulong)gd->ram_top); + } + arch_print_bdinfo(); return 0; diff --git a/test/cmd/bdinfo.c b/test/cmd/bdinfo.c index 6480393..8c09281 100644 --- a/test/cmd/bdinfo.c +++ b/test/cmd/bdinfo.c @@ -205,6 +205,13 @@ static int bdinfo_test_move(struct unit_test_state *uts) ut_assertok(test_num_l(uts, " clock", info.clock)); } + if (IS_ENABLED(CONFIG_CMD_BDINFO_EXTRA)) { + ut_assert_nextlinen("stack ptr"); + ut_assertok(test_num_ll(uts, "ram_top ptr", + (unsigned long long)gd->ram_top)); + ut_assertok(test_num_l(uts, "malloc base", gd_malloc_start())); + } + ut_assertok(ut_check_console_end(uts)); return 0; -- 2.7.4