This article will discuss the steps needed to download and compile a Bootable (SD) Linux Image for the ZCU102 using the OSL flow.
...
NOTE: If building on an Ubuntu (or derivative machine), ensure that the default shell has been changed from Dash to Bash. Compiling in Dash may result in syntax errors within the Makefile that will prevent the code from compiling.
Build FSBL
- git clone https://github.com/Xilinx/embeddedsw
- cd embeddedsw
- git checkout master-rel-2020.2
- cd embeddedsw/lib/sw_apps/zynqmp_fsbl/src
- make "BOARD=zcu102-es2" "PROC=a53" "CFLAGS+=-DFSBL_DEBUG_INFO"
Build PMU Firmware
- cd embeddedsw/lib/sw_apps/zynqmp_pmufw/src
- make
Build ATF
...
I have structured this in a way that users can copy this into their Makefile for ease of use.
Getting Sources:
Code Block |
---|
language | c# |
---|
title | get_sources |
---|
|
get_sources:
if [ ! -d "./bootgen" ];then \
git clone https://github.com/Xilinx/bootgen; \
$(MAKE) -C bootgen; \
fi
if [ ! -d "./linux-xlnx" ];then \
git clone https://github.com/Xilinx/linux-xlnx; \
cd linux-xlnx && git checkout xilinx-v$(VERSION); \
fi
if [ ! -d "./embeddedsw" ];then \
git clone https://github.com/Xilinx/embeddedsw; \
cd embeddedsw && git checkout xilinx-v$(VERSION); \
fi
if [ ! -d "./repo" ];then \
mkdir -p repo/my_dtg; \
cd repo/my_dtg && git clone https://github.com/Xilinx/device-tree-xlnx; \
cd device-tree-xlnx && git checkout xilinx-v$(VERSION); \
fi
if [ ! -d "./u-boot-xlnx" ];then \
git clone https://github.com/Xilinx/u-boot-xlnx; \
cd u-boot-xlnx && git checkout xilinx-v$(VERSION); \
fi
if [ ! -d "./arm-trusted-firmware" ];then \
git clone https://github.com/Xilinx/arm-trusted-firmware; \
cd arm-trusted-firmware && git checkout xilinx-v$(VERSION); \
fi
if [ ! -d "./dtc" ];then \
git clone https://git.kernel.org/pub/scm/utils/dtc/dtc.git; \
$(MAKE) -C dtc; \
fi |
Build FSBL
Code Block |
---|
|
$(MAKE) -f embeddedsw/lib/sw_apps/zynqmp_fsbl/src/Makefile "BOARD=zcu102-es2" "PROC=a53" "CFLAGS+=-DFSBL_DEBUG_INFO" |
Build PMU Firmware
Code Block |
---|
|
$(MAKE) -f embeddedsw/lib/sw_apps/zynqmp_pmufw/src/Makefile |
Build ATF
Code Block |
---|
|
atf:
$(MAKE) -C arm-trusted-firmware clean
source $(TOOLS); \
export CROSS_COMPILE=aarch64-none-elf-; \
cd arm-trusted-firmware; \
$(MAKE) -f Makefile DEBUG=0 RESET_TO_BL31=1 PLAT=zynqmp bl31 |
Note: If users want to debug (ie use the symbols) the ATF in Vitis, then set the DEBUG=1. This will place the ATF in DDR at 0x1000
Build u-boot
...
Code Block |
---|
|
uboot:
$(MAKE) -C u-boot-xlnx clean
source $(TOOLS); \
export CROSS_COMPILE=aarch64-linux-gnu-; \
export ARCH=aarch64; \
export CC=aarch64-linux-gnu- |
...
gcc; \
export PATH=$$PATH:$(shell pwd)/dtc; \
cd u-boot-xlnx; \
$(MAKE) -f Makefile xilinx_zynqmp_ |
...
...
Note: If users want to debug (ie use the symbols) the u-boot in Vitis, then use the u-boot (renamed u-boot.elf) in the boot image.
Build Linux Image:
- git clone https://github.com/Xilinx/linux-xlnx.git
- cd linux-xlnx
- git checkout xilinx-v2020.1
- export CROSS_COMPILE=aarch64-linux-gnu-
- export ARCH=arm64
- make xilinx_zynqmp_defconfig
- make
Build device-tree
...
defconfig; \
$(MAKE) -f Makefile all -j 32 |
Note: If users want to debug (ie use the symbols) the u-boot in Vitis, then use the u-boot (renamed u-boot.elf) in the boot image.
Build Linux Image:
Code Block |
---|
|
kernel:
$(MAKE) -C linux-xlnx clean
source $(TOOLS); \
export CROSS_COMPILE=aarch64-linux-gnu-; \
export ARCH=arm64; \
export CC=aarch64-linux-gnu-gcc; \
cd linux-xlnx; \
$(MAKE) -f Makefile xilinx_zynqmp_defconfig; \
$(MAKE) -f Makefile all -j 32 |
Build device-tree
- Create a xsct_script.tcl file with the following contents:
Code Block |
---|
|
proc gen_dtb {hdf} { build_dts {} {
set xsa [glob -nocomplain -directory [pwd] -type f *.xsa]
hsi::open_hw_design $hdf$xsa
hsi::set_repo_path ./repo
hsi::create_sw_design device-tree -os device_tree -proc psu_cortexa53_0
generate_target -dir my_dts
} |
...
proc psu_cortexa53_0
hsi::generate_target -dir my_dts
hsi::close_hw_design [hsi::current_hw_design]
} |
Then we can call this from our Makefile:
Code Block |
---|
|
build_dts:
$(RM) -r my_dts
$(XSCT) -eval "source xsct_script.tcl; build_dts" |
Users can make changes to their DeviceTree in my_dts/system-top.dts. For example, since I am using the ZCU102. I will add the PHY.
Do do this, open my_dts/system-top.dts and update the gem3 node, by appending the content below:
Code Block |
---|
|
&gem3 {
status = "okay";
local-mac-address = [00 0a 35 00 02 90];
phy-mode = "rgmii-id";
phy-handle = <&phy0>;
phy0: phy@c {
reg = <0xc>;
ti,rxrx-internal-delay = <0x8>;
ti,tx-internal-delay = <0x8><0xa>;
ti,txfifo-internal-delaydepth = <0xa><0x1>;
};
}; |
Users can also add the dtsi here to my_dts directory, and include this into the DT structure. For a quick guide on Devicetree debugging, see the wiki here
Compile the devicetree (DTB)
Code Block |
---|
|
build_dtb:
$(RM) -r system.dtb
ti,fifo-depth = <0x1>;
};
}; |
Users can also add the dtsi here to my_dts directory, and include this into the DT structure. For a quick guide on Devicetree debugging, see the wiki here
Compile the devicetree (DTB)
- dtc -I dts -O dtb -o my_dts/system-top.dtb my_dts/system-top.dts
Note: For the 2018.3 release version onward, the 'include' syntax in device-tree files changed from /include/ to the 'C' style #include. Depending on which version of the device-tree-compiler (dtc) is being used, this may cause parsing errors when the .dts file is read. To fix this, all instances of #include need to be replaced with /include/.
Note: To verify, users can use the command below and investigate if the gem3 node was updated:dtc -I dtb -O dts -o my_dts/system-dump.dts export PATH=$$PATH:$(shell pwd)/dtc; \
gcc -I my_dts -E -nostdinc -undef -D__DTS__ -x assembler-with-cpp -o my_dts/system-top.dts.tmp my_dts/system-top.dts; \
dtc -I dts -O dtb -o system.dtb my_dts/system-top. |
dtbCreate SD image
Build The bootgen binary
git clone https://github.com/Xilinx/bootgencd bootgenmakeexport PATH=$PATH:/<Your Path>/bootgen
Create SD image
Create the BIF file with the contents below:
Code Block |
---|
|
the_ROM_image:
{
[fsbl_config] a53_x64
[bootloader, destination_cpu=a53-0] embedded/lib/sw_apps/zynqmp_fsbl/src/fsbl.elf
[pmufw_image] embeddedsw/lib/sw_apps/zynqmp_pmufw/src/executable.elf
[destination_device=pl] design_1_wrapper.bit
[destination_cpu=a53-0, load=0x00100000] my_dts/system-top.dtb
[destination_cpu=a53-0,exception_level=el-3,trustzone] arm-trusted-firmware/build/zynqmp/release/bl31/bl31.elf
[destination_cpu=a53-0,exception_level=el-2] u-boot-xlnx/u-boot.elf
} |
Then in bootgen
run the command
below from XSCTbootgen -arch zynqmp -image bootgen.bif -o i BOOT.BIN -w onfrom your Makefile
Code Block |
---|
|
bootimage:
export PATH=$$PATH:$(shell pwd)/bootgen; \
bootgen -arch zynqMP -image bootgen.bif -w -o BOOT.BIN |
Creating the FIT image:
Code Block |
---|
|
/dts-v1/;
/ {
description = "U-Boot fitImage for plnx_aarch64 kernel";
#address-cells = <1>;
images {
kernel@0 {
description = "Linux Kernel";
data = /incbin/("./linux-xlnx/arch/arm64/boot/Image");
type = "kernel";
arch = "arm64";
os = "linux";
compression = "none";
load = <0x80000>;
entry = <0x80000>;
hash@1 {
algo = "sha1";
};
};
fdt@0 {
description = "Flattened Device Tree blob";
data = /incbin/("./my_dts/system.dtb");
type = "flat_dt";
arch = "arm64";
compression = "none";
hash@1 {
algo = "sha1";
};
};
ramdisk@0 {
description = "ramdisk";
data = /incbin/("./petalinux-user-image-plnx_aarch64.cpio.gz");
type = "ramdisk";
arch = "arm64";
os = "linux";
compression = "none";
hash@1 {
algo = "sha1";
};
};
};
configurations {
default = "conf@1";
conf@1 {
description = "Boot Linux kernel with FDT blob + ramdisk";
kernel = "kernel@0";
fdt = "fdt@0";
ramdisk = "ramdisk@0";
hash@1 {
algo = "sha1";
};
};
conf@2 {
description = "Boot Linux kernel with FDT blob";
kernel = "kernel@0";
fdt = "fdt@0";
hash@1 {
algo = "sha1";
};
};
};
}; |
Use the
command below to created the ITB file:command below to created the .ub file:
Code Block |
---|
|
fit_image:
export PATH=$$PATH:$(shell pwd)/dtc; \
../u-boot-xlnx/tools/mkimage -f fitimage.its image.ub |
- u-boot-xlnx/tools/mkimage -f fitimage.its fitimageimage.itbub
Load the BOOT.BIN and the
fitImage.itb image.ub and boot.scr on the SD card and boot.
Stop at uboot, and- fatload mmc 0 0x10000000 fitimage
- bootm 0x10000000
Users, can also update add the boot.scr to the SD Card from here:2020.1 Release