- 論壇徽章:
- 9
|
請參考:http://blog.csdn.net/u010587742/article/details/17772901
USB轉(zhuǎn)串口+DNW燒寫程序 Linux環(huán)境
分類: Linux 2014-01-03 02:04 198人閱讀 評論(0) 收藏 舉報
1.工具下載dnw_linux:http://download.csdn.net/detail/plaza02/1011140 ;需要發(fā)郵箱的可信息我,893564115@qq.com
2.tar -vxf dnw_linux_tar.bz2
3.加載USB轉(zhuǎn)串口驅(qū)動:在root權(quán)限下,insmod ch341.ko && modprobe usbserial ,同時插上usb轉(zhuǎn)串口線,此時可以ls /dev/ttyUSB0。
4.下載minicom,yum install minicom,可以使用rpm -qa|grep minicom來查看是否安裝成功。安裝完畢后minicom -s配置串口,詳細可參考:(http://wenku.baidu.com/link?url= ... 9x-jiLbYAgWCM_1ZSi7)
5.加載DNW燒寫軟件的驅(qū)動:在root權(quán)限下,insmod secbulk.ko,同時插上usb-OTG數(shù)據(jù)線,此時可以用dmesg查看是否加載驅(qū)動。
6.編譯DNW燒寫軟件:
6.1使用redhat5編譯軟件時會出現(xiàn)如下錯誤:
[root@localhost secbulk]# make
make -C /lib/modules/2.6.18-53.el5/build M=/root/Desktop/dnw_linux/secbulk modules
make[1]: Entering directory `/usr/src/kernels/2.6.18-53.el5-i686'
CC [M] /root/Desktop/dnw_linux/secbulk/secbulk.o
/root/Desktop/dnw_linux/secbulk/secbulk.c: In function ‘secbulk_write’:
/root/Desktop/dnw_linux/secbulk/secbulk.c:58: warning: comparison of distinct pointer types lacks a cast
/root/Desktop/dnw_linux/secbulk/secbulk.c: In function ‘secbulk_probe’:
/root/Desktop/dnw_linux/secbulk/secbulk.c:147: error: implicit declaration of function ‘usb_endpoint_is_bulk_out’
make[2]: *** [/root/Desktop/dnw_linux/secbulk/secbulk.o] Error 1
make[1]: *** [_module_/root/Desktop/dnw_linux/secbulk] Error 2
make[1]: Leaving directory `/usr/src/kernels/2.6.18-53.el5-i686'
make: *** [default] Error 2
[root@localhost secbulk]# ls
Makefile secbulk.c tmp_Makefile
經(jīng)調(diào)試,在secbulk.C中手動添加如下三個函數(shù)即可(然后重新make ,insmod secbulk.ko):
static inline int usb_endpoint_xfer_bulk(
const struct usb_endpoint_descriptor *epd)
{
return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
USB_ENDPOINT_XFER_BULK);
}
static inline int usb_endpoint_dir_out(
const struct usb_endpoint_descriptor *epd)
{
return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT);
}
static inline int usb_endpoint_is_bulk_out(
const struct usb_endpoint_descriptor *epd)
{
return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd));
}
6.2使用命令lsusb(一下內(nèi)容引用自:http://blog.csdn.net/fei1700/article/details/4709773),查看ID_table的值,并在secbulk.C中更改,重新編譯后加載驅(qū)動模塊。
secbulk設備未建立,手動建立/dev/secbulk0并不起作用,原因是secbulk probe會匹配id_table,這個是為QQ2440準備的,所以需要改id_table
static struct usb_device_id secbulk_table[]= {
{ USB_DEVICE(0x04e8, 0x1234)},
{ }
};
可以通過lsusb獲得idProduct和idVendor,需要在插上板子,并準備下載時此時設備連上時lsusb,0x04e8:0x1234就是我需要的
[zhourr@localhost ~]$ lsusb
Bus 002 Device 005: ID 04e8:1234 Samsung Electronics Co., Ltd
Bus 002 Device 004: ID 064e:a116 Suyin Corp.
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 002: ID 093a:2510 Pixart Imaging, Inc.
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 002: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 002: ID 0b05:1751 ASUSTek Computer, Inc.
Bus 005 Device 003: ID 147e:1000 Upek |
|