[U-Boot] [PATCH 1/1] doc/qemu_mips: add doc howto debug u-boot with gdb

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com --- doc/README.qemu_mips | 64 +++++++++++++++++++++++++++++++++++++++++++++++++- include/bcd.h | 7 ++++- lib_generic/Makefile | 1 + 3 files changed, 69 insertions(+), 3 deletions(-)
diff --git a/doc/README.qemu_mips b/doc/README.qemu_mips index c9ac3f3..472469f 100644 --- a/doc/README.qemu_mips +++ b/doc/README.qemu_mips @@ -1,7 +1,7 @@
Notes for the Qemu MIPS port
-Example usage: +I) Example usage:
# ln -s u-boot.bin mips_bios.bin start it: @@ -16,3 +16,65 @@ create image: # dd of=flash bs=1k conv=notrunc if=u-boot.bin start it: # qemu-system-mips -M mips -pflash flash -monitor null -nographic + +II) How to debug U-Boot + +In order to debug U-Boot you need to start qemu with gdb server support (-s) +and waiting the connection to start the CPU (-S) + +# qemu-system-mips -S -s -M mips -pflash flash -monitor null -nographic + +in an other console you start gdb + +1) Debugging of U-Boot Before Relocation + +Before relocation, the addresses in the ELF file can be used without any problems +buy connecting to the gdb server localhost:1234 + +# mipsel-unknown-linux-gnu-gdb u-boot +GNU gdb 6.6 +Copyright (C) 2006 Free Software Foundation, Inc. +GDB is free software, covered by the GNU General Public License, and you are +welcome to change it and/or distribute copies of it under certain conditions. +Type "show copying" to see the conditions. +There is absolutely no warranty for GDB. Type "show warranty" for details. +This GDB was configured as "--host=i486-linux-gnu --target=mipsel-unknown-linux-gnu"... +(gdb) target remote localhost:1234 +Remote debugging using localhost:1234 +_start () at start.S:64 +64 RVECENT(reset,0) /* U-boot entry point */ +Current language: auto; currently asm +(gdb) b board.c:289 +Breakpoint 1 at 0xbfc00cc8: file board.c, line 289. +(gdb) c +Continuing. + +Breakpoint 1, board_init_f (bootflag=<value optimized out>) at board.c:290 +290 relocate_code (addr_sp, id, addr); +Current language: auto; currently c +(gdb) p/x addr +$1 = 0x87fa0000 + +2) Debugging of U-Boot After Relocation + +For debugging U-Boot after relocation we need to know the address to which +U-Boot relocates itself to 0x87fa0000 by default. +And replace the symbol table to this offset. + +(gdb) symbol-file +Discard symbol table from `/private/u-boot-arm/u-boot'? (y or n) y +Error in re-setting breakpoint 1: +No symbol table is loaded. Use the "file" command. +No symbol file now. +(gdb) add-symbol-file u-boot 0x87fa0000 +add symbol table from file "u-boot" at + .text_addr = 0x87fa0000 +(y or n) y +Reading symbols from /private/u-boot-arm/u-boot...done. +Breakpoint 1 at 0x87fa0cc8: file board.c, line 289. +(gdb) c +Continuing. + +Program received signal SIGINT, Interrupt. +0xffffffff87fa0de4 in udelay (usec=<value optimized out>) at time.c:78 +78 while ((tmo - read_c0_count()) < 0x7fffffff) diff --git a/include/bcd.h b/include/bcd.h index c545308..efdbd15 100644 --- a/include/bcd.h +++ b/include/bcd.h @@ -10,8 +10,11 @@ #ifndef _BCD_H #define _BCD_H
-#define BCD2BIN(val) (((val) & 0x0f) + ((val)>>4)*10) -#define BIN2BCD(val) ((((val)/10)<<4) + (val)%10) +unsigned bcd2bin(unsigned char val); +unsigned char bin2bcd(unsigned val); + +#define BCD2BIN(val) bcd2bin(val) +#define BIN2BCD(val) bin2bcd(val)
/* backwards compat */ #define BCD_TO_BIN(val) ((val)=BCD2BIN(val)) diff --git a/lib_generic/Makefile b/lib_generic/Makefile index 7df5a2c..794bc22 100644 --- a/lib_generic/Makefile +++ b/lib_generic/Makefile @@ -25,6 +25,7 @@ include $(TOPDIR)/config.mk
LIB = $(obj)libgeneric.a
+COBJS-$(CONFIG_CMD_DATE) += bcd.o COBJS-y += bzlib.o COBJS-y += bzlib_crctable.o COBJS-y += bzlib_decompress.o

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com --- diff with V1 remove unrelated changement doc/README.qemu_mips | 64 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 63 insertions(+), 1 deletions(-)
diff --git a/doc/README.qemu_mips b/doc/README.qemu_mips index c9ac3f3..472469f 100644 --- a/doc/README.qemu_mips +++ b/doc/README.qemu_mips @@ -1,7 +1,7 @@
Notes for the Qemu MIPS port
-Example usage: +I) Example usage:
# ln -s u-boot.bin mips_bios.bin start it: @@ -16,3 +16,65 @@ create image: # dd of=flash bs=1k conv=notrunc if=u-boot.bin start it: # qemu-system-mips -M mips -pflash flash -monitor null -nographic + +II) How to debug U-Boot + +In order to debug U-Boot you need to start qemu with gdb server support (-s) +and waiting the connection to start the CPU (-S) + +# qemu-system-mips -S -s -M mips -pflash flash -monitor null -nographic + +in an other console you start gdb + +1) Debugging of U-Boot Before Relocation + +Before relocation, the addresses in the ELF file can be used without any problems +buy connecting to the gdb server localhost:1234 + +# mipsel-unknown-linux-gnu-gdb u-boot +GNU gdb 6.6 +Copyright (C) 2006 Free Software Foundation, Inc. +GDB is free software, covered by the GNU General Public License, and you are +welcome to change it and/or distribute copies of it under certain conditions. +Type "show copying" to see the conditions. +There is absolutely no warranty for GDB. Type "show warranty" for details. +This GDB was configured as "--host=i486-linux-gnu --target=mipsel-unknown-linux-gnu"... +(gdb) target remote localhost:1234 +Remote debugging using localhost:1234 +_start () at start.S:64 +64 RVECENT(reset,0) /* U-boot entry point */ +Current language: auto; currently asm +(gdb) b board.c:289 +Breakpoint 1 at 0xbfc00cc8: file board.c, line 289. +(gdb) c +Continuing. + +Breakpoint 1, board_init_f (bootflag=<value optimized out>) at board.c:290 +290 relocate_code (addr_sp, id, addr); +Current language: auto; currently c +(gdb) p/x addr +$1 = 0x87fa0000 + +2) Debugging of U-Boot After Relocation + +For debugging U-Boot after relocation we need to know the address to which +U-Boot relocates itself to 0x87fa0000 by default. +And replace the symbol table to this offset. + +(gdb) symbol-file +Discard symbol table from `/private/u-boot-arm/u-boot'? (y or n) y +Error in re-setting breakpoint 1: +No symbol table is loaded. Use the "file" command. +No symbol file now. +(gdb) add-symbol-file u-boot 0x87fa0000 +add symbol table from file "u-boot" at + .text_addr = 0x87fa0000 +(y or n) y +Reading symbols from /private/u-boot-arm/u-boot...done. +Breakpoint 1 at 0x87fa0cc8: file board.c, line 289. +(gdb) c +Continuing. + +Program received signal SIGINT, Interrupt. +0xffffffff87fa0de4 in udelay (usec=<value optimized out>) at time.c:78 +78 while ((tmo - read_c0_count()) < 0x7fffffff)

Hi Jean,
Jean-Christophe PLAGNIOL-VILLARD wrote:
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com
diff with V1 remove unrelated changement doc/README.qemu_mips | 64 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 63 insertions(+), 1 deletions(-)
Although I can't fully try this out by myself, it's good to improve the contents of README. U-Boot/QEMU users, if anything is wrong with this or there is someting else worth documentation, revise it, revise it.
Will pick up and push it out soon. Thanks!
Shinya
participants (2)
-
Jean-Christophe PLAGNIOL-VILLARD
-
Shinya Kuribayashi