Skip to contentSkip to conversation

README.arm-relocation: debugging options update

PATCH Superseded Ben Gardiner 3 participants 6 messages Apr 28, 2011 – May 12, 2011

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover README.arm-relocation: debugging options update

As Wolfgang pointed out, bdinfo can be used to get the relocation address so update the README to indicate that this can be done instead of suggesting that u-boot get rebuilt with debugging enabled.

Since it can also be useful to script the operation, describe also a method whereby the relocation address is obtained from a register in a breakpoint.

Ben Gardiner (2):
README.arm-relocation: get relocated address from bdinfo README.arm-relocation: get relocated address in gdb

 doc/README.arm-relocation |  104 +++++++++++++++++++++++++++++++-------------
 1 files changed, 73 insertions(+), 31 deletions(-)
#1 lore raw

PATCH v2 1/2 README.arm-relocation: get relocated address from bdinfo

The bdinfo command prints the relocaddr on ARM as it does on PPC.

Update the debugging instructions for arm relocation to reflect this fact rather than requiring that the user rebuild the u-boot image using -DDEBUG.

---

No changes since V1 / introduced in this version

---
 doc/README.arm-relocation |   53 ++++++++++++++++++--------------------------
 1 files changed, 22 insertions(+), 31 deletions(-)
doc/README.arm-relocation +22 -31
index c0957c2..8bfb500 100644
@@ -106,13 +106,9 @@ TBC
 Debugging u-boot in RAM:
 (example on the qong board)
 
-a) add in config.mk:
-
-PLATFORM_CPPFLAGS += -DDEBUG
-
 -----------------
 
-b) start debugger
+a) start debugger
 
 arm-linux-gdb u-boot
 
@@ -130,7 +126,7 @@ The target architecture is set automatically (currently arm)
 
 -----------------
 
-c) connect to target
+b) connect to target
 
 target remote bdi10:2001
 
@@ -141,7 +137,7 @@ Remote debugging using bdi10:2001
 
 -----------------
 
