GT

Gennaro Tortone homepage

0%

Linux on Zynq

References

Getting Started

https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18841738/Getting+Started

Useful guide

https://gitlab.telecom-paristech.fr/renaud.pacalet/secbus/wikis/zedboard-linux-uboot-dtb-buildroot

Prerequisites

Install Xilinx Tools

Install Vivado Design Suite - HLx Editions - 2018.3 Full Product Installation from
https://www.xilinx.com/support/download.html

Note 1

docnav executable will not work on Debian Stretch due to libpng12.so
library unavailable

Solution:

1
2
wget http://ftp.de.debian.org/debian/pool/main/libp/libpng/libpng12-0_1.2.50-2+deb8u3_amd64.deb
sudo dpkg -i libpng12-0_1.2.50-2+deb8u3_amd64.deb

Note 2

Vivado HLS reports error when printf is using on Linux amd64.

Solution:

1
2
3
apt-get install libc6-dev-amd64
mkdir /usr/include/asm
cp /usr/lib/x86_64-linux-gnu/asm/\* /usr/include/asm/

Fetch sources

1
2
3
git clone http://github.com/Xilinx/u-boot-xlnx.git
git clone https://github.com/Xilinx/linux-xlnx.git
git clone https://github.com/Xilinx/device-tree-xlnx.git

Install cross toolchain

1
apt-get install gcc-arm-linux-gnueabihf
1
apt-get install gcc-aarch64-linux-gnu

Kernel build

1
2
3
4
5
export CROSS_COMPILE=arm-linux-gnueabihf-
make ARCH=arm xilinx_zynq_defconfig
make ARCH=arm menuconfig
make -j4 ARCH=arm UIMAGE_LOADADDR=0x8000 uImage dtbs modules
make -j4 ARCH=arm UIMAGE_LOADADDR=0x8000 modules_install INSTALL_MOD_PATH=/media/tortone/ROOTFS/

Output file: arch/arm/boot/uImage

1
2
3
4
5
export CROSS_COMPILE=aarch64-linux-gnu-
make ARCH=arm64 xilinx_zynqmp_defconfig
make ARCH=arm64 menuconfig
make -j4 ARCH=arm64 Image dtbs modules
make -j4 ARCH=arm64 modules_install INSTALL_MOD_PATH=/media/tortone/ROOTFS/

Output file: arch/arm64/boot/Image

Device Tree

  • Generate a device tree from a Vivado project
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
hsi

set_param board.repoPaths <path>

(/opt/Xilinx/Vivado/2018.3/data/boards/board_files)

open_hw_design <design_name>.hdf

(contained in <project>.sdk directory)

set_repo_path <path to device-tree-xlnx repository>

(/home/tortone/devel/training/zynq-linux/device-tree-xlnx)

create_sw_design device-tree -os device_tree -proc ps7_cortexa9_0

generate_target -dir my_dts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
hsi

set_param board.repoPaths <path>

(/opt/Xilinx/Vivado/2018.3/data/boards/board_files)

open_hw_design <design_name>.hdf

(contained in <project>.sdk directory)

set_repo_path <path to device-tree-xlnx repository>

(/home/tortone/devel/training/zynq-linux/device-tree-xlnx)

create_sw_design device-tree -os device_tree -proc psu_cortexa53_0

generate_target -dir my_dts
  • Compile device tree blob (.dtb) from device tree source (.dts)
1
2
3
cd my_dts
cpp -nostdinc -I include -I arch -undef -x assembler-with-cpp system-top.dts > system-top-preproc.dts
dtc -I dts -O dtb system-top-preproc.dts -o devicetree.dtb

Output file: my_dts/devicetree.dtb

U-Boot

1
2
3
4
5
6
7
8
9
export CROSS_COMPILE=arm-linux-gnueabihf-

make zynq_zed_defconfig
or
make xilinx_zynq_virt_defconfig

make menuconfig

make
1
2
3
4
5
6
7
export CROSS_COMPILE=aarch64-linux-gnu-

make xilinx_zynqmp_zcu102_rev1_0_defconfig

make menuconfig

make

Output file: u-boot.elf

FSBL

1
2
3
4
5
6
7
8
9
10
11
hsi

set_param board.repoPaths <path>

(/opt/Xilinx/Vivado/2018.3/data/boards/board_files)

set hwdsgn [open_hw_design /opt/Xilinx/SDK/2018.3/data/embeddedsw/lib/hwplatform_templates/zed_hw_platform/system.hdf]

