debian linux on zynq (xilinx arm-soc fpga) setup flow (vivado 2015.4)

98
Debian Linux on Zynq Setup Flow (Version March 2016 for Vivado 2015.4) Shinya Takamaeda-Yamazaki Nara Institute of Science and Technology (NAIST) E-mail: shinya_at_is.naist.jp

Upload: shinya-takamaeda-y

Post on 08-Jan-2017

5.989 views

Category:

Technology


14 download

TRANSCRIPT

Page 1: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Debian Linux on ZynqSetup Flow(Version March 2016 for Vivado 2015.4)

Shinya Takamaeda-YamazakiNara Institute of Science and Technology (NAIST)

E-mail: shinya_at_is.naist.jp

Page 2: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Goal of this tutorialn Constructing Zynq system with GPIO I/F and Debian Linux

l GPIO devices (LED and SW) are accessed from software on CPU

l (User IP can be added on PL part, if needed)

Shinya T-Y, NAIST 2

ARMCore

L1L2

DRAMI/F

ARMCore

L1

PS

PL

GPIO User IP

LED SW

FPGA

DRAM

GP

ACP HP

Page 3: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Setup flow for Debian Linux on Zynqn Download and setup of FPGA board file (for Zybo)

n Hardware development on Vivado

n U-boot SPL and U-boot (only once)

n Linux kernel (only once) and device tree (only once)

n Debian root file system (only once)n Setup SD card (only once)

n Boot from SD card

n CMA (Continuous memory allocator) driver (only once)

n Run test applications

n How to replace the bitstream

Shinya T-Y, NAIST 3

Page 4: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Reference platformn FPGA board: Digilent Zybo (Zynq XC7Z010)

l Almost same flow can be applied to ZedBoard and ZC706

n FPGA tool: Xilinx Vivado 2015.4l License is "Web Pack"

n Target OS: Debian 8.0 (Jessie)

n Host OS: Ubuntu 14.04

Shinya T-Y, NAIST 4

Page 5: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Download and setup FPGA board file

Shinya T-Y, NAIST 5

Page 6: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

FPGA board file for Zybon Zybo's board setting (I/O pins, …) is not included in Vivado.

Download and install it from Digilent web pagel https://reference.digilentinc.com/vivado:boardfiles/

l Follow the procedure on the web page

Shinya T-Y, NAIST 6

Page 7: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Install board file into Vivado systemn Unzip the download file and copy it into Vivado system

Shinya T-Y, NAIST 7

