Introduction
The following two related articles describe how to generate a boot loader and boot Linux from the boot loader.
Reference:
- Bootloader generation flow for SoC EDS v19.1 std / v19.3 pro or later (Cyclone® V SoC / Arria® V SoC edition)
- Bootloader generation flow for SoC EDS v19.1 Std / v19.3 Pro or later (Arria® 10 SoC edition)
To boot Linux from the bootloader as described in the above article, you will need a Linux kernel, Linux device tree, and root file system (hereafter referred to as RootFs).
This article explains how to build them.
Please also refer to the following Rocketboards.org page for the latest information.
Reference: Building Bootloader for Cyclone V and Arria 10 ⇒ Appendix - Building Linux Binaries
This article describes how to build the following Linux kernels.
| Device | Linux Branch |
| Cyclone® V SoC Arria® 10 SoC |
5.15.70-lts |
Note: The above is the device and Linux compatibility table as of March 1, 2023 (content will be updated at with each release).
1. Prerequisites
Note: Please make sure your development environment meets the following Yocto system requirements:
Yocto Project Overview and Concepts Manual
1 System Requirements
1.1 Supported Linux Distributions
1.2 Required Packages for the Build Host
This article uses the following environment (the environment used here is just an example):
- Host machine running Linux. In this article we used VirtualBox + Ubuntu 20.04 LTS.
- An internet connection to download tools and clone the U-Boot git tree from GitHub. If you have a firewall or proxy, you will need to allow the system administrator access to the git tree.
- SoC FPGA development kit with the desired device: Cyclone® V SoC / Arria® 10 SoC
If you have a proxy, such as an internal network, you will need to configure the following proxy settings:
On your Linux host machine, open the /etc/apt/apt.conf file using a text editor (such as gedit),
write the proxy settings as shown below, and save it.
$ sudo gedit /etc/apt/apt.conf
Acquire::http::proxy "http://proxy.address:proxy.port";
Acquire::https::proxy "https://proxy.address:proxy.port";
Acquire::ftp::proxy "ftp://proxy.address:proxy.port";
* In the above proxy settings, proxy.address means the proxy address, and proxy.port means the proxy port number.
Please set the appropriate settings according to the user's network environment.
On your Linux host machine, open the .bashrc file in a text editor (such as gedit),
add the following proxy to the last line, and then save the file.
$ gedit ~/.bashrc
export http_proxy="http://proxy.address:proxy.port"
export https_proxy="https://proxy.address:proxy.port"
export ftp_proxy="ftp://proxy.address:proxy.port"
* In the above proxy settings, proxy.address means the proxy address, and proxy.port means the proxy port number.
Please set the appropriate settings according to the user's network environment.
Close the terminal on your Linux host machine and then start it again.
Open the terminal and enter the following command to update the package information:
$ sudo apt update
$ sudo apt upgrade
To build the Linux kernel and RootFs, you need to install some Linux packages at. On the Ubuntu 20.04 LTS machine used in this article, the following command was used to perform the installation:
$ sudo apt install gawk wget git git-core diffstat unzip texinfo gcc gcc-multilib \
build-essential chrpath socat cpio python python3 python3-pip python3-pexpect \
xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa \
libsdl1.2-dev pylint3 xterm python3-subunit libncurses-dev flex bison openssl \
libssl-dev mesa-common-dev zstd liblz4-tool
$ sudo apt install make python3-pip
$ sudo pip3 install sphinx sphinx_rtd_theme pyyaml
$ sudo apt install g++-multilib
$ sudo apt install libgmp-dev libmpc-dev
If you have a proxy, such as an internal network, it is necessary to configure proxy settings with the following
git config --global command (please configure the appropriate settings for your network environment).
$ git config --global http.proxy http://proxy.address:proxy.port
$ git config --global https.proxy https://proxy.address:proxy.port
2. Build Linux binaries
This section describes how to build Linux binaries.
2-1. Preparation
- If you are running Embedded Command Shell, close the terminal on the Linux host machine once and then open it again.
- If you have a proxy, such as an internal network, you will need to configure the proxy settings described in
"1. Prerequisites" above. - Prepare the $LINUX_BIN/a9 folder to place the Linux build binaries used in the related boot loader article introduced in "Introduction" above:
$ rm -rf linux-bin && mkdir linux-bin
$ export set LINUX_BIN='pwd'/linux-bin
$ mkdir -p $LINUX_BIN/a9
2-2. Building the Linux Kernel
Note: The Linux kernel build procedure is common to Cyclone® V, Arria® V and Arria® 10.
(1) Prepare the Top folder:
$ rm -rf linux && mkdir linux
$ export set LINUX_TOP=`pwd`/linux
(2) Download and set up the toolchain:
$ cd $LINUX_TOP
$ wget https://developer.arm.com/-/media/Files/downloads/gnu/11.2-2022.02/binrel/gcc-arm-11.2-2022.02-x86_64-arm-none-linux-gnueabihf.tar.xz
$ tar xf gcc-arm-11.2-2022.02-x86_64-arm-none-linux-gnueabihf.tar.xz
$ rm gcc-arm-11.2-2022.02-x86_64-arm-none-linux-gnueabihf.tar.xz
$ export PATH='pwd'/gcc-arm-11.2-2022.02-x86_64-arm-none-linux-gnueabihf/bin:$PATH
$ export ARCH=arm
$ export CROSS_COMPILE=arm-none-linux-gnueabihf-
(3) Duplicate the Linux git tree and retrieve the code:
$ cd $LINUX_TOP
$ git clone https://github.com/altera-opensource/linux-socfpga linux-socfpga.a9
$ cd linux-socfpga.a9
# Comment out the following line to use the latest Linux kernel branch
$ git checkout -b test-kernel -t origin/socfpga-5.15.70-lts
Note: (only with Cyclone® V SoC Development Kit)
Most Cyclone® V SoC development kits come with a 512MB QSPI flash device, but the Linux kernel DTS assumes 1Gb (128MB) by default.
If you wish to use the standard 512MB, see below. Perform the procedure "(4) Build the Linux kernel" before, linux-socfpga/arch/arm/boot/dts/socfpga_cyclone5_socdk.dts file as appropriate:
$ gedit arch/arm/boot/dts/socfpga_cyclone5_socdk.dts
Figure 1. Modification of dts file according to the QSPI device size of the Cyclone® V SoC Development Kit
(4) Build the Linux kernel:
$ make socfpga_defconfig
$ make -j 48 zImage Image dtbs modules
$ make -j 48 modules_install INSTALL_MOD_PATH=modules_install
$ rm -rf modules_install/lib/modules/*/build
$ rm -rf modules_install/lib/modules/*/source
(5) Link all relevant files to $LINUX_BIN/a9
$ ln -s $LINUX_TOP/linux-socfpga.a9/arch/arm/boot/zImage $LINUX_BIN/a9/
$ ln -s $LINUX_TOP/linux-socfpga.a9/arch/arm/boot/Image $LINUX_BIN/a9/
$ ln -s $LINUX_TOP/linux-socfpga.a9/arch/arm/boot/dts/socfpga_cyclone5_socdk.dtb $LINUX_BIN/a9/
$ ln -s $LINUX_TOP/linux-socfpga.a9/arch/arm/boot/dts/socfpga_arria10_socdk_sdmmc.dtb $LINUX_BIN/a9/
$ ln -s $LINUX_TOP/linux-socfpga.a9/arch/arm/boot/dts/socfpga_arria10_socdk_qspi.dtb $LINUX_BIN/a9/
$ ln -s $LINUX_TOP/linux-socfpga.a9/arch/arm/boot/dts/socfpga_arria10_socdk_nand.dtb $LINUX_BIN/a9/
$ ln -s $LINUX_TOP/linux-socfpga.a9/modules_install/lib/modules $LINUX_BIN/a9/
The following files are linked to the $LINUX_BIN/a9 folder:
Table 1. Linux Kernel Build Generation Files
| File | Description |
| zImage | Compressed kernel image |
| Image | Uncompressed kernel image |
| socfpga_cyclone5_socdk.dtb | Device tree blob for both SD/MMC boot and QSPI boot for Cyclone® V SoCs |
| socfpga_arria10_socdk_sdmmc.dtb | Device tree for SD/MMC boot for Arria® 10 SoC blob |
| socfpga_arria10_socdk_qspi.dtb | Device tree for QSPI boot for Arria® 10 SoC blob |
| socfpga_arria10_socdk_nand.dtb | Device tree for NAND boot for Arria® 10 SoC blob |
| modules | Kernel loadable modules |
2-3. Build RootFs
This example shows how to build Linux RootFs using a Yocto recipe.
Note that the Yocto recipe actually builds everything, but this article focuses only on RootFs.
Prepare the Top folder for RootFs:
$ cd $LINUX_TOP
$ mkdir rootfs && cd rootfs
$ export set ROOTFS_TOP='pwd'
2-3-1. For Cyclone® V SoC:
To build RootFs for Cyclone® V SoC, follow the steps below:
$ cd $ROOTFS_TOP
$ rm -rf cv && mkdir cv && cd cv
$ git clone -b honister https://git.yoctoproject.org/poky
$ git clone -b honister https://git.yoctoproject.org/meta-intel-fpga
$ source poky/oe-init-build-env ./build
$ echo 'MACHINE = "cyclone5"' >> conf/local.conf
$ echo 'BBLAYERS += " ${TOPDIR}/. /meta-intel-fpga "' >> conf/bblayers.conf
# To add more packages to the image, uncomment the following line
# $ echo 'CORE_IMAGE_EXTRA_INSTALL += "openssh gdbserver"' >> conf/local.conf
$ bitbake core-image-minimal
$ ln -s $ROOTFS_TOP/cv/build/tmp/deploy/images/cyclone5/core-image-minimal-cyclone5.tar.gz $LINUX_BIN/a9/
The following files are linked to the $LINUX_BIN/a9 folder by executing the above procedure:
Table 2. RootFs Build Generation Files for Cyclone® V SoC
| File | Description |
| core-image-minimal-cyclone5.tar.gz | RootFs for Cyclone® V SoC (tar archive format) |
2-3-2. For Arria® 10 SoC:
To build RootFs for Arria® 10 SoC, follow the steps below:
$ cd $ROOTFS_TOP
$ rm -rf a10 && mkdir a10 && cd a10
$ git clone -b kirkstone https://git.yoctoproject.org/poky
$ git clone -b kirkstone https://git.yoctoproject.org/meta-intel-fpga
$ source poky/oe-init-build-env ./build
$ echo 'MACHINE = "arria10"' >> conf/local.conf
$ echo 'BBLAYERS += " ${TOPDIR}/../meta-intel-fpga "' >> conf/bblayers.conf
# To add more packages to the image, uncomment the following line
# $ echo 'CORE_IMAGE_EXTRA_INSTALL += "openssh gdbserver"' >> conf/local.conf
$ bitbake core-image-minimal
$ ln -s $ROOTFS_TOP/a10/build/tmp/deploy/images/arria10/core-image-minimal-arria10.tar.gz $LINUX_BIN/a9/
The following files are linked to the $LINUX_BIN/a9 folder by executing the above procedure:
Table 3. RootFs Build Generation Files for Arria® 10 SoC
| File | Description |
| core-image-minimal-arria10.tar.gz | RootFs for Arria® 10 SoC (tar archive format) |
Conclusion
This article has provided a reference guide to the minimal steps required to build the Linux kernel, device tree, and RootFs needed to boot Linux from the bootloader for the Cyclone® V SoC / Arria® 10 SoC. We hope this will be of help to you in booting Linux from the boot loader.
Please also refer to the following article on how to create the SD card image used to boot the HPS (Hard Processor System) side of an Altera® (Intel®) SoC FPGA.