e-tipsmemo

ごった煮

zybo 割り込み② SDK, devicetree編

前回の続き
e-tipsmemo.hatenablog.com

SDK

VivadoでBitstreamがでたら。
File->Export Hardwareでhdfファイルを出力する。(Include bitstreamにチェックをいれる。)
File->Launch SDK

SDKの準備

Xilinx Wiki - Build Device Tree Blob

google:xilinx sdk device tree generator
あたりを参考にし、device treeを自動生成するツールを入れていおく。

Device Treeとその編集

File->New->Board Support Package
f:id:katakanan:20170409013859p:plain
にて、device_treeを選択してFinish

Overview->device_treeのbootargsに
console=ttyPS0,115200 root=/dev/ram rw earlyprintk rootwait devtmpfs.mount=1 earlycon earlycon earlycon
を入力。
(デフォルトのドライバの設定などもできるらしい?)
「OK」で必要なDeviceTreeが分割された状態で生成される。

Interruptの関係のプロパティは自動で入れてくれないので、自分て追記する。
zynq-7000.dtsiをみると、割り込みのコントローラーである
cortex-a9-gicが、intc: interrupt-controller@f8f01000となっている。
pl.dtsiの自分の追加した割り込み信号を発生するロジックのモジュール内に以下の文言を入れる。

interrupt-parent = <&intc>;
interrupts = <0 29 4>;

f:id:katakanan:20170409015147p:plain

devicetreeについては
Device Tree Usage - eLinux.org
など
interruptのプロパティの数字については
Solved: IRQF2P Interupt not being seen in driver when movi... - Community Forums
より、

For interrupts = < 0 29 4 >, 0 is defining it as a SPI ( general purpose ) interrupt, 29 is the LSB of IRQ_F2P ( TRM says 61, subtract 32 ), and 4 is level-high triggered.

(割り込み番号は29から順番?
次に割り込みのデバイスを入れたら30になると..)

このdtsをコンパイルし、dtbを作成する。

dtc -I dts -O dtb -o devicetree.dtb system-top.dts
FSBL, uImage, uramdisk.image.gz

digilentGithubリポジトリをcloneして
Linuxをビルド。
uImageを作成。
u-boot.elfを同様にして作成する。

一方SDKでは
File->New->Application Project
nameをfsblにしてnext。
Zynq FSBLを選択してFinish
FSBLがビルドされてfsbl.elfができていたら
プロジェクトを右クリックしてCreate Boot Image
Addで最後のパーティションにu-boot.elfを追加する。
Create Boot ImageでBoot.binが作られる。

uramdisk.image.gzはzedboardかどこかの別のプロジェクトに入っていたものを持ってきた。

(ramdiskを編集したいときはイメージをマウントする必要があるので
Bash On windowsだけではできなかった。。。)

  • boot.bin
  • devicetree.dtb
  • uramdisk.image.gz
  • uImage

これらが最低限必要なもの。

次はデバイスドライバ