Introduction
This article provides instructions for building a boot loader and Linux kernel for the Mpression Sulfur Type-A Development Kit (hereafter referred to as Sulfur). The basic procedure is similar to the one in the following link.
Reference: Building Bootloader for Agilex 5 | Documentation | RocketBoards.org
Please note that only the following three points are uniquely supported.
- Download and use the source trees specifically for Sulfur.
- U-Boot configuration settings use dedicated defconfig (socfpga_agilex5_sulfur_defconfig).
- Linux device tree is generated from dedicated device tree source (socfpga_agilex5_sulfur.dts).
Note: Please note that the U-Boot and Linux kernel build process must be performed under a Linux OS environment. The procedures in this document have been verified on Ubuntu 22.04 LTS.
1. Setup of compiler tool chain
1-1. Download & unzip the toolchain
Store the toolchain in an appropriate location on your development machine. Go to the directory where you plan to store the toolchain and execute the following
wget https://developer.arm.com/-/media/Files/downloads/gnu/11.2-2022.02/binrel/gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu. tar.xz tar xf gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu.tar.xz rm -f gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu.tar.xz
1-2. Setup environment variables
export PATH=`pwd`/gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu/bin:$PATH
export ARCH=arm64
export CROSS_COMPILE=aarch64-none-linux-gnu-
If the above export statement is added to an initial configuration file such as ~/.bashrc, the environment variables will be automatically applied when the terminal is booted. Or, write it in a dedicated shell script and execute the script at each terminal startup.
1-3. Installation of other necessary packages
In addition to the tool chain, there are other necessary packages, which can be installed with the following commands.
sudo apt install build-essential bison flex ncurses-dev swig libssl-dev
Point: If you are using an OS environment other than Ubuntu, the package management commands and required packages will be different.
2. How to obtain the source tree
The source tree of the boot loader (U-Boot & ATF) and Linux kernel that make up the SD card image released for Sulfur can be downloaded from the link in the Note column of the SD card image.
Reference: Macnica Sulfur ~ Development Kit for Agilex™ 5 FPGA E-Series ~
The contents of the downloaded archive consists of the following files.
A summary of each file is as follows
File name (xxx is variable) | Summary |
README.EN / README.JP | Text of the original source tree location information and build instructions |
arm-trusted-firmware-xxx.tgz | Arm Trusted Firmware (ATF) source tree |
u-boot-socfpga-xxx.tgz | Source tree of U-Boot |
linux-socfpga-xxx.tgz | Linux kernel/driver source tree |
poky-build-xxx.tgz | Archive of configuration and recipes for RootFS (Yocto Poky) build |
poky-socfpga-sources-xxx.tgz | Archive of OSS source tree included in RootFS (*1) |
(*1) Because the file size is large, you may need to download it separately. (See README)
3. Build Arm Trusted Firmware (ATF)
Extract the source tree and move to the extracted source tree Top directory.
tar xf arm-trusted-firmware-xxx.tgz
cd arm-trusted-firmware-xxx
Build ATF with the following command
make -j 48 PLAT=agilex5 bl31
Execution example:
4. Build SSBL (U-Boot) and FSBL (U-Boot SPL)
Extract the source tree and move to the extracted source tree Top directory.
tar xf u-boot-socfpga-xxx.tgz
cd u-boot-socfpga-xxx
Link the previously built ATF (bl31.bin) directly under the U-Boot source tree. (The location of the ATF source tree specified in the following command should be read and adapted to your own build environment.)
ln -s . /arm-trusted-firmware-xxx/build/agilex5/release/bl31.bin .
This step is required to build the image file (u-boot.itb) containing both the U-Boot and the ATF. After setting up the link, also make sure that the link destination is correctly recognized by using the ls -al command as shown below.
Build FSBL (U-Boot SPL) and SSBL (U-Boot) with the following command
make mrproper
make socfpga_agilex5_sulfur_defconfig
make -j 48
For FSBL (U-Boot SPL), the file converted to Intel HEX format is used, but you can use spl/u-boot-spl-dtb.hex, which is automatically generated at the time of make. You can also convert it manually with the following command:
aarch64-none-linux-gnu-objcopy -I binary -O ihex --change-addresses 0x0 spl/u-boot-spl-dtb.bin spl/u-boot-spl.ihex
Point: The auto-generated u-boot-spl-dtb.hex and the manually generated u-boot-spl.ihex are identical. The latter is an old procedure used in designs prior to Quartus® Prime 24.2.
Execution example:
5. Build Linux kernel/driver
Extract the source tree and move to the extracted source tree Top directory.
tar xf linux-socfpga-xxx.tgz
cd linux-socfpga-xxx
Build the Linux kernel and device tree with the following commands
make defconfig make -j 48 Image && make intel/socfpga_agilex5_sulfur.dtb
Execution example:
Continue to build the driver module (.ko) with the following command. In addition, install the driver module under the modules_install directory.
make -j 48 modules
mkdir modules_install
export INSTALL_MOD_PATH=./modules_install
make modules_install
Execution example:
Archive the installed kernel modules (.ko) under the modules_install directory. The archived kernel modules will be used when installing to rootfs.
cd modules_install
tar czf modules_sulfur_xxx.tgz lib
Execution example:
6. Build results
Finally, here is the list of deliverables that will be built in the previous steps.
Deliverables | File name (xxx is optional) | Summary |
FSBL |
u-boot-spl-dtb.hex or u-boot-spl.ihex |
ihex image of U-Boot SPL, used in combination with configuration data to be written to SDM (* see appendix) |
SSBL & ATF | u-boot.itb | .itb file containing the U-Boot and ATF. Stored on the FAT partition of the boot SD card. |
Linux kernel | Image | Linux kernel image. Stored on the FAT partition of the SD card for boot. |
Linux Device Tree | socfpga_agilex5_sulfur.dtb |
Linux device tree Blob, stored in the FAT partition of the boot SD card. |
Linux driver Module |
modules_sulfur_xxx.tgz | Linux driver module archive. Extracted and used under /lib/modules in the rootfs partition of the boot SD card. |
Note: Combine FSBL with configuration file
Overwrite the FSBL (u-boot-spl-dtb.hex or u-boot-spl.ihex) under output_files of the Quartus project for Sulfur and then execute the following command
Point: This procedure requires the appropriate version of Quartus® Prime or Quartus® Prime Programmer set up (quartus_pfg enabled). Please use the tool version that generated the configuration data to be combined.
When combining to a .sof file:
quartus_pfg -c output_files/sulfur_ghrd_top.sof output_files/sulfur_ghrd_top_hps.sof \ -o hps_path=output_files/u-boot-spl-dtb.hex
When combining to a .jic file (.sof is also generated automatically):
quartus_pfg -c output_files/sulfur_ghrd_top.sof output_files/sulfur_ghrd_top_hps.jic \ -o device=MT25QU128 \ -o flash_loader=A5ED065BB32AE5SR0 \ -o hps_path=output_files/u-boot-spl-dtb.hex \ -o mode=ASX4
Note: There are two different names for FSBL Intel HEX format files depending on the design version. When executing the command, change the FSBL (u-boot-spl-dtb.hex or u-boot-spl.ihex) file name specified with -o hps_path= as appropriate.
Summary
In this article, we have described the procedure for building the boot loader and Linux kernel separately. Please use this article if you wish to verify the boot loader or Linux kernel (or both) by replacing them with customized ones based on the pre-built SD card image.