9
By Abdulaziz A. Alasows King Abdulaziz City for Science and Technology

By Abdulaziz A. Alasows King Abdulaziz City for Science

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: By Abdulaziz A. Alasows King Abdulaziz City for Science

By Abdulaziz A. Alasows

King Abdulaziz City for Science and Technology

Page 2: By Abdulaziz A. Alasows King Abdulaziz City for Science

Hardware:

- AD-FMCOMMS4-EBZ.

- ZedBoard Rev D.

- Host PC: Ubuntu Linux 16.04.

Installed tools:

- Xilinx Vivado 2017.4.

- Xilinx SDK 2014.4.

- Petalinux 2017.4.

1. Create a Petalinux project by specifying the targeted board BSP.

(BSP for ZedBoard, ZC702, and ZC706 can be downloaded from Xilinx. Match versions with Petalinux tool!).

Ex:

2. Import hardware configuration Get the needed HDLs from analog devices for the specified boards (AD-FMCOMMS4-EBZ, ZedBoard) and get

HDF file by generating it from Vivado tool.

To initialize a Petalinux project with new hardware configuration:

Ex:

See ug1157 (v2017.4) page 10 for different commands.

A configuration windows shall pop up, we will be working with ADI kernel (xcomm_zynq) rather than Xilinx

kernel (linux-xlnx) in order to get the needed drivers for AD9361/AD9364 and others.

Open a new terminal (Ctrl+Alt+t) and download ADI kernel:

NOTE: xcomm_zynq kernel version is 4.9 which is compatible with petalinux 2017.4 (it expects 4.9 kernel

version). It would fail sanity check if you don’t. One can check kernel version by looking at the beginning of

the file “Makefile” in ADI kernel root. So make sure which branch you should clone from ADI linux.

Using popped window:

Linux Components Selection >> Linux Kernel

>> Choose “ext-local-src”.

>> External Linux-kernel local source settings.

>> Place path to downloaded ADI kernel.

plnx-proj-dir $ petalinux-config --get-hw-description=/opt/projs/zynq/hdls/zed_orig/zed_orig.sdk

plnx-proj-dir$ petalinux-config --get-hw-description=<PATH-TO-HDF-DIRECTORY>

$ petalinux-create -t project -n fmcomms4_zed -s bsp_file/avnet-digilent-zedboard-v2017.4-final.bsp

$ petalinux-create -t project -n <NAME> -s <BSP-SRC-FILE>

$ git clone -b xcomm_zynq --single-branch https://github.com/analogdevicesinc/linux.git

Page 3: By Abdulaziz A. Alasows King Abdulaziz City for Science

Save configurations.

3. Configure device tree.

All dts files can be found in “<adi-kernel-root>/arch/arm/boot/dts” (zynq only – arm).

Since we are using Zedboard and AD-FMCOMMS4-EBZ, we need (zynq-zed-adv7511-ad9364-fmcomms4.dts)

i. Open up the file “system-user.dtsi” found in (<plnx-proj-dir>/project-spec/meta-user/recipes-

bsp/device-tree/files) and copy the content of “zynq-zed-adv7511-ad9364-fmcomms4.dts” and place at

the end, as shown :

ii. Delete lines as shown:

iii. Copy the following dts files to (<plnx-proj-dir>/project-spec/meta-user/recipes-bsp/device-tree/files) –

why those files, see include statements in “zynq-zed-adv7511-ad9364-fmcomms4.dts”.

a. zynq-zed-adv7511.dtsi.

b. adi-fmcomms4.dtsi.

c. adi-fmcomms3-up-down-converter.dtsi.

Page 4: By Abdulaziz A. Alasows King Abdulaziz City for Science

iv. Edit “device-tree-generation_%.bbappend” found in (<plnx-proj-dir>/project-spec/meta-user/recipes-

bsp/device-tree) as shown:

Simply, we are including the previously copied files.

v. Replace “fpga_axi” in files (system-user.dtsi, zynq-zed-adv7511.dtsi) with “amba_pl”, in order to

overwrite node entry that is auto-generated by petalinux in file “pl.dtsi” found in (<plnx-proj-

dir>/components/plnx_workspace/device-tree/device-tree-generation) – Note: you need to build the

project to see it.

Page 5: By Abdulaziz A. Alasows King Abdulaziz City for Science

vi. Add to rx_dma and tx_dma in file “system-user.dtsi” (see thread) the following:

4. Configure kernel:

