Ax5soc Build linux image from scratch
From Terasic Wiki
(Difference between revisions)
(Created page with "reference: rocket https://www.rocketboards.org/foswiki/Documentation/BuildingBootloaderForAgilex5 OS: Ubuntu-22.04 (PC or Windows WLS) ---- '''1. Setting Up Environment''' * In...") |
|||
Line 29: | Line 29: | ||
export ARCH=arm64 | export ARCH=arm64 | ||
export CROSS_COMPILE=aarch64-none-linux-gnu- | export CROSS_COMPILE=aarch64-none-linux-gnu- | ||
+ | </pre> | ||
+ | |||
+ | '''2. Build Arm Trusted Firmware''' | ||
+ | <pre> | ||
+ | cd $TOP_FOLDER | ||
+ | rm -rf arm-trusted-firmware | ||
+ | git clone -b QPDS24.1_REL_AGILEX5_GSRD_PR https://github.com/altera-opensource/arm-trusted-firmware arm-trusted-firmware | ||
+ | cd arm-trusted-firmware | ||
+ | make -j $(nproc) PLAT=agilex5 bl31 | ||
+ | cd .. | ||
+ | The following files is created: | ||
+ | $TOP_FOLDER/arm-trusted-firmware/build/agilex5/release/bl31.bin (to used for u-boot.itb generation) | ||
+ | Edit | ||
+ | </pre> | ||
+ | |||
+ | '''3. Build U-Boot''' | ||
+ | <pre> | ||
+ | cd $TOP_FOLDER | ||
+ | rm -rf u-boot-socfpga | ||
+ | git clone -b atuma5_v1.1 https://github.com/terasic/u-boot-socfpga u-boot-socfpga | ||
+ | cd u-boot-socfpga | ||
+ | make mrproper | ||
+ | cp atuma5.config .config | ||
+ | # link to ATF | ||
+ | ln -s ../arm-trusted-firmware/build/agilex5/release/bl31.bin | ||
+ | make -j $(nproc) | ||
+ | The following files is created: | ||
+ | $TOP_FOLDER/u-boot-socfpga/u-boot.itb | ||
+ | $TOP_FOLDER/u-boot-socfpga/spl/u-boot-spl-dtb.hex | ||
+ | Edit | ||
+ | </pre> | ||
+ | |||
+ | '''4. Creating the Boot Script''' | ||
+ | <pre> | ||
+ | cd $TOP_FOLDER | ||
+ | rm -rf uboot-script && mkdir uboot-script && cd uboot-script | ||
+ | wget https://releases.rocketboards.org/2023.12/qspi/agilex5/agilex5_uboot.txt | ||
+ | wget https://releases.rocketboards.org/2021.11/uboot-script/agilex/uboot_script.its | ||
+ | mv agilex5_uboot.txt uboot.txt | ||
+ | nano uboot.txt # content see bloew | ||
+ | mkimage -f uboot_script.its boot.scr.uimg | ||
+ | cd .. | ||
+ | uboot.txt | ||
+ | |||
+ | echo "Trying to boot Linux from device ${target}"; | ||
+ | |||
+ | if test ${target} = "mmc0"; then | ||
+ | echo "Found kernel in mmc0"; | ||
+ | mmc rescan; | ||
+ | fatload mmc 0:1 ${kernel_addr_r} Image; | ||
+ | fatload mmc 0:1 ${fdt_addr_r} socfpga_agilex5_terasic.dtb; | ||
+ | setenv bootargs "console=ttyS0,115200 root=${mmcroot} rw rootwait"; | ||
+ | booti ${kernel_addr_r} - ${fdt_addr_r}; | ||
+ | exit; | ||
+ | fi | ||
+ | The following files is created: | ||
+ | $TOP_FOLDER/uboot-script/boot.scr.uimg | ||
+ | Edit | ||
</pre> | </pre> |
Revision as of 10:11, 18 October 2024
reference: rocket https://www.rocketboards.org/foswiki/Documentation/BuildingBootloaderForAgilex5
OS: Ubuntu-22.04 (PC or Windows WLS)
1. Setting Up Environment
- Install the required packages on Ubuntu:
sudo apt-get update sudo apt-get upgrade sudo apt install make bison flex python3-dev libssl-dev swig sudo apt install u-boot-tools sudo apt install qemu-user-static
- Create top folder:
mkdir ATUM_A5_V1.2.sdmmc cd ATUM_A5_V1.2.sdmmc export TOP_FOLDER=`pwd`
- Download and setup the the toolchain as follows:
cd $TOP_FOLDER 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 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-
2. Build Arm Trusted Firmware
cd $TOP_FOLDER rm -rf arm-trusted-firmware git clone -b QPDS24.1_REL_AGILEX5_GSRD_PR https://github.com/altera-opensource/arm-trusted-firmware arm-trusted-firmware cd arm-trusted-firmware make -j $(nproc) PLAT=agilex5 bl31 cd .. The following files is created: $TOP_FOLDER/arm-trusted-firmware/build/agilex5/release/bl31.bin (to used for u-boot.itb generation) Edit
3. Build U-Boot
cd $TOP_FOLDER rm -rf u-boot-socfpga git clone -b atuma5_v1.1 https://github.com/terasic/u-boot-socfpga u-boot-socfpga cd u-boot-socfpga make mrproper cp atuma5.config .config # link to ATF ln -s ../arm-trusted-firmware/build/agilex5/release/bl31.bin make -j $(nproc) The following files is created: $TOP_FOLDER/u-boot-socfpga/u-boot.itb $TOP_FOLDER/u-boot-socfpga/spl/u-boot-spl-dtb.hex Edit
4. Creating the Boot Script
cd $TOP_FOLDER rm -rf uboot-script && mkdir uboot-script && cd uboot-script wget https://releases.rocketboards.org/2023.12/qspi/agilex5/agilex5_uboot.txt wget https://releases.rocketboards.org/2021.11/uboot-script/agilex/uboot_script.its mv agilex5_uboot.txt uboot.txt nano uboot.txt # content see bloew mkimage -f uboot_script.its boot.scr.uimg cd .. uboot.txt echo "Trying to boot Linux from device ${target}"; if test ${target} = "mmc0"; then echo "Found kernel in mmc0"; mmc rescan; fatload mmc 0:1 ${kernel_addr_r} Image; fatload mmc 0:1 ${fdt_addr_r} socfpga_agilex5_terasic.dtb; setenv bootargs "console=ttyS0,115200 root=${mmcroot} rw rootwait"; booti ${kernel_addr_r} - ${fdt_addr_r}; exit; fi The following files is created: $TOP_FOLDER/uboot-script/boot.scr.uimg Edit