-
Notifications
You must be signed in to change notification settings - Fork 48
Building nSIM OSCI Linux Virtual Platform
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.
Software:
- libSDL development package needs to be installed
- SystemC 2.3.0
- SCML 2.1.3
- nSIM 2013.06 or later
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 withoutsudo
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 havesudo
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.
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
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
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 too). Command halt
in Linux on Platform will halt the system, but Platform still will be running.
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 usual
SC_SIGNAL_WRITE_CHECK=DISABLE ./sc_top
In a separate terminal window start GDB client and proceed as with normal remote GDB debug session
$ arc-elf32-gdb vmlinux
GNU gdb (ARCompact/ARCv2 ISA elf32 toolchain (GCC arc-4.8-R3-rc2)) 7.5.1
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-unknown-linux-gnu --target=arc-elf32".
For bug reporting instructions, please see:
<http://solvnet.synopsys.com>...
Reading symbols from vmlinux...(no debugging symbols found)...done.
(gdb) target remote localhost:12345
Remote debugging using localhost:12345
0x00000000 in ?? ()
(gdb) load
Loading section .vector, size 0x2000 lma 0x80000000
Loading section .init.ramfs, size 0x15aa84 lma 0x80002000
Loading section .init.text, size 0xf408 lma 0x8015e000
Loading section .init.data, size 0xb4e4 lma 0x8016d420
Loading section .init.arch.info, size 0x54 lma 0x80178904
Loading section .exit.text, size 0x3e4 lma 0x8017a000
Loading section .text, size 0x292a1c lma 0x8017c000
Loading section __ex_table, size 0x82e8 lma 0x8040ea40
Loading section .rodata, size 0x82438 lma 0x80418000
Loading section __ksymtab, size 0x4bc8 lma 0x8049a438
Loading section __ksymtab_gpl, size 0x2700 lma 0x8049f000
Loading section __ksymtab_strings, size 0xf98c lma 0x804a1700
Loading section __param, size 0x460 lma 0x804b108c
Loading section __modver, size 0xb14 lma 0x804b14ec
Loading section .data, size 0x1a760 lma 0x804b2000
Loading section .debug_frame, size 0x4b9ac lma 0x80506000
Loading section .notes, size 0x24 lma 0x805519ac
Start address 0x8015e000, load size 5318108
Transfer rate: 25 KB/sec, 658 bytes/write.
(gdb) b arc_cache_init
Breakpoint 1 at 0x80160b0e
(gdb) c
Continuing.
Breakpoint 1, 0x80160b0e in arc_cache_init ()
(gdb) disassemble
Dump of assembler code for function arc_cache_init:
0x80160b08 <+0>: push_s blink
0x80160b0a <+2>: sub sp,sp,0x100
=> 0x80160b0e <+6>: mov r2,0x100
0x80160b12 <+10>: mov r1,sp
0x80160b16 <+14>: bl.d 0x80182250 <arc_cache_mumbojumbo>
0x80160b1a <+18>: mov_s r0,0
0x80160b1c <+20>: bl 0x80401104 <printk>
0x80160b20 <+24>: ld r2,[0x804d0010]
0x80160b28 <+32>: breq_s r2,0,0x80160b86 <arc_cache_init+126>
0x80160b2a <+34>: ld r3,[0x804d000c]
0x80160b32 <+42>: breq r3,2,0x80160b44 <arc_cache_init+60>
0x80160b36 <+46>: mov r0,0x8048398c
0x80160b3e <+54>: bl 0x80400e90 <panic>
0x80160b42 <+58>: nop_s
0x80160b44 <+60>: ld r3,[0x804d0008]
0x80160b4c <+68>: cmp_s r3,64
0x80160b4e <+70>: bnz 0x80160b36 <arc_cache_init+46>
0x80160b52 <+74>: breq r2,3,0x80160b7c <arc_cache_init+116>
0x80160b56 <+78>: ld r2,[0x804bac40]
0x80160b5e <+86>: tst r2,r2
0x80160b62 <+90>: mov.nz r0,0x804839b4
0x80160b6a <+98>: jlnz 0x80400e90 <panic>
0x80160b72 <+106>: mov_s r0,0x804839d8
0x80160b78 <+112>: bl 0x80401104 <printk>
0x80160b7c <+116>: lr r2,[0x11]
0x80160b80 <+120>: bclr_s r2,r2,0
0x80160b82 <+122>: sr r2,[0x11]
0x80160b86 <+126>: ld r2,[0x804d0024]
0x80160b8e <+134>: breq r2,0,0x80160bda <arc_cache_init+210>
0x80160b92 <+138>: ld r2,[0x804d0020]
0x80160b9a <+146>: brne r2,4,0x80160b36 <arc_cache_init+46>
0x80160b9e <+150>: ld r2,[0x804d001c]
0x80160ba6 <+158>: cmp r2,64
0x80160baa <+162>: bnz 0x80160b36 <arc_cache_init+46>
0x80160bae <+166>: ld r2,[0x804d0018]
0x80160bb6 <+174>: cmp r2,0x8003
0x80160bbe <+182>: mov.hi r0,0x80483a10
0x80160bc6 <+190>: jlhi 0x80400e90 <panic>
0x80160bce <+198>: lr r2,[0x48]
0x80160bd2 <+202>: and r2,r2,-66
0x80160bd6 <+206>: sr r2,[0x48]
0x80160bda <+210>: ld.as blink,[sp,64]
0x80160bde <+214>: j_s.d [blink]
0x80160be0 <+216>: add sp,sp,0x104
End of assembler dump.
(gdb) stepi
0x80160b12 in arc_cache_init ()
(gdb) info registers
r0 0x40 64
r1 0x3 3
r2 0x100 256
r3 0x800 2048
r4 0x0 0
r5 0x0 0
r6 0x5 5
r7 0x0 0
r8 0x1e4 484
r9 0x0 0
r10 0x5 5
r11 0x2 2
r12 0x0 0
r13 0x804b3ff0 2152415216
r14 0x0 0
r15 0x0 0
r16 0x0 0
r17 0x0 0
r18 0x0 0
r19 0x0 0
r20 0x0 0
r21 0x0 0
r22 0x0 0
r23 0x0 0
r24 0x0 0
r25 0x804ba2b0 2152440496
gp 0x1b 0x1b
fp 0x0 0x0
sp 0x804b3ce0 0x804b3ce0 <init_thread_union+7392>
ilink1 0x0 0x0
ilink2 0x0 0x0
blink 0x8015ff20 0x8015ff20 <setup_processor+40>
r32 0x0 0
r33 0x0 0
r34 0x0 0
r35 0x0 0
r36 0x0 0
r37 0x0 0
r38 0x0 0
r39 0x0 0
r40 0x0 0
r41 0x0 0
r42 0x0 0
r43 0x0 0
r44 0x0 0
r45 0x0 0
r46 0x0 0
r47 0x0 0
r48 0x0 0
r49 0x0 0
r50 0x0 0
r51 0x0 0
r52 0x0 0
r53 0x0 0
r54 0x0 0
r55 0x0 0
r56 0x0 0
r57 0x0 0
r58 0x0 0
r59 0x0 0
lp_count 0x0 0
pcl 0x80160b10 0x80160b10 <arc_cache_init+8>
pc 0x80160b12 0x80160b12 <arc_cache_init+10>
(gdb) c
Continuing.