USB Device
Pic Ref: http://www.geekalerts.com/usb-missile-launcher-with-webcam/
- 上圖是我在找Usb Driver時看到的Application,呵呵...不知道準不準就是.
- 拉回主題.
底下用Usb Lib來做到Remote Control or Device Configure.
可應用的範圍有 JTAG debug, Erase Flash.....
可參考 Print Port Control 2 JTAG control
http://funningboy.blogspot.com/2010/02/print-port-control.html
http://funningboy.blogspot.com/2010/02/jtag.html
- 準備工具
libusb-win32
http://libusb-win32.sourceforge.net/
安裝流程就請參考底下
download, 且安裝
libusb-win32-filter-bin-0.1.12.2.exe
底下有個測試程式,會幫你Detected 目前的Usb Device, Test Program
下載測試檔
libusb-win32-device-bin-0.1.12.2.tar.gz
這邊會有compiler好的Dll, 跟Driver, 把bin/libusb0.dll 放到 windows/system32 底下,
libusb0.sys 放到 windows/system32/driver底下.
Cygwin + Mingw( cross compiler)
Cygwin為模擬Linux的環境, Mingw 為Windows 的 gcc/g++ compiler. 雖然Cygwin 內建有 gcc/g++ compiler,但是那個是針對Linux Based的.我們現在是用Cygwin 來模擬Linux環境, 實際再run的時候, 最底層的Protocl 還是Windows Based, Cygwin 只是個Wrapper用 DLL來溝通.
安裝流程
下載Cygwin (略過) 請記的環境變數 Path的部分要加入系統變數中
Default : /usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin..
可鍵入
% echo $PATH
確定gcc / g++ version
% gcc -v
確保Mingw 的Path 有被安裝進去
Ref : http://www.mingw.org/wiki/FAQ
PS: 如果你要自己compiler 出DLL檔的話, 可以下載src 資料夾.
libusb-win32-src-0.1.12.2.tar.gz
解壓之後,把makefile內的 -mno-cygwin 拿掉, 雖然 -mno-cygwin 會告訴gcc/g++ 現在是用Mingw來當compiler, 但是我用這個指令時會fail. 之後就鍵入
%make
....
會產生 libusb0.dll, libusb0.sys ....
就我們之前用Binary安裝的檔案.
- 結果
在libusb-win32-src-0.1.12.2底下有個tests的資料夾,用裡面的sample當例子
鍵入
%gcc -O2 -Wall -o DLSPD.exe -I./src testlibusb.c -s -L. -lusb -lgdi32 -luser32 -lcfgmgr32 -lsetupapi -lcomctl32
%./DLSPD.exe

最後就是要K API摟....
Ref:
http://dannynote.blogspot.com/2008/11/linuxlibusblibrarylinuxusbkernel-device.html
http://realchecko.blogspot.com/2009/04/build-openocd-under-mingw-with-ftd2232.html
ubuntu install:
回覆刪除http://mpathirage.com/getting-started-with-libusb-on-ubuntu/