generate_app -hw $hwdsgn -os standalone -proc ps7_cortexa9_0 -app zynq_fsbl -compile -sw fsbl -dir fsbl

quit
1
2
3
4
5
6
7
hsi

set_param board.repoPaths <path>

(/opt/Xilinx/Vivado/2018.3/data/boards/board_files)

generate_app -hw [open_hw_design <design_name>.hdf] -os standalone -proc psu_cortexa53_0 -app zynqmp_fsbl -compile -sw fsbl -dir fsbl

Output file: executable.elf

PMU

1
2
3
hsi

generate_app -hw [open_hw_design MercuryXU5_PE1.sdk/system_top.hdf] -os standalone -proc psu_pmu_0 -app zynqmp_pmufw -compile -sw pmu -dir pmu

BL31

1
2
3
4
export CROSS_COMPILE=aarch64-linux-gnu-
git clone https://github.com/Xilinx/arm-trusted-firmware.git
cd arm-trusted-firmware
make PLAT=zynqmp RESET_TO_BL31=1

Output file: build/zynqmp/release/bl31/bl31.elf

boot.bin

  • Create boot.bif
1
2
3
4
5
image : {
[bootloader]<FSBL_PATH>/executable.elf
<BITSTREAM_PATH>/zedboard.bit
<UBOOT_PATH>/u-boot.elf
}
1
2
3
4
5
6
7
8
9
image:
{
[pmufw_image] <PMU_PATH>/executable.elf
[bootloader, destination_cpu=a53-0] <FSBL_PATH>/executable.elf
[destination_device=pl] <BITSTREAM_PATH>/system_top.bit
[destination_cpu=a53-0,exception_level=el-3,trustzone] <BL31_PATH>/bl31.elf
[destination_cpu=a53-0,exception_level=el-2] <UBOOT_PATH>/u-boot.elf
}

  • Generate boot.bin
1
bootgen -image boot.bif -o boot.bin -w on
1
bootgen -arch zynqmp -image boot.bif -o boot.bin -w on

SD card formatting

  • Create two partitions

    1. ~50 MB fat32
    2. remaining space ext4

Partitions naming

!!! Double-check partitions naming with dmesg command to avoid format of system disk !!!

  • Format partitions
1
2
mkfs.vfat /dev/sdb1
mkfs.ext4 /dev/sdb2
  • Label partitions
1
2
dosfslabel /dev/sdb1 BOOT
e2label /dev/sdb2 ROOTFS
  • Copy to first partition:
1
2
3
boot.bin
<KERNEL_DIR>/arch/arm/boot/uImage
<DT_DIR>/devicetree.dtb

Debian rootfs

1
2
sudo debootstrap --verbose --arch armhf --variant=minbase --foreign buster debian10 http://ftp.it.debian.org/debian
sudo cp /usr/bin/qemu-armeb-static debian10/usr/bin
1
2
sudo debootstrap --verbose --arch arm64 --variant=minbase --foreign buster debian10 http://ftp.it.debian.org/debian
sudo cp /usr/bin/qemu-aarch64-static debian10/usr/bin
1
2
3
4
sudo mkdir debian10/dev/pts
sudo mount -t devpts devpts debian10/dev/pts
sudo mount -t proc proc debian10/proc
sudo chroot debian10 /bin/bash
  • In chroot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/debootstrap/debootstrap --second-stage

cat <<! >> /etc/apt/sources.list
deb http://security.debian.org/ buster/updates main
deb-src http://security.debian.org/ buster/updates main
deb http://ftp.it.debian.org/debian/ buster main
deb-src http://ftp.it.debian.org/debian/ buster main
!

apt-get update
apt-get upgrade

export LANG=C
apt-get -y install apt-utils dialog locales
dpkg-reconfigure locales
export LANG=en_US.UTF-8
apt-get -y install udev netbase ifupdown iproute openssh-server iputils-ping wget net-tools ntpdate nano less kmod vim
apt-get -y install sysvinit-core sysvinit-utils

cat <<! >> /etc/fstab
tmpfs /tmp tmpfs defaults 0 0
!

echo "Zynq" > /etc/hostname
passwd

cat <<! >> /etc/securetty
ttyPS0
ttyPS1
!
  • Comment out the tty1 to tty6 specifications in /etc/inittab and add the serial console
1
T0:23:respawn:/sbin/getty -L ttyPS0 115200 vt100
  • Copy rootfs to SD
1
sudo rsync -va debian10/ /media/tortone/ROOTFS