qemu-mips.rst 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. .. SPDX-License-Identifier: GPL-2.0+
  2. .. sectionauthor:: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
  3. QEMU MIPS
  4. =========
  5. Qemu for MIPS is based on the MIPS Malta board. The built Malta U-Boot
  6. images can be used for Qemu and on physical hardware. The Malta board
  7. supports all combinations of Little and Big Endian as well as 32 bit
  8. and 64 bit.
  9. Limitations & comments
  10. ----------------------
  11. The memory size for Qemu is hard-coded to 256 MiB. For Malta Little Endian
  12. targets an extra endianness swapped image named *u-boot-swap.bin* is
  13. generated and required for Qemu.
  14. Example usage
  15. -------------
  16. Build for 32 bit, big endian:
  17. .. code-block:: bash
  18. make malta_defconfig
  19. make
  20. UBOOT_BIN=u-boot.bin
  21. QEMU_BIN=qemu-system-mips
  22. QEMU_CPU=24Kc
  23. Build for 32 bit, little endian:
  24. .. code-block:: bash
  25. make maltael_defconfig
  26. make
  27. UBOOT_BIN=u-boot-swap.bin
  28. QEMU_BIN=qemu-system-mipsel
  29. QEMU_CPU=24Kc
  30. Build for 64 bit, big endian:
  31. .. code-block:: bash
  32. make malta64_defconfig
  33. make
  34. UBOOT_BIN=u-boot.bin
  35. QEMU_BIN=qemu-system-mips64
  36. QEMU_CPU=MIPS64R2-generic
  37. Build for 64 bit, little endian:
  38. .. code-block:: bash
  39. make malta64el_defconfig
  40. make
  41. UBOOT_BIN=u-boot-swap.bin
  42. QEMU_BIN=qemu-system-mips64el
  43. QEMU_CPU=MIPS64R2-generic
  44. Generate NOR flash image with U-Boot binary:
  45. .. code-block:: bash
  46. dd if=/dev/zero bs=1M count=4 | tr '\000' '\377' > pflash.img
  47. dd if=${UBOOT_BIN} of=pflash.img conv=notrunc
  48. Start Qemu:
  49. .. code-block:: bash
  50. mkdir tftproot
  51. ${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
  52. .. code-block:: bash
  53. U-Boot 2021.04-00963-g60279a2b1d (Apr 21 2021 - 19:54:32 +0200)
  54. Board: MIPS Malta CoreLV
  55. DRAM: 256 MiB
  56. Flash: 4 MiB
  57. Loading Environment from Flash... *** Warning - bad CRC, using default environment
  58. In: serial@3f8
  59. Out: serial@3f8
  60. Err: serial@3f8
  61. Net: pcnet#0
  62. IDE: Bus 0: not available
  63. maltael #
  64. How to debug U-Boot
  65. -------------------
  66. In order to debug U-Boot you need to start qemu with gdb server support (-s)
  67. and waiting the connection to start the CPU (-S). Start Qemu in the first console:
  68. .. code-block:: bash
  69. mkdir tftproot
  70. ${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
  71. In the second console start gdb:
  72. .. code-block:: bash
  73. gdb-multiarch --eval-command "target remote :1234" u-boot
  74. .. code-block:: bash
  75. GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2
  76. Copyright (C) 2020 Free Software Foundation, Inc.
  77. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
  78. This is free software: you are free to change and redistribute it.
  79. There is NO WARRANTY, to the extent permitted by law.
  80. Type "show copying" and "show warranty" for details.
  81. This GDB was configured as "x86_64-linux-gnu".
  82. Type "show configuration" for configuration details.
  83. For bug reporting instructions, please see:
  84. <http://www.gnu.org/software/gdb/bugs/>.
  85. Find the GDB manual and other documentation resources online at:
  86. <http://www.gnu.org/software/gdb/documentation/>.
  87. For help, type "help".
  88. Type "apropos word" to search for commands related to "word"...
  89. Reading symbols from u-boot...
  90. Remote debugging using :1234
  91. 0xbfc00000 in ?? ()
  92. (gdb) c
  93. Continuing.