初期状態で、秋月で販売されているAE-UM232Rを接続すると次のようになる
code:stdout
hub 1-0:1.0: unable to enumerate USB device on port 1
usb 2-1: new full speedd USB device using cnc18xx-ohci and address 2
usb 2-1: New USB device found, idVendor=0403, idProduct=6001
usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 2-1: Product: FT232R USB UART
usb 2-1: Manufacturer: FTDI
usb 2-1: SerialNumber: AL0340DY
usb 2-1: configuration #1 chosen from 1 choice これ、普通にビルドしてサービス化すれば普通にいけそう
とりま以下にあるLinuxドライバーのarmv6向けのものを落としてくる
STEP1: libftd2xxのビルド
とりあえずgcluster-dev環境(githubにあげてあるdockerのやつ)を使って、
/env/ott/build-libftd2xx/v5/release/examples/BitModeあたりに
をビルド
source myenvでパス通してから
ビルドするときは、MakeFileに以下のようにクロスコンパイラーを使うように修正して
code:MakeFile
CC=$(CROSS_COMPILE)gcc
LD=$(CROSS_COMPILE)ld
dynamicな場所においてないのでallではなくmake bitmode-staticでビルド
あとはこのファイルを適当なUSBメモリー等に移して実行できる
STEP2:起動確認
FT232Rを刺さないで実行すると
code:shell
DSM232:/mnt/jffs2 # ./bitmode-static
FT_Open(0) failed (error 2).
Use lsmod to check if ftdi_sio (and usbserial) are present.
If so, unload them using rmmod, as they conflict with ftd2xx.
さして実行すると
code:shell
DSM232:/mnt/jffs2 # ./bitmode-static
Selecting asynchronous bit-bang mode.
Setting clock rate to 153600
Success: pin data is AA, as expected.
ということで、とりあえずbit-bang modeで使えるようになっているのが分かった。
STEP3: UIOを使ってgpioとして認識されるようにする
さて、ここからは/sys/class/gpioとかで出てくるようにしたいねぇ
kernel source dirは
code:shell
/env/ott/crisprelease/kernel/linux-2.6.32
ファイルUSB転送用
code:shell
cp -r ~/mydev/build-dsm232-docker/app/buildlog/build-libftd2xx/mymodule/ .
# gcluster側から
cp -r /mnt/usb/mymodule /mnt/jffs2/
code:shell
test: module license 'unspecified' taints kernel.
Disabling lock debugging due to kernel taint
Hello my module
Bye bye my module
---
gpioのunbindはどこだろう
code:shell
echo "gpiochip1" | tee -a /sys/bus/gpio/drivers/gpio_stub_drv/unbind
なぜかkernelで呼ばれちゃってるんだよなあ
code:shell
gpiochip1 - 4 lines:
line 0: unnamed kernel input active-high used line 1: unnamed kernel input active-high used line 2: unnamed kernel input active-high used line 3: unnamed kernel input active-high used unbindしてもgpiochip自体には変化がなく、、