LoginSignup
9
2

More than 5 years have passed since last update.

tinyFPGA-BX boardにTerminalのみでbuildとボードへの書き込みを行った

Posted at

tinyFPGA-BX boardを購入

最初書き込み方がよくわからなかったのと、tutorialがAtom使ってたが

結局Terminalから全部できたのでそれでいく

環境は
Mac OS Mojave
Python3.7.0 (書き込みソフトのインストールにPythonが必要です, 3系でないとだめかも)

基本的には下記公式なチュートリアル通り
TinyFPGA BX User Guide

ツールをインストールしていく

$ pip install -U apio
$ pip install tinyprog
$ apio install system scons icestorm iverilog
$ apio drivers --serial-enable


途中, apio install のところで

Warning: full platform does not match: darwin_x86_64                
         Trying OS name: darwin 

みたいなのでたけど一応

Package 'iverilog' has been successfully installed!

みたいな感じでsuccessfullyとは出てきたのでとりあえず大丈夫だった


TinyFPGA-BXボードを接続して認識するか確認

TinyFPGA-BXボードにマイクロUSB経由でMacに接続したら、ターミナルを開いてbootloaderが反応するか$ tinyprog --update-bootloaderと打ち込んでみて試してみる

まず、TinyFPGAをMacにUSBケーブルで接続していない場合は下記のように結果が出力されました

$ tinyprog --update-bootloader
    TinyProg CLI
    ------------
    Using device id 1d50:6130
    No port was specified and no active bootloaders found.
    Activate bootloader by pressing the reset button.


TinyFPGAを接続している場合は下記のように出た

$ tinyprog --update-bootloader

    TinyProg CLI
    ------------
    Using device id 1d50:6130
    Only one board with active bootloader, using it.
    All connected and active boards are up to date!

Atomのインストールは無視でよい

公式のチュートリアルではエディタとしてAtom使っていてそこから書き込みとかコマンド打てるって書いてあったが
自分がPythonをvenvで入れていて環境合わせるのが面倒だったのと

とりあえず書き込みやverilogファイルのコンパイルならTerminalつかったほうが早かったのでそのままおこなった

TinyFPGA BX Repositoryからファイルをダウンロードして解答する、適当なディレクトリに置いておく

apio_templateってフォルダが出てくるので、ターミナルでそこまでcdコマンドで移動しておく

apio_templateの中身は

$ tree apio_template
apio_template/
├── apio.ini
├── install_apio.bat
├── install_apio.sh
├── pins.pcf
└── top.v

のようになっているはずなので

apio_templateのディレクトリで$ apio build とコマンドを打つとbuildがはじまって、成功すると最後にSUCCESSみたいなのが出てくる

$ apio build
[Thu Feb  7 22:19:39 2019] Processing TinyFPGA-BX
--------------------------------------------------------------------------------------------------------------------------------------------
yosys -p "synth_ice40 -blif hardware.blif" -q top.v
arachne-pnr -d 8k -P cm81 -p pins.pcf -o hardware.asc -q hardware.blif
pins.pcf:41: warning: no port `PIN_1' in top-level module `top', 
...
...
icepack hardware.asc hardware.bin
======================================================= [SUCCESS] Took 3.88 seconds =======================================================

途中、PIN_1とかPIN_2とか使ってませんよ~みたいなwarningが出てくるけど無視して大丈夫です

build後のディレクトリ構成が下記

.
├── apio.ini
├── hardware.asc
├── hardware.bin
├── hardware.blif
├── install_apio.bat
├── install_apio.sh
├── pins.pcf
└── top.v

buildして出てきた hardware.bin ファイルを書き込みます


TinyFPGAをUSBケーブルでMacに接続して

$ tinyprog --update-bootloader
$ tinyprog -p hardware.bin

    TinyProg CLI
    ------------
    Using device id 1d50:6130
    Only one board with active bootloader, using it.
    Programming USB 20.5 with hardware.bin
    Programming at addr 028000
    Waking up SPI flash
    135100 bytes to program
    Erasing: 100%|████████████████████████████████████████████████████████████████████████████████████████| 135k/135k [00:00<00:00, 166kB/s]
    Writing: 100%|████████████████████████████████████████████████████████████████████████████████████████| 135k/135k [00:00<00:00, 194kB/s]
    Reading: 100%|████████████████████████████████████████████████████████████████████████████████████████| 135k/135k [00:00<00:00, 365kB/s]
    Success!

のように出てきたら書き込み成功!

TinyFPGA上のボード上LEDがいろいろなパターンで点滅開始したら成功です

蛇足: 必要なツールについて調べたこと

9
2
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
2