ZC702 Linux

Introduction

The purpose of this page is to describe how to use the ZC702 board with u-boot and Linux. The items on this page are intended to be specific details about the ZC702 rather than general u-boot / Linux information.

Linux

Board Support Package (BSP) Files

The Linux kernel for 3.0 kernel is using platform data to define a number of devices on the platform bus as many of the device drivers don't support device tree yet. The file arch/arm/mach-zynq/board_zc702.c contains the platform specific information for the board.

GPIOs and LEDs

As of 14.1 release, only the DS23 LED on the ZC702 is working with Linux. The Linux kernel is setup so that the GPIO can be used through the sysfs to control the LED.

Create a GPIO corresponding to MIO 10 and then configure GPIO 10 so that it is an output.

zynq> echo 10 > /sys/class/gpio/export
zynq> echo out > /sys/class/gpio/gpio10/direction

Turn on LED DS23 using the following command.

zynq> echo 1 > /sys/class/gpio/gpio10/value

Turn off LED DS23 using the following command.

zynq> echo 0 > /sys/class/gpio/gpio10/value

The following commands can be used to change the MIO 8 such that it can be used with GPIO to control the DS12 LED.

zynq> devmem 0xF8000008 32 0xDF0D
zynq> devmem 0xF8000720 32 0x1200

I2C Devices

The 14.1 release is not supporting these devices as the I2C mux is not setup in the default kernel configuration. The top of the Linux kernel tree from Xilinx is supporting I2C on the ZC702 now.

All of the following devices are connected to the I2C bus through a 1:8 mux/switch. I2C Bus 0 is the mux

I2C EEPROM

The I2C EEPROM can be read and written from sysfs such that is can be used programmatically or from a bash script. The device is on the 3rd virtual I2C bus off of the mux.

View the contents of the 1KB EEPROM using the following command.

zynq> hexdump /sys/bus/i2c/devices/3-0054/eeprom

A 1KB data file of random data can be generated and then written to the I2C EEPROM using the following command.

zynq> dd if=/dev/urandom of=/data.bin bs=1K count=1
zynq> cat /data.bin > /sys/bus/i2c/devices/3-0054/eeprom

The contents of the I2C EEPROM can be read back and compared to the data written in the previous command to verify it was successful.

zynq> cat /sys/bus/i2c/devices/3-0054/eeprom > /readback.bin
zynq> diff /readback.bin /data.bin

I2C Clock Generator (SI570)

There is an SI570 I2C clock generator on the board that can be used to generate a clock for designs in the programmable logic (PL). This device is on the 1st virtual I2C bus off of the mux.

The driver for this device is based on a driver that was in the open source community but was never accepted as it is a driver located in drivers/misc. Xilinx is supporting this driver to allow testing on the ZC702.

The driver provides an interface in sysfs to setup the frequency. The following command can be used to get the frequency that the device is generating.

zynq> cat /sys/bus/i2c/devices/1-005d/frequency

The following command can be used to set the frequency of the clock that the device is to generate.

zynq> echo 10000000 > /sys/bus/i2c/devices/1-0050/frequency

Real Time Clock (RTC)

A real time clock device is located on the I2C bus. The device is on the 5th virtual I2C bus off of the mux.
The following commands can be used to read the date and time from the RTC.

zynq> cat /sys/bus/i2c/devices/5-0051/rtc/rtc0/date
zynq> cat /sys/bus/i2c/devices/5-0051/rtc/rtc0/time

Networking

The network is setup by default with a static IP address as described on Zynq Release.
The network supports 10/100/1000 rates.

QSPI Flash Memory

The QSPI flash memory on the board can be read and written thru the MTD file system of Linux. The partitions have been setup in the BSP as the device tree was not supported for this in the 3.0 kernel.

The following command displays the partitions for the QSPI flash memory.

zynq> cat /proc/mtd

MTD devices are setup for each of the partitions with block (/dev/mtdblockX) and character devices (/dev/mtdX).
The prebuilt images for a release can be written from the SD card to the QSPI easily. The following command mounts the SD card into the /mnt directory so that files on it are accessible.

zynq> mount /dev/mmcblk0 /mnt

Note: Before proceeding, please note that the partitions used in the following sections could be different based on the release such that the correct partition (mtdX) should be specified.

Copy the images (FSBL/u-boot, Linux kernel, the device tree, and the ramdisk) from the SD card to the QSPI flash memory partitions. The flashcp command erases the flash, writes it, and verifies it. After the following command are completed, the board can be booted from QSPI flash memory after setting the boot mode jumpers.

zynq> flashcp -v BOOT.BIN /dev/mtd0
zynq> flashcp -v zImage /dev/mtd2
zynq> flashcp -v devicetree.dtb /dev/mtd3
zynq> flashcp -v ramdisk8M.image.gz /dev/mtd6

The following command will umount the SD card.

zyqn> umount /mnt

The QSPI memory can also be accessed as a block device from Linux.

SD Card

The SD card is accessible thru the MMC subsystem of Linux.

The following command will format the SD card with a FAT file system and then mount it. Note that any files contained on the SD card will be lost. The SD card can not be mounted already as done in previous commands.

zynq> mkdosfs /dev/mmcblk0
zynq> mount /dev/mmcblk0 /mnt

The following commands copy each MTD partition from QSPI flash memory onto the SD card assuming that the QSPI flash memory was previously written with the files as done in the QSPI flash memory section above.

zynq> cp /dev/mtdblock0 /mnt/BOOT.BIN
zynq> cp /dev/mtdblock2 /mnt/zImage
zynq> cp /dev/mtdblock3 /mntdevicetree.dtb
zynq> cp /dev/mtdblock6 /mnt/ramdisk8M.image.gz
zynq> sync

The board can now be rebooted in SD boot mode and it should boot into Linux. Note that the files that were created are the size of the MTD partition from which they were read.

Unmount the SD card using the following command.

zynq> umount mnt

USB Host

The default setup for the USB port is host mode based on the jumpers. A USB memory stick is the easiest way to exercise the functionality. A USB memory stick emulates a SCSI device in Linux using device nodes /dev/sdX where the 1st device is /dev/sda.

The following commands will format a USB memory stick which is plugged into the USB port with a FAT file system. Note that any files contained on the USB memory stick will be lost.

zynq> mkdosfs /dev/sda
zynq> mount /dev/sda /mnt

Files can be copied from the SD card to the USB memory stick using the following commands.

zynq> mkdir /sdmnt
zynq> mount /dev/mmcblk0 /sdmnt
zynq> cp /sdmnt/<file name>  /mnt/<file name>
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License