In this post we will design our custom hardware for the Zedboard that includes a simple gray counter, a led Ip and the buttons which interact with each other via an Axi-4-Lite protocol. After that we developed a software application which uses a polling method to read the buttons input and we use that to control the gray counter(for example the upper one freezes the counter and the down one resumes it). The state of the counter is propagated through the software to the leds of the Zedboard.
Here you can find the Vivado project which is written in verilog and the software app in C. We will dive in depth on how to create those apps in order to use them on petalinux in a next post.
This is the block_design of the Vivado project.
According to the Xilinx guide and the Svenand blog we must configure the zynq processing system according to the bring up guide in order our designed hardware to be bootable. So after a double-click on the ZYNQ7 Processing System block:
If you want to use the Ethernet port of the Zedboard with Petalinux you have to make the changes as shown in the following pictures.
At last you have to change the PS clock frequency from 100MHz to 50MHz.
After all the above steps are done, now we generate the bitstream. Then export the hardware including the bitstream and launch SDK. After it finishes importing the hardware specification close the SDK and copy the .hdf file from the .sdk/ directory to the petalinux project/ directory.
Now we are ready to create a bootable image which includes the hardware we just created!! These steps are to be followed for every hardware specification you want to import to the petalinux kernel.
1)Create a Petalinux Project
petalinux-create --type project --template zynq --name <project-name>
2)Get the hardware description from the .hdf file
petalinux-config --get-hw-description -p <project-name-directory/>
After this command the kernel configuration window appears. We don’t want to change anything here so we simply select exit.
3) Enter in project directory <project-name/> and in order to add some apps that work with the hardware you designed.
petalinux-create -t apps --name <app name>
ATTENTION! You have to replace the <app name.c> code with yours in the app directory (components/apps/).
4)In order to include your app in the Petalinux Kernel
petalinux-config -c rootfs
Then you see the following window.
Select Apps and enable your app.
5) Build your new Kernel
After this the image.ub is created in the images/linux/ directory
6) Create the bootable file
petalinux-package --boot --format BIN --force --fsbl images/linux/zynq_fsbl.elf --fpga images/linux/<project_name.bit> --uboot
Now the BOOT.BIN file is created in the project directory.
7) Copy the BOOT.bin & image.ub to an empty SD card(not in any folder).
8) Connect to the Zedboard uart interface as shown in the pictures.
9) Open a serial console(gtkterm, minicom etc.) to get access to the board(port:ACM0-baud:115200). Needs superuser.
10) Insert the SD to the Zedboard and press PS-RST to see all the booting screen messages.
11) Login to the zedboard user: root
12) Run your app just by typing its name on the console.
For example run:
13) Have fun!!