- 论坛徽章:
- 9
|
请参考:http://blog.csdn.net/u010587742/article/details/17772901
USB转串口+DNW烧写程序 Linux环境
分类: Linux 2014-01-03 02:04 198人阅读 评论(0) 收藏 举报
1.工具下载dnw_linux:http://download.csdn.net/detail/plaza02/1011140 ;需要发邮箱的可信息我,893564115@qq.com
2.tar -vxf dnw_linux_tar.bz2
3.加载USB转串口驱动:在root权限下,insmod ch341.ko && modprobe usbserial ,同时插上usb转串口线,此时可以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烧写软件的驱动:在root权限下,insmod secbulk.ko,同时插上usb-OTG数据线,此时可以用dmesg查看是否加载驱动。
6.编译DNW烧写软件:
6.1使用redhat5编译软件时会出现如下错误:
[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
经调试,在secbulk.C中手动添加如下三个函数即可(然后重新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(一下内容引用自:http://blog.csdn.net/fei1700/article/details/4709773),查看ID_table的值,并在secbulk.C中更改,重新编译后加载驱动模块。
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 |
|