Bin Meng | 93ca4bc | 2019-07-18 00:34:17 -0700 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+ |
Daniel Schwierzeck | 835b4fd | 2021-04-21 21:13:14 +0200 | [diff] [blame] | 2 | .. sectionauthor:: Daniel Schwierzeck <daniel.schwierzeck@gmail.com> |
Bin Meng | 93ca4bc | 2019-07-18 00:34:17 -0700 | [diff] [blame] | 3 | |
| 4 | QEMU MIPS |
| 5 | ========= |
| 6 | |
Daniel Schwierzeck | 835b4fd | 2021-04-21 21:13:14 +0200 | [diff] [blame] | 7 | Qemu for MIPS is based on the MIPS Malta board. The built Malta U-Boot |
| 8 | images can be used for Qemu and on physical hardware. The Malta board |
| 9 | supports all combinations of Little and Big Endian as well as 32 bit |
| 10 | and 64 bit. |
Bin Meng | 93ca4bc | 2019-07-18 00:34:17 -0700 | [diff] [blame] | 11 | |
| 12 | Limitations & comments |
| 13 | ---------------------- |
Daniel Schwierzeck | 835b4fd | 2021-04-21 21:13:14 +0200 | [diff] [blame] | 14 | The memory size for Qemu is hard-coded to 256 MiB. For Malta Little Endian |
| 15 | targets an extra endianness swapped image named *u-boot-swap.bin* is |
| 16 | generated and required for Qemu. |
Bin Meng | 93ca4bc | 2019-07-18 00:34:17 -0700 | [diff] [blame] | 17 | |
| 18 | Example usage |
Daniel Schwierzeck | 835b4fd | 2021-04-21 21:13:14 +0200 | [diff] [blame] | 19 | ------------- |
Bin Meng | 93ca4bc | 2019-07-18 00:34:17 -0700 | [diff] [blame] | 20 | |
Daniel Schwierzeck | 835b4fd | 2021-04-21 21:13:14 +0200 | [diff] [blame] | 21 | Build for 32 bit, big endian: |
Bin Meng | 93ca4bc | 2019-07-18 00:34:17 -0700 | [diff] [blame] | 22 | |
Heinrich Schuchardt | bfaa54f | 2020-01-01 08:34:03 +0100 | [diff] [blame] | 23 | .. code-block:: bash |
Bin Meng | 93ca4bc | 2019-07-18 00:34:17 -0700 | [diff] [blame] | 24 | |
Daniel Schwierzeck | 835b4fd | 2021-04-21 21:13:14 +0200 | [diff] [blame] | 25 | make malta_defconfig |
| 26 | make |
| 27 | UBOOT_BIN=u-boot.bin |
| 28 | QEMU_BIN=qemu-system-mips |
| 29 | QEMU_CPU=24Kc |
Bin Meng | 93ca4bc | 2019-07-18 00:34:17 -0700 | [diff] [blame] | 30 | |
Daniel Schwierzeck | 835b4fd | 2021-04-21 21:13:14 +0200 | [diff] [blame] | 31 | Build for 32 bit, little endian: |
Bin Meng | 93ca4bc | 2019-07-18 00:34:17 -0700 | [diff] [blame] | 32 | |
Heinrich Schuchardt | bfaa54f | 2020-01-01 08:34:03 +0100 | [diff] [blame] | 33 | .. code-block:: bash |
Bin Meng | 93ca4bc | 2019-07-18 00:34:17 -0700 | [diff] [blame] | 34 | |
Daniel Schwierzeck | 835b4fd | 2021-04-21 21:13:14 +0200 | [diff] [blame] | 35 | make maltael_defconfig |
| 36 | make |
| 37 | UBOOT_BIN=u-boot-swap.bin |
| 38 | QEMU_BIN=qemu-system-mipsel |
| 39 | QEMU_CPU=24Kc |
Bin Meng | 93ca4bc | 2019-07-18 00:34:17 -0700 | [diff] [blame] | 40 | |
Daniel Schwierzeck | 835b4fd | 2021-04-21 21:13:14 +0200 | [diff] [blame] | 41 | Build for 64 bit, big endian: |
Bin Meng | 93ca4bc | 2019-07-18 00:34:17 -0700 | [diff] [blame] | 42 | |
Heinrich Schuchardt | bfaa54f | 2020-01-01 08:34:03 +0100 | [diff] [blame] | 43 | .. code-block:: bash |
| 44 | |
Daniel Schwierzeck | 835b4fd | 2021-04-21 21:13:14 +0200 | [diff] [blame] | 45 | make malta64_defconfig |
| 46 | make |
| 47 | UBOOT_BIN=u-boot.bin |
| 48 | QEMU_BIN=qemu-system-mips64 |
| 49 | QEMU_CPU=MIPS64R2-generic |
Heinrich Schuchardt | bfaa54f | 2020-01-01 08:34:03 +0100 | [diff] [blame] | 50 | |
Daniel Schwierzeck | 835b4fd | 2021-04-21 21:13:14 +0200 | [diff] [blame] | 51 | Build for 64 bit, little endian: |
Heinrich Schuchardt | bfaa54f | 2020-01-01 08:34:03 +0100 | [diff] [blame] | 52 | |
| 53 | .. code-block:: bash |
| 54 | |
Daniel Schwierzeck | 835b4fd | 2021-04-21 21:13:14 +0200 | [diff] [blame] | 55 | make malta64el_defconfig |
| 56 | make |
| 57 | UBOOT_BIN=u-boot-swap.bin |
| 58 | QEMU_BIN=qemu-system-mips64el |
| 59 | QEMU_CPU=MIPS64R2-generic |
Bin Meng | 93ca4bc | 2019-07-18 00:34:17 -0700 | [diff] [blame] | 60 | |
Daniel Schwierzeck | 835b4fd | 2021-04-21 21:13:14 +0200 | [diff] [blame] | 61 | Generate NOR flash image with U-Boot binary: |
Bin Meng | 93ca4bc | 2019-07-18 00:34:17 -0700 | [diff] [blame] | 62 | |
Heinrich Schuchardt | bfaa54f | 2020-01-01 08:34:03 +0100 | [diff] [blame] | 63 | .. code-block:: bash |
Bin Meng | 93ca4bc | 2019-07-18 00:34:17 -0700 | [diff] [blame] | 64 | |
Daniel Schwierzeck | 835b4fd | 2021-04-21 21:13:14 +0200 | [diff] [blame] | 65 | dd if=/dev/zero bs=1M count=4 | tr '\000' '\377' > pflash.img |
| 66 | dd if=${UBOOT_BIN} of=pflash.img conv=notrunc |
Bin Meng | 93ca4bc | 2019-07-18 00:34:17 -0700 | [diff] [blame] | 67 | |
Daniel Schwierzeck | 835b4fd | 2021-04-21 21:13:14 +0200 | [diff] [blame] | 68 | Start Qemu: |
Bin Meng | 93ca4bc | 2019-07-18 00:34:17 -0700 | [diff] [blame] | 69 | |
Heinrich Schuchardt | bfaa54f | 2020-01-01 08:34:03 +0100 | [diff] [blame] | 70 | .. code-block:: bash |
Bin Meng | 93ca4bc | 2019-07-18 00:34:17 -0700 | [diff] [blame] | 71 | |
Daniel Schwierzeck | 835b4fd | 2021-04-21 21:13:14 +0200 | [diff] [blame] | 72 | 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 Meng | 93ca4bc | 2019-07-18 00:34:17 -0700 | [diff] [blame] | 74 | |
Heinrich Schuchardt | bfaa54f | 2020-01-01 08:34:03 +0100 | [diff] [blame] | 75 | .. code-block:: bash |
Bin Meng | 93ca4bc | 2019-07-18 00:34:17 -0700 | [diff] [blame] | 76 | |
Daniel Schwierzeck | 835b4fd | 2021-04-21 21:13:14 +0200 | [diff] [blame] | 77 | U-Boot 2021.04-00963-g60279a2b1d (Apr 21 2021 - 19:54:32 +0200) |
Bin Meng | 93ca4bc | 2019-07-18 00:34:17 -0700 | [diff] [blame] | 78 | |
Daniel Schwierzeck | 835b4fd | 2021-04-21 21:13:14 +0200 | [diff] [blame] | 79 | Board: MIPS Malta CoreLV |
| 80 | DRAM: 256 MiB |
| 81 | Flash: 4 MiB |
| 82 | Loading Environment from Flash... *** Warning - bad CRC, using default environment |
Bin Meng | 93ca4bc | 2019-07-18 00:34:17 -0700 | [diff] [blame] | 83 | |
Daniel Schwierzeck | 835b4fd | 2021-04-21 21:13:14 +0200 | [diff] [blame] | 84 | In: serial@3f8 |
| 85 | Out: serial@3f8 |
| 86 | Err: serial@3f8 |
| 87 | Net: pcnet#0 |
| 88 | IDE: Bus 0: not available |
| 89 | maltael # |
Bin Meng | 93ca4bc | 2019-07-18 00:34:17 -0700 | [diff] [blame] | 90 | |
| 91 | How to debug U-Boot |
| 92 | ------------------- |
| 93 | |
| 94 | In order to debug U-Boot you need to start qemu with gdb server support (-s) |
Daniel Schwierzeck | 835b4fd | 2021-04-21 21:13:14 +0200 | [diff] [blame] | 95 | and waiting the connection to start the CPU (-S). Start Qemu in the first console: |
Bin Meng | 93ca4bc | 2019-07-18 00:34:17 -0700 | [diff] [blame] | 96 | |
Heinrich Schuchardt | bfaa54f | 2020-01-01 08:34:03 +0100 | [diff] [blame] | 97 | .. code-block:: bash |
Bin Meng | 93ca4bc | 2019-07-18 00:34:17 -0700 | [diff] [blame] | 98 | |
Daniel Schwierzeck | 835b4fd | 2021-04-21 21:13:14 +0200 | [diff] [blame] | 99 | 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 Meng | 93ca4bc | 2019-07-18 00:34:17 -0700 | [diff] [blame] | 101 | |
Daniel Schwierzeck | 835b4fd | 2021-04-21 21:13:14 +0200 | [diff] [blame] | 102 | In the second console start gdb: |
Bin Meng | 93ca4bc | 2019-07-18 00:34:17 -0700 | [diff] [blame] | 103 | |
Daniel Schwierzeck | 835b4fd | 2021-04-21 21:13:14 +0200 | [diff] [blame] | 104 | .. code-block:: bash |
Bin Meng | 93ca4bc | 2019-07-18 00:34:17 -0700 | [diff] [blame] | 105 | |
Daniel Schwierzeck | 835b4fd | 2021-04-21 21:13:14 +0200 | [diff] [blame] | 106 | gdb-multiarch --eval-command "target remote :1234" u-boot |
Bin Meng | 93ca4bc | 2019-07-18 00:34:17 -0700 | [diff] [blame] | 107 | |
Daniel Schwierzeck | 835b4fd | 2021-04-21 21:13:14 +0200 | [diff] [blame] | 108 | .. code-block:: bash |
Bin Meng | 93ca4bc | 2019-07-18 00:34:17 -0700 | [diff] [blame] | 109 | |
Daniel Schwierzeck | 835b4fd | 2021-04-21 21:13:14 +0200 | [diff] [blame] | 110 | 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 Meng | 93ca4bc | 2019-07-18 00:34:17 -0700 | [diff] [blame] | 122 | |
Daniel Schwierzeck | 835b4fd | 2021-04-21 21:13:14 +0200 | [diff] [blame] | 123 | 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. |