]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
bdinfo: Show the RAM top and approximate stack pointer
authorSimon Glass <sjg@chromium.org>
Sun, 16 Jul 2023 03:38:46 +0000 (21:38 -0600)
committerBin Meng <bmeng@tinylab.org>
Mon, 17 Jul 2023 09:12:03 +0000 (17:12 +0800)
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 <sjg@chromium.org>
Reviewed-by: Nikhil M Jain <n-jain1@ti.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Nikhil M Jain <n-jain1@ti.com>
cmd/Kconfig
cmd/bdinfo.c
test/cmd/bdinfo.c

index fd76972eaa378bd2e231ef9d4928c62d9af9b484..ecfd5752377265aa9fb35f0e113675fa1c43ae3c 100644 (file)
@@ -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
index dab73f1d93c472b7e4cddfc161c5cd39bc4b83bd..44e6d6a972e49fb5d40fd1da8cfb973478036bb0 100644 (file)
@@ -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;
index 6480393fd5d877e060c31dc522f13115e339a747..8c09281cac0d97c4486da21d13e77c4eed457860 100644 (file)
@@ -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;