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