cp -a vivado-boardfiles-master/new/boardfiles/* ¥/opt/Xilinx/Vivado/2015.4/data/boards/board_files/

Page 8: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Hardware development on Vivado

Shinya T-Y, NAIST 8

Page 9: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Hardware development on Vivadon Setup PATH

l If you use bash (default) or zsh

l If you use tcsh

n Create a working directory and launch Vivado

Shinya T-Y, NAIST 9

source /opt/Xilinx/Vivado/2015.4/settings64.sh

source /opt/Xilinx/Vivado/2015.4/settings64.csh

cd ~/mkdir zybo_debianmkdir zybo_debian/hwcd zybo_debian/hwvivado &

Page 10: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Create a new project

Shinya T-Y, NAIST 10

Page 11: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Shinya T-Y, NAIST 11

Page 12: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Shinya T-Y, NAIST 12

Page 13: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Shinya T-Y, NAIST 13

Page 14: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Shinya T-Y, NAIST 14

Page 15: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Shinya T-Y, NAIST 15

Page 16: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Shinya T-Y, NAIST 16

Page 17: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Shinya T-Y, NAIST 17

Select your board

Page 18: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Shinya T-Y, NAIST 18

Page 19: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Add a block design

Shinya T-Y, NAIST 19

Page 20: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Shinya T-Y, NAIST 20

Page 21: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Add IP

Shinya T-Y, NAIST 21

Page 22: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Add CPU

Shinya T-Y, NAIST 22

Page 23: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Add GPIO for LED and switch

Shinya T-Y, NAIST 23

Page 24: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Customize CPU

Shinya T-Y, NAIST 24

Double click

Page 25: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Connect to DRAM

Shinya T-Y, NAIST 25

Page 26: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Customize GPIO

Shinya T-Y, NAIST 26

Double click

Page 27: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Connect to LED and switches

Shinya T-Y, NAIST 27

Page 28: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Connect CPU and GPIO

Shinya T-Y, NAIST 28

Page 29: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Connect S_AXI and GPIO by auto

Shinya T-Y, NAIST 29

Page 30: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Connect LED and GPIO

Shinya T-Y, NAIST 30

Page 31: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Connect switches and GPIO2

Shinya T-Y, NAIST 31

Page 32: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Complete HW block design

Shinya T-Y, NAIST 32

Page 33: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Modify address value

Shinya T-Y, NAIST 33

0x43c0_0000 is recommended

Page 34: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Validate design

Shinya T-Y, NAIST 34

Page 35: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Create HDL wrapper

Shinya T-Y, NAIST 35

Then right click the block design,and select "Create HDL Wrapper"

Page 36: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Shinya T-Y, NAIST 36

Page 37: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Generate Bitstream

Shinya T-Y, NAIST 37

Click "Generate Bitstream"

Page 38: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Bitstream has been Generated

Shinya T-Y, NAIST 38

Page 39: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Export Hardware with Bitstream (only once)

n This step is required only once for U-boot compilation

Shinya T-Y, NAIST 39

File -> Export -> Export Hardware

Page 40: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Export Hardware with Bitstream (only once)

Shinya T-Y, NAIST 40

Page 41: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Prepare "ps7_init_gpl.{c,h}" by using "hsi" (only once, for Zybo)n Go to the SDK directory

n Launch "hsi"

n Open HW design

n Generate application filesl Type this command in 1 line!

n Complete!

Shinya T-Y, NAIST 41

cd ~/zybo_debian/hw/zybo/zybo.sdk

hsi

open_hw_design zybo_wrapper.hdf

generate_app -hw zybo_wrapper -os standalone -procps7_cortex9_0 -app zynq_fsbl -sw fsbl -dir zynq_fsbl

quit

Page 42: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Prepare "ps7_init_gpl.{c,h}" by using "hsi" (only once, for Zybo)n Example in PNG

n If you use Zybo or other special boards unlike ZedBoardand ZC706, you must create ps7_init_gpl.*l ps7_init_gpl.* for ZedBoard and ZC706 are already included in U-

boot as default

n Generated "ps7_init_gpl.{c,h}" files are used later for building U-boot

Shinya T-Y, NAIST 42

Page 43: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Hardware development completedn Your bitstream can be found at

zynq_debian/hw/zybo/zybo.runs/impl_1/zybo_wrapper.bit

n Copy the bitstream to somewhere (BOOT)

Shinya T-Y, NAIST 43

mkdir ~/zybo_debian/BOOTcp ~/zybo_debian/hw/zybo/zybo.runs/impl_1/zybo_wrapper.bit ~/zybo_debian/BOOT

Page 44: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

U-boot SPL and U-boot

Shinya T-Y, NAIST 44

Page 45: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Download U-boot and modify itn Create a new working directory for software

n Clone from GitHub

n Checkout the tagged version for Vivado 2015.4

n Edit "zynq-common.h"

Shinya T-Y, NAIST 45

mkdir ~/zybo_debian/swcd ~/zybo_debian/sw

git clone https://github.com/Xilinx/u-boot-xlnx.git

emacs include/configs/zynq-common.h

cd u-boot-xlnxgit checkout xilinx-v2015.4

Page 46: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Edit "CONFIG_EXTRA_ENV_SETTINGS" and "CONFIG_BOOTCOMMAND"n CONFIG_EXTRA_ENV_SETTINGS

n CONFIG_BOOTCOMMAND

Shinya T-Y, NAIST 46

/* Default environment */#define CONFIG_EXTRA_ENV_SETTINGS ¥

"fpgaload=load mmc 0 0x1000000 zynq.bit¥0 " ¥"fpgaboot=fpga loadb 0 0x1000000 $filesize¥0 " ¥"bootimage=uImage¥0" ¥"fdtaddr=0x00000100¥0" ¥"fdtimage=devicetree.dtb¥0" ¥"loadaddr=0x8000¥0" ¥"mmcloadcmd=fatload¥0" ¥"mmcloadpart=1¥0" ¥"mmcroot=/dev/mmcblk0p2¥0" ¥"mmcload=mmc rescan; fatload mmc 0:1 ${loadaddr} ${bootimage}; fatload mmc 0:1 ${fdtaddr} ${fdtimage}¥0" ¥"mmcboot=setenv bootargs console=ttyPS0,115200 root=${mmcroot} rw rootwait uio_pdrv_genirq.of_id=dmem-uio; bootm ${loadaddr} - ${fdtaddr}¥0" ¥DFU_ALT_INFO

