Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 1 | On this page you will find device specific information for QEMU v7 (Armv7-A) and |
| 2 | QEMU v8 (Armv8-A). |
| 3 | |
| 4 | .. _qemu_v7: |
| 5 | |
| 6 | ####### |
| 7 | QEMU v7 |
| 8 | ####### |
| 9 | The instructions here will tell how to run OP-TEE using QEMU for Armv7-A. |
| 10 | |
| 11 | Build instructions |
| 12 | ****************** |
| 13 | As long as you pick the v7 manifest, i.e., ``default.xml`` the |
| 14 | ":ref:`get_and_build_the_solution`" tells all you need to know to build and boot |
| 15 | up QEMU v7. |
| 16 | |
| 17 | |
| 18 | Consoles |
| 19 | ******** |
| 20 | After running ``make run`` you will end up in the QEMU console and it will also |
| 21 | spawn two UART consoles. One console containing the UART for secure world and |
| 22 | one console containing the UART for normal world. You will see that it stops |
| 23 | waiting for input on the QEMU console. To continue, do: |
| 24 | |
| 25 | .. code-block:: none |
| 26 | |
| 27 | (qemu) c |
| 28 | |
| 29 | Host-Guest folder sharing |
| 30 | ************************* |
| 31 | You can use the VirtFS QEMU feature to avoid changing rootfs CPIO archive every |
| 32 | time you need to add additional files or modify existing files. To do this, you |
| 33 | share a folder between the guest and host operating systems. To enable and use |
| 34 | this feature you have to provide additional arguments when running make, |
| 35 | example: |
| 36 | |
| 37 | .. code-block:: bash |
| 38 | |
| 39 | $ make QEMU_VIRTFS_ENABLE=y QEMU_USERNET_ENABLE=y |
| 40 | |
| 41 | .. hint:: |
| 42 | |
| 43 | You can also add ``QEMU_VIRTFS_HOST_DIR=<share>`` in case you don't want to |
| 44 | use the default sharing location (which is the root of <qemu-v7-project>). |
| 45 | |
| 46 | When QEMU with OP-TEE is up and running, you can mount the host folder in QEMU |
| 47 | (normal world UART). |
| 48 | |
| 49 | .. code-block:: none |
| 50 | |
| 51 | # mount -t 9p -o trans=virtio host <mount_point> |
| 52 | |
| 53 | ``<mount_point>`` here is folder in the QEMU where you want to mount the host |
| 54 | PC's shared folder. So if you want to mount it at ``/mnt/host`` you typically do |
| 55 | this from QEMU NW/UART. |
| 56 | |
| 57 | .. code-block:: none |
| 58 | |
| 59 | # mkdir -p /mnt/host |
| 60 | # mount -t 9p -o trans=virtio host /mnt/host |
| 61 | |
| 62 | Networking |
| 63 | ********** |
| 64 | After booting QEMU, ``eth0`` will automatically receive an IP address from |
| 65 | QEMU via DHCP using the SLiRP user networking feature. QEMU will act as a |
| 66 | gateway to the host network `SLiRP`_. |
| 67 | |
| 68 | Please note that ICMP won't work in the guest unless additional configuration is |
| 69 | made, so the ``ping`` utility won't work. |
| 70 | |
| 71 | GDB - Normal world |
| 72 | ****************** |
| 73 | If you need to debug a client application, using GDB in a remote debugging |
| 74 | configuration may be useful. Remote debugging means ``gdb`` runs on your PC, |
| 75 | where it can access the source code, while the program being debugged runs on |
| 76 | the remote system (in this case, in the QEMU environment in normal world). Here |
| 77 | is how to do that. On your PC, build with ``GDBSERVER=y``: |
| 78 | |
| 79 | .. code-block:: bash |
| 80 | |
| 81 | $ cd <qemu-v7-project>/build |
| 82 | # You **only** need to rm -rf the first time you build with the new flag. |
| 83 | # If you omit doing so, it's likely that you will see "stamp" errors in the |
| 84 | # build log. |
| 85 | $ rm -rf <qemu-v7-project>/out-br |
| 86 | $ make -j8 run GDBSERVER=y |
| 87 | |
| 88 | Boot up as usual |
| 89 | |
| 90 | .. code-block:: bash |
| 91 | |
| 92 | (qemu) c |
| 93 | |
| 94 | Inside QEMU (Normal World UART), run your application with gdbserver (for |
| 95 | example ``xtest 4002``): |
| 96 | |
| 97 | .. code-block:: none |
| 98 | |
| 99 | # gdbserver :12345 xtest 4002 |
| 100 | Process xtest created; pid = 654 |
| 101 | Listening on port 12345 |
| 102 | |
| 103 | Back on your PC, open another terminal, start GDB and connect to the target: |
| 104 | |
| 105 | .. code-block:: bash |
| 106 | |
| 107 | $ <qemu-v7-project>/out-br/host/bin/arm-buildroot-linux-gnueabihf-gdb |
| 108 | (gdb) set sysroot <qemu-v7-project>/out-br/host/arm-buildroot-linux-gnueabihf/sysroot |
| 109 | (gdb) target remote :12345 |
| 110 | |
| 111 | Now GDB is connected to the remote application. You may use GDB normally. |
| 112 | |
| 113 | .. code-block:: none |
| 114 | |
| 115 | (gdb) b main |
| 116 | (gdb) c |
| 117 | |
| 118 | |
| 119 | .. _qemu_v8: |
| 120 | |
| 121 | ####### |
| 122 | QEMU v8 |
| 123 | ####### |
| 124 | The instructions here will tell how to run OP-TEE using QEMU for Armv7-A. |
| 125 | |
| 126 | Build instructions |
| 127 | ****************** |
| 128 | As long as you pick the v8 manifest, i.e., ``qemu_v8.xml`` the |
| 129 | ":ref:`get_and_build_the_solution`" tells all you need to know to build and boot |
| 130 | up QEMU v8. |
| 131 | |
| 132 | All other things (networking, GDB etc) in the v7 section above is also |
| 133 | applicable on QEMU v8 as long as you replace ``<qemu-v7-project>`` with |
| 134 | ``<qemu-v8-project>`` to get the correct paths relative to your QEMU v8 setup. |
| 135 | |
| 136 | .. _SLiRP: https://wiki.qemu.org/Documentation/Networking#User_Networking_.28SLIRP.29 |