-
Notifications
You must be signed in to change notification settings - Fork 13
How to build filesystem and kernel images for ARC cores with Buildroot
Buildroot is an open source project (essentially a set of smart Makefiles) that automates the process of (optionally) building a tool-chain, downloading and cross-compiling various packages (including bootloader and the Linux kernel) and generating binary images which can be run on target.
This article will focus on helping ARC users generate images of filesystems and Linux kernel for ARC cores using Buildroot.
Buildroot is meant to be run on Linux host and because of that fact to proceed with instructions below it is necessary to have access to Linux-powered host computer (be it laptop, desktop or remote server) or virtual machine (for example VirtualBox or VMWare player).
It is likely that the Linux distribution on the user's host machine may not have all pre-requisite software packages already installed. The need to install these required software packages on the machine in turn requires root/administrator privileges. For users that don't have root privileges, a virtual machine environment may be more convenient.
Two most popular virtual machines available free of charge are VirtualBox from Oracle (Installing VirtualBox and extension packs) and VMWare Player (VMware Player Documentation).
Once virtual machine is installed Linux distribution of choice has to be installed as a guest OS in virtual machine. Please follow instructions provided for your virtual machine.
We recommend to use either Ubuntu LTS (as of writing this is 14.04) or CentOS 6 or 7. These distributions have pretty long life cycle (Ubuntu 14.04 will be supported by Canonical until April 2019, CentOS 6 will reach end of life in November 2020 and CentOS 7 in June 2024) so they will be around for quite some time and user may expect instructions below to work through all this time.
Please refer to Buildroot documentation and in particular section System requirements that lists mandatory and optional packages needed for successful completion of Buildroot execution.
Depending on Linux distribution installed on development host procedure of package installation will differ. On RedHat-based distros (RedHat, CentOS, Fedora etc) user needs to run:
sudo dnf install subversion binutils bzip2 gcc gcc-c++ gawk gettext flex ncurses-devel zlib-devel make patch unzip perl-ExtUtils-MakeMaker glibc glibc-devel glibc-static quilt ncurses-lib sed sdcc intltool sharutils bison wget perl-devel
On Debian-based distros (Debian, Ubuntu, Mint etc) user needs to run:
sudo apt-get install build-essential subversion libncurses5-dev zlib1g-dev gawk gcc-multilib flex git-core gettext libssl-dev
Stable Buildroot releases are published every three months. Tarballs are available for each stable release (http://buildroot.org/downloads/). However, it is generally more convenient to clone the upstream Git repository.
$ git clone https://git.busybox.net/buildroot
$ cd buildroot
Buildroot comes with a number of existing defconfigs for various processor architectures and corresponding publicly available hardware platforms. List them using
$ make list-defconfigs
To configure Buildroot for generating images of filesystems and Linux kernel for ARC cores you may need one of the following minimal defconfigs:
-
snps_arc700_axs101_defconfig
(build for AXS101 board), -
snps_archs38_axs103_defconfig
(build for AXS103 board), -
snps_archs38_haps_defconfig
(build for ZeBU or HAPS boards or nSIM simulation), -
snps_hs38_vdk_defconfig
(build for VDK with quad-core ARC HS38), -
snps_hsdk_defconfig
(build for HSDK board)
To build an image for nSIM simulation (binary compatible with HAPS FPGA board)
$ make snps_archs38_haps_defconfig
This builds a SMP Linux kernel by default. The kernel config for this buildroot configuration can be modified in several ways
$ gvim configs/snps_archs38_haps_defconfig
change BR2_LINUX_KERNEL_DEFCONFIG="haps_hs" # picks a different kernel config in kernel sources
$ make snps_archs38_haps_defconfig
$ make linux-menuconfig # launches the kernel configuration menu
By default toolchain, Linux kernel and user-space apps are built for little-endian target. But it is very simple to change configuration and build for big-endian machine.
Note this operation consists of 2 steps:
-
Instruct Buildroot to build toolchain and user-space apps for big-endian.
$ make menuconfig
Target options -> Target architecture (ARC (big-enadian)) -
Change Linux kernel configuration from default little-endian to big-endian.
$ make linux-menuconfig
ARC Architecture Configuration -> ARC CPU Configuration -> Enable Big Endian Mode
$ make
After build process is finished (which could take 30+ minutes) results can be found in output/images/
.
Among others a linux kernel binary vmlinux
is generated.
Note that as part of build, buildroot downloads source tarballs and this may take significantly long especially if your internet connection is slow. To address this offline build can be done. First user downloads all sources with make source
command and then building itself make
could be done without connection to internet at all.
And now we're ready to run created binary in simulator (we will use standalone nSIM)
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,kind=dwuart,base=0xf0000000,irq=24 -prop=nsim_isa_aps_feature=1 -prop=nsim_isa_num_actionpoints=4 vmlinux
You'll see following output in the same console window:
Console now belongs to UART, hit CRTL-] to return to simulator.
Linux version 4.8.6 (vineetg@vineetg-Latitude-E7450) (gcc version 6.2.1 20160824 (Buildroot 2016.11-00001-g74e728cadf2e-dirty) ) #2 PREEMPT Fri Dec 9 15:49:18 PST 2016
Memory @ 80000000 [512M]
Memory @ 100000000 [1024M] Not used
OF: fdt:Machine model: snps,nsim_hs
earlycon: arc_uart0 at MMIO32 0xc0fc1000 (options '115200n8')
bootconsole [arc_uart0] enabled
archs-intc : 15 priority levels (default 14)
IDENTITY : ARCVER [0x53] ARCNUM [0x0] CHIPID [ 0x0]
Timers : Timer0 Timer1 Local-64-bit-Ctr (not used)
ISA Extn : atomic ll64 unalign (not used)
: mpy[opt 9] div_rem norm barrel-shift swap minmax swape
...
...
Welcome to Buildroot
buildroot login:
To log in just say root
and press Enter.
Now you may play with simple utilities that are provided by Busybox, for example:
# ls /
bin home lib32 mnt root sys var
dev init linuxrc opt run tmp
etc lib media proc sbin
To terminate debug session first press Ctrl-]
, then Ctrl-C
four times in a row.