/* default boot is according to the bootmode switch settings */#define CONFIG_BOOTCOMMAND "run fpgaload; run fpgaboot; run mmcload; run mmcboot"

Page 47: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Edit "CONFIG_EXTRA_ENV_SETTINGS" and "CONFIG_BOOTCOMMAND"n Example in PNG (Check carefully!)

Shinya T-Y, NAIST 47

Page 48: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Build U-bootn Setup PATH

l If you use bash (default) or zsh

l If you use tcsh

n Setup some parametersl If you use bash or zsh

l If you use tcsh

Shinya T-Y, NAIST 48

source /opt/Xilinx/Vivado/2015.4/settings64.sh

source /opt/Xilinx/Vivado/2015.4/settings64.csh

export CROSS_COMPILE=arm-xilinx-linux-gnueabi-export ARCH=arm

setenv CROSS_COMPILE arm-xilinx-linux-gnueabi-setenv ARCH arm

Page 49: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Build U-bootn If you use Zybo (or an other board that its fsbl software

source code is NOT included in "u-boot-xlnx/board/zynq/"), copy "ps7_init_gpl.{c,h}" from SDK directory to "u-boot-xlnx/board/xilinx/zynq/custom_hw_platform"l Files for ZedBoard and ZC706 are included as default

You can find these files, such like"u-boot-xlnx/board/xilinx/zynq/zed_hw_platform"

n At "u-boot-xlnx"

Shinya T-Y, NAIST 49

cp ~/zybo_debian/hw/zybo/zybo.sdk/ps7_init_gpl.* ¥board/xilinx/zynq/custom_hw_platform

Page 50: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Build U-bootn At u-boot-xlnx

l If you youse other boards, such as ZedBoard, please find its corresponding config command at u-boo-xlnx/configs, such as "configs/zynq_zed_defconfig"

n Then, make

Shinya T-Y, NAIST 50

make zynq_zybo_defconfig

make

Page 51: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Build U-bootn Example in PNG

n "u-boot.img" and "boot.bin" have been generated at u-boot-xlnx

Shinya T-Y, NAIST 51

Page 52: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

U-boot has been successfully generated

n Copy two files into somewhere

n Boot order is(1) U-boot SPL -> (2) U-boot -> (3) Linux Kernel

n Even if you want to change the hardware design, no build of U-boot is required anymore

Shinya T-Y, NAIST 52

cp u-boot.img ~/zybo_debian/BOOT/cp boot.bin ~/zybo_debian/BOOT/

Page 53: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Linux kernel

Shinya T-Y, NAIST 53

Page 54: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Download Linux kerneln Move to the software directory

n Clone from GitHub

n Checkout the tagged version for Vivado 2015.4

Shinya T-Y, NAIST 54

cd ~/zybo_debian/sw

git clone https://github.com/Xilinx/linux-xlnx.git

cd linux-xlnxgit checkout xilinx-v2015.4.01

Page 55: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Edit device tree filen Edit "zynz-zybo.dts"

l if you use other device, please find the corresponding device tree file in "linux-xlnx/arch/arm/boot/dts/"

n Edit it to addUIO(user-space I/O)interfaces

Shinya T-Y, NAIST 55

emacs arch/arm/boot/dts/zynq-zybo.dtsaxis0 {

compatible = "dmem-uio";reg = < 0x43c00000 0x010000 >; // (address, size)

};

axis1 {compatible = "dmem-uio";reg = < 0x43c10000 0x010000 >; // (address, size)

};

axis2 {compatible = "dmem-uio";reg = < 0x43c20000 0x010000 >; // (address, size)

};

axis3 {compatible = "dmem-uio";reg = < 0x43c30000 0x010000 >; // (address, size)

};

axis4 {compatible = "dmem-uio";reg = < 0x43c40000 0x010000 >; // (address, size)

};

axis5 {compatible = "dmem-uio";reg = < 0x43c50000 0x010000 >; // (address, size)

};

axis6 {compatible = "dmem-uio";reg = < 0x43c60000 0x010000 >; // (address, size)

};

axis7 {compatible = "dmem-uio";reg = < 0x43c70000 0x010000 >; // (address, size)

};

Insert these lines

Page 56: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Configure the kernel optionsn At linux-xlnx, load the default options

n Configure the kernel options by menuconfig

Shinya T-Y, NAIST 56

make xilinx_zynq_defconfig

make menuconfig

