1*61c4878aSAndroid Build Coastguard Worker.. _module-pw_emu-config: 2*61c4878aSAndroid Build Coastguard Worker 3*61c4878aSAndroid Build Coastguard Worker============= 4*61c4878aSAndroid Build Coastguard WorkerConfiguration 5*61c4878aSAndroid Build Coastguard Worker============= 6*61c4878aSAndroid Build Coastguard Worker.. pigweed-module-subpage:: 7*61c4878aSAndroid Build Coastguard Worker :name: pw_emu 8*61c4878aSAndroid Build Coastguard Worker 9*61c4878aSAndroid Build Coastguard Worker``pw_emu`` configuration is done in the ``pw.pw_emu`` namespace of 10*61c4878aSAndroid Build Coastguard Worker:ref:`pigweed.json <seed-0101>`. 11*61c4878aSAndroid Build Coastguard Worker 12*61c4878aSAndroid Build Coastguard WorkerThe target configuration allows users to start other programs before 13*61c4878aSAndroid Build Coastguard Workeror after starting the main emulator process. This allows extending the 14*61c4878aSAndroid Build Coastguard Workeremulated target with simulation or emulation outside of the main 15*61c4878aSAndroid Build Coastguard Workeremulator. For example, for BLE emulation the main emulator could 16*61c4878aSAndroid Build Coastguard Workeremulate just the serial port while the HCI emulation done is in an 17*61c4878aSAndroid Build Coastguard Workerexternal program (e.g. `bumble <https://google.github.io/bumble>`_, 18*61c4878aSAndroid Build Coastguard Worker`netsim <https://android.googlesource.com/platform/tools/netsim>`_). 19*61c4878aSAndroid Build Coastguard Worker 20*61c4878aSAndroid Build Coastguard Worker.. _module-pw_emu-config-fragments: 21*61c4878aSAndroid Build Coastguard Worker 22*61c4878aSAndroid Build Coastguard Worker----------------------- 23*61c4878aSAndroid Build Coastguard WorkerConfiguration fragments 24*61c4878aSAndroid Build Coastguard Worker----------------------- 25*61c4878aSAndroid Build Coastguard WorkerEmulation targets can be stored in JSON files outside of ``pigweed.json``. 26*61c4878aSAndroid Build Coastguard WorkerThese are known as *configuration fragments*. ``pigweed.json`` imports these 27*61c4878aSAndroid Build Coastguard Workerfragments via ``target_files``. 28*61c4878aSAndroid Build Coastguard Worker 29*61c4878aSAndroid Build Coastguard WorkerExample configuration fragments: 30*61c4878aSAndroid Build Coastguard Worker 31*61c4878aSAndroid Build Coastguard Worker* `//pw_emu/qemu-lm3s6965evb.json <https://cs.opensource.google/pigweed/pigweed/+/main:pw_emu/qemu-lm3s6965evb.json>`_ 32*61c4878aSAndroid Build Coastguard Worker* `//pw_emu/renode-stm32f4_discovery.json <https://cs.opensource.google/pigweed/pigweed/+/main:pw_emu/renode-stm32f4_discovery.json>`_ 33*61c4878aSAndroid Build Coastguard Worker 34*61c4878aSAndroid Build Coastguard Worker.. _module-pw_emu-config-options: 35*61c4878aSAndroid Build Coastguard Worker 36*61c4878aSAndroid Build Coastguard Worker----------------------- 37*61c4878aSAndroid Build Coastguard WorkerConfiguration reference 38*61c4878aSAndroid Build Coastguard Worker----------------------- 39*61c4878aSAndroid Build Coastguard WorkerThe following list explains the valid schema for the ``pw_emu`` dict in 40*61c4878aSAndroid Build Coastguard Worker:ref:`pigweed.json <seed-0101>`. 41*61c4878aSAndroid Build Coastguard Worker 42*61c4878aSAndroid Build Coastguard Worker.. caution:: 43*61c4878aSAndroid Build Coastguard Worker 44*61c4878aSAndroid Build Coastguard Worker All the values below should be nested under ``pw.pw_emu`` in ``pigweed.json``. 45*61c4878aSAndroid Build Coastguard Worker For example, the top-level ``gdb`` item in the list below actually lives 46*61c4878aSAndroid Build Coastguard Worker here: 47*61c4878aSAndroid Build Coastguard Worker 48*61c4878aSAndroid Build Coastguard Worker .. code-block:: json 49*61c4878aSAndroid Build Coastguard Worker 50*61c4878aSAndroid Build Coastguard Worker { 51*61c4878aSAndroid Build Coastguard Worker "pw": { 52*61c4878aSAndroid Build Coastguard Worker "pw_emu": { 53*61c4878aSAndroid Build Coastguard Worker "gdb": ["..."] 54*61c4878aSAndroid Build Coastguard Worker } 55*61c4878aSAndroid Build Coastguard Worker } 56*61c4878aSAndroid Build Coastguard Worker } 57*61c4878aSAndroid Build Coastguard Worker 58*61c4878aSAndroid Build Coastguard Worker.. Note to maintainers: Multi-level unordered lists in reST are very finicky. 59*61c4878aSAndroid Build Coastguard Worker.. The syntax below is the only one that works (e.g. spaces are significant). 60*61c4878aSAndroid Build Coastguard Worker 61*61c4878aSAndroid Build Coastguard Worker* ``gdb`` (list of strings) - The default GDB command to run. 62*61c4878aSAndroid Build Coastguard Worker Can be overridden at the target level. 63*61c4878aSAndroid Build Coastguard Worker 64*61c4878aSAndroid Build Coastguard Worker* ``target_files`` (list of strings) - Relative or absolute paths 65*61c4878aSAndroid Build Coastguard Worker to :ref:`module-pw_emu-config-fragments`. Relative paths are 66*61c4878aSAndroid Build Coastguard Worker interpreted relative to the project root directory. 67*61c4878aSAndroid Build Coastguard Worker 68*61c4878aSAndroid Build Coastguard Worker* ``qemu`` (dict) - QEMU options. 69*61c4878aSAndroid Build Coastguard Worker 70*61c4878aSAndroid Build Coastguard Worker * ``executable`` (string) - The default command for starting 71*61c4878aSAndroid Build Coastguard Worker QEMU, e.g. ``system-arm-qemu``. Can be overridden at the target level. 72*61c4878aSAndroid Build Coastguard Worker 73*61c4878aSAndroid Build Coastguard Worker * ``args`` (list of strings) - Command line options to pass 74*61c4878aSAndroid Build Coastguard Worker directly to QEMU when ``executable`` is invoked. Can be **extended** (not 75*61c4878aSAndroid Build Coastguard Worker overridden) at the target level. 76*61c4878aSAndroid Build Coastguard Worker 77*61c4878aSAndroid Build Coastguard Worker * ``channels`` (dict) - Channel options. 78*61c4878aSAndroid Build Coastguard Worker 79*61c4878aSAndroid Build Coastguard Worker * ``type`` (string) - The :ref:`channel type 80*61c4878aSAndroid Build Coastguard Worker <module-pw_emu-config-channel-types>`. Optional. 81*61c4878aSAndroid Build Coastguard Worker 82*61c4878aSAndroid Build Coastguard Worker * ``gdb`` (dict) - Channel-specific GDB options. Optional. 83*61c4878aSAndroid Build Coastguard Worker 84*61c4878aSAndroid Build Coastguard Worker * ``type`` (string) - The :ref:`channel type 85*61c4878aSAndroid Build Coastguard Worker <module-pw_emu-config-channel-types>`. Optional. 86*61c4878aSAndroid Build Coastguard Worker 87*61c4878aSAndroid Build Coastguard Worker * ``qmp`` (dict) - Channel-specific QMP options. Optional. 88*61c4878aSAndroid Build Coastguard Worker 89*61c4878aSAndroid Build Coastguard Worker * ``type`` (string) - The :ref:`channel type 90*61c4878aSAndroid Build Coastguard Worker <module-pw_emu-config-channel-types>`. Optional. 91*61c4878aSAndroid Build Coastguard Worker 92*61c4878aSAndroid Build Coastguard Worker * ``monitor`` (dict) - Channel-specific Monitor options. Optional. 93*61c4878aSAndroid Build Coastguard Worker 94*61c4878aSAndroid Build Coastguard Worker * ``type`` (string) - The :ref:`channel type 95*61c4878aSAndroid Build Coastguard Worker <module-pw_emu-config-channel-types>`. Optional. 96*61c4878aSAndroid Build Coastguard Worker 97*61c4878aSAndroid Build Coastguard Worker* ``renode`` (dict) - Renode options. 98*61c4878aSAndroid Build Coastguard Worker 99*61c4878aSAndroid Build Coastguard Worker * ``executable`` (string) - The default command for starting Renode. Can be 100*61c4878aSAndroid Build Coastguard Worker overridden at the target level. 101*61c4878aSAndroid Build Coastguard Worker 102*61c4878aSAndroid Build Coastguard Worker * ``channels`` (dict) - Channel options. 103*61c4878aSAndroid Build Coastguard Worker 104*61c4878aSAndroid Build Coastguard Worker * ``terminals`` (dict) - Generic options for exposed terminal devices, e.g. 105*61c4878aSAndroid Build Coastguard Worker serial ports. 106*61c4878aSAndroid Build Coastguard Worker 107*61c4878aSAndroid Build Coastguard Worker * ``type`` (string) - The :ref:`channel type 108*61c4878aSAndroid Build Coastguard Worker <module-pw_emu-config-channel-types>`. Optional. 109*61c4878aSAndroid Build Coastguard Worker 110*61c4878aSAndroid Build Coastguard Worker* ``targets`` (dict) - Target configuration. Each key of this dict represents 111*61c4878aSAndroid Build Coastguard Worker a target name. 112*61c4878aSAndroid Build Coastguard Worker 113*61c4878aSAndroid Build Coastguard Worker * ``<target-name>`` (dict) - Configuration for a single target. Replace 114*61c4878aSAndroid Build Coastguard Worker ``<target-name>`` with a real target name, e.g. ``qemu-lm3s6965evb``. 115*61c4878aSAndroid Build Coastguard Worker 116*61c4878aSAndroid Build Coastguard Worker * ``gdb`` (list of strings) - The GDB command to run for this target. 117*61c4878aSAndroid Build Coastguard Worker Overrides the top-level ``gdb`` command. 118*61c4878aSAndroid Build Coastguard Worker 119*61c4878aSAndroid Build Coastguard Worker * ``pre-start-cmds`` (dict) - Commands to run before the emulator 120*61c4878aSAndroid Build Coastguard Worker is started. See also :ref:`module-pw_emu-config-pre-post-substitutions`. 121*61c4878aSAndroid Build Coastguard Worker 122*61c4878aSAndroid Build Coastguard Worker * ``<command-id>`` (list of strings) - A pre-start command. 123*61c4878aSAndroid Build Coastguard Worker Replace ``<command-id>`` with a descriptive name for the command. 124*61c4878aSAndroid Build Coastguard Worker 125*61c4878aSAndroid Build Coastguard Worker * ``post-start-cmds`` (dict) - Commands to run after the emulator 126*61c4878aSAndroid Build Coastguard Worker is started. See also :ref:`module-pw_emu-config-pre-post-substitutions`. 127*61c4878aSAndroid Build Coastguard Worker 128*61c4878aSAndroid Build Coastguard Worker * ``<command-id>`` (list of strings) - A post-start command. 129*61c4878aSAndroid Build Coastguard Worker Replace ``<command-id>`` with a descriptive name. 130*61c4878aSAndroid Build Coastguard Worker 131*61c4878aSAndroid Build Coastguard Worker * ``qemu`` (dict) - QEMU options for this target. Overrides the top-level 132*61c4878aSAndroid Build Coastguard Worker ``qemu`` command. 133*61c4878aSAndroid Build Coastguard Worker 134*61c4878aSAndroid Build Coastguard Worker * ``executable`` (string) - The command for starting QEMU on this target. 135*61c4878aSAndroid Build Coastguard Worker Required. 136*61c4878aSAndroid Build Coastguard Worker 137*61c4878aSAndroid Build Coastguard Worker * ``machine`` (string) - The QEMU ``-machine`` value for this target, 138*61c4878aSAndroid Build Coastguard Worker e.g. ``stm32vldiscovery``. See ``qemu-system-<arch> -machine help`` 139*61c4878aSAndroid Build Coastguard Worker for a list of supported machines. Required. 140*61c4878aSAndroid Build Coastguard Worker 141*61c4878aSAndroid Build Coastguard Worker * ``args`` (list of strings) - Command line options to pass 142*61c4878aSAndroid Build Coastguard Worker directly to QEMU when ``executable`` is invoked. This value **extends** 143*61c4878aSAndroid Build Coastguard Worker the top-level ``args`` value; it does *not* override it. Optional. 144*61c4878aSAndroid Build Coastguard Worker 145*61c4878aSAndroid Build Coastguard Worker * ``channels`` (dict) - Channel options for this target. 146*61c4878aSAndroid Build Coastguard Worker 147*61c4878aSAndroid Build Coastguard Worker * ``chardevs`` (dict) - QEMU chardev device configuration. Usually 148*61c4878aSAndroid Build Coastguard Worker serial ports. 149*61c4878aSAndroid Build Coastguard Worker 150*61c4878aSAndroid Build Coastguard Worker * ``<channel-name>`` (dict) - The configuration for a single channel. 151*61c4878aSAndroid Build Coastguard Worker Replace ``<channel-name>`` with a descriptive name. 152*61c4878aSAndroid Build Coastguard Worker 153*61c4878aSAndroid Build Coastguard Worker * ``id`` (string) - The ID of the QEMU chardev. 154*61c4878aSAndroid Build Coastguard Worker 155*61c4878aSAndroid Build Coastguard Worker * ``type`` (string) - The :ref:`channel type 156*61c4878aSAndroid Build Coastguard Worker <module-pw_emu-config-channel-types>`. Optional. 157*61c4878aSAndroid Build Coastguard Worker 158*61c4878aSAndroid Build Coastguard Worker * ``gdb`` (dict) - Channel-specific GDB options. Optional. 159*61c4878aSAndroid Build Coastguard Worker 160*61c4878aSAndroid Build Coastguard Worker * ``type`` (string) - The :ref:`channel type 161*61c4878aSAndroid Build Coastguard Worker <module-pw_emu-config-channel-types>`. Optional. 162*61c4878aSAndroid Build Coastguard Worker 163*61c4878aSAndroid Build Coastguard Worker * ``qmp`` (dict) - Channel-specific QMP options. Optional. 164*61c4878aSAndroid Build Coastguard Worker 165*61c4878aSAndroid Build Coastguard Worker * ``type`` (string) - The :ref:`channel type 166*61c4878aSAndroid Build Coastguard Worker <module-pw_emu-config-channel-types>`. Optional. 167*61c4878aSAndroid Build Coastguard Worker 168*61c4878aSAndroid Build Coastguard Worker * ``monitor`` (dict) - Channel-specific Monitor options. Optional. 169*61c4878aSAndroid Build Coastguard Worker 170*61c4878aSAndroid Build Coastguard Worker * ``type`` (string) - The :ref:`channel type 171*61c4878aSAndroid Build Coastguard Worker <module-pw_emu-config-channel-types>`. Optional. 172*61c4878aSAndroid Build Coastguard Worker 173*61c4878aSAndroid Build Coastguard Worker * ``renode`` (dict) - Renode options for this target. 174*61c4878aSAndroid Build Coastguard Worker 175*61c4878aSAndroid Build Coastguard Worker * ``executable`` (string) - The command for starting Renode on this target, 176*61c4878aSAndroid Build Coastguard Worker e.g. ``renode``. 177*61c4878aSAndroid Build Coastguard Worker 178*61c4878aSAndroid Build Coastguard Worker * ``machine`` (string) - The Renode script to use for machine definitions, 179*61c4878aSAndroid Build Coastguard Worker e.g. ``platforms/boards/stm32f4_discovery-kit.repl``. 180*61c4878aSAndroid Build Coastguard Worker 181*61c4878aSAndroid Build Coastguard Worker * ``channels`` (dict) - Channel options. 182*61c4878aSAndroid Build Coastguard Worker 183*61c4878aSAndroid Build Coastguard Worker * ``terminals`` (dict) - Exposed terminal devices, usually serial ports. 184*61c4878aSAndroid Build Coastguard Worker 185*61c4878aSAndroid Build Coastguard Worker * ``<device-name>`` (dict) - Device configuration. Replace ``<device-name>`` 186*61c4878aSAndroid Build Coastguard Worker with a descriptive name, e.g. ``serial0``. 187*61c4878aSAndroid Build Coastguard Worker 188*61c4878aSAndroid Build Coastguard Worker * ``device-path`` (string) - The path to the device, e.g. 189*61c4878aSAndroid Build Coastguard Worker ``sysbus.usart1``. 190*61c4878aSAndroid Build Coastguard Worker 191*61c4878aSAndroid Build Coastguard Worker * ``type`` (string) - The :ref:`channel type 192*61c4878aSAndroid Build Coastguard Worker <module-pw_emu-config-channel-types>`. Optional. 193*61c4878aSAndroid Build Coastguard Worker 194*61c4878aSAndroid Build Coastguard Worker.. _module-pw_emu-config-channel-types: 195*61c4878aSAndroid Build Coastguard Worker 196*61c4878aSAndroid Build Coastguard WorkerChannel types 197*61c4878aSAndroid Build Coastguard Worker============= 198*61c4878aSAndroid Build Coastguard WorkerThe following channel types are currently supported: 199*61c4878aSAndroid Build Coastguard Worker 200*61c4878aSAndroid Build Coastguard Worker* ``pty`` - Full support on macOS and Linux. Renode only supports PTYs for 201*61c4878aSAndroid Build Coastguard Worker ``terminals``. 202*61c4878aSAndroid Build Coastguard Worker 203*61c4878aSAndroid Build Coastguard Worker* ``tcp`` - Full support on all platforms and channels. This is the default 204*61c4878aSAndroid Build Coastguard Worker value if no channel type is configured. 205*61c4878aSAndroid Build Coastguard Worker 206*61c4878aSAndroid Build Coastguard WorkerThe channel configuration can be set at the emulator, target, or channel level. 207*61c4878aSAndroid Build Coastguard WorkerThe channel level takes precedence, then the target level, then the emulator 208*61c4878aSAndroid Build Coastguard Workerlevel. 209*61c4878aSAndroid Build Coastguard Worker 210*61c4878aSAndroid Build Coastguard Worker.. _module-pw_emu-config-pre-post-substitutions: 211*61c4878aSAndroid Build Coastguard Worker 212*61c4878aSAndroid Build Coastguard WorkerPre-start and post-start expression substitutions 213*61c4878aSAndroid Build Coastguard Worker================================================= 214*61c4878aSAndroid Build Coastguard WorkerThe following expressions are substituted in the ``pre-start-cmd`` and 215*61c4878aSAndroid Build Coastguard Worker``post-start-cmd`` strings: 216*61c4878aSAndroid Build Coastguard Worker 217*61c4878aSAndroid Build Coastguard Worker* ``$pw_emu_wdir{relative-path}`` - Replaces the statement with an absolute path 218*61c4878aSAndroid Build Coastguard Worker by concatenating the emulator's working directory with the given relative path. 219*61c4878aSAndroid Build Coastguard Worker 220*61c4878aSAndroid Build Coastguard Worker* ``$pw_emu_channel_port{channel-name}`` - Replaces the statement with the port 221*61c4878aSAndroid Build Coastguard Worker number for the given channel name. The channel type should be ``tcp``. 222*61c4878aSAndroid Build Coastguard Worker 223*61c4878aSAndroid Build Coastguard Worker* ``$pw_emu_channel_host{channel-name}`` - Replaces the statement with the host 224*61c4878aSAndroid Build Coastguard Worker for the given channel name. The channel type should be ``tcp``. 225*61c4878aSAndroid Build Coastguard Worker 226*61c4878aSAndroid Build Coastguard Worker* ``$pw_emu_channel_path{channel-name}`` - Replaces the statement with the path 227*61c4878aSAndroid Build Coastguard Worker for the given channel name. The channel type should be ``pty``. 228*61c4878aSAndroid Build Coastguard Worker 229*61c4878aSAndroid Build Coastguard Worker.. _module-pw_emu-config-string-substitutions: 230*61c4878aSAndroid Build Coastguard Worker 231*61c4878aSAndroid Build Coastguard WorkerConfiguration string substitutions 232*61c4878aSAndroid Build Coastguard Worker================================== 233*61c4878aSAndroid Build Coastguard WorkerThe following expressions are substituted in configuration strings, including 234*61c4878aSAndroid Build Coastguard Worker:ref:`module-pw_emu-config-fragments`: 235*61c4878aSAndroid Build Coastguard Worker 236*61c4878aSAndroid Build Coastguard Worker* ``$pw_env{envvar}`` - Replaces the statement with the value of ``envvar``. 237*61c4878aSAndroid Build Coastguard Worker If ``envvar`` doesn't exist a configuration error is raised. 238*61c4878aSAndroid Build Coastguard Worker 239*61c4878aSAndroid Build Coastguard Worker---------------- 240*61c4878aSAndroid Build Coastguard WorkerMore pw_emu docs 241*61c4878aSAndroid Build Coastguard Worker---------------- 242*61c4878aSAndroid Build Coastguard Worker.. include:: docs.rst 243*61c4878aSAndroid Build Coastguard Worker :start-after: .. pw_emu-nav-start 244*61c4878aSAndroid Build Coastguard Worker :end-before: .. pw_emu-nav-end 245