[U-Boot] [PATCH] README.arm-relocation: get relocated address in gdb

When your emulator is connected at reset (or is used to load u-boot) it is possible to get the relocation address from the parameter passed to relocate_code() instead of building with -DDEBUG and extracting from the console messages.
Document this alternate method following the style of the original method written by Heiko Schocher.
Signed-off-by: Ben Gardiner bengardiner@nanometrics.ca CC: Heiko Schocher hs@denx.de --- doc/README.arm-relocation | 56 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 56 insertions(+), 0 deletions(-)
diff --git a/doc/README.arm-relocation b/doc/README.arm-relocation index c0957c2..1c2d783 100644 --- a/doc/README.arm-relocation +++ b/doc/README.arm-relocation @@ -192,3 +192,59 @@ Now running in RAM - U-Boot at: 8ff08000 ^^^^^^^^
Now you can use gdb as usual :-) + +An alternative to retrieving the relocated base address from the debug printfs +is to evaluate the 'addr' parameter of relocate_code() and use its value as the +argument to add-symbol-file. This method is only available when your emulator +is connected to the target on reset. + +----------------- + +a) [different than above] Compile as usual -- adding -DDEBUG can change the +relocated base address, this method will work on builds that do not have any +extra verbosity on boot + +----------------- +b) [same as above] start debugger +c) [same as above] connect to target +[remainder is different than above] +----------------- + +d) set breakpoint on relocate_code + +(gdb) b relocate_code +Breakpoint 1 at 0xc1080078: file start.S, line 196. + +----------------- + +e) run target until relocate_code + +(gdb) c +Breakpoint 2, relocate_code () at start.S:197 +197 mov r5, r1 /* save addr of gd */ +(gdb) d +Delete all breakpoints? (y or n) y + +----------------- + +f) discard symbol file + +(gdb) symbol-file +Discard symbol table from `/home/bengardiner/src/u-boot/u-boot'? (y or n) y +No symbol file now. +(gdb) + +----------------- + +g) load new symbol table using the addr parameter (aka $r2) + +(gdb) add-symbol-file u-boot $r2 +add symbol table from file "u-boot" at + .text_addr = 0xc7f53000 +(y or n) y +Reading symbols from /home/bengardiner/src/u-boot/u-boot...done. + +----------------- + +h) set breakpoints for any function after (and including) board_init_r +

Dear Ben Gardiner,
In message 1303996341-6582-1-git-send-email-bengardiner@nanometrics.ca you wrote:
When your emulator is connected at reset (or is used to load u-boot) it is possible to get the relocation address from the parameter passed to relocate_code() instead of building with -DDEBUG and extracting from the console messages.
Hm... Maybe we should try and unify code a bit better.
On PowerPC, relocaddr (the start address of the U-Boot image in RAM) is part of the global data structure, and simply gets printed with the "bdinfo" command:
=> bdinfo memstart = 0x00000000 memsize = 0x20000000 flashstart = 0xFC000000 flashsize = 0x04000000 flashoffset = 0x00000000 sramstart = 0x00000000 sramsize = 0x00000000 bootflags = 0xFFFE72CC intfreq = 1066.667 MHz busfreq = 266.667 MHz ethaddr = 00:10:ec:01:08:84 eth1addr = 00:10:ec:81:08:84 IP addr = 192.168.100.6 baudrate = 115200 bps ===> relocaddr = 0x1FF50000
Why not simply follow this example?
Best regards,
Wolfgang Denk

On Thu, Apr 28, 2011 at 9:46 AM, Wolfgang Denk wd@denx.de wrote:
Dear Ben Gardiner,
In message 1303996341-6582-1-git-send-email-bengardiner@nanometrics.ca you wrote:
When your emulator is connected at reset (or is used to load u-boot) it is possible to get the relocation address from the parameter passed to relocate_code() instead of building with -DDEBUG and extracting from the console messages.
Hm... Maybe we should try and unify code a bit better.
On PowerPC, relocaddr (the start address of the U-Boot image in RAM) is part of the global data structure, and simply gets printed with the "bdinfo" command:
=> bdinfo memstart = 0x00000000 memsize = 0x20000000 flashstart = 0xFC000000 flashsize = 0x04000000 flashoffset = 0x00000000 sramstart = 0x00000000 sramsize = 0x00000000 bootflags = 0xFFFE72CC intfreq = 1066.667 MHz busfreq = 266.667 MHz ethaddr = 00:10:ec:01:08:84 eth1addr = 00:10:ec:81:08:84 IP addr = 192.168.100.6 baudrate = 115200 bps ===> relocaddr = 0x1FF50000
Why not simply follow this example?
Good question, I don't see any reason why someone could not simply follow that example. bdinfo also prints the relocaddr on ARM:
DA850-evm > bdinfo arch_number = 0x0000086D boot_params = 0xC0000100 DRAM bank = 0x00000000 -> start = 0xC0000000 -> size = 0x08000000 ethaddr = 00:08:EE:03:D6:D2 ip_addr = 192.168.1.3 baudrate = 115200 bps TLB addr = 0xC7FF0000 ==> relocaddr = 0xC7F53000 reloc off = 0x06ED3000 irq_sp = 0xC7E22F70 sp start = 0xC7E22F68 FB base = 0x00000000
I'm not proposing that others do not get the relocaddr by other means. My intention was only to share the current recipe I am using to debug after relocation.
Best Regards, Ben Gardiner
--- Nanometrics Inc. http://www.nanometrics.ca

Dear Ben Gardiner,
In message 1303996341-6582-1-git-send-email-bengardiner@nanometrics.ca you wrote:
When your emulator is connected at reset (or is used to load u-boot) it is possible to get the relocation address from the parameter passed to relocate_code() instead of building with -DDEBUG and extracting from the console messages.
Document this alternate method following the style of the original method written by Heiko Schocher.
Signed-off-by: Ben Gardiner bengardiner@nanometrics.ca CC: Heiko Schocher hs@denx.de
...
+d) set breakpoint on relocate_code
...
+e) run target until relocate_code
...
+g) load new symbol table using the addr parameter (aka $r2)
Actually in my previous message I also wanted to point out that "relocaddr" is a member of struct global_data, so you can simply read it anywhere in U-Boot code, even if you did nt set any breakpoint before.
Best regards,
Wolfgang Denk
participants (2)
-
Ben Gardiner
-
Wolfgang Denk