Skip to content

Commit 57af793

Browse files
Nikolay Agishevnashif
authored andcommitted
ARC: nSIM: Add RMX100 platform
This PR adds support for new Synopsys nSIM RMX100 platform. New platform based on RISC-V ISA instead of classic ARC. Signed-off-by: Nikolay Agishev <[email protected]>
1 parent ea7a876 commit 57af793

File tree

21 files changed

+438
-1
lines changed

21 files changed

+438
-1
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright (c) 2024 Synopsys, Inc.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
if BOARD_NSIM_ARC_V_RMX100
5+
6+
config SYS_CLOCK_TICKS_PER_SEC
7+
default 1000
8+
9+
config SYS_CLOCK_HW_CYCLES_PER_SEC
10+
default 5000000
11+
12+
endif # BOARD_NSIM_ARC_V_RMX100
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2024 Synopsys, Inc.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config BOARD_NSIM_ARC_V
5+
select SOC_RMX100 if BOARD_NSIM_ARC_V_RMX100

boards/snps/nsim/arc_v/board.cmake

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
set(SUPPORTED_EMU_PLATFORMS nsim)
4+
5+
string(SUBSTRING "${BOARD_QUALIFIERS}" 1 -1 NSIM_BASE_FILENAME)
6+
string(REPLACE "/" "_" NSIM_BASE_FILENAME "${NSIM_BASE_FILENAME}")
7+
8+
board_set_flasher_ifnset(arc-nsim)
9+
board_set_debugger_ifnset(arc-nsim)
10+
11+
set(NSIM_PROPS "${NSIM_BASE_FILENAME}.props")
12+
board_runner_args(arc-nsim "--props=${NSIM_PROPS}")
13+
14+
board_finalize_runner_args(arc-nsim)
15+
include(${ZEPHYR_BASE}/boards/common/mdb-nsim.board.cmake)
16+
include(${ZEPHYR_BASE}/boards/common/mdb-hw.board.cmake)

boards/snps/nsim/arc_v/board.yml

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

boards/snps/nsim/arc_v/rmx100.dtsi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include "rmx1xx.dtsi"
2+
3+
/ {
4+
ddr0: memory@80000000 {
5+
device_type = "memory";
6+
reg = <0x80000000 0x10000000>; /* 256 MB */
7+
};
8+
};

boards/snps/nsim/arc_v/rmx1xx.dtsi

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/ {
2+
#address-cells = <1>;
3+
#size-cells = <1>;
4+
5+
cpus {
6+
timebase-frequency = <5000000>;
7+
#address-cells = <1>;
8+
#size-cells = <0>;
9+
10+
cpu0: cpu@0 {
11+
compatible = "snps,av5rmx", "riscv";
12+
device_type = "cpu";
13+
reg = <0>;
14+
clock-frequency = <5000000>;
15+
riscv,isa = "rv32imac_zicsr_zifencei";
16+
17+
cpu0_intc: interrupt-controller {
18+
compatible = "riscv,cpu-intc";
19+
interrupt-controller;
20+
#address-cells = <0>;
21+
#interrupt-cells = <1>;
22+
};
23+
};
24+
};
25+
26+
soc {
27+
compatible = "simple-bus";
28+
ranges;
29+
interrupt-parent = <&clint>;
30+
#address-cells = <1>;
31+
#size-cells = <1>;
32+
33+
clint: clint@2000000 {
34+
compatible = "sifive,clint0";
35+
reg = <0x2000000 0x1000>;
36+
interrupts-extended = <&cpu0_intc 3 &cpu0_intc 7>;
37+
interrupt-names = "soft0", "timer0";
38+
};
39+
40+
uart0: serial@10000000{
41+
compatible = "ns16550", "snps,dw-apb-uart";
42+
reg = <0x10000000 0x400>;
43+
reg-shift = <2>;
44+
45+
/* AIA interrupt controller is not currently implemented,
46+
* so connect UART interrupt to 17th line as a stub to
47+
* make build system and test framework happy.
48+
*/
49+
interrupt-parent = <&cpu0_intc>;
50+
interrupts = <17>;
51+
clock-frequency = <50000000>;
52+
status = "disabled";
53+
};
54+
};
55+
};

0 commit comments

Comments
 (0)