Building U-Boot 23.1¶
- Table of contents
- Building U-Boot 23.1
This guide covers the creation of the Critical Link provided preloader and U-Boot images. Because of the sensitivity of the preloader to the HPS peripheral pin multiplexing and boot options, you must follow the basic flow for generating the auto-generated files used by both the preloader and the U-Boot applications prior to being able to build a working copy of either one. The auto-generated files are not included in the Git repository, so you won't be able to build a preloader or a U-Boot image unless you follow these steps.
Note: The file names and some commands are designed specifically for use with the sample FPGA projects provided by Critical Link.
The v2023.07 version of the u-Boot, recommended for use with Quartus versions greater than 19.3, transitions from a single bootloader image running in SRAM to 2 boot images. The first image is the secondary program loader (SPL), which runs in the on-board HPS SRAM. The SPL is responsible for loading the peripheral bitstream into the FPGA, configuring the HPS EMIF memory interfaces and loading the tertiary program loader, u-Boot, into DDR4 for final boot execution. The default configuration for the MitySOM-5CSX is to load from the SD MMC card. However, support is included for booting from the on-board eMMC device.
These instructions have been tested with Quartus Prime 23.1
Repository¶
Description | Repository | Branch | U-Boot Version |
U-Boot Source | https://git.criticallink.com/git/u-boot-socfpga.git | socfpga_v2023.07 | v2023.07 |
Pre-Requisites¶
ARM GCC Toolchain¶
Launch a terminal and run a NIOS2 Command Shell. Execute the following commands to download and install the ARM gcc toolchain.
cd wget https://developer.arm.com/-/media/Files/downloads/gnu-a/10.2-2020.11/binrel/\ gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf.tar.xz tar xf gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf.tar.xz export PATH=`pwd`/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf/bin:$PATH
NOTE: the last command adds the compiler to your PATH. If you launch a new shell, you will need to re-add it to your path by changing directories to your download location and re-running the last command.
Linux Packages¶
You will need the following packages (this list is for Ubuntu 22.04 LTS):
sudo apt-get install gawk wget git-core diffstat unzip texinfo \ 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 \ libncurses-dev gawk flex bison openssl libssl-dev
Quick steps used reference project¶
The Makefile included in the development kit reference project includes a bootloader target, which will perform the steps outlined in the next section. From a NIOS2 Embedded Shell, simply run the following command at the top level directory of the reference project:
make uboot
Detailed steps to Building U-Boot¶
Note: Building uBoot requires a completed FPGA build directory on your host machine.
In this example, TOP_FOLDER is the top directory of your FPGA project area.
- Launch a terminal and run a NIOS2 Command Shell.
- Fetch the u-Boot source code.
mkdir -p $TOP_FOLDER/software/bootloader cd software/bootloader/ git clone https://git.criticallink.com/git/u-boot-socfpga.git cd u-boot-socfpga git checkout -b socfpga_v2023.07 origin/socfpga_v2023.07
- Run the cv_bsp_generator.py script to take the sources from the handoff folder, format them appropriately and copy them to the U-Boot source code:
cd $TOP_FOLDER/software/bootloader/u-boot-socfpga ./arch/arm/mach-socfpga/cv_bsp_generator/cv_bsp_generator.py \ -i ../../../hps_isw_handoff/dev_5cs_hps_0 \ -o board/cl/mitysom-5cs/qts
- Configure and build U-Boot and the SPL:
cd $TOP_FOLDER/software/bootloader/u-boot-socfpga export CROSS_COMPILE=arm-none-linux-gnueabihf- make socfpga_mitysom5cs_defconfig make -j 48
- Create the default U-Boot environment (note: environment text file may be customized for your application)
cd $TOP_FOLDER/software/bootloader/u-boot-socfpga tools/mkenvimage -s 8192 -o ubootenv.bin ../uBootMMCEnv.txt
Outputs¶
Description | Location |
U-Boot image with SPL binaries | $TOP_FOLDER/software/bootloader/u-boot-socfpga/spl/u-boot-with-spl.sfp |
U-Boot Environment Binary | $TOP_FOLDER/software/bootloader/u-boot-socfpga/ubootenv.bin |
Customizing U-Boot¶
Customization through updating the U-boot environment¶
Most U-Boot customization for a carrier board can be done by adjusting the scripts/macros in the U-boot environment. This includes changing the name of the core FPGA image (RBF), Kernel, or device tree block (DTB). The U-boot environment is stored in the SD Card, 512 Bytes from the beginning of the SD Card. It can also be updated inside of U-boot by using the editenv, setenv, and saveenv commands. Please see the U-Boot documentation in Further Reading for more usages.
The U-Boot environment binary is built through the FPGA project, it's source is the uBootMMCEnv.txt
FAQ¶
When should I rebuild my bootloader?¶
Your bootloader should be rebuilt anytime the settings in the HPS block in Platform Designer is changed. This includes but not limited to: changing the HPS pin mux, changing any of the clocks generated by the HPS, enabling/changing and the FPGA bridges (Light Weight HPS-to-FPGA, HPS-to-FPGA, FPGA-to-HPS, FPGA-to-SDRAM). When in doubt rebuilt and reflash U-Boot.
Further Read¶
Go to top