Skip to content

How to quickly get started with Linux for ARC cores with prebuilt components

Vineet Gupta edited this page Jan 12, 2017 · 23 revisions

(A) Introduction

A minimal Designware ARC Linux system is comprised of the following components:

  1. Linux kernel built for a specific core (ARC770D or HS38x) and the corresponding supported board/platform
  • nSIM OSCI Linux Virtual Platform (VP) for both ARC770D and HS38
  • DesignWare ARC FPGA Software Development Platforms (SDP): AXS101 (ARC 770D based), AXS103 (HS38x based)
  1. rootfs (root file system) containing system libraries (libc.so, libm.so ...), system programs (init, shell ...) and utilities (mount, ls ...) which are executed after bootup
  2. 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 or Disk 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 rootfs 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 u-boot is well supported for both ARC cores).

As the title suggests this document covers manual build using more of prebuilt components. There's a richer build environment based on Buildroot project which you can use 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

(B) Prerequisites

(1). 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)

(2). 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

(3). ARC GNU toolchain: Building Linux for HS38 vs. ARC700 core requires a differently configured/built GNU toolchain [footnote]. Since the gcc driver is named the same for both (arc-linux-uclibc-gcc), please ensure you use the right variant of toolchain.

$ csh
$ module avail arc_gnu
--------------- /global/etc/modulefiles/freeware/opensource -------------------------
arc_gnu/2016.09-linux-arc700   arc_gnu/2016.09-linux-archs

(4). Prepend GNU toolchain's bin folder to PATH $ export PATH=/abs-path-to-gnu-tools/bin:$PATH

(C) Building ARC Linux kernel

(1). Downloading/building kernel might require some additional host packages (git, make, ncurses-devel...) to be installed on Host machine. This might vary for your host distro (RedHat or Debian etc)

(2). Downloading ARC Linux kernel sources 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.

  • Using git to fetch the kernel repository
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
$ cd linux
$ git checkout -b arc-4.9 v4.9
  • Alternately, a quicker way is to download the source tarball (which lacks any git revision history)
$ wget https://kernel.org/pub/linux/kernel/v4.x/linux-4.9.tar.xz
$ tar -Jxf linux-4.9.tar.xz ; mv linux-4.9 linux; cd linux

Note that the initramfs extracted in step (B)2 and kernel source need to be at same directory hierarchy.

(3). Configure Linux kernel for one of the many supported ARC platforms / target systems. 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
OSCI VP for HS38 : $ make ARCH=arc nsimosci_hs_defconfig
OSCI VP for HS38x2: $ make ARCH=arc nsimosci_hs_smp_defconfig
OSCI VP for ARC770: $ make ARCH=arc nsimosci_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_*

(4). Build the kernel image for standalone nSIM (nsim_hs_defconfig)

$ make ARCH=arc -j

The kernel binary vmlinux is generated

(5). Run Linux with nSIM

$ nsimdrv -tcf=$NSIM_HOME/etc/tcf/templates/hs38_full.tcf -prop=nsim_mem-dev=uart0,base=0xc0fc1000,irq=24 vmlinux

Without using tcf file, full set of toggles need to be passed to nsimdrv

$ 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

(D) Troubleshooting

  1. On SNPS Farm Machines, default versions of make or git might not work
    /depot/git-1.8.4.3/bin/git
    /depot/make-3.82.bin/make

  2. Trouble accessing github

Clone this wiki locally