Page 57: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Device Drivers->

Shinya T-Y, NAIST 57

Page 58: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Device Drivers->Userspace I/O drivers

Shinya T-Y, NAIST 58

Page 59: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Enable UIO

Shinya T-Y, NAIST 59

Page 60: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Device Drivers->Generic Driver Options

Shinya T-Y, NAIST 60

Page 61: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Edit Size in Mega Bytes of CMA

Shinya T-Y, NAIST 61

Set 256

Page 62: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

(Option) File systems->Network File Systems

Shinya T-Y, NAIST 62

Page 63: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Check "linux-xlnx/.config"n At linux-xlnx

n Especially, check the size of CMA

Shinya T-Y, NAIST 63

less .config

Page 64: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Build Linux kernel and device treen Setup PATH

l If you use bash (default) or zsh

l If you use tcsh

n Build the kernel image and device tree

Shinya T-Y, NAIST 64

export PATH=~/zybo_debian/sw/u-boot-xlnx/tools:$PATH

make uImage LOADADDR=0x00008000

setenv PATH ~/zybo_debian/sw/u-boot-xlnx/tools:$PATH

Page 65: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Build Linux kernel and device treen Example in PNG

Shinya T-Y, NAIST 65

Page 66: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Linux kernel and device tree have been successfully generatedn Copy uImage and zynq-zybo.dtb to somewhere

n Even if you want to change the hardware design, no build of Linux kernel is required anymorel Device tree should be modified, if you change different address

mapping

Shinya T-Y, NAIST 66

cp arch/arm/boot/uImage ~/zybo_debian/BOOTcp arch/arm/boot/dts/zynq-zybo.dtb ~/zybo_debian/BOOT

Page 67: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Debian root file sytem

Shinya T-Y, NAIST 67

Page 68: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Setup environmentn Setup parameters (on bash)

n Build the root file system in $targetdir (= rootfs)

Shinya T-Y, NAIST 68

cd ~/zybo_debiansudo apt-get install qemu-user-static debootstrap binfmt-supportexport targetdir=rootfsexport distro=jessie

mkdir $targetdirsudo debootstrap --arch=armhf --foreign $distro $targetdirsudo cp /usr/bin/qemu-arm-static $targetdir/usr/binsudo cp /etc/resolv.conf $targetdir/etcsudo chroot $targetdir

Page 69: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Build rootfs with QEMUn Setup APT

Shinya T-Y, NAIST 69

distro=jessieexport LANG=C/debootstrap/debootstrap --second-stage

cat <<EOT > /etc/apt/sources.listdeb http://ftp.jp.debian.org/debian $distro main contrib non-freedeb-src http://ftp.jp.debian.org/debian $distro main contrib non-freedeb http://ftp.debian.org/debian $distro-updates main contrib non-freedeb-src http://ftp.debian.org/debian $distro-updates main contrib non-freedeb http://security.debian.org/debian-security $distro/updates main contrib non-freedeb-src http://security.debian.org/debian-security $distro/updates main contrib non-freeEOT

cat << EOT > /etc/apt/apt.conf.d/71-no-recommendsAPT::Install-Recommends "0";APT::Install-Suggests "0";EOT

Page 70: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Build rootfs with QEMUn Install applications and setup root password

n IP address

Shinya T-Y, NAIST 70

apt-get updateapt-get install locales dialog dpkg-reconfigure localesapt-get install openssh-server ntpdate resolvconf sudo less hwinfo ntp tcsh zshpasswd

echo <<EOT >> /etc/network/interfacesauto eth0iface eth0 inet statichwaddress ether 00:0a:35:00:02:00address 192.168.0.100netmask 255.255.255.0gateway 192.168.0.1dns-nameservers 192.168.0.1EOT

Page 71: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Build rootfs with QEMUn resolve.conf

n sshd_config

l “PasswordAuthentication yes”

Shinya T-Y, NAIST 71

echo <<EOT >> /etc/resolv.confnameserver 192.168.0.1EOT

vi /etc/ssh/sshd_config

Page 72: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Build rootfs with QEMUn Add a new admin user

l Enter, enter, …

n Edit sudo user

l Edit like below

Shinya T-Y, NAIST 72

adduser username

editor=vi visudo

# User privilege specificationroot ALL=(ALL:ALL) ALLusername ALL=(ALL:ALL) ALL

Page 73: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Build rootfs with QEMUn ntp.conf

n Insert a new server (in my case "ntp.nict.jp")

