boards/snps/nsim/arc_v/doc/index.html · boards/snps/nsim/arc_v/doc/index.rst 공식 원문 ↗

Zephyr 3.7.0 · Boards · Synopsys · RISC-V nSIM

DesignWare RISC-V nSIM과 HAPS FPGA Boards

Synopsys RMX100 RISC-V core를 nSIM에서 실행하고 GDB로 debug합니다.

Official pathboards/snps/nsim/arc_v/doc/index.html
Source fileboards/snps/nsim/arc_v/doc/index.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

본문 기준: Zephyr 3.7.0 LTS3 · 이후 유지보수 패치는 별도입니다.

Part 1

요약·해설

RISC-V GNU/MWDT 선택, single-core GDB workflow, .props의 UART·CLINT model과 -march 설정을 다룹니다.

Core

RMX100

ISA

riscv32

Console

ns16550

GNU option

-march

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 AFEC710E6C07284F67588D5B1E0BA407F0CFBA600256D09C87AC9C307B049CE6
.. _nsim_arc_v:

DesignWare RISC-V nSIM and HAPS FPGA boards
###########################################

Overview
********

This platform can be used to run Zephyr RTOS on the widest possible range of Synopsys RISC-V processors in
simulation with `Designware ARC nSIM`_ or run same images on FPGA prototyping platform `HAPS`_. The
platform includes the following features:

* RISC-V processor core, which implements riscv32 ISA
* Virtual serial console (a standard ``ns16550`` UART model)

Supported board targets for that platform are listed below:

* ``nsim_arc_v/rmx100`` - Synopsys RISC-V RMX100 core

.. _board_nsim_arc_v_prop_files:

It is recommended to look at precise description of a particular board target in ``.props``
files in :zephyr_file:`boards/snps/nsim_arc_v/support/` directory to understand
which options are configured and so will be used on invocation of the simulator.

.. warning::
   All nSIM targets are used for demo and testing purposes. They are not meant to
   represent any real system and so might be renamed, removed or modified at any point.

Programming and Debugging
*************************

Required Hardware and Software
==============================

To run single-core Zephyr RTOS applications in simulation on this board,
either `DesignWare ARC nSIM`_ or `DesignWare ARC Free nSIM`_ is required.

Building & Running Sample Applications
======================================

Most board targets support building with both GNU and ARC MWDT toolchains, however
there might be exceptions from that, especially for newly added targets. You can check supported
toolchains for the board targets in the corresponding ``.yaml`` file.

I.e. for the ``nsim_arc_v/rmx100`` board we can check :zephyr_file:`boards/snps/nsim_arc_v/nsim_arc_v_rmx100.yaml`

The supported toolchains are listed in ``toolchain:`` array in ``.yaml`` file, where we can find:

* **zephyr** - implies RISC-V GNU toolchain from Zephyr SDK. You can find more information about
  Zephyr SDK :ref:`here <toolchain_zephyr_sdk>`.
* **cross-compile** - implies RISC-V GNU cross toolchain, which is not a part of Zephyr SDK. Note that
  some (especially new) board targets may declare ``cross-compile`` toolchain support without
  ``zephyr`` toolchain support because corresponding target CPU support hasn't been added to Zephyr
  SDK yet. You can find more information about its usage here: :ref:`here <other_x_compilers>`.
* **arcmwdt** - implies proprietary ARC MWDT toolchain. You can find more information about its
  usage here: :ref:`here <toolchain_designware_arc_mwdt>`.

.. note::
   Note that even if both GNU and MWDT toolchain support is declared for the target some tests or
   samples can be only built with either GNU or MWDT toolchain due to some features limited to a
   particular toolchain.

Use this configuration to run basic Zephyr applications and kernel tests in
nSIM, for example, with the :zephyr:code-sample:`synchronization` sample:

.. zephyr-app-commands::
   :zephyr-app: samples/synchronization
   :host-os: unix
   :board: nsim_arc_v/rmx100
   :goals: flash

This will build an image with the synchronization sample app, boot it using
nSIM, and display the following console output:

