blob: 5fd8a0a23bf71f7c824b9d9c7b685271d2245bf9 [file] [log] [blame]
Bin Meng475d4bd2019-07-18 00:34:17 -07001.. SPDX-License-Identifier: GPL-2.0+
Daniel Schwierzeck61951342021-04-21 21:13:14 +02002.. sectionauthor:: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Bin Meng475d4bd2019-07-18 00:34:17 -07003
4QEMU MIPS
5=========
6
Daniel Schwierzeck61951342021-04-21 21:13:14 +02007Qemu for MIPS is based on the MIPS Malta board. The built Malta U-Boot
8images can be used for Qemu and on physical hardware. The Malta board
9supports all combinations of Little and Big Endian as well as 32 bit
10and 64 bit.
Bin Meng475d4bd2019-07-18 00:34:17 -070011
12Limitations & comments
13----------------------
Daniel Schwierzeck61951342021-04-21 21:13:14 +020014The memory size for Qemu is hard-coded to 256 MiB. For Malta Little Endian
15targets an extra endianness swapped image named *u-boot-swap.bin* is
16generated and required for Qemu.
Bin Meng475d4bd2019-07-18 00:34:17 -070017
18Example usage
Daniel Schwierzeck61951342021-04-21 21:13:14 +020019-------------
Bin Meng475d4bd2019-07-18 00:34:17 -070020
Daniel Schwierzeck61951342021-04-21 21:13:14 +020021Build for 32 bit, big endian:
Bin Meng475d4bd2019-07-18 00:34:17 -070022
Heinrich Schuchardtfad68352020-01-01 08:34:03 +010023.. code-block:: bash
Bin Meng475d4bd2019-07-18 00:34:17 -070024
Daniel Schwierzeck61951342021-04-21 21:13:14 +020025 make malta_defconfig
26 make
27 UBOOT_BIN=u-boot.bin
28 QEMU_BIN=qemu-system-mips
29 QEMU_CPU=24Kc
Bin Meng475d4bd2019-07-18 00:34:17 -070030
Daniel Schwierzeck61951342021-04-21 21:13:14 +020031Build for 32 bit, little endian:
Bin Meng475d4bd2019-07-18 00:34:17 -070032
Heinrich Schuchardtfad68352020-01-01 08:34:03 +010033.. code-block:: bash
Bin Meng475d4bd2019-07-18 00:34:17 -070034
Daniel Schwierzeck61951342021-04-21 21:13:14 +020035 make maltael_defconfig
36 make
37 UBOOT_BIN=u-boot-swap.bin
38 QEMU_BIN=qemu-system-mipsel
39 QEMU_CPU=24Kc
Bin Meng475d4bd2019-07-18 00:34:17 -070040
Daniel Schwierzeck61951342021-04-21 21:13:14 +020041Build for 64 bit, big endian:
Bin Meng475d4bd2019-07-18 00:34:17 -070042
Heinrich Schuchardtfad68352020-01-01 08:34:03 +010043.. code-block:: bash
Bin Meng475d4bd2019-07-18 00:34:17 -070044
Daniel Schwierzeck61951342021-04-21 21:13:14 +020045 make malta64_defconfig
46 make
47 UBOOT_BIN=u-boot.bin
48 QEMU_BIN=qemu-system-mips64
49 QEMU_CPU=MIPS64R2-generic
Bin Meng475d4bd2019-07-18 00:34:17 -070050
Daniel Schwierzeck61951342021-04-21 21:13:14 +020051Build for 64 bit, little endian:
Bin Meng475d4bd2019-07-18 00:34:17 -070052
Heinrich Schuchardtfad68352020-01-01 08:34:03 +010053.. code-block:: bash
Bin Meng475d4bd2019-07-18 00:34:17 -070054
Daniel Schwierzeck61951342021-04-21 21:13:14 +020055 make malta64el_defconfig
56 make
57 UBOOT_BIN=u-boot-swap.bin
58 QEMU_BIN=qemu-system-mips64el
59 QEMU_CPU=MIPS64R2-generic
Bin Meng475d4bd2019-07-18 00:34:17 -070060
Daniel Schwierzeck61951342021-04-21 21:13:14 +020061Generate NOR flash image with U-Boot binary:
Bin Meng475d4bd2019-07-18 00:34:17 -070062
Heinrich Schuchardtfad68352020-01-01 08:34:03 +010063.. code-block:: bash
Bin Meng475d4bd2019-07-18 00:34:17 -070064
Daniel Schwierzeck61951342021-04-21 21:13:14 +020065 dd if=/dev/zero bs=1M count=4 | tr '\000' '\377' > pflash.img
66 dd if=${UBOOT_BIN} of=pflash.img conv=notrunc
Bin Meng475d4bd2019-07-18 00:34:17 -070067
Daniel Schwierzeck61951342021-04-21 21:13:14 +020068Start Qemu:
Bin Meng475d4bd2019-07-18 00:34:17 -070069
Heinrich Schuchardtfad68352020-01-01 08:34:03 +010070.. code-block:: bash
Bin Meng475d4bd2019-07-18 00:34:17 -070071
Daniel Schwierzeck61951342021-04-21 21:13:14 +020072 mkdir tftproot
73 ${QEMU_BIN} -nographic -cpu ${QEMU_CPU} -m 256 -drive if=pflash,file="$(pwd)/pflash.img",format=raw -netdev user,id=net0,tftp="$(pwd)/tftproot" -device pcnet,netdev=net0
Bin Meng475d4bd2019-07-18 00:34:17 -070074
Heinrich Schuchardtfad68352020-01-01 08:34:03 +010075.. code-block:: bash
Bin Meng475d4bd2019-07-18 00:34:17 -070076
Daniel Schwierzeck61951342021-04-21 21:13:14 +020077 U-Boot 2021.04-00963-g60279a2b1d (Apr 21 2021 - 19:54:32 +0200)
Bin Meng475d4bd2019-07-18 00:34:17 -070078
Daniel Schwierzeck61951342021-04-21 21:13:14 +020079 Board: MIPS Malta CoreLV
80 DRAM: 256 MiB
81 Flash: 4 MiB
82 Loading Environment from Flash... *** Warning - bad CRC, using default environment
Heinrich Schuchardtfad68352020-01-01 08:34:03 +010083
Daniel Schwierzeck61951342021-04-21 21:13:14 +020084 In: serial@3f8
85 Out: serial@3f8
86 Err: serial@3f8
87 Net: pcnet#0
88 IDE: Bus 0: not available
89 maltael #
Bin Meng475d4bd2019-07-18 00:34:17 -070090
91How to debug U-Boot
92-------------------
93
94In order to debug U-Boot you need to start qemu with gdb server support (-s)
Daniel Schwierzeck61951342021-04-21 21:13:14 +020095and waiting the connection to start the CPU (-S). Start Qemu in the first console:
Bin Meng475d4bd2019-07-18 00:34:17 -070096
Heinrich Schuchardtfad68352020-01-01 08:34:03 +010097.. code-block:: bash
Bin Meng475d4bd2019-07-18 00:34:17 -070098
Daniel Schwierzeck61951342021-04-21 21:13:14 +020099 mkdir tftproot
100 ${QEMU_BIN} -s -S -nographic -cpu ${QEMU_CPU} -m 256 -drive if=pflash,file="$(pwd)/pflash.img",format=raw -netdev user,id=net0,tftp="$(pwd)/tftproot" -device pcnet,netdev=net0
Bin Meng475d4bd2019-07-18 00:34:17 -0700101
Daniel Schwierzeck61951342021-04-21 21:13:14 +0200102In the second console start gdb:
Bin Meng475d4bd2019-07-18 00:34:17 -0700103
Daniel Schwierzeck61951342021-04-21 21:13:14 +0200104.. code-block:: bash
Bin Meng475d4bd2019-07-18 00:34:17 -0700105
Daniel Schwierzeck61951342021-04-21 21:13:14 +0200106 gdb-multiarch --eval-command "target remote :1234" u-boot
Bin Meng475d4bd2019-07-18 00:34:17 -0700107
Daniel Schwierzeck61951342021-04-21 21:13:14 +0200108.. code-block:: bash
Bin Meng475d4bd2019-07-18 00:34:17 -0700109
Daniel Schwierzeck61951342021-04-21 21:13:14 +0200110 GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2
111 Copyright (C) 2020 Free Software Foundation, Inc.
112 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
113 This is free software: you are free to change and redistribute it.
114 There is NO WARRANTY, to the extent permitted by law.
115 Type "show copying" and "show warranty" for details.
116 This GDB was configured as "x86_64-linux-gnu".
117 Type "show configuration" for configuration details.
118 For bug reporting instructions, please see:
119 <http://www.gnu.org/software/gdb/bugs/>.
120 Find the GDB manual and other documentation resources online at:
121 <http://www.gnu.org/software/gdb/documentation/>.
Bin Meng475d4bd2019-07-18 00:34:17 -0700122
Daniel Schwierzeck61951342021-04-21 21:13:14 +0200123 For help, type "help".
124 Type "apropos word" to search for commands related to "word"...
125 Reading symbols from u-boot...
126 Remote debugging using :1234
127 0xbfc00000 in ?? ()
128 (gdb) c
129 Continuing.