Jean-Christophe PLAGNIOL-VILLARD | f59f693 | 2008-05-02 19:48:56 +0200 | [diff] [blame] | 1 | |
| 2 | Notes for the Qemu MIPS port |
| 3 | |
Jean-Christophe PLAGNIOL-VILLARD | d9fabb4 | 2008-09-02 02:58:32 +0200 | [diff] [blame] | 4 | I) Example usage: |
Jean-Christophe PLAGNIOL-VILLARD | f59f693 | 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 | 3762825 | 2008-08-06 14:05:38 +0200 | [diff] [blame] | 18 | # qemu-system-mips -M mips -pflash flash -monitor null -nographic |
Jean-Christophe PLAGNIOL-VILLARD | d9fabb4 | 2008-09-02 02:58:32 +0200 | [diff] [blame] | 19 | |
Jean-Christophe PLAGNIOL-VILLARD | d33caef | 2008-12-16 22:10:31 +0100 | [diff] [blame^] | 20 | Ide Disk |
| 21 | |
| 22 | # dd of=ide bs=1k cout=100k if=/dev/zero |
| 23 | |
| 24 | # sfdisk -C 261 -d ide |
| 25 | # partition table of ide |
| 26 | unit: sectors |
| 27 | |
| 28 | ide1 : start= 63, size= 32067, Id=83 |
| 29 | ide2 : start= 32130, size= 32130, Id=83 |
| 30 | ide3 : start= 64260, size= 4128705, Id=83 |
| 31 | ide4 : start= 0, size= 0, Id= 0 |
| 32 | |
| 33 | # Generate uImage |
| 34 | # tools/mkimage -A mips -O linux -T kernel -C gzip -a 0x80010000 -e 0x80245650 -n "Linux 2.6.24.y" -d vmlinux.bin.gz uImage |
| 35 | # Copy to Flash |
| 36 | # dd if=uImage bs=1k conv=notrunc seek=224 of=flash |
| 37 | # Copy to ide |
| 38 | # dd if=uImage bs=512 conv=notrunc seek=63 of=ide |
| 39 | |
| 40 | # Generate ext2 on part 2 |
| 41 | # Attached as loop device ide offset = 32130 * 512 |
| 42 | # losetup -o 16450560 -f ide |
| 43 | # Format as ext2 ( arg2 : nb blocks) |
| 44 | # mke2fs /dev/loop0 16065 |
| 45 | # losetup -d /dev/loop0 |
| 46 | # Mount and copy uImage and initrd.gz to it |
| 47 | # mount -o loop,offset=16450560 -t ext2 ide /mnt |
| 48 | # Umount it |
| 49 | # umount /mnt |
| 50 | |
| 51 | Now you can boot from flash, ide, ide+ext2 and tfp |
| 52 | |
| 53 | # qemu-system-mips -M mips -pflash flash -monitor null -nographic -net nic -net user -tftp `pwd` -hda ide |
| 54 | |
Jean-Christophe PLAGNIOL-VILLARD | d9fabb4 | 2008-09-02 02:58:32 +0200 | [diff] [blame] | 55 | II) How to debug U-Boot |
| 56 | |
| 57 | In order to debug U-Boot you need to start qemu with gdb server support (-s) |
| 58 | and waiting the connection to start the CPU (-S) |
| 59 | |
Jean-Christophe PLAGNIOL-VILLARD | d33caef | 2008-12-16 22:10:31 +0100 | [diff] [blame^] | 60 | # qemu-system-mips -S -s -M mips -pflash flash -monitor null -nographic -net nic -net user -tftp `pwd` -hda ide |
Jean-Christophe PLAGNIOL-VILLARD | d9fabb4 | 2008-09-02 02:58:32 +0200 | [diff] [blame] | 61 | |
| 62 | in an other console you start gdb |
| 63 | |
| 64 | 1) Debugging of U-Boot Before Relocation |
| 65 | |
| 66 | Before relocation, the addresses in the ELF file can be used without any problems |
| 67 | buy connecting to the gdb server localhost:1234 |
| 68 | |
| 69 | # mipsel-unknown-linux-gnu-gdb u-boot |
| 70 | GNU gdb 6.6 |
| 71 | Copyright (C) 2006 Free Software Foundation, Inc. |
| 72 | GDB is free software, covered by the GNU General Public License, and you are |
| 73 | welcome to change it and/or distribute copies of it under certain conditions. |
| 74 | Type "show copying" to see the conditions. |
| 75 | There is absolutely no warranty for GDB. Type "show warranty" for details. |
| 76 | This GDB was configured as "--host=i486-linux-gnu --target=mipsel-unknown-linux-gnu"... |
| 77 | (gdb) target remote localhost:1234 |
| 78 | Remote debugging using localhost:1234 |
| 79 | _start () at start.S:64 |
Wolfgang Denk | 9dbbd7b | 2008-09-13 02:23:05 +0200 | [diff] [blame] | 80 | 64 RVECENT(reset,0) /* U-boot entry point */ |
Jean-Christophe PLAGNIOL-VILLARD | d9fabb4 | 2008-09-02 02:58:32 +0200 | [diff] [blame] | 81 | Current language: auto; currently asm |
| 82 | (gdb) b board.c:289 |
| 83 | Breakpoint 1 at 0xbfc00cc8: file board.c, line 289. |
| 84 | (gdb) c |
| 85 | Continuing. |
| 86 | |
| 87 | Breakpoint 1, board_init_f (bootflag=<value optimized out>) at board.c:290 |
Wolfgang Denk | 9dbbd7b | 2008-09-13 02:23:05 +0200 | [diff] [blame] | 88 | 290 relocate_code (addr_sp, id, addr); |
Jean-Christophe PLAGNIOL-VILLARD | d9fabb4 | 2008-09-02 02:58:32 +0200 | [diff] [blame] | 89 | Current language: auto; currently c |
| 90 | (gdb) p/x addr |
| 91 | $1 = 0x87fa0000 |
| 92 | |
| 93 | 2) Debugging of U-Boot After Relocation |
| 94 | |
| 95 | For debugging U-Boot after relocation we need to know the address to which |
| 96 | U-Boot relocates itself to 0x87fa0000 by default. |
| 97 | And replace the symbol table to this offset. |
| 98 | |
| 99 | (gdb) symbol-file |
| 100 | Discard symbol table from `/private/u-boot-arm/u-boot'? (y or n) y |
| 101 | Error in re-setting breakpoint 1: |
| 102 | No symbol table is loaded. Use the "file" command. |
| 103 | No symbol file now. |
| 104 | (gdb) add-symbol-file u-boot 0x87fa0000 |
| 105 | add symbol table from file "u-boot" at |
Wolfgang Denk | 9dbbd7b | 2008-09-13 02:23:05 +0200 | [diff] [blame] | 106 | .text_addr = 0x87fa0000 |
Jean-Christophe PLAGNIOL-VILLARD | d9fabb4 | 2008-09-02 02:58:32 +0200 | [diff] [blame] | 107 | (y or n) y |
| 108 | Reading symbols from /private/u-boot-arm/u-boot...done. |
| 109 | Breakpoint 1 at 0x87fa0cc8: file board.c, line 289. |
| 110 | (gdb) c |
| 111 | Continuing. |
| 112 | |
| 113 | Program received signal SIGINT, Interrupt. |
| 114 | 0xffffffff87fa0de4 in udelay (usec=<value optimized out>) at time.c:78 |
Wolfgang Denk | 9dbbd7b | 2008-09-13 02:23:05 +0200 | [diff] [blame] | 115 | 78 while ((tmo - read_c0_count()) < 0x7fffffff) |