Chapter1 Zynq Basics
Recommended Book or Tutorial
- The Zynq Book 目前最完整的書 被國外許多相關課程拿來當參考用書
- Zedboard Community Training Zedboard 社群提供的training 入門推薦!
- Xilinx Design Hub
Xilinx 官方的文件分類收集區 整理齊全 翻找相關文檔可先到這邊
Repository
細項資源就看下面兩個囉~
Build Overview
Xilinx zynq platform 整個build流程大致是 (以zynq zc702為例)
Download版子的pre-built部分和source 這裡面boot.bin和 devicetree.dtb都已經編譯好可以直接拿來放進SD card用
- SD card放入我們的uramdisk.image.gz和相關library及軟體(uvcstremer, cpabe, qt_img, ...)
- 更改環境變數以及開機script
In /etc/init.d/rcS
In /etc/init.d/rcS 的 IP address和設定//mount /dev/mmcblk0p1 /home/delta mount /dev/mmcblk0 /home/delta
In /etc/profileifconfig eth0 140.113.212.99 netmask 255.255.255.0 route add default gw 140.113.212.254
(這部分每次開機要重設 如果要永久寫入要重編uramdisk.image.gz 詳見後)export LD_LIBRARY_PATH = .....:/home/delta/prj
- 進到/home/delta/prj
./uvcstreamer-master_arm -n -p 8001 -w ./www -r 1280x720 (-p 為port -r 為resolution)
各部分建置維護
- 修改Rootfilesystem
- 修改boot.bin 有附hardware vivado project 可照流程重新建bitstream & fsbl這兩個檔 uboot xilinx github有 maintain fork 持續更新
修改kernel xilinx github有持續maintaㄛn linux kernel fork 官網boot.bin中kernel為3.19版
About Each Part
Boot.bin
Board specific file contains MAC address for the internet, so you need a unique one!!
First Stage Boot Loader (fsbl) (board-specific)
Initialize ARM processor and DRAM controller, setting the PLL coefficients etc. http://www.wiki.xilinx.com/Build+FSBL (Generate dircetly from SDK template fsbl.elf, so you need to use the Xilinx IDE to create a project and then use their Codesourcery gcc toolchain to compile, source code editable) But that alone would not get you any further. Hence a common boot image consists of an FSBL and U-Boot The bootgen utility uses the description from the boot.bif file to create the final boot.bin
bootgen -image boot.bif -o i boot.bin
(File order does matter!!)
- U-boot (ssbl, open source project) Provides console interface to execute commands or macros, thus it is suitable for debugging if the system is crash after upgrading some part of SD card. You can clone it from Xilinx git repository using the git clone command git clone git://git.xilinx.com/u-boot-xlnx.git
Let's look the source code to see how to boot using U-boot, below is a common configuration to boot from SD card.
modeboot:
run sdboot
sdboot:
mmcinfo;
fatload mmc 0 0x8000 zImage;
fatload mmc 0 0x1000000 devicetree.dtb;
fatload mmc 0 0x2000000 ramdisk32M.image.gz;
Linux kernel begins executing from memory at address 0x8000 where it is expected to find the device tree at address 0x1000000 and the root file system at address 0x2000000
The other commn configuration is where the default size of compressed ramdisk is limited to 10MB
u-boot> fatload mmc 0 0x3000000 uImage
u-boot> fatload mmc 0 0x2A00000 devicetree.dtb
u-boot> fatload mmc 0 0x2000000 uramdisk.image.gz
u-boot> bootm 0x3000000 0x2000000 0x2A00000
zImage
This is the linux kernel, compiled from:
github. linux-xlnx.git
It is special Kbuild system to handle complex configuration
For miniitx
git clone https://github.com/analogdevicesinc/linux.git
cd linux
git checkout xcomm_zynq
# For AD-FMCOMMS2-EBZ use
# git checkout xcomm_zynq
export ARCH=arm
export CROSS_COMPILE=/path/to/your/arm/cross-compiler
make zynq_xcomm_adv7511_defconfig
#
# configuration written to .config
#
make uImage LOADADDR=0x00008000
...
OBJCOPY arch/arm/boot/uImage
Kernel: arch/arm/boot/uImage is ready
For zc702
git clone https://github.com/Xilinx/linux-xlnx.git
cd linux-xlnx
export ARCH=arm
export CROSS_COMPILE=/path/to/your/arm/cross-compiler
make xilinx_zynq_defconfig
# To enable USB gadget in menuconfig
make uImage LOADADDR=0x00008000
ramdisk (rootfilesystem)
This is created from the files linux-xlnx.git or some partner http://www.wiki.xilinx.com/Linux Kernel can mount a block device image as a RAM Disk (EXT3) Kernel can mount a partition fo the SD card (FAT32)
gunzip ramdisk8M.image.gz
mkdir tmp
sudo mount –o loop ramdisk8M.image tmp
cd tmp
#modification
sudo umount tmp
gzip -9 ramdisk8M.image
http://www.wiki.xilinx.com/Build+and+Modify+a+Rootfs
The default ramdisk is 16MB or 8MB (ucompressed). If you want to expand the ramdisk size, follow the below instructions and remember you have to rebuilt the kernel with new config http://www.wiki.xilinx.com/Expanding+File+System
Devicetree.dtb (board-specific)
This is device tree specification of peripherals (Needed since most peripherials are not discoverable through runtime probing) The devicetree compiler source code is part of the Linux kernel source code. Here is how to build the devicetree compiler without building the entire kernel:
http://www.wiki.xilinx.com/Build+Device+Tree+Blob
> make zynq-zed-adv7511-xcomm.dtb
DTC arch/arm/boot/zynq-zed-adv7511-xcomm.dtb
DTC: dts->dtb on file "arch/arm/boot/dts/zynq-zed-adv7511-xcomm.dts"
Notice: Start from kernel 3.19, ZYNQ USB driver was removed since there was already a different driver for the same IP core which is used now. The driver that is now used is the chipidea driver. Make sure that you have it enabled in your kernel config (CONFIG_USB_CHIPIDEA). The xcomm_zynq_adv7511_defconfig has it enabled by default.
However, the USB device is now configured for OTG mode by default, this means in order to use the USB port in host mode you need a proper OTG adapter. The cable has to pull the ID to GND. If you do not have such a cable you can add the 'dr_mode = "host";' property to the usb node in the devicetree similar to this https://github.com/analogdevicesinc/linux/blob/xcomm_zynq/arch/arm/boot/dts/zynq-zed-adv7511-imageon-loopback.dts#L153L155