Skip to content

Building nSIM OSCI Linux Virtual Platform

Alexey Brodkin edited this page Dec 13, 2017 · 26 revisions

Linux Virtual Platform is an internal platform to run Linux on ARC simulator. Please use ARC HS VDK for similiar functionality in commercial product.

Abstract

This document provides a step-by-step guide on building nSIM OSCI Linux Virtual Platform. Platform allows to run Linux kernel for ARC processors on the nSIM simulator.

Prerequisites

Software:

Environment:

  • In its default configuration platform creates xterm windows, so it requires to be started from GUI. If you from terminal interface, then build platform in headless mode.
  • Ethernet implementation
  • Ethernet implementation requires networking capabilities to be set for Platform binary. Setting those capabilities requires sudo access on host system. You can use Platform without sudo but without Ethernet. Capabilities can be set only on local file system, they can not be set on NFS. For full experience you need to have sudo access and run platform from local file system.

Following document refers to $NSIM_HOME as path to nSIM installation. It is recommended to set this as an environment variable.

Building SystemC and SCML libraries

Note. You need to create directories where you will install SystemC and SCML before building them, which is why we use mkdir in the instructions below.

Build and install SystemC:

$ tar xzf systemc-2.3.2.tar.gz
$ mkdir systemc-2.3.2/BUILD
$ pushd systemc-2.3.2/BUILD
$ mkdir -p /path/to/systemc-install
$ ../configure --prefix=/path/to/systemc-install
$ make
$ make install
$ popd

The same for SCML (use make install, make will not work):

$ tar xzf scml-2.4.1-20170405.tgz
$ mkdir scml-2.4.1/BUILD
$ pushd scml-2.4.1/BUILD
$ mkdir -p /path/to/scml-install
$ ../configure --prefix=/path/to/scml-install \
  --with-systemc=/path/to/systemc-install CPPFLAGS='-fpermissive'
$ make install
$ popd

Please note that make install command should be used for scml building and installation at once instead of separate execution of make and make install.

On attempt to execute make after configuration this kind of error messages may appear:

In file included from ../../../src/scml2_testing/memory_element_value_proxy.cc:12:0:
../../../src/scml2_testing/../scml2_testing/test_memory_element.h:13:19: fatal error: scml2.h: No such file or directory
 #include <scml2.h>
                   ^
compilation terminated.
In file included from ../../../src/scml2_testing/initiator_socket_proxy_base.cc:11:0:
../../../src/scml2_testing/../scml2_testing/initiator_socket_proxy_base.h:14:19: fatal error: scml2.h: No such file or directory
 #include <scml2.h>

Now with SCML 2.4.1 it is possible to run make and make install separately which was not the case for say v2.3.3.

Configure nSIM with your newly built libraries. In $NSIM_HOME/systemc/scripts/config.sh set SYSTEMC_HOME and SCML_HOME to the installation paths of respective libraries. Set TLM_HOME to the same value as SYSTEMC_HOME. Set MW_HOME to empty string, set NSIM_HOME to the nSIM installation path.

Source $NSIM_HOME/systemc/scripts/setup.sh. This setup environment for the Platform.

$ . $NSIM_HOME/systemc/scripts/setup.sh

Building the Platform

Change dir to Platform directory.

Build platform for ARC 700:

$ make CPU=arc700

Or if you want to run Linux without UART and PGU then build Platform in "headless" mode:

$ make CPU=arc700 HEADLESS_MODE=1

If you are going to use Ethernet, then set capabilities:

$ sudo setcap cap_net_admin,cap_net_bind_service=pe sc_top

Same options apply for ARC HS model:

$ make CPU=archs

Note that archs is selected by default, so you can build Platform for ARC HS using:

$ make

With HS you can also build dual-core model:

$ make CPU=archs NUM_CORES=2

Note that current platform implementation doesn't support more than two cores for ARC HS systems, and more than one core for ARC 700 systems.

Running the Platform

Build Linux image using that guide.
Note. If you use kernel version < 4.7 the following patch should be applied to the kernel before build. Add this patch to your $(buildroot)/linux/ directory and it will be applied before linux being built.To do this you can just execute the following command in your linux source directory:

$ git format-patch -1 86651650d16a359e4142c6a8b0467c87e48c4c94 -o $(buildroot)/linux/

Copy kernel image to Platform directory or create a respective symlink to image. Alternatively in Platform directory edit properties.ini file to point to the valid kernel image location.

Before running the Platform make sure that xterm is installed on your host.

Generate a pair of PTY devices using socat:

$ socat -d -d pty pty
2016/09/26 20:14:24 socat[27753] N PTY is /dev/pts/33
2016/09/26 20:14:24 socat[27753] N PTY is /dev/pts/34

Then connect to one of PTYs with minicom as a regular COM port:

$ minicom -D /dev/pts/33

Pass the second PTY to sc_top binary. Environment variable SC_SIGNAL_WRITE_CHECK must be set to DISABLE to run Platform. Run:

$ SC_SIGNAL_WRITE_CHECK=DISABLE ./sc_top -s /dev/pts/34

If you want to start Platform with an Xwindow pass -l to sc_top binary. Platform will open an Xwindow with Linux terminal in it.

$ SC_SIGNAL_WRITE_CHECK=DISABLE ./sc_top -l -s /dev/pts/34

If Ethernet is configured properly, than on your host system will be created TAP device with IP address 192.168.218.1, Linux on Platform will be available at IP 192.168.218.2. If you've built "headless" system then Ethernet will the only way to communicate with it (use telnet 192.168.218.2 to access the system).

To close system press Ctrl+C in the terminal which runs Platform (kill -SIGINT should work too). Command halt in Linux on Platform will halt the system, but Platform still will be running.

Debugging bare-metal applications via GDB on the Platform

Make sure GDB server is enabled in the platform configuration file properties.ini and port number on which GDB server will accept connections is specified.

[bool]
top.nsim_1./model_config/halt_on_reset: true
top.nsim_1./debugger_config/gdb_server/enabled: true

[uint]
top.nsim_1./debugger_config/gdb_server/port: 12345

Now start the platform as described in previous paragraph:

$ SC_SIGNAL_WRITE_CHECK=DISABLE ./sc_top -s /dev/pts/34

In a separate terminal window start GDB client and proceed as with normal remote GDB debug session

$ arc-elf32-gdb -q vmlinux
Reading symbols from vmlinux...(no debugging symbols found)...done.
(gdb) target remote localhost:12345
Remote debugging using localhost:12345
0x00000000 in ?? ()
(gdb) load
(gdb) b arc_cache_init
Breakpoint 1 at 0x80160b0e
(gdb) c
Continuing.
Breakpoint 1, 0x80160b0e in arc_cache_init ()
(gdb) c

Appendix: Kernel for nSIM Virtual Platform in headless mode

Default configuration for nSIM Virtual Platform contains drivers for Pixel Graphics Unit, PS/2-like input and UART16550 terminal. None of drivers will work with Platform built in headless mode - they will attempt to access memory at unmapped addresses. In kernel configuration disable INPUT_KEYBOARD, INPUT_MOUSE, SERIAL_8250 and frame buffer device FB.

Clone this wiki locally