blob: 8fa4907cb95eef187493dbcea0dff2efb66add45 [file] [log] [blame]
Jean-Christophe PLAGNIOL-VILLARDf59f6932008-05-02 19:48:56 +02001
2Notes for the Qemu MIPS port
3
Jean-Christophe PLAGNIOL-VILLARDd9fabb42008-09-02 02:58:32 +02004I) Example usage:
Jean-Christophe PLAGNIOL-VILLARDf59f6932008-05-02 19:48:56 +02005
6# ln -s u-boot.bin mips_bios.bin
7start it:
8qemu-system-mips -L . /dev/null -nographic
9
10or
11
12if you use a qemu version after commit 4224
13
14create image:
15# dd of=flash bs=1k count=4k if=/dev/zero
16# dd of=flash bs=1k conv=notrunc if=u-boot.bin
17start it:
Stefan Roese37628252008-08-06 14:05:38 +020018# qemu-system-mips -M mips -pflash flash -monitor null -nographic
Jean-Christophe PLAGNIOL-VILLARDd9fabb42008-09-02 02:58:32 +020019
Jean-Christophe PLAGNIOL-VILLARDd33caef2008-12-16 22:10:31 +010020Ide 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
26unit: 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
51Now 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-VILLARDd9fabb42008-09-02 02:58:32 +020055II) How to debug U-Boot
56
57In order to debug U-Boot you need to start qemu with gdb server support (-s)
58and waiting the connection to start the CPU (-S)
59
Jean-Christophe PLAGNIOL-VILLARDd33caef2008-12-16 22:10:31 +010060# qemu-system-mips -S -s -M mips -pflash flash -monitor null -nographic -net nic -net user -tftp `pwd` -hda ide
Jean-Christophe PLAGNIOL-VILLARDd9fabb42008-09-02 02:58:32 +020061
62in an other console you start gdb
63
641) Debugging of U-Boot Before Relocation
65
66Before relocation, the addresses in the ELF file can be used without any problems
67buy connecting to the gdb server localhost:1234
68
69# mipsel-unknown-linux-gnu-gdb u-boot
70GNU gdb 6.6
71Copyright (C) 2006 Free Software Foundation, Inc.
72GDB is free software, covered by the GNU General Public License, and you are
73welcome to change it and/or distribute copies of it under certain conditions.
74Type "show copying" to see the conditions.
75There is absolutely no warranty for GDB. Type "show warranty" for details.
76This GDB was configured as "--host=i486-linux-gnu --target=mipsel-unknown-linux-gnu"...
77(gdb) target remote localhost:1234
78Remote debugging using localhost:1234
79_start () at start.S:64
Wolfgang Denk9dbbd7b2008-09-13 02:23:05 +02008064 RVECENT(reset,0) /* U-boot entry point */
Jean-Christophe PLAGNIOL-VILLARDd9fabb42008-09-02 02:58:32 +020081Current language: auto; currently asm
82(gdb) b board.c:289
83Breakpoint 1 at 0xbfc00cc8: file board.c, line 289.
84(gdb) c
85Continuing.
86
87Breakpoint 1, board_init_f (bootflag=<value optimized out>) at board.c:290
Wolfgang Denk9dbbd7b2008-09-13 02:23:05 +020088290 relocate_code (addr_sp, id, addr);
Jean-Christophe PLAGNIOL-VILLARDd9fabb42008-09-02 02:58:32 +020089Current language: auto; currently c
90(gdb) p/x addr
91$1 = 0x87fa0000
92
932) Debugging of U-Boot After Relocation
94
95For debugging U-Boot after relocation we need to know the address to which
96U-Boot relocates itself to 0x87fa0000 by default.
97And replace the symbol table to this offset.
98
99(gdb) symbol-file
100Discard symbol table from `/private/u-boot-arm/u-boot'? (y or n) y
101Error in re-setting breakpoint 1:
102No symbol table is loaded. Use the "file" command.
103No symbol file now.
104(gdb) add-symbol-file u-boot 0x87fa0000
105add symbol table from file "u-boot" at
Wolfgang Denk9dbbd7b2008-09-13 02:23:05 +0200106 .text_addr = 0x87fa0000
Jean-Christophe PLAGNIOL-VILLARDd9fabb42008-09-02 02:58:32 +0200107(y or n) y
108Reading symbols from /private/u-boot-arm/u-boot...done.
109Breakpoint 1 at 0x87fa0cc8: file board.c, line 289.
110(gdb) c
111Continuing.
112
113Program received signal SIGINT, Interrupt.
1140xffffffff87fa0de4 in udelay (usec=<value optimized out>) at time.c:78
Wolfgang Denk9dbbd7b2008-09-13 02:23:05 +020011578 while ((tmo - read_c0_count()) < 0x7fffffff)