Shinya T-Y, NAIST 73

vi /etc/ntp.conf

#server 0.debian.pool.ntp.org iburst#server 1.debian.pool.ntp.org iburst#server 2.debian.pool.ntp.org iburst#server 3.debian.pool.ntp.org iburst

server ntp.nict.jp

Page 74: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Build rootfs with QEMUn rc.local

n Insert 3 lines for NTP setup

Shinya T-Y, NAIST 74

vi /etc/rc.local

service ntp stopntpdate ntp.nict.jpservice ntp startexit 0

Page 75: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Build rootfs with QEMUn fstab

n Insert 1 line (to mount 1st partition of SD card)

n Create a new directory for 1st partition of SD card

Shinya T-Y, NAIST 75

vi /etc/fstab

/dev/mmcblk0p1 /sdcard auto defaults 0 0

mkdir sdcard

Page 76: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Build rootfs with QEMUn Permission rule of /dev/uio (Userspace I/O)

n Permission rule of /dev/xdevconfig (Configuration port)

Shinya T-Y, NAIST 76

echo KERNEL=="uio*", MODE="0666",OWNER="root",GROUP="root" >> /etc/udev/rules.d/50-uio.rules

echo KERNEL=="xdevcfg", MODE="0666",OWNER="root",GROUP="root" >> /etc/udev/rules.d/50-xdevcfg.rules

Page 77: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Build rootfs with QEMUn Hostname, etc.

n Install applications (if you need)

n Finish

Shinya T-Y, NAIST 77

echo debian-zynq > /etc/hostnameecho T0:2345:respawn:/sbin/getty -L ttyS0 115200 vt1000 >> /etc/inittabecho 127.0.0.1 debian-zynq >> /etc/hosts

apt-get install build-essentialapt-get install screen bash-completion timeapt-get install python python-pip python3 python3-pipapt-get install nis nfs-common

exitsudo rm -f $targetdir/usr/bin/qemu-arm-static

Page 78: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Setup SD card

Shinya T-Y, NAIST 78

Page 79: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Format SD cardn Prepare SD card (> 8GB)

n Install and launch gparted

n Setup 2 partitionsl BOOT (64MB, FAT32, with "bootable" flag)

ü 4MB empty space ahead

l rootfs (rest all, ext4)

Shinya T-Y, NAIST 79

sudo apt-get install gparted -ysudo gparted &

empty(4MB)

BOOT(64MB, FAT32, bootable)

rootfs(rest, ext4)

Page 80: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Copy the created files into the SD cardn Mount the formatted SD card

l /media/yourname/BOOT and /media/yourname/rootfs

n Copy bitstream, U-boot, Linux kernel, and device tree

n Copy rootfs

n Unmount BOOT and rootfs

Shinya T-Y, NAIST 80

cp ~/zybo_debian/BOOT/boot.bin /media/yourname/BOOT/cp ~/zybo_debian/BOOT/u-boot.img /media/yourname/BOOT/cp ~/zybo_debian/BOOT/zybo_wrapper.bit /media/yourname/BOOT/zynq.bitcp ~/zybo_debian/BOOT/uImage /media/yourname/BOOT/cp ~/zybo_debian/BOOT/zynq-zybo.dtb /media/yourname/BOOT/devicetree.dtb

