Skip to content

Building nSIM OSCI Linux Virtual Platform

Alexey Brodkin edited this page Apr 14, 2014 · 26 revisions

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.0.tgz
mkdir systemc-2.3.0/BUILD
pushd systemc-2.3.0/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.1.3.tgz
mkdir scml-2.1.3/BUILD
pushd scml-2.1.3/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>

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. This is the location of the SystemC Linux VP example - typically in $NSIM_HOME/systemc/examples/Linux_VP

Update reference to TLM directory in Makefile, because for some reasons TLM which goes with SystemC uses another directory structure than the one which is shipped separatly:

sed -i Makefile -e 's|\$(TLM_HOME)/include/tlm$|\$(TLM_HOME)/include/tlm_core|'

If you are going to use Ethernet, then you'll have to set capabilities. The side effect is that application with set capabilities won't search for shared libraries in LD_LIBRARY_PATH. To overcome this you need to either copy nSIM and SystemC shared libraries to system library directories (not recommended) or set rpath during build time. This guide uses second approach.

sed -i.bak Makefile -e 's|LINK_OPTION=.*|LINK_OPTION := -Wl,-rpath=$(NSIM_HOME)/lib -Wl,-rpath=$(SYSTEMC_HOME)/lib-linux64|'

Build platform:

make EXTRA_CXXFLAGS=-fpermissive

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

make EXTRA_CXXFLAGS="-fpermissive -DHEADLESS_MODE"

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

sudo setcap cap_net_admin,cap_net_bind_service=pe sc_top

Running the Platform

Build Linux image using that guide. 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.

Environment variable SC_SIGNAL_WRITE_CHECK must be set to DISABLE to run Platform. Run:

SC_SIGNAL_WRITE_CHECK=DISABLE ./sc_top

If you've built normal Platform it will open an Xwindow with Linux terminal in it. 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 to). Command halt in Linux on Platform will halt the system, but Platform still will be running.

Clone this wiki locally