echo/ulx3s_examples
#ULX3S
ulx3s_examplesのひとつ、シリアル通信でループバックを行う「echo」を試してみる。
https://github.com/lawrie/ulx3s_examples/tree/master/protocols/echo
ビルド & アップロード
以下のコマンドでビルドしてアップロード。オリジナルのビルド方法だとエラーが出るので、いろいろ試して以下の方法でビルドできることを確認できた。
code:sh
$ git clone git@github.com:lawrie/ulx3s_examples.git
$ cd ulx3s_examples/protocols/echo/
$ yosys -p "hierarchy -top top" -p "proc; opt" -p "synth_ecp5 -noccu2 -nomux -nodram -json toplevel.json" top.v uart_tx.v uart_rx.v
$ nextpnr-ecp5 --85k --json toplevel.json --lpf ulx3s_v20.lpf --textcfg ulx3s_out.config
$ ecppack ulx3s_out.config ulx3s.bit
$ fujprog ulx3s.bit
ループバックを確認
Ardinoのシリアルモニタで確認。一見いい感じに送受信できてそうだけど...
https://gyazo.com/444cf6e8108cfeb6df276e1f8610be15
複数文字を送ると取りこぼす...
https://gyazo.com/929220885cbc9867d97184b97a47baaf
別の方法、sttyとechoとcatでも試してみる。
まずは通信速度を設定。
code:sh
# 通信速度を設定
$ stty -f /dev/cu.usbserial-D00084 115200 raw
# 正しく通信速度が設定されたかを確認
$ /Users/thata% stty -f /dev/cu.usbserial-D00084
speed 115200 baud;
lflags: -icanon -isig -iexten -echo
iflags: -icrnl -ixon -ixany -imaxbel ignbrk -brkint
oflags: -opost -onlcr -oxtabs
cflags: cs8 -parenb
ターミナルをふたつ用意して、ひとつは受信。
code:sh
$ cat /dev/cu.usbserial-D00084
もうひとつのターミナルでは送信。
code:sh
$ cat > /dev/cu.usbserial-D00084
a
b
c
こちらも、1文字ならいい感じに送れるが、二文字以上は取りこぼしがち。