sudo cp -a ~/zybo_debian/rootfs/* /media/yourname/rootfs/

Page 81: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Boot from SD card

Shinya T-Y, NAIST 81

Page 82: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Jumper pin (Zybo): Set SD boot

Shinya T-Y, NAIST 82

Page 83: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Jumper pin (ZedBoard)

Shinya T-Y, NAIST 83

Page 84: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Boot system from SD cardn Connect Zybo to network

l Or connect UART port to the host PC

n Insert SD card and power-on

n Login via SSH (type password)

n Or login via UART: type username and password

Shinya T-Y, NAIST 84

ssh username192.168.0.100

Page 85: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Time zone and localen Change the time zone

l In my case, Asia -> Tokyo

n Change the locale

l Select "en_US.UTF-8", "ja_JP.UTF-8", and "ja_JP.EUC-JP"

l Then select "en_US.UTF-8" as default

n Reboot

Shinya T-Y, NAIST 85

(on zynq) sudo dpkg-reconfigure tzdata

(on zynq) sudo dpkg-reconfigure locales

(on zynq) sudo reboot

Page 86: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

CMA (Continuous memory allocator) driver

Shinya T-Y, NAIST 86

Page 87: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Copy linux-xlnx into the SD cardn Mount the formatted SD card

l /media/yourname/BOOT and /media/yourname/rootfs

n Copy linux-xlnx into rootfs

n Create symbolic link to "linux"

n Download "udmabuf" from GitHub

n Remove SD card and boot again from SD card

Shinya T-Y, NAIST 87

sudo cp -a ~/zybo_debian/sw/linux-xlnx /media/yourname/rootfs/usr/src/linux

sudo ln -s /media/yourname/rootfs/usr/src/linux /media/yourname/rootfs/usr/src/kernel

git clone https://github.com/shtaxxx/udmabuf.gitsudo mkdir /media/yourname/rootfs/driverssudo cp -a udmabuf /media/yourname/rootfs/drivers/

Page 88: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Build CMA drivern Login

n Compile kernel modules

n Compile CMA driver

Shinya T-Y, NAIST 88

(on zynq) cd /usr/src/kernel(on zynq) sudo make modules_prepare

(on zynq) cd /drivers/udmabuf(on zynq) sudo make(on zynq) sudo cp udmabuf.ko /drivers/(on zynq) sudo cp settings/setup_udmabuf.sh /drivers/

Page 89: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Modify /etc/rc.local for CMA drivern Edit /etc/rc.local

n Insert 1 line before "exit 0"

n Reboot

Shinya T-Y, NAIST 89

sh /drivers/setup_udmabuf.shexit 0

(on zynq) sudo vi /etc/rc.local

(on zynq) sudo reboot

Page 90: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Run test applications

Shinya T-Y, NAIST 90

Page 91: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Download applications and libraryn Download "zynq-linux" from GitHub

n Copy zynq-linux to Zynq system

l Type password

n Login on Zynq and go to zynq-linux/sample

Shinya T-Y, NAIST 91

(on zynq) cd zynq-linux/sample

git clone https://github.com/PyHDI/zynq-linux.git

scp -r zynq-linux [email protected]

Page 92: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Run GPIO testn Compile "axis_test.c" and run it

l LED pattern is changed

l The value of switches is read

Shinya T-Y, NAIST 92

(on zynq) gcc -O2 -I ../lib/ -o axis.out axis_test.c(on zynq) ./axis.out 15

write: 15read: 1

Page 93: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Run CMA testn Compile "cma_test.c" and run it

n RUN MODE 0: No CMA

n RUN MODE 1-3: CMAl 1: Cache Enabled

l 2: Cache Disabled

l 3: Cache Disabled, Write-merged

Shinya T-Y, NAIST 93

(on zynq) gcc -O2 -I ../lib/ -o cma.out cma_test.c(on zynq) ./cma.out 10000000 0(on zynq) ./cma.out 10000000 1(on zynq) ./cma.out 10000000 2(on zynq) ./cma.out 10000000 3

Page 94: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

How to replace the bitstream

Shinya T-Y, NAIST 94

Page 95: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Method1: Replace zynq.bit in /sdcard/n The bitstream on SD card can be replaced on host PC

n Since 1st partition of SD card is mounted on /sdcard/, the bistream can be replaced directly by Zynq software

n No modifications of U-boot and Linux kernel are required

n If you don't chage the address mapping for GPIO, no modification of device tree is required

Shinya T-Y, NAIST 95

(on zynq) sudo cp new_zynq.bit /sdcard/zynq.bit(on zynq) sudo reboot

Page 96: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Method2: Reconfigure via /dev/xdevcfg

n Logic part (PL) can be dynamically changed from SW

n If you change the CPU settings, such as frequency, port configuration, etc., this flow is not perfect.Replace "zynq.bit" on SD card and reboot, instead of this flow

Shinya T-Y, NAIST 96

(on zynq) cat new_zynq.bit > /dev/xdevcfg

Page 97: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Reference

Shinya T-Y, NAIST 97

Page 98: Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)

Referencen Yet Another Guide to Running Linaro Ubuntu Linux Desktop

on Xilinx Zynq on the ZedBoardl https://fpgacpu.wordpress.com/2013/05/24/yet-another-guide-to-

running-linaro-ubuntu-desktop-on-xilinx-zynq-on-the-zedboard/

n Building a pure Debian armhf rootfsl https://blog.night-shade.org.uk/2013/12/building-a-pure-debian-

armhf-rootfs/

n FPGA Magazine (No.12, March 2016)l http://www.kumikomi.net/fpga/contents/0012.php

Shinya T-Y, NAIST 98