blob: e6a3855738b7b163478dc490046a77b2ee71ee4c [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-VILLARD0faf0f42008-09-08 22:27:18 +0200202) Download kernel + initrd
21
22On ftp://ftp.denx.de/pub/contrib/Jean-Christophe_Plagniol-Villard/qemu_mips/
23you can downland
24
25#config to build the kernel
26qemu_mips_defconfig
Mike Williamsbf895ad2011-07-22 04:01:30 +000027#patch to fix mips interrupt init on 2.6.24.y kernel
Jean-Christophe PLAGNIOL-VILLARD0faf0f42008-09-08 22:27:18 +020028qemu_mips_kernel.patch
29initrd.gz
30vmlinux
31vmlinux.bin
32System.map
33
344) Generate uImage
35
36# 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
37
385) Copy uImage to Flash
39# dd if=uImage bs=1k conv=notrunc seek=224 of=flash
40
416) Generate Ide Disk
Jean-Christophe PLAGNIOL-VILLARDd33caef2008-12-16 22:10:31 +010042
43# dd of=ide bs=1k cout=100k if=/dev/zero
44
45# sfdisk -C 261 -d ide
46# partition table of ide
47unit: sectors
48
49 ide1 : start= 63, size= 32067, Id=83
50 ide2 : start= 32130, size= 32130, Id=83
51 ide3 : start= 64260, size= 4128705, Id=83
52 ide4 : start= 0, size= 0, Id= 0
53
Jean-Christophe PLAGNIOL-VILLARD0faf0f42008-09-08 22:27:18 +0200547) Copy to ide
55
Jean-Christophe PLAGNIOL-VILLARDd33caef2008-12-16 22:10:31 +010056# dd if=uImage bs=512 conv=notrunc seek=63 of=ide
57
Jean-Christophe PLAGNIOL-VILLARD0faf0f42008-09-08 22:27:18 +0200588) Generate ext2 on part 2 on Copy uImage and initrd.gz
59
Jean-Christophe PLAGNIOL-VILLARDd33caef2008-12-16 22:10:31 +010060# Attached as loop device ide offset = 32130 * 512
61# losetup -o 16450560 -f ide
62# Format as ext2 ( arg2 : nb blocks)
63# mke2fs /dev/loop0 16065
64# losetup -d /dev/loop0
65# Mount and copy uImage and initrd.gz to it
66# mount -o loop,offset=16450560 -t ext2 ide /mnt
Jean-Christophe PLAGNIOL-VILLARD0faf0f42008-09-08 22:27:18 +020067# mkdir /mnt/boot
68# cp {initrd.gz,uImage} /mnt/boot/
Jean-Christophe PLAGNIOL-VILLARDd33caef2008-12-16 22:10:31 +010069# Umount it
70# umount /mnt
71
Jean-Christophe PLAGNIOL-VILLARD0faf0f42008-09-08 22:27:18 +0200729) Set Environment
73
74setenv rd_start 0x80800000
75setenv rd_size 2663940
76setenv kernel BFC38000
77setenv oad_addr 80500000
78setenv load_addr2 80F00000
79setenv kernel_flash BFC38000
80setenv load_addr_hello 80200000
81setenv bootargs 'root=/dev/ram0 init=/bin/sh'
82setenv load_rd_ext2 'ide res; ext2load ide 0:2 ${rd_start} /boot/initrd.gz'
83setenv load_rd_tftp 'tftp ${rd_start} /initrd.gz'
84setenv load_kernel_hda 'ide res; diskboot ${load_addr} 0:2'
85setenv load_kernel_ext2 'ide res; ext2load ide 0:2 ${load_addr} /boot/uImage'
86setenv load_kernel_tftp 'tftp ${load_addr} /qemu_mips/uImage'
87setenv boot_ext2_ext2 'run load_rd_ext2; run load_kernel_ext2; run addmisc; bootm ${load_addr}'
88setenv boot_ext2_flash 'run load_rd_ext2; run addmisc; bootm ${kernel_flash}'
89setenv boot_ext2_hda 'run load_rd_ext2; run load_kernel_hda; run addmisc; bootm ${load_addr}'
90setenv boot_ext2_tftp 'run load_rd_ext2; run load_kernel_tftp; run addmisc; bootm ${load_addr}'
91setenv boot_tftp_hda 'run load_rd_tftp; run load_kernel_hda; run addmisc; bootm ${load_addr}'
92setenv boot_tftp_ext2 'run load_rd_tftp; run load_kernel_ext2; run addmisc; bootm ${load_addr}'
93setenv boot_tftp_flash 'run load_rd_tftp; run addmisc; bootm ${kernel_flash}'
94setenv boot_tftp_tftp 'run load_rd_tftp; run load_kernel_tftp; run addmisc; bootm ${load_addr}'
95setenv load_hello_tftp 'tftp ${load_addr_hello} /examples/hello_world.bin'
96setenv go_tftp 'run load_hello_tftp; go ${load_addr_hello}'
97setenv addmisc 'setenv bootargs ${bootargs} console=ttyS0,${baudrate} rd_start=${rd_start} rd_size=${rd_size} ethaddr=${ethaddr}'
98setenv bootcmd 'run boot_tftp_flash'
99
10010) Now you can boot from flash, ide, ide+ext2 and tfp
Jean-Christophe PLAGNIOL-VILLARDd33caef2008-12-16 22:10:31 +0100101
102# qemu-system-mips -M mips -pflash flash -monitor null -nographic -net nic -net user -tftp `pwd` -hda ide
103
Jean-Christophe PLAGNIOL-VILLARDd9fabb42008-09-02 02:58:32 +0200104II) How to debug U-Boot
105
106In order to debug U-Boot you need to start qemu with gdb server support (-s)
107and waiting the connection to start the CPU (-S)
108
Jean-Christophe PLAGNIOL-VILLARDd33caef2008-12-16 22:10:31 +0100109# 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 +0200110
111in an other console you start gdb
112
1131) Debugging of U-Boot Before Relocation
114
115Before relocation, the addresses in the ELF file can be used without any problems
Jean-Christophe PLAGNIOL-VILLARD0faf0f42008-09-08 22:27:18 +0200116by connecting to the gdb server localhost:1234
Jean-Christophe PLAGNIOL-VILLARDd9fabb42008-09-02 02:58:32 +0200117
118# mipsel-unknown-linux-gnu-gdb u-boot
119GNU gdb 6.6
120Copyright (C) 2006 Free Software Foundation, Inc.
121GDB is free software, covered by the GNU General Public License, and you are
122welcome to change it and/or distribute copies of it under certain conditions.
123Type "show copying" to see the conditions.
124There is absolutely no warranty for GDB. Type "show warranty" for details.
125This GDB was configured as "--host=i486-linux-gnu --target=mipsel-unknown-linux-gnu"...
126(gdb) target remote localhost:1234
127Remote debugging using localhost:1234
128_start () at start.S:64
Wolfgang Denk9dbbd7b2008-09-13 02:23:05 +020012964 RVECENT(reset,0) /* U-boot entry point */
Jean-Christophe PLAGNIOL-VILLARDd9fabb42008-09-02 02:58:32 +0200130Current language: auto; currently asm
131(gdb) b board.c:289
132Breakpoint 1 at 0xbfc00cc8: file board.c, line 289.
133(gdb) c
134Continuing.
135
136Breakpoint 1, board_init_f (bootflag=<value optimized out>) at board.c:290
Wolfgang Denk9dbbd7b2008-09-13 02:23:05 +0200137290 relocate_code (addr_sp, id, addr);
Jean-Christophe PLAGNIOL-VILLARDd9fabb42008-09-02 02:58:32 +0200138Current language: auto; currently c
139(gdb) p/x addr
140$1 = 0x87fa0000
141
1422) Debugging of U-Boot After Relocation
143
144For debugging U-Boot after relocation we need to know the address to which
145U-Boot relocates itself to 0x87fa0000 by default.
146And replace the symbol table to this offset.
147
148(gdb) symbol-file
149Discard symbol table from `/private/u-boot-arm/u-boot'? (y or n) y
150Error in re-setting breakpoint 1:
151No symbol table is loaded. Use the "file" command.
152No symbol file now.
153(gdb) add-symbol-file u-boot 0x87fa0000
154add symbol table from file "u-boot" at
Wolfgang Denk9dbbd7b2008-09-13 02:23:05 +0200155 .text_addr = 0x87fa0000
Jean-Christophe PLAGNIOL-VILLARDd9fabb42008-09-02 02:58:32 +0200156(y or n) y
157Reading symbols from /private/u-boot-arm/u-boot...done.
158Breakpoint 1 at 0x87fa0cc8: file board.c, line 289.
159(gdb) c
160Continuing.
161
162Program received signal SIGINT, Interrupt.
1630xffffffff87fa0de4 in udelay (usec=<value optimized out>) at time.c:78
Wolfgang Denk9dbbd7b2008-09-13 02:23:05 +020016478 while ((tmo - read_c0_count()) < 0x7fffffff)