Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
programmable-logic:zybo-z7:demos:petalinux [2022/09/05 07:20] – [Using the demo] Radu-Augustin Veleprogrammable-logic:zybo-z7:demos:petalinux [2023/08/25 00:29] (current) – Move to direct file links for downloads Arthur Brown
Line 1: Line 1:
 +====== Zybo Z7 Petalinux Demo ======
  
 +{{:programmable-logic:zybo-z7:demos:plnx_image.jpg?400|}}
 +===== Description =====
 +
 +The Zybo Z7 Petalinux demo demonstrates the usage of various board features from within a Linux environment.
 +
 +Available features:
 +  * Ethernet with Unique MAC address and DHCP support
 +  * USB Host support
 +  * UIO drivers for onboard switches, buttons and LEDs
 +  * SSH server
 +  * Build essentials package group for on-board compilation using gcc, etc.
 +  * HDMI output with KMS (kernel mode setting)
 +  * HDMI input via UIO drivers
 +  * Pcam 5C input via V4L2 drivers (only for Zybo Z7-20)
 +
 +----
 +===== Inventory =====
 +
 +  * Zybo Z7 (-10 or -20) with a MicroUSB Programming Cable.
 +  * Petalinux Installation compatible with the latest release of this demo
 +    * //See Xilinx's [[https://docs.xilinx.com/v/u/2020.1-English/ug1144-petalinux-tools-reference-guide|Petalinux Tools Documentation (2020.1) (UG1144)]] for installation instructions. Make sure that the documentation version and the project version that you want to use are the same.//
 +  * Serial Terminal application to receive messages printed by the demo
 +    * //See [[programmable-logic:guides:serial-terminals:start]] for more information.//
 +  * Micro SD card formatted as a FAT filesystem
 +
 +
 +**For the Pcam 5C demo**:
 +  * Pcam 5C to use video for Linux functionality
 +  * Ethernet cable to retrieve the pictures as .bin files (useful for testing the Ethernet feature as well)
 +  * External 5V power supply
 +
 +**For testing the HDMI and USB features**:
 +  * 1 HDMI Type A to Type A or HDMI Type A to DVI-D cable
 +  * HDMI or DVI monitor
 +  * Keyboard with USB 2.0 cable
 +
 +**For changing or extending the hardware platform**:
 +  * Vivado installation compatible with the latest release of this demo
 +    * //See [[programmable-logic:guides:installing-vivado-and-vitis|Installing Vivado, Vitis, and Digilent Board Files]] for installation instructions.//
 +
 +----
 +===== Download and Usage Instructions =====
 +
 +First and foremost, releases - consisting of a set of files for download - are only compatible with a specific version of the Xilinx tools, as specified in the name of the release (referred to as a //release tag//). In addition, releases are only compatible with the specified variant of the board. For example, a release tagged "20/DMA/2020.1" for the Zybo Z7 is only to be used with the -20 variant of the board and Vivado 2020.1.
 +
 +The latest release version for this demo is highlighted in green.
 +
 +**Note:** //Releases for FPGA demos from before 2020.1 used a different git structure, and used a different release tag naming scheme.//
 +
 +^ Board Variant  ^ Release Tag                      ^ Release Downloads                                                                                     ^ Setup Instructions                             ^
 +| Zybo Z7-10     | @#C0EEBD: 10/Petalinux/2022.1-1  | {{https://github.com/Digilent/Zybo-Z7/releases/tag/10/Petalinux/2022.1-1/Zybo-Z7-10-Petalinux-2022-1.bsp}}  | See //Using the Latest Release//, below  |
 +| Zybo-Z7-20     | @#C0EEBD: 20/Petalinux/2022.1-1  | {{https://github.com/Digilent/Zybo-Z7/releases/tag/20/Petalinux/2022.1-1/Zybo-Z7-20-Petalinux-2022-1.bsp}}  | See //Using the Latest Release//, below  |
 +| Zybo Z7-10     | 10/Petalinux/2021.1-1            | {{https://github.com/Digilent/Zybo-Z7/releases/tag/10/Petalinux/2021.1-1/Zybo-Z7-10-Petalinux-2021-1.bsp}}  | See //Using the Latest Release//, below  |
 +| Zybo Z7-20     | 20/Petalinux/2021.1-1            | {{https://github.com/Digilent/Zybo-Z7/releases/tag/20/Petalinux/2021.1-1/Zybo-Z7-20-Petalinux-2021-1.bsp}}  | See //Using the Latest Release//, below  |
 +| Zybo Z7-10     | 10/Petalinux/2020.1-1            | {{https://github.com/Digilent/Zybo-Z7/releases/tag/10/Petalinux/2020.1-1/Zybo-Z7-10-Petalinux-2020-1.bsp}}  | See //Using the Latest Release//, below  |
 +| Zybo Z7-20     | 20/Petalinux/2020.1-1            | {{https://github.com/Digilent/Zybo-Z7/releases/tag/20/Petalinux/2020.1-1/Zybo-Z7-20-Petalinux-2020-1.bsp}}  | See //Using the Latest Release//, below  |
 +| Zybo Z7-20     | v2017.4-3                        | [[https://github.com/Digilent/Petalinux-Zybo-Z7-20/releases/tag/v2017.4-3|Release ZIP Downloads]]     | [[https://github.com/Digilent/Petalinux-Zybo-Z7-10/tree/v2017.4-3|Github README]]  |
 +| Zybo Z7-10     | v2017.4-1                        | [[https://github.com/Digilent/Petalinux-Zybo-Z7-10/releases/tag/v2017.4-1|Release ZIP Downloads]]     | [[https://github.com/Digilent/Petalinux-Zybo-Z7-10/tree/v2017.4-1|Github README]]  |
 +| Zybo Z7-20     | v2017.2-1                        | [[https://github.com/Digilent/Petalinux-Zybo-Z7-20/releases/tag/v2017.2-1|Release ZIP Downloads]]     | [[https://github.com/Digilent/Petalinux-Zybo-Z7-20/tree/v2017.2-1|Github README]]  |
 +| Zybo Z7-10     | v2017.2-1                        | [[https://github.com/Digilent/Petalinux-Zybo-Z7-10/releases/tag/v2017.2-1|Release ZIP Downloads]]     | [[https://github.com/Digilent/Petalinux-Zybo-Z7-10/tree/v2017.2-1|Github README]]  |
 +
 +**Note for Advanced Users:** //GitHub sources for this demo can be found in the [[https://github.com/digilent/zybo-z7/tree/10/Petalinux/master|10/Petalinux/master]] and [[https://github.com/digilent/zybo-z7/tree/20/Petalinux/master|20/Petalinux/master]] branches of the Zybo-Z7 repository. Further documentation on the structure of this repository can be found on this wiki's [[programmable-logic:documents:git]] page.//
 +----
 +Instructions on the use of the latest release can be found in this dropdown:
 +
 +--> Using the Latest Release #^
 +
 +<WRAP group>
 +
 +{{page>programmable-logic:guides:using-github-releases#petalinux_release_before_programming&noheader}}
 +
 +--> (Alternative for building the project) Use the pre-built image #
 +
 +**Note**: This procedure only works if you are using the .bsp release. If you cloned the project source directly from GitHub, skip this section.
 +
 +If the project created from the .bsp release contains the //**pre-built**// folder you can copy the files **BOOT.BIN, boot.scr, image.ub** directly from there. The details on how to use these files to boot Petalinux on the board are described in the //Booting Petalinux on a Zynq Board// section below.
 +
 +----
 +<--
 +
 +--> Set up the Zybo Z7-20 #
 +
 +**Set up for booting Petalinux on the Board**:
 +
 +     * Plug the Zybo Z7-20 into the computer via the microUSB programming cable and power on the board (you can also use an external power supply, but make sure the JP6 is set properly). Make sure the JP5 jumper is set to SD. Use the steps described in //Booting Petalinux on a Zynq Board//.
 +
 +** Additional set up for the Pcam 5C demo: **
 +
 +     * Make sure you are powering the Zybo Z7-20 with an external 5V power supply and have the JP6 jumper on the **WALL** option.
 +     * For retrieving the pictures you can use multiple procedures described in the //Using the demo// section.
 +     * Attach the Pcam 5C assembly (which includes the Pcam 5C and the attached 15-pin flat flexible cable) by inserting the other end of the FFC into the Pcam connector on the Zybo Z7 as shown in image below. Ensure the cable is securely latched by pressing down firmly on the connector with two fingers. For a more detailed set of instructions, see the Pcam section in the [[programmable-logic:zybo-z7:reference-manual#pcam_port|Zybo Z7 Reference Manual]]. If the cable has become disconnected from the Pcam 5C, please see the [[add-ons:pcam-5c:reference-manual|Pcam 5C reference manual]] for instructions on how to reattach it.
 +
 +{{:reference:programmable-logic:zybo-z7:zybo-z7-pcam-attach.png|}}
 +----
 +<--
 +
 +{{page>programmable-logic:guides:using-github-releases#petalinux_release_programming&noheader}}
 +
 +At this point, the demo is now running on your board. Refer to the [[#description|Description]] section of this document for more information on what it does.
 +</WRAP>
 +<--
 +
 +----
 +A brief set of instructions to some of the configurations which can be done in Petalinux can be found in this dropdown:
 +
 +--> Petalinux Configurations #
 +<WRAP group>
 +
 +{{page>programmable-logic:guides:using-github-releases#petalinux_configurations&noheader}}
 +
 +</WRAP>
 +<--
 +----
 +===== Using the demo =====
 +
 +The functionality of the demo features are presented in the sections below.
 +
 +--> Testing the Ethernet connection #
 +<WRAP group>
 +
 +After you connect the Ethernet cable to the network (wall outlet, router, PC) run the following command in the serial terminal. You can choose as address your PC's Ethernet or Wi-Fi IP address (depending on how your PC is connected to the network).
 +
 +<code>
 +ping <address>
 +</code>
 +
 +Upon success you should see no packet loss.
 +
 +Alternatively you can run the command:
 +
 +<code>
 +ip a
 +</code>
 +
 +If there is a successful connection, you should be able to read the board's eth0's assigned ip address
 +
 +<code>
 +2: eth0: (...)
 +   (...)
 +   inet <ip address>
 +   (...)
 +</code>
 +
 +
 +</WRAP>
 +
 +<--
 +
 +--> Testing the USB support #
 +<WRAP group>
 +For testing USB support you can insert a FAT-formatted USB stick into the board's USB port.
 +If the device is detected you should see in the terminal a message similar to:
 +<code>
 +usb-storage 1-1:1.0: USB Mass Storage device detected
 +</code>
 +
 +Next, run the command
 +<code>
 +fdisk -l
 +</code>
 +
 +This way you can identify the device location, e.g. /dev/sda1. If that location is different in your case, you should use it instead of /dev/sda1 next.
 +
 +To mount the USB drive you should run the following commands
 +<code>
 +mkdir /media/usb-data # create a mount point directory
 +mount /dev/sda1 /media/usb-data # mount the detected device into the newly created directory
 +</code>
 +You could use that directory to transfer data between the board and your PC.
 +
 +Before removing the USB stick from the board you can unmount it using the command 
 +<code>
 +umount /media/usb-data
 +</code>
 +
 +</WRAP>
 +
 +<--
 +
 +--> Testing the LEDs, switches and buttons using UIO drivers #
 +<WRAP group>
 +</WRAP>
 +
 +The boards LEDs, switches and buttons can be accessed through UIO drivers. In some of the earlier versions of the project (before 2020) a series of [[https://github.com/Digilent/digilent-apps|apps]] were available for testing some of the GPIOs. However these are no longer maintained. In the newer versions of petalinux, the user can select whether or not to include the gpio-demo and peekpoke apps.
 +
 +<--
 +
 +--> Testing the SSH server#
 +<WRAP group>
 +
 +One way to test the SSH server is to connect to the board from your PC via SSH.
 +
 +First, get your board's eth0 IP address (as explained in //Testing the Ethernet connection// above). Then open a command line on your PC and connect to the board using:
 +<code>
 +ssh root@<board eth0 IP address>
 +</code>
 +
 +You should be able to interact with the linux environment similarly to the serial terminal.
 +
 +</WRAP>
 +
 +<--
 +
 +--> Testing the packages #
 +<WRAP group>
 +
 +To view all installed packages run the command
 +<code>
 +ls /usr/bin
 +</code>
 +
 +For testing for instance your gcc package you can try to create and compile a C source file.
 +Create a source file:
 +<code>
 +cd ~
 +touch source_file.c
 +</code>
 +Open it using the vi editor:
 +<code>
 +vi source_file.c
 +</code>
 +Insert a simple C program code. Press **i** and copy-paste the following code using **Ctrl+Insert** - **Shift+Insert**:
 +<code>
 +#include <stdio.h>
 +
 +int main() {
 +    printf("Hello World!\n");
 +    return 0;
 +}
 +</code>
 +Save it by pressing **Esc** and typing **:wq**
 +
 +Compile and run it
 +<code>
 +gcc source_file.c -o my_app
 +./my_app
 +</code>
 +
 +Upon success you should see the output: Hello World
 +
 +</WRAP>
 +
 +<--
 +
 +--> Testing the HDMI output and USB input from keyboard #
 +<WRAP group>
 +</WRAP>
 +
 +To test the HDMI output with kernel mode setting, connect a HDMI cable between your HDMI TX port and an HDMI monitor. Next, connect your keyboard to the USB port.
 +
 +You should be able to use the monitor the same way as the serial terminal, type in commands using the connected keyboard and access all features in the demo.
 +
 +----
 +
 +**Note**: For the HDMI input there is currently no demo application that uses the UIO drivers.
 +
 +<--
 +
 +--> Taking pictures using V4L2 and the Pcam 5C (Z7-20 only) #
 +<WRAP group>
 +
 +Run the following commands in the serial console connected to your board.
 +
 +**Set the width, height, and frame rate of your capture.**
 +<code>
 +width=1920 && height=1080 && rate=15
 +</code>
 +
 +Before running the next commands make sure to use arguments that correspond to the data in the device topology.
 +To view the information about the video device run the command:
 +<code>
 +media-ctl /dev/media0 -p
 +</code> 
 +
 +You should be able to view the device topology with various entities and pads. Pay attention to the **ov5640 2-003c** and **43c60000.mipi_csi2_rx_subsystem** entities whose names could slightly change. If any of the names differ from the ones used in the commands below make sure to modify them to include the correct name.
 +
 +**Prepare your media and video pipeline.**
 +<code>
 +media-ctl -d /dev/media0 -V '"ov5640 2-003c":0 [fmt:UYVY/'"$width"x"$height"'@1/'"$rate"' field:none]'
 +media-ctl -d /dev/media0 -V '"43c60000.mipi_csi2_rx_subsystem":1 [fmt:UYVY/'"$width"x"$height"' field:none]'
 +v4l2-ctl -d /dev/video0 --set-fmt-video=width="$width",height="$height",pixelformat='YUYV'
 +</code>
 +
 +**Capture 14 frames.**
 +<code>
 +yavta -c14 -f YUYV -s "$width"x"$height" -F /dev/video0
 +</code>
 +
 +As a result you should obtain 14 .bin files
 +
 +<WRAP round important>
 +==Warning==
 +The camera module takes some time to automatically adjust the exposure and white balance. While this is happening, the frames will come out dark and with green tints. Capture more frames than needed for your usecase.
 +</WRAP>
 +
 +</WRAP>
 +<--
 +
 +--> Retrieving the pictures #
 +<WRAP group>
 +
 +To retrieve the pictures you need to transfer the .bin files on your Linux machine. Next they are processed and converted to .png using the //ffmpeg// tool. There are multiple ways to move the pictures from the board to the PC: through scp (make sure to have the board and PC connected to the same network), through the SD card (by copying the binary files to /mnt/sd-mmcblk0p1), or through a USB stick (as described in the //Testing the USB support//). 
 +
 +Make sure no data was lost during the transfer of the files. 
 +
 +Run the following commands in a terminal on your Linux machine to copy the files via SSH.
 +
 +Replace 10.113.0.117 with your board's IP address.
 +<code>
 +scp [email protected]:~/*.bin .
 +</code>
 +
 +<WRAP round tip>
 +You can also find the IP address of your board by running the following command in your serial console.
 +<code>
 +ip addr show
 +</code>
 +</WRAP>
 +
 +Set the width, height, and framerate of your capture.
 +<code>
 +width=1920 && height=1080 && rate=15
 +</code>
 +
 +Using ffmpeg, convert the files you copied into PNG.
 +<code>
 +for f in *.bin; do mv "$f" "${f%.bin}.yuv"; done
 +for f in *.yuv; do ffmpeg -s "$width"x"$height" -pix_fmt yuyv422 -i "$f" -y "${f%.yuv}.png"; done
 +</code>
 +
 +</WRAP>
 +<--
 +
 +--> (Non-functional) Audio input / output #
 +<WRAP group>
 +<WRAP round important>
 +==Warning==
 +Audio features are currently completely non-functional.
 +</WRAP>
 +
 +Run the following commands in the serial console connected to your board.
 +
 +Start a pulseaudio server.
 +<code>
 +pulseaudio --start
 +</code>
 +
 +<WRAP round tip>
 +If you see a message similar to the following one, you need to start the pulseaudio server again.
 +<code>
 +ALSA lib ../../alsa-plugins-1.1.9/pulse/pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refused
 +</code>
 +</WRAP>
 +
 +See the [[https://alsa-project.org/wiki/SoundcardTesting|Soundcard Testing]] page of the ALSA project to find out how to capture and play back sound.
 +
 +</WRAP>
 +<--
 +
 +----
 +===== Additional Resources =====
 +
 +All materials related to the use of the Zybo Z7 can be found on its [[..:start|Resource Center]].
 +
 +All materials related to the use of the Pcam 5C can be found on its [[add-ons:pcam-5c:start|Resource Center]].
 +
 +For additional and in-depth information about how Petalinux works please consult the  [[https://docs.xilinx.com/v/u/2020.1-English/ug1144-petalinux-tools-reference-guide|UG1144 v.2020.1]]
 +
 +For technical support, please visit the [[https://forum.digilent.com/forum/27-embedded-linux/|Embedded Linux]] section of the Digilent Forum.
 +
 +----
 +{{tag>project zybo-z7}}