Note: The file “zynq_xcomm_adv7511_defconfig” will be loaded from <adi-kernel-root>/arch/arm/configs.

It is good idea to double check if kernel configured correctly by running:

[Device Drivers >> Industrial I/O support >> Analog to Digital Converter >> AD9361/AD9364] is checked.

Note: There are times I had to re-configure kernel (repeat step 4) after configuring rootfs because kernel lost its

configuration!

interrupt-parent = <&intc>;

plnx-proj-dir$ petalinux-config -c kernel --defconfig zynq_xcomm_adv7511_defconfig

plnx-proj-dir$ petalinux-config -c kernel

Page 6: By Abdulaziz A. Alasows King Abdulaziz City for Science
Page 7: By Abdulaziz A. Alasows King Abdulaziz City for Science

5. Build the project:

Note: I personally use sstate cache, which can be downloaded from Xilinx, in order build the project without

internet (faster for me). You need internet later in the step of adding libiio to petalinux rootfs.

6. Boot the petalinux image. There are different ways to boot petalinux image on hardware. I personally use tftpboot during embedded linux

development. See ug1144(v2017.4) to setup tftpboot.

You need also to setup tftp server see the following link here or search “setup tftpboot”

Note: You can skip Package Prebuilt image and in step 8 (ug1144-v2017.4 – page 37) run the following command

instead:

It is going to download the following

- bitstream <plnx-proj-root>/images/linux/system_top.bit

- fsbl <plnx-proj-root>/images/linux/zynq_fsbl.elf - U-Boot <plnx-proj-root>/images/linux/u-boot.elf.

Follow the remaining steps in ug1144(v2017.4) page 37.

7. Check IIO devices are found, in target linux terminal run the following:

8. To connect remotely to IIO Oscilloscope we need to install libiio to our root file system.

a. Create a new app:

The app will be at (<plnx-proj-dir>/project-spec/meta-user/recipes-apps/libiio).

b. Edit libiio.bb (download script) and copy the following:

plnx-proj-dir$ petalinux-build

plnx-proj-dir$ petalinux-boot --jtag --fpga --u-boot

root@avnet-digilent-zedboard-2017_4:~# grep "" /sys/bus/iio/devices/iio\:device*/name

plnx-proj-dir$ petalinux-create -t apps -n libiio --template install --enable

Page 8: By Abdulaziz A. Alasows King Abdulaziz City for Science

It is very important to change SRCREV if new commit have been made:

- Browse to Analog Device Libiio github.

https://github.com/analogdevicesinc/libiio

- Make sure the branch selected is “master” or else as long as you change it from the code (SRCBRANCH = "master") - Click commits.

- Choose the most recent commit.

- Copy hash on the link and paste it in SRCREV.

9. Build the project:

10. Boot the petalinux image (step 6).

11. Type “iio_info” or “iiod --version” to check if libiio is installed successfully.

DESCRIPTION = "Analog Devices Libiio"

LICENSE = "LGPLv2.1" LIC_FILES_CHKSUM = "file://COPYING.txt;md5=7c13b3376cea0ce68d2d2da0a1b3a72c" SRCREV = "6ecff5d46e1b12c2859f0b63a73282940e3402bb" SRCBRANCH = "master" PVBASE := "${PV}" FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}-${PVBASE}:" PV = "${PVBASE}.${SRCPV}" SRC_URI = "git://github.com/analogdevicesinc/libiio.git;protocol=https;branch=${SRCBRANCH}" S = "${WORKDIR}/git" inherit autotools cmake DEPENDS += "libxml2 bison flex ncurses avahi" PARALLEL_MAKE = ""

plnx-proj-dir$ petalinux-build

Page 9: By Abdulaziz A. Alasows King Abdulaziz City for Science

12. Connecting our device (ad9364) remotely to IIO Oscilloscope. a. Establish a network between target Linux and host PC.

i. Connect Ethernet cable.

ii. Configure IP for the target Linux:

iii. Configure IP for the host PC.

iv. Ping host IP:

b. Install IIO Oscilloscope on host PC and run it.

See: https://wiki.analog.com/resources/tools-software/linux-software/iio_oscilloscope

c. Start IIOD Daemon. Type in target Linux virtual terminal:

d. Connect to target hardware.

root@avnet-digilent-zedboard-2017_4:/# iiod &

root@avnet-digilent-zedboard-2017_4:/# ifconfig eth0 192.168.33.30 up