blob: 9fd97e1249a915dc9befd6414bba0a1a0089a156 [file] [log] [blame]
Vlad Lungu045b4d22008-05-05 14:20:03 +03001By Vlad Lungu vlad.lungu@windriver.com 2007-Oct-01
Vlad Lungu0764c162008-01-16 19:27:51 +02002----------------------------------------
3Qemu is a full system emulator. See
4
Michal Simek5b2da6a2009-08-21 06:52:25 +10005http://www.nongnu.org/qemu/
Vlad Lungu0764c162008-01-16 19:27:51 +02006
7Limitations & comments
8----------------------
9Supports the "-m mips" configuration of qemu: serial,NE2000,IDE.
10Support is big endian only for now (or at least this is what I tested).
11Derived from au1x00 with a lot of things cut out.
Vlad Lungu045b4d22008-05-05 14:20:03 +030012
13Supports emulated flash (patch Jean-Christophe PLAGNIOL-VILLARD) with
14recent qemu versions. When using emulated flash, launch with
15-pflash <filename> and erase mips_bios.bin.
Wolfgang Denk702e6012012-04-29 23:57:39 +000016
17
18
19Notes for the Qemu MIPS port
20----------------------------
21
22I) Example usage:
23
24# ln -s u-boot.bin mips_bios.bin
25start it:
26qemu-system-mips -L . /dev/null -nographic
27
28or
29
30if you use a qemu version after commit 4224
31
32create image:
33# dd of=flash bs=1k count=4k if=/dev/zero
34# dd of=flash bs=1k conv=notrunc if=u-boot.bin
35start it:
36# qemu-system-mips -M mips -pflash flash -monitor null -nographic
37
382) Download kernel + initrd
39
40On ftp://ftp.denx.de/pub/contrib/Jean-Christophe_Plagniol-Villard/qemu_mips/
41you can downland
42
43#config to build the kernel
44qemu_mips_defconfig
45#patch to fix mips interrupt init on 2.6.24.y kernel
46qemu_mips_kernel.patch
47initrd.gz
48vmlinux
49vmlinux.bin
50System.map
51
524) Generate uImage
53
54# 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
55
565) Copy uImage to Flash
57# dd if=uImage bs=1k conv=notrunc seek=224 of=flash
58
596) Generate Ide Disk
60
61# dd of=ide bs=1k cout=100k if=/dev/zero
62
63# sfdisk -C 261 -d ide
64# partition table of ide
65unit: sectors
66
67 ide1 : start= 63, size= 32067, Id=83
68 ide2 : start= 32130, size= 32130, Id=83
69 ide3 : start= 64260, size= 4128705, Id=83
70 ide4 : start= 0, size= 0, Id= 0
71
727) Copy to ide
73
74# dd if=uImage bs=512 conv=notrunc seek=63 of=ide
75
768) Generate ext2 on part 2 on Copy uImage and initrd.gz
77
78# Attached as loop device ide offset = 32130 * 512
79# losetup -o 16450560 -f ide
80# Format as ext2 ( arg2 : nb blocks)
81# mke2fs /dev/loop0 16065
82# losetup -d /dev/loop0
83# Mount and copy uImage and initrd.gz to it
84# mount -o loop,offset=16450560 -t ext2 ide /mnt
85# mkdir /mnt/boot
86# cp {initrd.gz,uImage} /mnt/boot/
87# Umount it
88# umount /mnt
89
909) Set Environment
91
92setenv rd_start 0x80800000
93setenv rd_size 2663940
94setenv kernel BFC38000
95setenv oad_addr 80500000
96setenv load_addr2 80F00000
97setenv kernel_flash BFC38000
98setenv load_addr_hello 80200000
99setenv bootargs 'root=/dev/ram0 init=/bin/sh'
100setenv load_rd_ext2 'ide res; ext2load ide 0:2 ${rd_start} /boot/initrd.gz'
101setenv load_rd_tftp 'tftp ${rd_start} /initrd.gz'
102setenv load_kernel_hda 'ide res; diskboot ${load_addr} 0:2'
103setenv load_kernel_ext2 'ide res; ext2load ide 0:2 ${load_addr} /boot/uImage'
104setenv load_kernel_tftp 'tftp ${load_addr} /qemu_mips/uImage'
105setenv boot_ext2_ext2 'run load_rd_ext2; run load_kernel_ext2; run addmisc; bootm ${load_addr}'
106setenv boot_ext2_flash 'run load_rd_ext2; run addmisc; bootm ${kernel_flash}'
107setenv boot_ext2_hda 'run load_rd_ext2; run load_kernel_hda; run addmisc; bootm ${load_addr}'
108setenv boot_ext2_tftp 'run load_rd_ext2; run load_kernel_tftp; run addmisc; bootm ${load_addr}'
109setenv boot_tftp_hda 'run load_rd_tftp; run load_kernel_hda; run addmisc; bootm ${load_addr}'
110setenv boot_tftp_ext2 'run load_rd_tftp; run load_kernel_ext2; run addmisc; bootm ${load_addr}'
111setenv boot_tftp_flash 'run load_rd_tftp; run addmisc; bootm ${kernel_flash}'
112setenv boot_tftp_tftp 'run load_rd_tftp; run load_kernel_tftp; run addmisc; bootm ${load_addr}'
113setenv load_hello_tftp 'tftp ${load_addr_hello} /examples/hello_world.bin'
114setenv go_tftp 'run load_hello_tftp; go ${load_addr_hello}'
115setenv addmisc 'setenv bootargs ${bootargs} console=ttyS0,${baudrate} rd_start=${rd_start} rd_size=${rd_size} ethaddr=${ethaddr}'
116setenv bootcmd 'run boot_tftp_flash'
117
11810) Now you can boot from flash, ide, ide+ext2 and tfp
119
120# qemu-system-mips -M mips -pflash flash -monitor null -nographic -net nic -net user -tftp `pwd` -hda ide
121
122II) How to debug U-Boot
123
124In order to debug U-Boot you need to start qemu with gdb server support (-s)
125and waiting the connection to start the CPU (-S)
126
127# qemu-system-mips -S -s -M mips -pflash flash -monitor null -nographic -net nic -net user -tftp `pwd` -hda ide
128
129in an other console you start gdb
130
1311) Debugging of U-Boot Before Relocation
132
133Before relocation, the addresses in the ELF file can be used without any problems
134by connecting to the gdb server localhost:1234
135
136# mipsel-unknown-linux-gnu-gdb u-boot
137GNU gdb 6.6
138Copyright (C) 2006 Free Software Foundation, Inc.
139GDB is free software, covered by the GNU General Public License, and you are
140welcome to change it and/or distribute copies of it under certain conditions.
141Type "show copying" to see the conditions.
142There is absolutely no warranty for GDB. Type "show warranty" for details.
143This GDB was configured as "--host=i486-linux-gnu --target=mipsel-unknown-linux-gnu"...
144(gdb) target remote localhost:1234
145Remote debugging using localhost:1234
146_start () at start.S:64
14764 RVECENT(reset,0) /* U-boot entry point */
148Current language: auto; currently asm
149(gdb) b board.c:289
150Breakpoint 1 at 0xbfc00cc8: file board.c, line 289.
151(gdb) c
152Continuing.
153
154Breakpoint 1, board_init_f (bootflag=<value optimized out>) at board.c:290
155290 relocate_code (addr_sp, id, addr);
156Current language: auto; currently c
157(gdb) p/x addr
158$1 = 0x87fa0000
159
1602) Debugging of U-Boot After Relocation
161
162For debugging U-Boot after relocation we need to know the address to which
163U-Boot relocates itself to 0x87fa0000 by default.
164And replace the symbol table to this offset.
165
166(gdb) symbol-file
167Discard symbol table from `/private/u-boot-arm/u-boot'? (y or n) y
168Error in re-setting breakpoint 1:
169No symbol table is loaded. Use the "file" command.
170No symbol file now.
171(gdb) add-symbol-file u-boot 0x87fa0000
172add symbol table from file "u-boot" at
173 .text_addr = 0x87fa0000
174(y or n) y
175Reading symbols from /private/u-boot-arm/u-boot...done.
176Breakpoint 1 at 0x87fa0cc8: file board.c, line 289.
177(gdb) c
178Continuing.
179
180Program received signal SIGINT, Interrupt.
1810xffffffff87fa0de4 in udelay (usec=<value optimized out>) at time.c:78
18278 while ((tmo - read_c0_count()) < 0x7fffffff)