-
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:
yum install -y 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
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 git://git.busybox.net/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_axs101_defconfig
(build for snps_axs101),
snps_axs103_defconfig
(build for snps_axs103),
snps_hs38_smp_vdk_defconfig
(build for snps_hs38_smp_vdk),
snps_hs38_vdk_defconfig
(build for snps_hs38_vdk)
.
$ cd buildroot
$ make snps_axs103_defconfig
Starting from a default configuration buildroot can be configured to choose packages (say openssh), specific version of say Linux kernel, tools etc. For extra configuration use:
$ make menuconfig
So e.g., if we want to build an image for standalone nSIM (and not axs101 board which was configured above), navigate the menu GUI which comes up and choose the defconfig
Kernel --->
Kernel configuration ---> (Using an in-tree defconfig file)
(nsim_hs) Defconfig name
Additionally configure the kernel not use fixed initramfs path, but the initramfs built by Buildroot
$ make linux-menuconfig
Clear out the initramfs source, which Buildroot over-rides !
General setup --->
Initramfs source file(s)
$ make
After build process is finished (which could take 30+ minutes) results could 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,base=0xc0fc1000,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.
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.