-
Notifications
You must be signed in to change notification settings - Fork 13
How to quickly get started with Linux for ARC cores with prebuilt components
A minimal Designware ARC Linux system is comprised of the following components:
-
Linux kernel built for a specific core (ARC770D, HS38 or HS48) and the corresponding supported board/platform
-
DesignWare ARC FPGA Software Development Platforms (SDP): AXS101 (ARC 770D based), AXS103 (HS38x based), see https://www.synopsys.com/dw/ipdir.php?ds=arc-software-development-platform
-
DesignWare HS Development Kit (HSDK), see https://www.synopsys.com/dw/ipdir.php?ds=arc-hs-development-kit
-
-
rootfs (root file system) containing system libraries (libc.so, libm.so ...), system programs (init, shell ...) and utilities (mount, ls ...) which are executed after bootup
-
Host GNU toolchain to generate one/both of the above from the corresponding sources: essentially to cross-compile anything to run for ARC on typical x86 host
Typically root file system is hosted on a persistent storage media such as SD Card, HDD/SSD or network share. However to reduce external dependencies, especially in simulation environments, and to quickly get started, we will build ARC Linux with an initramfs (CONFIG_INITRAMFS_SOURCE
) where the root file system is embedded within kernel image at build time.
Embedded systems generally use a bootloader which we will avoid here for the sake of simplicity (although Das U-Boot is well supported for both ARC cores and is used on ARC development boards).
As the title suggests this document covers manual build using more of prebuilt components. There're a richer build environments based on Buildroot, OpenEmbedded or OpenWrt projects which could be used to build a customized ARC Linux system from scratch. Refer to https://github.com/foss-for-synopsys-dwc-arc-processors/linux/wiki/How-to-build-filesystem-and-kernel-images-for-ARC-cores-with-Buildroot as one of examples.
This document assumes a Linux host (it could be a native Linux server or even a Virtual Machine such as VirtualBox/VMware Player running a Linux installation).
We will use a prebuilt Busybox based rootfs which can be downloaded from this organization's github portal. HS38 and ARC700 require different rootfs's as they are based on different Instructions Set Architecture (ISA) versions: ARCv2 and ARCompact respectively.
For Linux for ARC HS38:
$ wget --no-check-certificate https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_initramfs_archives/master/arc_initramfs_hs_1612-gnu-2016.09.tgz
$ tar -jxvf arc_initramfs_hs_1612-gnu-2016.09.tgz # generates directory arc_initramfs_hs
For Linux for ARC 770D:
$ wget --no-check-certificate https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_initramfs_archives/master/ARC700/arc_initramfs_arc700_1612-gnu-2016.09.tgz
$ tar -jxvf arc_initramfs_arc700_1612-gnu-2016.09.tgz # generates directory arc_initramfs
Building Linux for HS38 vs. ARC700 core requires a differently configured/built GNU toolchain [footnote]. Since the gcc driver is named the same arc-linux-gcc
for both, please ensure you use the right variant of the toolchain.
Prebuilt toolchains can be downloaded from our GitHub toolchain releases page
-
For building your own toolchain refer to https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/blob/arc-2018.09-release/README.md
-
For Synopsys internal users, Farm Machines host these tools as modules
$ source /global/etc/sh.bashrc $ module -t avail arc_gnu 2>&1 | tail -n 5 arc_gnu/2018.09-linux-arc700 arc_gnu/2018.09-linux-arc700-eb arc_gnu/2018.09-linux-archs arc_gnu/2018.09-linux-archs-eb arc_gnu/2018.09-linux-glibc-archs
$ export PATH=/abs-path-to-gnu-tools/bin:$PATH
Downloading/building kernel might require some additional host packages (git
, make
, ncurses-devel
etc) to be installed on host machine. This might vary for your host Linux distribution (RedHat or Debian etc)
ARC Linux is supported in upstream kernel repository maintained by Linus Torvalds (https://www.kernel.org/). As of August 2015 (v4.2 release), supports both ARC700 as well as ARC HS38x cores.
This is a preferred way for subsequent experiments or even development of the kernel because:
- Entire history of changes is available so it's possible to check which change was done, when and what was the reason for it.
- Easy to track your own changes and compare to what was there before
- Easy to apply random changes from other developers (typically back-ports with fixes and improvements) as well as switch to newer version of entire source tree
$ git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
$ cd linux
Download archive with the latest release from https://www.kernel.org
A quicker way is to download the source tarball (which lacks any git revision history) with a particular Linux kernel release:
$ wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.20.3.tar.xz
$ tar -Jxf linux-4.20.3.tar.xz ; cd linux-4.20.3
Note that the initramfs extracted in step Prebuilt Busybox-based root file sysystem and kernel source need to be at same directory hierarchy.
Before compiling the kernel it's required to configure it for a particular board. For each supported platform, ARC Linux contains a "defconfig" which configures the kernel appropriately: preselects the right ISA, Processor, Device Tree, relevant device drivers etc.
- nSIM (HS38):
$ make ARCH=arc nsim_hs_defconfig
- nSIM (ARC770):
$ make ARCH=arc nsim_700_defconfig
- AXS103 SDP:
$ make ARCH=arc axs103_smp_defconfig
- AXS101 SDP:
$ make ARCH=arc axs101_defconfig
- HAPS/ZeBu for HS38:
$ make ARCH=arc zebu_hs_defconfig
- HAPS/ZeBu for HS38x2:
$ make ARCH=arc zebu_hs_smp_defconfig
Note that starting 4.10 kernel onwards, the HAPS/Zebu defconfigs have been renamed to haps_hs_
* instead of zebu_hs_
*
Here we're building kernel image for standalone nSIM (nsim_hs_defconfig
)
$ make ARCH=arc CROSS_COMPILE=arc-linux-
The kernel binary vmlinux
is generated.
-
On ARC HS38 model:
- Using .tcf file from nSIM distribution
$ nsimdrv -tcf=$NSIM_HOME/etc/tcf/templates/hs38_full.tcf -prop=nsim_mem-dev=uart0,base=0xc0fc1000,irq=24 vmlinux
- Specifying manually full set of toggles
$ nsimdrv -prop=nsim_isa_family=av2hs -prop=nsim_isa_core=1 -prop=chipid=0xffff -prop=nsim_isa_atomic_option=1 -prop=nsim_isa_ll64_option=1 -prop=nsim_mmu=4 -prop=mmu_pagesize=8192 -prop=mmu_super_pagesize=2097152 -prop=mmu_stlb_entries=16 -prop=mmu_ntlb_ways=4 -prop=mmu_ntlb_sets=128 -prop=icache=32768,64,4,0 -prop=dcache=16384,64,2,0 -prop=nsim_isa_shift_option=2 -prop=nsim_isa_swap_option=1 -prop=nsim_isa_bitscan_option=1 -prop=nsim_isa_sat=1 -prop=nsim_isa_div_rem_option=1 -prop=nsim_isa_mpy_option=9 -prop=nsim_isa_enable_timer_0=1 -prop=nsim_isa_enable_timer_1=1 -prop=nsim_isa_number_of_interrupts=32 -prop=nsim_isa_number_of_external_interrupts=32 -prop=isa_counters=1 -prop=nsim_isa_pct_counters=8 -prop=nsim_isa_pct_size=48 -prop=nsim_isa_pct_interrupt=1 -prop=nsim_mem-dev=uart0,base=0xc0fc1000,irq=24 -prop=nsim_isa_aps_feature=1 -prop=nsim_isa_num_actionpoints=4 vmlinux
- Using .tcf file from nSIM distribution
-
On ARC 770D model:
- Using .tcf file from nSIM distribution
$ nsimdrv -tcf=$NSIM_HOME/etc/tcf/templates/arc770d.tcf -prop=nsim_mem-dev=uart0,base=0xf0000000,kind=dwuart,irq=24 -on=nsim_trace -prop=nsim_trace-output=trace.txt -prop=nsim_isa_atomic_option=1 -prop=nsim_isa_enable_timer_0=1 -prop=nsim_isa_enable_timer_1=1 -prop=icache=32768,64,2,0 -prop=dcache=32768,64,4,0 vmlinux
- Specifying manually full set of toggles
$ nsimdrv -prop=nsim_isa_family=a700 -prop=nsim_isa_atomic_option=1 -prop=nsim_mmu=3 -prop=icache=32768,64,2,0 -prop=dcache=32768,64,4,0 -prop=nsim_isa_dpfp=none -prop=nsim_isa_shift_option=2 -prop=nsim_isa_swap_option=1 -prop=nsim_isa_bitscan_option=1 -prop=nsim_isa_sat=1 -prop=nsim_isa_mpy32=1 -prop=nsim_isa_enable_timer_0=1 -prop=nsim_isa_enable_timer_1=1 -prop=nsim_mem-dev=uart0,kind=dwuart,base=0xf0000000,irq=24 -prop=isa_counters=1 -prop=nsim_isa_pct_counters=8 -prop=nsim_isa_pct_size=48 vmlinux
- Using .tcf file from nSIM distribution
-
On SNPS Farm Machines, default versions of make or git might not work, work-around that by loading corresponding
module
:module load git module load gmake/3.81
-
If you've got an error
Makefile: *** source directory cannot contain spaces or colons. Stop
, you should check the paths togmake
binary. You can obtain correct path by typingmodule load gmake/4.3
. -
If you've got an error
flex: -Cf/-CF and %option yylineno are incompatible
, you should remove all occurrences of/usr/local/bin
,/usr/local/sbin
and~/.local/bin
from$PATH
. -
If you have no output after loading vmlinux in nSim using .tcf, please make sure that hardware options are also present in nSim configuration section in .tcf.