2019-07-18 15:34:17 +08:00
|
|
|
.. SPDX-License-Identifier: GPL-2.0+
|
2021-04-22 03:13:14 +08:00
|
|
|
.. sectionauthor:: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
|
2019-07-18 15:34:17 +08:00
|
|
|
|
|
|
|
QEMU MIPS
|
|
|
|
=========
|
|
|
|
|
2021-04-22 03:13:14 +08:00
|
|
|
Qemu for MIPS is based on the MIPS Malta board. The built Malta U-Boot
|
|
|
|
images can be used for Qemu and on physical hardware. The Malta board
|
|
|
|
supports all combinations of Little and Big Endian as well as 32 bit
|
|
|
|
and 64 bit.
|
2019-07-18 15:34:17 +08:00
|
|
|
|
|
|
|
Limitations & comments
|
|
|
|
----------------------
|
2021-04-22 03:13:14 +08:00
|
|
|
The memory size for Qemu is hard-coded to 256 MiB. For Malta Little Endian
|
|
|
|
targets an extra endianness swapped image named *u-boot-swap.bin* is
|
|
|
|
generated and required for Qemu.
|
2019-07-18 15:34:17 +08:00
|
|
|
|
|
|
|
Example usage
|
2021-04-22 03:13:14 +08:00
|
|
|
-------------
|
2019-07-18 15:34:17 +08:00
|
|
|
|
2021-04-22 03:13:14 +08:00
|
|
|
Build for 32 bit, big endian:
|
2019-07-18 15:34:17 +08:00
|
|
|
|
2020-01-01 15:34:03 +08:00
|
|
|
.. code-block:: bash
|
2019-07-18 15:34:17 +08:00
|
|
|
|
2021-04-22 03:13:14 +08:00
|
|
|
make malta_defconfig
|
|
|
|
make
|
|
|
|
UBOOT_BIN=u-boot.bin
|
|
|
|
QEMU_BIN=qemu-system-mips
|
|
|
|
QEMU_CPU=24Kc
|
2019-07-18 15:34:17 +08:00
|
|
|
|
2021-04-22 03:13:14 +08:00
|
|
|
Build for 32 bit, little endian:
|
2019-07-18 15:34:17 +08:00
|
|
|
|
2020-01-01 15:34:03 +08:00
|
|
|
.. code-block:: bash
|
2019-07-18 15:34:17 +08:00
|
|
|
|
2021-04-22 03:13:14 +08:00
|
|
|
make maltael_defconfig
|
|
|
|
make
|
|
|
|
UBOOT_BIN=u-boot-swap.bin
|
|
|
|
QEMU_BIN=qemu-system-mipsel
|
|
|
|
QEMU_CPU=24Kc
|
2019-07-18 15:34:17 +08:00
|
|
|
|
2021-04-22 03:13:14 +08:00
|
|
|
Build for 64 bit, big endian:
|
2019-07-18 15:34:17 +08:00
|
|
|
|
2020-01-01 15:34:03 +08:00
|
|
|
.. code-block:: bash
|
|
|
|
|
2021-04-22 03:13:14 +08:00
|
|
|
make malta64_defconfig
|
|
|
|
make
|
|
|
|
UBOOT_BIN=u-boot.bin
|
|
|
|
QEMU_BIN=qemu-system-mips64
|
|
|
|
QEMU_CPU=MIPS64R2-generic
|
2020-01-01 15:34:03 +08:00
|
|
|
|
2021-04-22 03:13:14 +08:00
|
|
|
Build for 64 bit, little endian:
|
2020-01-01 15:34:03 +08:00
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
2021-04-22 03:13:14 +08:00
|
|
|
make malta64el_defconfig
|
|
|
|
make
|
|
|
|
UBOOT_BIN=u-boot-swap.bin
|
|
|
|
QEMU_BIN=qemu-system-mips64el
|
|
|
|
QEMU_CPU=MIPS64R2-generic
|
2019-07-18 15:34:17 +08:00
|
|
|
|
2021-04-22 03:13:14 +08:00
|
|
|
Generate NOR flash image with U-Boot binary:
|
2019-07-18 15:34:17 +08:00
|
|
|
|
2020-01-01 15:34:03 +08:00
|
|
|
.. code-block:: bash
|
2019-07-18 15:34:17 +08:00
|
|
|
|
2021-04-22 03:13:14 +08:00
|
|
|
dd if=/dev/zero bs=1M count=4 | tr '\000' '\377' > pflash.img
|
|
|
|
dd if=${UBOOT_BIN} of=pflash.img conv=notrunc
|
2019-07-18 15:34:17 +08:00
|
|
|
|
2021-04-22 03:13:14 +08:00
|
|
|
Start Qemu:
|
2019-07-18 15:34:17 +08:00
|
|
|
|
2020-01-01 15:34:03 +08:00
|
|
|
.. code-block:: bash
|
2019-07-18 15:34:17 +08:00
|
|
|
|
2021-04-22 03:13:14 +08:00
|
|
|
mkdir tftproot
|
|
|
|
${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
|
2019-07-18 15:34:17 +08:00
|
|
|
|
2020-01-01 15:34:03 +08:00
|
|
|
.. code-block:: bash
|
2019-07-18 15:34:17 +08:00
|
|
|
|
2021-04-22 03:13:14 +08:00
|
|
|
U-Boot 2021.04-00963-g60279a2b1d (Apr 21 2021 - 19:54:32 +0200)
|
2019-07-18 15:34:17 +08:00
|
|
|
|
2021-04-22 03:13:14 +08:00
|
|
|
Board: MIPS Malta CoreLV
|
|
|
|
DRAM: 256 MiB
|
|
|
|
Flash: 4 MiB
|
|
|
|
Loading Environment from Flash... *** Warning - bad CRC, using default environment
|
2019-07-18 15:34:17 +08:00
|
|
|
|
2021-04-22 03:13:14 +08:00
|
|
|
In: serial@3f8
|
|
|
|
Out: serial@3f8
|
|
|
|
Err: serial@3f8
|
|
|
|
Net: pcnet#0
|
|
|
|
IDE: Bus 0: not available
|
|
|
|
maltael #
|
2019-07-18 15:34:17 +08:00
|
|
|
|
2021-04-22 03:13:14 +08:00
|
|
|
How to debug U-Boot
|
|
|
|
-------------------
|
2019-07-18 15:34:17 +08:00
|
|
|
|
2021-04-22 03:13:14 +08:00
|
|
|
In order to debug U-Boot you need to start qemu with gdb server support (-s)
|
|
|
|
and waiting the connection to start the CPU (-S). Start Qemu in the first console:
|
2019-07-18 15:34:17 +08:00
|
|
|
|
2020-01-01 15:34:03 +08:00
|
|
|
.. code-block:: bash
|
2019-07-18 15:34:17 +08:00
|
|
|
|
2021-04-22 03:13:14 +08:00
|
|
|
mkdir tftproot
|
|
|
|
${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
|
2019-07-18 15:34:17 +08:00
|
|
|
|
2021-04-22 03:13:14 +08:00
|
|
|
In the second console start gdb:
|
2020-01-01 15:34:03 +08:00
|
|
|
|
|
|
|
.. code-block:: bash
|
2019-07-18 15:34:17 +08:00
|
|
|
|
2021-04-22 03:13:14 +08:00
|
|
|
gdb-multiarch --eval-command "target remote :1234" u-boot
|
2019-07-18 15:34:17 +08:00
|
|
|
|
2020-01-01 15:34:03 +08:00
|
|
|
.. code-block:: bash
|
2019-07-18 15:34:17 +08:00
|
|
|
|
2021-04-22 03:13:14 +08:00
|
|
|
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2
|
|
|
|
Copyright (C) 2020 Free Software Foundation, Inc.
|
|
|
|
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
|
|
|
|
This is free software: you are free to change and redistribute it.
|
|
|
|
There is NO WARRANTY, to the extent permitted by law.
|
|
|
|
Type "show copying" and "show warranty" for details.
|
|
|
|
This GDB was configured as "x86_64-linux-gnu".
|
|
|
|
Type "show configuration" for configuration details.
|
|
|
|
For bug reporting instructions, please see:
|
|
|
|
<http://www.gnu.org/software/gdb/bugs/>.
|
|
|
|
Find the GDB manual and other documentation resources online at:
|
|
|
|
<http://www.gnu.org/software/gdb/documentation/>.
|
|
|
|
|
|
|
|
For help, type "help".
|
|
|
|
Type "apropos word" to search for commands related to "word"...
|
|
|
|
Reading symbols from u-boot...
|
|
|
|
Remote debugging using :1234
|
|
|
|
0xbfc00000 in ?? ()
|
|
|
|
(gdb) c
|
|
|
|
Continuing.
|