This blog series describe the selection, set-up and usage of a development environment for Zynq.
- Part 1 – Overview
- Part 2 – Set-Up the development environment
- Part 3 – Build boot files
- Part 4 – Boot Linaro from SD Card
- Part 5 – Programmable Logic projects with Vivado
- Part 6 – Eclipse Project for register access
The following instructions use the development environment described in Part 2.
I am not interested in Desktop Linux like Ubuntu support. For Desktop Linux at least VGA support is needed. Therefore components in Programmable Logic, an adjusted Device Tree and Kernel patches are needed. Link to a good guide under yet-another-guide-to-running-linaro-ubuntu-desktop-on-xilinx-zynq-on-the-zedboard
Overview of needed files
For booting from SD Card following files are needed.
- Boot.bin
The boot file includes:- FSBL
A file with the first stage boot loader - Bitfile
File with code for the Program Logic - U-boot
Boatloader file to load the Kernel with the device Tree
- FSBL
- udev.txt
u-boot Parameter file - Kernel
uImage with the Linux kernel - Device Tree
dtb file with information about hardware system. The file is needed by the kernel - Linux distribution
A second partition with the Linux distribution file system
First Stage Boot Loader
Xilinx SDK use the command gmake not make. A symbolic link is needed to solve this problem.
sudo ln -s /usr/bin/make /usr/bin/gmake
Now we can start the SDK by double-clicking the icon “Xilinx SDK 2013.2”. Open the “New project” wizard with “File”=>”New”=>”Application Project” and use the following settings.
Finish the wizard and select “Project”=>”Build All” to generate the file FSBL.elf.
I use the zedboard. For a other platform select the correct “Hardware Platform”. If your platform is missing use the Vivado export function to generate it.
Bitfile
For bitfile generaton Vivado is used. Step-by-step instructions to generate a bitfile without extra logic can be found under http://zedboard.org/content/creating-base-zynq-design-vivado-ipi-20132.
U-boot
Open a terminal in home folder. Clone the U-boot source with
git clone git://git.xilinx.com/u-boot-xlnx.git
The U-boot version from Xilinx extract the Linux distribution from a file in RAM and boot it. We want to define the boot options in device tree. Therfore we need a “udev.txt” file.
fdt_high=0x10000000 bootcmd=fatload mmc 0 0x3000000 uImage; fatload mmc 0 0x2A00000 devicetree.dtb; bootm 0x3000000 - 0x2A00000 uenvcmd=echo "Booting SD...";boot
I want to work with DMA without usage of a device driver. Therefore I need a free memory block at the end of adress range. The device tree is loaded to memory, too. I reduce the fdt_high value so the device tree is not loaded to the end of memory address range.
The Xilinx U-Boot version is not configured for hard float. I have to change compiler flags for a successful build.
In file u-boot-xlnx/config.mk replace
PLATFORM_RELFLAGS =
with
PLATFORM_RELFLAGS =-mfloat-abi=hard -mfpu=vfpv3
It is necessary to disable the soft float flags. A search with grep -rnw ‘.’ -e “msoft” shows the file to change. In file u-boot-xlnx/arch/arm/cpu/armv7/config.mk replace
PLATFORM_RELFLAGS += -fno-common -ffixed-r8 -msoft-float
with
PLATFORM_RELFLAGS += -fno-common -ffixed-r8
I am not a makefile guru. I am sure that better solutions exists.
All is prepared for build U-boot. We need to expand the PATH variable temporary so that make find the toolchain.
PATH=$HOME/gcc-linaro-arm-linux-gnueabihf-4.8-2013.07-1_linux/bin:$PATH export PATH
It is possible define path changes permanently by appending /etc/profile with this commands. The available configurations are listed in board.cfg. Open the file or grep lines from interest with
grep -H -r "zynq_" ./boards.cfg
I use the zedboard therefore I define the hardware with
make ARCH=arm zynq_zed_config CROSS_COMPILE=arm-linux-gnueabihf-
After hardware is configured, we build U-boot with
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
Rename the result u-boot in e-boot.elf.
Boot.bin
All files needed for boot.bin are generated. We can use the Xilinx SDK to build the file. Select “Xilinx Tools”=>”Create Zynq Boot Image” and select your files. Press “Create Image” to buid it.
Another way is to use the bootgen without the gui. You can find a desktop script and the for bootgen needed bif file in buildBoot_bin.
Kernel
Open a terminal in home folder. Clone the U-boot source with
git clone git://git.xilinx.com/linux-xlnx.git
Change directory to the new folder linux-xlnx.
Print the PATH variable with command
echo $PATH
For building a uImage mkimage is needed. mkimage is part of U-Boot. We need to define the path so make can find it. If the toolchain is not part of the PATH variable anymore insert it again.
PATH=$HOME/gcc-linaro-arm-linux-gnueabihf-4.8-2013.07-1_linux/bin:$PATH PATH=$PATH:$HOME/u-boot-xlnx/tools export PATH
The available configs are listed in arch/arm/configs. Vor Zynq I use xilinx_zynq_defconfig.
make ARCH=arm xilinx_zynq_defconfig CROSS_COMPILE=arm-linux-gnueabihf-
Now we can build the uImage
make ARCH=arm UIMAGE_LOADADDR=0x8000 uImage CROSS_COMPILE=arm-linux-gnueabihf-
The uImage is located in /arch/arm/boot
Device Tree
Examples for device tree files are located under arch/arm/boot/dts in Kernel sources. I use zynq-zed.dts for Zedboard. I want to boot the Linux distribution from a partition. Therefore I change the bootargs to
bootargs = "console=ttyPS0,115200 root=/dev/mmcblk0p2 rw earlyprintk rootfstype=ext4 rootwait devtmpfs.mount=0 --no-log";
This change only work with the modified U-boot.
I want to use a part of memory for a DMA without driver support. Therefore I reduce the memory managed by Linux
ps7_ddr_0: memory@0 { device_type = "memory"; reg = < 0x0 0x18000000 >; } ;
For booting the dts file have to be converted in a dtb file. The kernel tool dtc is used for that. I write shellscripts for dts to dtb and back. All files in the defined folder are converted. Download dts_dtb
Did you notice a difference when using the vfpu for u-boot instead of the soft-float implemtation? And why didn’t you do any changes to the Kernel so it uses the vfpu?
cheers
eactor
I seem to recall that I get a kernel panic with mixed soft-float uboot and hard-float kernel.
I had big problems with soft-float libs on a hard-float linux distribution. Therefore I decide to build a consistent hard-float environment.
I did not notice a difference. I dare say there is no change in boot time. Benchmarks to compare hard-float and soft-float would be nice, but I have currently no time to generate them.