1.. zephyr:board:: nsim_arc_v 2 3Overview 4******** 5 6This platform can be used to run Zephyr RTOS on the widest possible range of Synopsys RISC-V processors in 7simulation with `Designware ARC nSIM`_ or run same images on FPGA prototyping platform `HAPS`_. The 8platform includes the following features: 9 10* RISC-V processor core, which implements riscv32 ISA 11* Virtual serial console (a standard ``ns16550`` UART model) 12 13Supported board targets for that platform are listed below: 14 15* ``nsim_arc_v/rmx100`` - Synopsys RISC-V RMX100 core 16 17.. _board_nsim_arc_v_prop_files: 18 19It is recommended to look at precise description of a particular board target in ``.props`` 20files in :zephyr_file:`boards/snps/nsim/arc_v/support/` directory to understand 21which options are configured and so will be used on invocation of the simulator. 22 23.. warning:: 24 All nSIM targets are used for demo and testing purposes. They are not meant to 25 represent any real system and so might be renamed, removed or modified at any point. 26 27Programming and Debugging 28************************* 29 30Required Hardware and Software 31============================== 32 33To run single-core Zephyr RTOS applications in simulation on this board, 34either `DesignWare ARC nSIM`_ or `DesignWare ARC Free nSIM`_ is required. 35 36Building & Running Sample Applications 37====================================== 38 39Most board targets support building with both GNU and ARC MWDT toolchains, however 40there might be exceptions from that, especially for newly added targets. You can check supported 41toolchains for the board targets in the corresponding ``.yaml`` file. 42 43I.e. for the ``nsim_arc_v/rmx100`` board we can check :zephyr_file:`boards/snps/nsim/arc_v/nsim_arc_v_rmx100.yaml` 44 45The supported toolchains are listed in ``toolchain:`` array in ``.yaml`` file, where we can find: 46 47* **zephyr** - implies RISC-V GNU toolchain from Zephyr SDK. You can find more information about 48 Zephyr SDK :ref:`here <toolchain_zephyr_sdk>`. 49* **cross-compile** - implies RISC-V GNU cross toolchain, which is not a part of Zephyr SDK. Note that 50 some (especially new) board targets may declare ``cross-compile`` toolchain support without 51 ``zephyr`` toolchain support because corresponding target CPU support hasn't been added to Zephyr 52 SDK yet. You can find more information about its usage here: :ref:`here <other_x_compilers>`. 53* **arcmwdt** - implies proprietary ARC MWDT toolchain. You can find more information about its 54 usage here: :ref:`here <toolchain_designware_arc_mwdt>`. 55 56.. note:: 57 Note that even if both GNU and MWDT toolchain support is declared for the target some tests or 58 samples can be only built with either GNU or MWDT toolchain due to some features limited to a 59 particular toolchain. 60 61Use this configuration to run basic Zephyr applications and kernel tests in 62nSIM, for example, with the :zephyr:code-sample:`synchronization` sample: 63 64.. zephyr-app-commands:: 65 :zephyr-app: samples/synchronization 66 :host-os: unix 67 :board: nsim_arc_v/rmx100 68 :goals: flash 69 70This will build an image with the synchronization sample app, boot it using 71nSIM, and display the following console output: 72 73.. code-block:: console 74 75 *** Booting Zephyr OS build zephyr-v3.2.0-3948-gd351a024dc87 *** 76 thread_a: Hello World from cpu 0 on nsim_arc_v! 77 thread_b: Hello World from cpu 0 on nsim_arc_v! 78 thread_a: Hello World from cpu 0 on nsim_arc_v! 79 thread_b: Hello World from cpu 0 on nsim_arc_v! 80 thread_a: Hello World from cpu 0 on nsim_arc_v! 81 82.. note:: 83 To exit the simulator, use :kbd:`Ctrl+]`, then :kbd:`Ctrl+c` 84 85.. _board_nsim_arc_v_verbose_build: 86 87.. tip:: 88 You can get more details about the building process by running build in verbose mode. It can be 89 done by passing ``-v`` flag to the west: ``west -v build -b nsim_hs samples/synchronization`` 90 91Debugging 92========= 93 94.. _board_nsim_arc_v_debugging_gdb: 95 96Debugging with GDB 97------------------ 98 99.. note:: 100 Debugging on nSIM via GDB is only supported on single-core targets (which use standalone 101 nSIM). 102 103.. note:: 104 The normal ``west debug`` command won't work for debugging applications using nsim boards 105 because both the nSIM simulator and the debugger use the same console for 106 input / output. 107 In case of GDB debugger it's possible to use a separate terminal windows for GDB and nSIM to 108 avoid intermixing their output. 109 110After building your application, open two terminal windows. In terminal one, use nSIM to start a GDB 111server and wait for a remote connection with following command: 112 113.. code-block:: console 114 115 west debugserver --runner arc-nsim 116 117In terminal two, connect to the GDB server using RISC-V GDB. You can find it in Zephyr SDK: 118 119* you should use :file:`riscv64-zephyr-elf-gdb` 120 121This command loads the symbol table from the elf binary file, for example the 122:file:`build/zephyr/zephyr.elf` file: 123 124.. code-block:: console 125 126 riscv64-zephyr-elf-gdb -ex 'target remote localhost:3333' -ex load build/zephyr/zephyr.elf 127 128Now the debug environment has been set up, and it's possible to debug the application with gdb 129commands. 130 131Modifying the configuration 132*************************** 133 134If modification of existing nsim configuration is required or even there's a need in creation of a 135new one it's required to maintain alignment between 136 137* Zephyr OS configuration 138* nSIM configuration 139* GNU & MWDT toolchain compiler options 140 141.. note:: 142 The ``.tcf`` configuration files are not supported by Zephyr directly. There are multiple 143 reasons for that. ``.tcf`` perfectly suits building of bare-metal single-thread application - 144 in that case all the compiler options from ``.tcf`` are passed to the compiler, so all the HW 145 features are used by the application and optimal code is being generated. 146 The situation is completely different when multi-thread feature-rich operation system is 147 considered. Of course it is still possible to build all the code with all the 148 options from ``.tcf`` - but that may be far from optimal solution. For example, such approach 149 require so save & restore full register context for all tasks (and sometimes even for 150 interrupts). And for DSP-enabled or for FPU-enabled systems that leads to dozens of extra 151 registers save and restore even if the most of the user and kernel tasks don't actually use 152 DSP or FPU. Instead we prefer to fine-tune the HW features usage which (with all its pros) 153 require us to maintain them separately from ``.tcf`` configuration. 154 155 156Zephyr OS configuration 157======================= 158 159Zephyr OS configuration is defined via Kconfig and Device tree. These are non RISC-V-specific 160mechanisms which are described in :ref:`board porting guide <board_porting_guide>`. 161 162It is advised to look for ``<board_name>_defconfig``, ``<board_name>.dts`` and 163``<board_name>.yaml`` as an entry point for board target. 164 165nSIM configuration 166================== 167 168nSIM configuration is defined in :ref:`props files <board_nsim_arc_v_prop_files>`. 169Generally they are identical to the values from corresponding ``.tcf`` configuration with few 170exceptions: 171 172* The UART model is added 173* CLINT model is added 174 175GNU & MWDT toolchain compiler options 176===================================== 177 178The hardware-specific compiler options are set in corresponding SoC cmake file. For ``nsim_arc_v`` board 179it is :zephyr_file:`soc/snps/nsim/arc_v/CMakeLists.txt`. 180 181For the GNU toolchain the basic configuration is set via ``-march`` which is defined in generic code 182and based on the selected CPU model via Kconfig. It still can be forcefully set to required value 183on SoC level. 184 185.. note:: 186 The non hardware-specific compiler options like optimizations, library selections, C / C++ 187 language options are still set in Zephyr generic code. It could be observed by 188 :ref:`running build in verbose mode <board_nsim_arc_v_verbose_build>`. 189 190References 191********** 192 193.. target-notes:: 194 195.. _Designware ARC nSIM: https://www.synopsys.com/dw/ipdir.php?ds=sim_nsim 196.. _DesignWare ARC Free nSIM: https://www.synopsys.com/cgi-bin/dwarcnsim/req1.cgi 197.. _HAPS: https://www.synopsys.com/verification/prototyping/haps.html 198.. _ARC MWDT: https://www.synopsys.com/dw/ipdir.php?ds=sw_metaware 199