Introduction: Booting Linux on the ZYBO
If you are new to linux I would recommend reading
through some of the references at the bottom of the page. For this tutorial I am working on a Linux Ubuntu 14.04 vm. Figure 1 is an important overview of the entire design process and how everything comes together to create the necessary components to boot linux on the Zynq-7000 SoC. The end goal of this tutorial is to cover the steps from the beginning stages all the way to booting a Linaro Linux distribution with a graphical user interface on the ZYBO. At this point the tutorial only covers the stages up to booting to a Linaro root shell.
Things you will need :
-Xilinx Vivado 2016.1
-Xilinx SDK 2016
-Digilent's ZYBO Linux-Digilent-Dev master-next branch obtained here: https://github.com/DigilentInc/LinuxDigilent-Dev u-boot-Digilent-Dev master-next branch obtained here: https://github.com/DigilentInc/LinuxDigilent-Dev
Step 1: Obtaining Necessary Files and Repositories
I would recommend making a project folder to work from. I am working from zee-bow on the desktop but it is up to you as to where you want to setup. Also create two more folders to put the boot files and root system files as we create them. I named these folders sd_boot and sd_fs.
1) Download the zybo base system from the Digilnets ZYBO product here: https://reference.digilentinc.com/_media/reference/programmable-logic/zybo/zybo_base_system.zip.
2) Download the Digilent Inc. u-boot-Digilent-Dev and Linux-Digilent-Dev repositories. Make sure to get the master-next branch as these contain the necessary zybo config and dts files. These will be used to create the kernel and u-boot.elf.
Step 2: Compiling U-Boot:Setting Up the Tools and the $PATH Environment Variable
In order to compile the U-Boot and later the kernel we need to set up the tools and extend the $PATH environment variable to find the tools. I would recommend moving the first two exports and the source into your .bashrc so you don't have to set them again after closing the terminal.
Step 3: Compiling U-Boot: Configure and Building U-Boot for ZYBO
The next step is to configure and compile the U-Boot. Navigate to the u-boot-Digilent-Dev folder in the terminal. before compiling the u-boot we need to change the zynq_zybo.h file to prevent the u-boot from loading the ramdisk. Instead we want it to pass to the root filesystem.
Step 4: Compiling U-Boot: Configure and Building U-Boot for ZYBO
Now lets compile the u-boot. Run make with the specific board zynq_zybo_config file and then run make and the execute and link u-boot should compile.
Step 5: Compiling U-Boot:Adding the Elf Extension to U-Boot
If you get an error during this step your $PATH environment variable most likely can not find the tools necessary to compile the u-boot. If the u-boot compiled correctly you should see a u-boot in the top level of the u-boot-Digilent-Dev folder. Lets move this to the sd_boot folder and add an elf extenstion. This will be used to generate the BOOT.bin in the following step.
Step 6: Building the Base Design: Upgrading IPs in Vivado 2016.1
Now on to the base design. Open your chosen version of Vivado, I am working with Vivado 2014.4 and the corresponding SDK. Open the base design project under zybo_base_system/source/vivado/hw/zybo_bsd/zybo_bsd.xpr. If you are using the version that the base design was created with then this next part does not pertain to you and you can go ahead and generate the bitstream. If you are not using the version that it was created on then you will be prompted with an Older Project Version warning and an option to automatically upgrade to the current version. Select okay to automatically upgrade. A second warning will apear saying Vivado no longer uses 'work', select okay. The third warning is notify you that some Xilinx IP's have undergone changes in this version of Vivado, select report ip status. Select the Upgrade Selected at the bottom of the design tool. It will ask if you wish to proceed, select ok.
Step 7: Building the Base Design: Exporting Hardware for SDK
The tool will notify you that there were six critical warning messages, select ok. These will not cause an issue with the system. The next step is to generate the bitstream. There are no implementations available so the tool will ask to launch synthesis and implementation before generating the bitstream, select yes. There will be warnings that appear during the sysnthesis and implementation, select ok do not worry about those for now. I would recommend reading up on some of the references as this may take some time depending on the processing power of your computer. Once the tool has finished you will need to export hardware.
Step 8: Building the Base Design: Include Bitstream When Exporting Hardware
Include the bitstream when exporting the hardware and then launch the SDK
Step 9: First Stage Boot Loader: New Application Project Specification
Once the SDK loads create a new application project. Make sure the hardware platform has selected the hardware you previously exported from Vivado. Select C and standalone for the target software language and OS platform. Name the project fsbl and select next.
Now we will need to modify the fsbl_hooks.c file and
set the mac address. Locate the ZYBO specific fsbl_hooks.c file in the zybo_base_system/source/vivado/SDK/fsbl folder and replace the one that was generated in the SDK fsbl project. Once you have replaced the fsbl_hooks clean and build the project. This will generate the fsbl.elf used to create the BOOT.bin in the next step.
Step 10: Building BOOT.bin:Generating BOOT.bin
Select create Zynq Boot image under the Xilinx Tools tab. We need to add, in order, the fsbl.elf, system_wrapper.bit, and the u-boot.elf in order to create the BOOT.bin. The fsbl can be found in the zybo_base_system/source/vivado/hw/zybo_bsd/zybo_bsd.sdk/fsbl/debug folder. The system_wrapper.bit can be found in the zybo_base_system/source/vivado/hw/zybo_bsd/zybo_bsd.sdk/system_wrapper_hw_platform_0 folder. In an earlier step we moved the u-boot.elf into a the sd_boot folder. Next specify the output path where you want the BOOT.bin to be generated.
Step 11: Building the Linux Kernel
The next step is to build the Linux kernel. Navigate to the Linux-Digilent-Dev folder we downloaded earlier. Now we are ready to compile the kernel. Make sure to run make on the xilinx_zynq_defconfig file to set up the configurations for the zynq chip before compiling the kernel.
Step 12: Generating the Device Tree Blob:Modifying the Zynq_zybo.dts
Before we generate the device tree blob we need to make some slight adjustments to the zynq_zybo.dts file found Linux-Digilent_dev/arch/arm/boot/dts. Particularly line 44, 53, and 62. changing the clock prevented an error that occured after booting up to the root shell.
Step 13: Generating the Device Tree
Now we are ready to generate the dtb file. After this
is complete copy it into the sd_boot folder and rename it devicetree.dtb.
The device tree will be generated in Linux-Digilent-Dev directory by writing this command line:
mlak33@ubuntu:~/Desktop/zee-bow/Linux-Digilent-Dev$./scripts/dtc/dtc -I dts –O dtb –o ./devicetree.dtb arch/arm/boot/dts/zynq-zybo.dts
Step 14: Partitioning the Boot SD Card Using GParted
There are a couple of ways to do this, the easier way is to use Gparted. A second way is to use the command line tool fdisk. If you do not have gparted it is fairly easy to download and install. Type sudo apt-get install gparted to install it and sudo gparted to run it. Once you have it install plug in your SD card and select it from the drop down window in the top left. If you have any information on the SD card make sure to back it up otherwise select the partition tab and unmount the partition then select and delete the partition. Select the check mark that appears, confirming you wish to delete the partition. Create two new partitions, the first with a beginning offset of 4 MiB. The first partition should be FAT32 and be 1 GiB, the second partition should be ext4 and can take the remaining space.
Step 15: Obtaining the Linaro File System
Download the Linaro file system tar. Extract the contents and cd into binary/boot/filesystem.dir. Now we need to sync the contents of this folder with the ROOT_FS partition we just created.
Step 16: Booting the ZYBO: Booting From SD on the ZYBO to the Linaro Root Shell
Now we need to put BOOT.bin, devicetree.dtb, and uImage onto the FAT32 boot partition. I would recommend creating a temporary folder, mounting the boot partition to that folder, and then using rsync to copy the files over. Once the files are on the correct partition eject the SD card and put it into your ZYBO. Make sure the JP5 jumper is set to SD and JP7 is set to wall. You can boot it from the usb but I would recommend using the wall to power the board. Connect to a uart port terminal, I use GtkTerm to connect to the hardware. It is available in the Ubuntu Software Center, when running it make sure to use sudo as it will need permission to connect to the usb port. Power on the ZYBO and then in the serial port terminal set the configuration to the port where the ZYBO is connected and set the baud rate to 11500, everything else should stay as defualt.
We have a be nice policy.
Please be positive and constructive.