-d) discard symbol-file
+c) discard symbol-file
 
 (gdb) symbol-file
 Discard symbol table from `/home/hs/celf/u-boot/u-boot'? (y or n) y
@@ -150,7 +146,7 @@ No symbol file now.
 
 -----------------
 
-e) load new symbol table:
+d) load new symbol table:
 
 (gdb) add-symbol-file u-boot 0x8ff08000
 add symbol table from file "u-boot" at
@@ -167,28 +163,23 @@ Program received signal SIGSTOP, Stopped (signal).
 
 add-symbol-file u-boot 0x8ff08000
 		       ^^^^^^^^^^
-		       get this address from u-boot debug printfs
-
-U-Boot 2010.06-rc2-00009-gf77b8b8-dirty (Jun 22 2010 - 09:43:46)
-
-U-Boot code: A0000000 -> A0058BAC  BSS: -> A0061F10
-CPU:   Freescale i.MX31 at 398 MHz
-Board: DAVE/DENX Qong
-mon: FFFFFFFF gd->monLen: 00061F10
-Top of RAM usable for U-Boot at: 90000000
-LCD panel info: 640 x 480, 16 bit/pix
-Reserving 600k for LCD Framebuffer at: 8ff6a000
-Reserving 391k for U-Boot at: 8ff08000
-			      ^^^^^^^^
-Reserving 1280k for malloc() at: 8fdc8000
-Reserving 24 Bytes for Board Info at: 8fdc7fe8
-Reserving 52 Bytes for Global Data at: 8fdc7fb4
-New Stack Pointer is: 8fdc7fb0
-RAM Configuration:
-Bank #0: 80000000 256 MiB
-relocation Offset is: eff08000
-mon: 00058BAC gd->monLen: 00061F10
-Now running in RAM - U-Boot at: 8ff08000
-				^^^^^^^^
+		       get this address from u-boot bdinfo command
+
+ => bdinfo
+rch_number = XXXXXXXXXX
+boot_params = XXXXXXXXXX
+DRAM bank   = XXXXXXXXXX
+-> start    = XXXXXXXXXX
+-> size     = XXXXXXXXXX
+ethaddr     = XXXXXXXXXX
+ip_addr     = XXXXXXXXXX
+baudrate    = XXXXXXXXXX
+TLB addr    = XXXXXXXXXX
+relocaddr   = 0x8ff08000
+              ^^^^^^^^^^
+reloc off   = XXXXXXXXXX
+irq_sp      = XXXXXXXXXX
+sp start    = XXXXXXXXXX
+FB base     = XXXXXXXXXX
 
 Now you can use gdb as usual :-)
Signature · 1 line
1.7.1
#2 lore raw

PATCH v2 1/2 README.arm-relocation: get relocated address from bdinfo

Dear Ben Gardiner,

Quoted 10 lines · In message <787a04417ee0eb01c6eb3a7a1edff7ee9a8f825e.1304008866.git.bengardiner…

The bdinfo command prints the relocaddr on ARM as it does on PPC.

Update the debugging instructions for arm relocation to reflect this fact rather than requiring that the user rebuild the u-boot image using -DDEBUG.

Quoted 7 lines

---

No changes since V1 / introduced in this version

---
 doc/README.arm-relocation |   53 ++++++++++++++++++--------------------------
 1 files changed, 22 insertions(+), 31 deletions(-)

Applied, thanks.

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
The flow chart is a most thoroughly oversold piece of  program  docu-
mentation.              -- Frederick Brooks, "The Mythical Man Month"
#3 lore raw

PATCH v2 2/2 README.arm-relocation: get relocated address in gdb

In reply to Ben Gardiner

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.

CC Heiko Schocher <[email protected]>
CC Wolfgang Denk <[email protected]>

---

Changes since V1:
* update to reflect proposed changes to existing debug instructions:
renumber seteps, remove note about -DDEBUG

---
 doc/README.arm-relocation |   51 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 51 insertions(+), 0 deletions(-)
doc/README.arm-relocation +51 -0
index 8bfb500..c5aef55 100644
@@ -183,3 +183,54 @@ sp start    = XXXXXXXXXX
 FB base     = XXXXXXXXXX
 
 Now you can use gdb as usual :-)
+
+An alternative to retrieving the relocated base address from the bdinfo command
+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) [same as above] start debugger
+b) [same as above] connect to target
+[remainder is different than above]
+-----------------
+
+c) set breakpoint on relocate_code
+
+(gdb) b relocate_code
+Breakpoint 1 at 0xc1080078: file start.S, line 196.
+
+-----------------
+
+d) 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
+
+-----------------
+
+e) 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)
+
+-----------------
+
+f) 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.
+
+-----------------
+
+g) set breakpoints for any function after (and including) board_init_r.
+"Now you can use gdb as usual :-)"
+
Signature · 1 line
1.7.1
#4 lore raw

PATCH 2/2 README.arm-relocation: get relocated address in gdb

Hello Ben,

Quoted 14 lines · Ben Gardiner

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.

CC Heiko Schocher <[email protected]>
CC Wolfgang Denk <[email protected]>

---

Quoted 7 lines

Changes since V1:
* update to reflect proposed changes to existing debug instructions:
renumber seteps, remove note about -DDEBUG

---
 doc/README.arm-relocation |   51 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 51 insertions(+), 0 deletions(-)

Thanks!

Quoted 38 lines
doc/README.arm-relocation +30 -0
index 8bfb500..c5aef55 100644
@@ -183,3 +183,54 @@ sp start    = XXXXXXXXXX
 FB base     = XXXXXXXXXX
 
 Now you can use gdb as usual :-)
+
+An alternative to retrieving the relocated base address from the bdinfo command
+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) [same as above] start debugger
+b) [same as above] connect to target
+[remainder is different than above]
+-----------------
+
+c) set breakpoint on relocate_code
+
+(gdb) b relocate_code
+Breakpoint 1 at 0xc1080078: file start.S, line 196.
+
+-----------------
+
+d) 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
+
+-----------------
+
+e) discard symbol file

doc/README.arm-relocation sp start = XXXXXXXXXX · line 225

Quoted 10 lines
doc/README.arm-relocation +10 -0
+
+(gdb) symbol-file
+Discard symbol table from `/home/bengardiner/src/u-boot/u-boot'? (y or n) y
+No symbol file now.
+(gdb)
+
+-----------------
+
+f) load new symbol table using the addr parameter (aka $r2)
+

Maybe we can add here also the info, that we can get this address through the bdinfo command?

doc/README.arm-relocation sp start = XXXXXXXXXX · line 236

Quoted 11 lines
doc/README.arm-relocation +11 -0
+(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.
+
+-----------------
+
+g) set breakpoints for any function after (and including) board_init_r.
+"Now you can use gdb as usual :-)"
+

bye,
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#5 lore raw

PATCH 2/2 README.arm-relocation: get relocated address in gdb

In reply to Ben Gardiner

Dear Ben Gardiner,

Quoted 14 lines · In message <713eaea232693cd6775d409b17c2e187328d1598.1304008866.git.bengardiner…

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.

CC Heiko Schocher <[email protected]>
CC Wolfgang Denk <[email protected]>

---

Quoted 7 lines

Changes since V1:
* update to reflect proposed changes to existing debug instructions:
renumber seteps, remove note about -DDEBUG

---
 doc/README.arm-relocation |   51 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 51 insertions(+), 0 deletions(-)

Applied, thanks.

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
Only two things are infinite,  the universe and human stupidity,  and
I'm not sure about the former.                     -- Albert Einstein