.. code-block:: console

      *** Booting Zephyr OS build zephyr-v3.2.0-3948-gd351a024dc87 ***
      thread_a: Hello World from cpu 0 on nsim_arc_v!
      thread_b: Hello World from cpu 0 on nsim_arc_v!
      thread_a: Hello World from cpu 0 on nsim_arc_v!
      thread_b: Hello World from cpu 0 on nsim_arc_v!
      thread_a: Hello World from cpu 0 on nsim_arc_v!

.. note::
   To exit the simulator, use :kbd:`Ctrl+]`, then :kbd:`Ctrl+c`

.. _board_nsim_arc_v_verbose_build:

.. tip::
   You can get more details about the building process by running build in verbose mode. It can be
   done by passing ``-v`` flag to the west: ``west -v build -b nsim_hs samples/synchronization``

Debugging
=========

.. _board_nsim_arc_v_debugging_gdb:

Debugging with GDB
------------------

.. note::
   Debugging on nSIM via GDB is only supported on single-core targets (which use standalone
   nSIM).

.. note::
   The normal ``west debug`` command won't work for debugging applications using nsim boards
   because both the nSIM simulator and the debugger use the same console for
   input / output.
   In case of GDB debugger it's possible to use a separate terminal windows for GDB and nSIM to
   avoid intermixing their output.

After building your application, open two terminal windows. In terminal one, use nSIM to start a GDB
server and wait for a remote connection with following command:

.. code-block:: console

   west debugserver --runner arc-nsim

In terminal two, connect to the GDB server using RISC-V GDB. You can find it in Zephyr SDK:

* you should use :file:`riscv64-zephyr-elf-gdb`

This command loads the symbol table from the elf binary file, for example the
:file:`build/zephyr/zephyr.elf` file:

.. code-block:: console

   riscv64-zephyr-elf-gdb  -ex 'target remote localhost:3333' -ex load build/zephyr/zephyr.elf

Now the debug environment has been set up, and it's possible to debug the application with gdb
commands.

Modifying the configuration
***************************

If modification of existing nsim configuration is required or even there's a need in creation of a
new one it's required to maintain alignment between

* Zephyr OS configuration
* nSIM configuration
* GNU & MWDT toolchain compiler options

.. note::
   The ``.tcf`` configuration files are not supported by Zephyr directly. There are multiple
   reasons for that. ``.tcf`` perfectly suits building of bare-metal single-thread application -
   in that case all the compiler options from ``.tcf`` are passed to the compiler, so all the HW
   features are used by the application and optimal code is being generated.
   The situation is completely different when multi-thread feature-rich operation system is
   considered. Of course it is still possible to build all the code with all the
   options from ``.tcf`` - but that may be far from optimal solution. For example, such approach
   require so save & restore full register context for all tasks (and sometimes even for
   interrupts). And for DSP-enabled or for FPU-enabled systems that leads to dozens of extra
   registers save and restore even if the most of the user and kernel tasks don't actually use
   DSP or FPU. Instead we prefer to fine-tune the HW features usage which (with all its pros)
   require us to maintain them separately from ``.tcf`` configuration.


Zephyr OS configuration
=======================

Zephyr OS configuration is defined via Kconfig and Device tree. These are non RISC-V-specific
mechanisms which are described in :ref:`board porting guide <board_porting_guide>`.

It is advised to look for ``<board_name>_defconfig``, ``<board_name>.dts`` and
``<board_name>.yaml`` as an entry point for board target.

nSIM configuration
==================

nSIM configuration is defined in :ref:`props files <board_nsim_arc_v_prop_files>`.
Generally they are identical to the values from corresponding ``.tcf`` configuration with few
exceptions:

* The UART model is added
* CLINT model is added

GNU & MWDT toolchain compiler options
=====================================

The hardware-specific compiler options are set in corresponding SoC cmake file. For ``nsim_arc_v`` board
it is :zephyr_file:`soc/snps/nsim/arc_v/CMakeLists.txt`.

For the GNU toolchain the basic configuration is set via ``-march`` which is defined in generic code
and based on the selected CPU model via Kconfig. It still can be forcefully set to required value
on SoC level.

.. note::
   The non hardware-specific compiler options like optimizations, library selections, C / C++
   language options are still set in Zephyr generic code. It could be observed by
   :ref:`running build in verbose mode <board_nsim_arc_v_verbose_build>`.

References
**********

