Jean-Christophe PLAGNIOL-VILLARD | 3648085 | 2008-05-02 19:48:56 +0200 | [diff] [blame] | 1 | |
| 2 | Notes for the Qemu MIPS port |
| 3 | |
Jean-Christophe PLAGNIOL-VILLARD | 7007c59 | 2008-09-02 02:58:32 +0200 | [diff] [blame] | 4 | I) Example usage: |
Jean-Christophe PLAGNIOL-VILLARD | 3648085 | 2008-05-02 19:48:56 +0200 | [diff] [blame] | 5 | |
| 6 | # ln -s u-boot.bin mips_bios.bin |
| 7 | start it: |
| 8 | qemu-system-mips -L . /dev/null -nographic |
| 9 | |
| 10 | or |
| 11 | |
| 12 | if you use a qemu version after commit 4224 |
| 13 | |
| 14 | create image: |
| 15 | # dd of=flash bs=1k count=4k if=/dev/zero |
| 16 | # dd of=flash bs=1k conv=notrunc if=u-boot.bin |
| 17 | start it: |
Stefan Roese | f2302d4 | 2008-08-06 14:05:38 +0200 | [diff] [blame] | 18 | # qemu-system-mips -M mips -pflash flash -monitor null -nographic |
Jean-Christophe PLAGNIOL-VILLARD | 7007c59 | 2008-09-02 02:58:32 +0200 | [diff] [blame] | 19 | |
| 20 | II) How to debug U-Boot |
| 21 | |
| 22 | In order to debug U-Boot you need to start qemu with gdb server support (-s) |
| 23 | and waiting the connection to start the CPU (-S) |
| 24 | |
| 25 | # qemu-system-mips -S -s -M mips -pflash flash -monitor null -nographic |
| 26 | |
| 27 | in an other console you start gdb |
| 28 | |
| 29 | 1) Debugging of U-Boot Before Relocation |
| 30 | |
| 31 | Before relocation, the addresses in the ELF file can be used without any problems |
| 32 | buy connecting to the gdb server localhost:1234 |
| 33 | |
| 34 | # mipsel-unknown-linux-gnu-gdb u-boot |
| 35 | GNU gdb 6.6 |
| 36 | Copyright (C) 2006 Free Software Foundation, Inc. |
| 37 | GDB is free software, covered by the GNU General Public License, and you are |
| 38 | welcome to change it and/or distribute copies of it under certain conditions. |
| 39 | Type "show copying" to see the conditions. |
| 40 | There is absolutely no warranty for GDB. Type "show warranty" for details. |
| 41 | This GDB was configured as "--host=i486-linux-gnu --target=mipsel-unknown-linux-gnu"... |
| 42 | (gdb) target remote localhost:1234 |
| 43 | Remote debugging using localhost:1234 |
| 44 | _start () at start.S:64 |
Wolfgang Denk | f12e454 | 2008-09-13 02:23:05 +0200 | [diff] [blame] | 45 | 64 RVECENT(reset,0) /* U-boot entry point */ |
Jean-Christophe PLAGNIOL-VILLARD | 7007c59 | 2008-09-02 02:58:32 +0200 | [diff] [blame] | 46 | Current language: auto; currently asm |
| 47 | (gdb) b board.c:289 |
| 48 | Breakpoint 1 at 0xbfc00cc8: file board.c, line 289. |
| 49 | (gdb) c |
| 50 | Continuing. |
| 51 | |
| 52 | Breakpoint 1, board_init_f (bootflag=<value optimized out>) at board.c:290 |
Wolfgang Denk | f12e454 | 2008-09-13 02:23:05 +0200 | [diff] [blame] | 53 | 290 relocate_code (addr_sp, id, addr); |
Jean-Christophe PLAGNIOL-VILLARD | 7007c59 | 2008-09-02 02:58:32 +0200 | [diff] [blame] | 54 | Current language: auto; currently c |
| 55 | (gdb) p/x addr |
| 56 | $1 = 0x87fa0000 |
| 57 | |
| 58 | 2) Debugging of U-Boot After Relocation |
| 59 | |
| 60 | For debugging U-Boot after relocation we need to know the address to which |
| 61 | U-Boot relocates itself to 0x87fa0000 by default. |
| 62 | And replace the symbol table to this offset. |
| 63 | |
| 64 | (gdb) symbol-file |
| 65 | Discard symbol table from `/private/u-boot-arm/u-boot'? (y or n) y |
| 66 | Error in re-setting breakpoint 1: |
| 67 | No symbol table is loaded. Use the "file" command. |
| 68 | No symbol file now. |
| 69 | (gdb) add-symbol-file u-boot 0x87fa0000 |
| 70 | add symbol table from file "u-boot" at |
Wolfgang Denk | f12e454 | 2008-09-13 02:23:05 +0200 | [diff] [blame] | 71 | .text_addr = 0x87fa0000 |
Jean-Christophe PLAGNIOL-VILLARD | 7007c59 | 2008-09-02 02:58:32 +0200 | [diff] [blame] | 72 | (y or n) y |
| 73 | Reading symbols from /private/u-boot-arm/u-boot...done. |
| 74 | Breakpoint 1 at 0x87fa0cc8: file board.c, line 289. |
| 75 | (gdb) c |
| 76 | Continuing. |
| 77 | |
| 78 | Program received signal SIGINT, Interrupt. |
| 79 | 0xffffffff87fa0de4 in udelay (usec=<value optimized out>) at time.c:78 |
Wolfgang Denk | f12e454 | 2008-09-13 02:23:05 +0200 | [diff] [blame] | 80 | 78 while ((tmo - read_c0_count()) < 0x7fffffff) |