新增serial port (USB to serial port) 的使用於JK2410
From JK2410.org
JK2410預設提供一個serial port (ttyS0) 作為 console使用。如果想要將其他的serial port裝置接上JK2410,我們可以利用USB to Serial cable提供額外的serial port。
[編輯] USB to Serial cable
市售的USB to Serial cable應該都有辦法被linux內建的USB to Serial converter driver支援。本範例使用的cable 晶片為PL-2303。我們可以先將cable接上host (此範例為Ubuntu 7.10) 並用lsusb指令來查詢。
$lsusb ... Bus 005 Device 002: ID 0557:2008 ATEN International Co., Ltd UC-232A Serial Port [pl2303]
[編輯] 新增USB to Serial driver
我們必須要新增JK2410對USB的支援再增加USB to serial的驅動程式。 切換到kernel原始碼的目錄底下
$make menuconfig
勾選下列設定
USB support --->
<*> Support for USB
│--- USB Controllers
│<*> S3C2410 OHCI-compatible host interface support
|(1) Maximum port(s) of RootHu
...
│USB Serial Converter support --->
<*> USB Serial Converter support
<*> USB Prolific 2303 Single Port Serial Driver (EXPERIMENTAL)
儲存設定並退出menuconfig
$make dep;make Image
[編輯] USB to Serial on JK2410
將新編譯的kernel下載到JK2410。將USB to Serial cable接上JK2410並且開機即可看到USB to Serial Device被正確偵測到的訊息。
... usb.c: registered new driver usbdevfs usb.c: registered new driver hub uhci.c: USB Universal Host Controller Interface driver v1.1 usb-ohci.c: USB OHCI at membase 0xe9000000, IRQ 26 usb.c: new USB bus registered, assigned bus number 1 hub.c: USB hub found port #1 suspened! port #0 alived! hub.c: 1 port detected usb.c: registered new driver serial usbserial.c: USB Serial Driver core v1.4 usbserial.c: USB Serial support registered for PL-2303 pl2303.c: Prolific PL2303 USB to serial adaptor driver v0.9 ... hub.c: USB new device connect on bus1/1, assigned device number 2 usbserial.c: PL-2303 converter detected usbserial.c: PL-2303 converter now attached to ttyUSB0 (or usb/tts/0 for devfs)
我們可以使用ls -al /dev/usb/tts/0指令來確認
# ls -al /dev/usb/tts/0 crw------- 1 root root 188, 0 Jan 1 1970 /dev/usb/tts/0
恭喜你,你已經可以在你的程式當中藉由存取/dev/usb/tts/0與你的Serial device溝通。


