Building Linux kernel with Filesystem Using Buildroot¶
Getting Buildroot¶
Clone the Buildroot repository:
git clone -b arc-2026.03 https://github.com/foss-for-synopsys-dwc-arc-processors/buildroot
cd buildroot
Using Predefined Configurations¶
Info
By default, snps_archs38_haps_defconfig uses haps_hs_smp
kernel configuration file. If you are going to run an image on nSIM with
a single core then change it to haps_hs through make menuconfig
(Kernel -> Defconfig name -> haps_hs).
Buildroot uses configuration files (defconfigs) for configuring a root filesystem,
a toolchain, a Linux kernel, etc. Buildroot comes with a number of existing predefined
configurations which may be found in config directory. Use make list-defconfigs command
to list all available configurations:
$ make list-defconfigs | grep snps
snps_arc32_defconfig - Build for snps_arc32
snps_arc64_defconfig - Build for snps_arc64
snps_arc700_axs101_defconfig - Build for snps_arc700_axs101
snps_archs38_axs103_defconfig - Build for snps_archs38_axs103
snps_archs38_haps_defconfig - Build for snps_archs38_haps
snps_archs38_hsdk_defconfig - Build for snps_archs38_hsdk
Here is a short description of each configuration:
snps_arc32_defconfig- A configuration for ARC HS5x on HAPS, nSIM or QEMU.snps_arc64_defconfig- A configuration for ARC HS6x on HAPS, nSIM or QEMU.snps_arc700_axs101_defconfig- A configuration for ARC 700 on AXS101 development board.snps_archs38_axs103_defconfig- A configuration for ARC HS38 on AXS103 development board.snps_archs38_haps_defconfig- A configuration for ARC HS3x/4x in ZeBU, HAPS, nSIM or QEMU.snps_archs38_hsdk_defconfig- A configuration for ARC HS3x/4x on HSDK and HSDK 4xD development boards. This configuration builds images for running Linux using U-Boot.
Configuring Root Filesystem¶
You can select a predefined configuration this way:
You can manually tune filesystem's configuration this way:
The final configuration file is saved in .config file.
Configuring Linux Kernel¶
Also, you can configure kernel's options this way:
Building Linux Image¶
Buildroot with default configurations, which are mentioned above, builds Linux images in this sequence:
- Download sources for a toolchain and build it.
- Download sources for packages, build them using the toolchain and put them
in a filesystem image (
rootfs). - Download sources for a Linux kernel and build it using the toolchain.
- Link the Linux kernel against
rootfs(vmlinux) or save it separately fromrootfs(bzImageoruImage). Whetherrootfsis linked against Linux kernel or not depends on a particular configuration. For example,snps_archs38_hsdk_defconfigconfiguration doesn't linkrootfsagainst Linux kernel.
You can build images using make:
By default, Buildroot builds everything in output directory. Images are placed in
output/images directory. For snps_archs38_haps_defconfig configuration you will find
a couple of filesystem images (rootfs.cpio and rootfs.tar) and vmlinux - a kernel
with the filesystem included:
For example, for snps_archs38_hsdk_defconfig configuration you will find much more
images (consider reading a guide about building Linux for HSDK for more details):
$ ls -1 output/images
boot.vfat
rootfs.ext2
rootfs.ext4
sdcard.img
u-boot
u-boot.bin
uImage
uboot-env.bin
Building Linux Kernel and Filesystem Separately¶
Sometimes it's more convenient to build root file system and a Linux kernel separately. This guide covers an example when it's necessary to build those images separately for ARC HS38 target.
Suppose, that a glibc-based toolchain for ARC HS38 is preinstalled in
/tools/toolchains/arc-linux-gnu.
Use snps_archs38_haps_defconfig configuration file for this example and enter
a configuration menu of Buildroot:
Deselect an option for the Linux kernel and select an appropriate filesystem for your needs:
Kernel -> [ ] Linux kernel
Filesystem images -> [*] cpio the root filesystem # For use as an initial RAM filesystem
-> ext2/3/4 root filesystem # For mounting from a storage
Choose a preinstalled toolchain (a list of available features may differ depending on a version of a toolchain, in case of errors follow Buildroot's recommendations in error messages):
Toolchain -> Toolchain type -> (X) External toolchain
-> (X) Custom toolchain
-> Toolchain origin -> (X) Pre-installed toolchain
-> Toolchain path -> /tools/toolchains/arc-linux-gnu
-> External toolchain gcc version -> (X) 14.x
-> External toolchain kernel headers series -> (X) 5.16.x
-> External toolchain C library -> (X) glibc
-> [ ] Toolchain has RPC support?
-> [X] Toolchain has C++ support?
-> [X] Toolchain has Fortran support?
Build the filesystem image:
Clone a Linux kernel repository and choose a version you want:
To link the Linux kernel with previously built root filesystem image (with .cpio extension), it's necessary to
set CONFIG_INITRAMFS_SOURCE options for the kernel. Configure the kernel and enter a configuration menu:
Fill CONFIG_INITRAMFS_SOURCE parameter with a path to rootfs.cpio, which was built previously:
General setup -> Initial RAM filesystem and RAM disk support
-> Initramfs source file(s) -> <Buildroot-source-tree>/output/images/rootfs.cpio
Put the toolchain to PATH environment variable and build the kernel:
The Linux kernel with root file system is saved as vmlinux file.