.. _Designware ARC nSIM: https://www.synopsys.com/dw/ipdir.php?ds=sim_nsim
.. _DesignWare ARC Free nSIM: https://www.synopsys.com/cgi-bin/dwarcnsim/req1.cgi
.. _HAPS: https://www.synopsys.com/verification/prototyping/haps.html
.. _ARC MWDT: https://www.synopsys.com/dw/ipdir.php?ds=sw_metaware

Part 3

한국어 전문 번역

개요

이 platform은 Synopsys RISC-V processor를 DesignWare ARC nSIM에서 simulation하거나 같은 image를 HAPS FPGA prototyping platform에서 실행합니다. 32-bit riscv32 ISA core와 표준 ns16550 UART model의 virtual serial console을 제공합니다. 지원 target은 Synopsys RISC-V RMX100 core인 nsim_arc_v/rmx100입니다.

정확한 option은 boards/snps/nsim_arc_v/support/의 target별 .props에서 확인합니다. 모든 nSIM target은 demo·test 목적이며 실제 system을 나타내지 않으므로 언제든 이름이 바뀌거나 삭제·수정될 수 있습니다.

Programming and debugging

필요 software

Single-core Zephyr application simulation에는 DesignWare ARC nSIM 또는 Free nSIM이 필요합니다.

Toolchain 선택

Target의 .yaml, 예를 들어 nsim_arc_v_rmx100.yaml의 toolchain 배열을 확인합니다. zephyr는 Zephyr SDK의 RISC-V GNU toolchain, cross-compile은 SDK 밖의 RISC-V GNU cross toolchain, arcmwdt는 proprietary ARC MWDT입니다. 두 toolchain이 선언되어도 일부 test·sample은 특정 기능 때문에 한쪽에서만 build될 수 있습니다.

Build와 실행

west build -b nsim_arc_v/rmx100 samples/synchronization
west flash
*** Booting Zephyr OS build zephyr-v3.2.0-3948-gd351a024dc87 ***
thread_a: Hello World from cpu 0 on nsim_arc_v!
thread_b: Hello World from cpu 0 on nsim_arc_v!
thread_a: Hello World from cpu 0 on nsim_arc_v!
thread_b: Hello World from cpu 0 on nsim_arc_v!
thread_a: Hello World from cpu 0 on nsim_arc_v!

Simulator 종료는 Ctrl+] 뒤 Ctrl+c입니다. west -v build -b nsim_hs samples/synchronization처럼 -v를 주면 build 과정을 더 자세히 볼 수 있습니다.

GDB debugging

nSIM의 GDB debugging은 standalone nSIM을 사용하는 single-core target만 지원합니다. Simulator와 debugger가 같은 console을 쓰므로 일반 west debug 대신 terminal 두 개를 사용합니다.

west debugserver --runner arc-nsim

두 번째 terminal에서 Zephyr SDK의 riscv64-zephyr-elf-gdb로 ELF symbol을 읽고 server에 연결합니다.

riscv64-zephyr-elf-gdb -ex 'target remote localhost:3333' -ex load build/zephyr/zephyr.elf

Configuration 수정

Zephyr OS configuration, nSIM configuration, GNU/MWDT compiler option을 서로 정렬해야 합니다. .tcf를 Zephyr가 직접 쓰지 않는 이유는 bare-metal에서 유리한 전체 hardware option이 multi-thread OS에서는 사용하지 않는 DSP/FPU register까지 모든 task와 interrupt에서 save·restore하게 할 수 있기 때문입니다. Zephyr는 feature 사용을 세밀하게 조정하고 별도 configuration으로 관리합니다.

Zephyr OS configuration

Kconfig와 Devicetree를 사용하며 <board_name>_defconfig, <board_name>.dts, <board_name>.yaml이 시작점입니다.

nSIM configuration

.props는 대응하는 .tcf 값과 대체로 같지만 UART model과 CLINT model이 추가됩니다.

GNU와 MWDT compiler option

soc/snps/nsim/arc_v/CMakeLists.txt가 hardware option을 설정합니다. GNU 기본 설정은 Kconfig CPU model에 따른 -march이며 SoC level에서 강제할 수 있습니다. Optimization, library, C/C++ language option은 Zephyr 공통 code가 설정하고 verbose build에서 확인할 수 있습니다.

참고 자료

Source

출처

영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.