README.arm-relocation: get relocated address in gdb
PATCH 1/1 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.
--- doc/README.arm-relocation | 56 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 56 insertions(+), 0 deletions(-)
doc/README.arm-relocation +56 -0
@@ -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 +
Signature · 1 line
1.7.1
PATCH 1/1 README.arm-relocation: get relocated address in gdb
Dear Ben Gardiner,
Quoted 4 lines · In message <[email protected]> you…
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
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de If the hours are long enough and the pay is short enough, someone will say it's women's work.
PATCH 1/1 README.arm-relocation: get relocated address in gdb
Quoted 31 lines · Wolfgang Denk
Dear Ben Gardiner,
Quoted 4 lines · In message <[email protected]> you…
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
Quoted 1 line
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 > bdinfoarch_number = 0x0000086Dboot_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
PATCH 1/1 README.arm-relocation: get relocated address in gdb
In reply to Ben GardinerDear Ben Gardiner,
Quoted 10 lines · In message <[email protected]> you…
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 <[email protected]>CC Heiko Schocher <[email protected]>
...
Quoted 1 line
+d) set breakpoint on
relocate_code
...
Quoted 1 line
+e) run target until
relocate_code
...
Quoted 1 line
+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
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "You can have my Unix system when you pry it from my cold, dead fingers." - Cal Keegan