semihosting.rst 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. .. SPDX-License-Identifier: GPL-2.0+
  2. .. Copyright 2014 Broadcom Corporation.
  3. Semihosting
  4. ===========
  5. Semihosting is ARM's way of having a real or virtual target communicate
  6. with a host or host debugger for basic operations such as file I/O,
  7. console I/O, etc. Please see `Arm's semihosting documentation
  8. <https://developer.arm.com/documentation/100863/latest/>`_ for more
  9. information.
  10. Platform Support
  11. ----------------
  12. Versatile Express
  13. ^^^^^^^^^^^^^^^^^
  14. For developing on armv8 virtual fastmodel platforms, semihosting is a
  15. valuable tool since it allows access to image/configuration files before
  16. eMMC or other NV media are available.
  17. There are two main ARM virtual Fixed Virtual Platform (FVP) models,
  18. `Versatile Express (VE) FVP and BASE FVP
  19. <http://www.arm.com/products/tools/models/fast-models/foundation-model.php>`_.
  20. The initial vexpress64 u-boot board created here runs on the VE virtual
  21. platform using the license-free Foundation_v8 simulator. Fortunately,
  22. the Foundation_v8 simulator also supports the BASE_FVP model which
  23. companies can purchase licenses for and contain much more functionality.
  24. So we can, in U-Boot, run either model by either using the VE FVP (default),
  25. or turning on ``CONFIG_BASE_FVP`` for the more full featured model.
  26. Rather than create a new armv8 board similar to ``armltd/vexpress64``, add
  27. semihosting calls to the existing one, enabled with ``CONFIG_SEMIHOSTING``
  28. and ``CONFIG_BASE_FVP`` both set. Also reuse the existing board config file
  29. vexpress_aemv8.h but differentiate the two models by the presence or
  30. absence of ``CONFIG_BASE_FVP``. This change is tested and works on both the
  31. Foundation and Base fastmodel simulators.
  32. QEMU
  33. ^^^^
  34. Another ARM emulator which supports semihosting is `QEMU
  35. <https://www.qemu.org/>`_. To enable semihosting, enable
  36. ``CONFIG_SERIAL_PROBE_ALL`` when configuring U-Boot, and use
  37. ``-semihosting`` when invoking QEMU. Adding ``-nographic`` can also be
  38. helpful. When using a semihosted serial console, QEMU will block waiting
  39. for input. This will cause the GUI to become unresponsive. To mitigate
  40. this, try adding ``-nographic``. For more information about building and
  41. running QEMU, refer to the :doc:`board documentation
  42. <../board/emulation/qemu-arm>`.
  43. OpenOCD
  44. ^^^^^^^
  45. Any ARM platform can use semihosting with an attached debugger. One such
  46. debugger with good support for a variety of boards and JTAG adapters is
  47. `OpenOCD <https://openocd.org/>`_. Semihosting is not enabled by default,
  48. so you will need to enable it::
  49. $ openocd -f <your board config> -c init -c halt -c \
  50. 'arm semihosting enable' -c resume
  51. Note that enabling semihosting can only be done after attaching to the
  52. board with ``init``, and must be done while the CPU is halted. For a more
  53. extended example, refer to the :ref:`LS1046ARDB docs <ls1046ardb_jtag>`.
  54. Loading files
  55. -------------
  56. The semihosting code adds a "semihosting filesystem"::
  57. load hostfs - <address> <image>
  58. That will load an image from the host filesystem into RAM at the specified
  59. address. If you are using U-Boot SPL, you can also use ``BOOT_DEVICE_SMH``
  60. which will load ``CONFIG_SPL_FS_LOAD_PAYLOAD_NAME``.
  61. Host console
  62. ------------
  63. U-Boot can use the host's console instead of a physical serial device by
  64. enabling ``CONFIG_SERIAL_SEMIHOSTING``. If you don't have
  65. ``CONFIG_DM_SERIAL`` enabled, make sure you disable any other serial
  66. drivers.
  67. Migrating from ``smhload``
  68. --------------------------
  69. If you were using the ``smhload`` command, you can migrate commands like::
  70. smhload <file> <address> [<end var>]
  71. to a generic load command like::
  72. load hostfs - <address> <file>
  73. The ``load`` command will set the ``filesize`` variable with the size of
  74. the file. The ``fdt chosen`` command has been updated to take a size
  75. instead of an end address. If you were adding the initramfs to your device
  76. tree like::
  77. fdt chosen <address> <end var>
  78. you can now run::
  79. fdt chosen <address> $filesize