在Linux下安装DNW
1. 下载Linux下DNW的PC端USB驱动和写入工具
下载地址:已上传至CSDN
2. 编译PC端USB驱动和写入工具
2.1 解压缩
$ tar xzvf /path/to/dnw_linux.tgz
dnw_linux/
dnw_linux/secbulk/
dnw_linux/secbulk/Makefile
dnw_linux/secbulk/secbulk.c
dnw_linux/dnw/
dnw_linux/dnw/dnw.c
其中secbulk.c是PC端USB驱动, dnw.c是写入工具
2.2 编译并加载secbulk.c内核模块
$cd secbulk
$make -C /lib/modules/`uname -r`/build M=`pwd` modules
编译成功后在当前目录下可以看到secbulk.ko
用insmod命令加载模块,这需要root权限
$sudo insmod ./secbulk.ko
2.3 编译dnw写入工具
$gcc -o dnw dnw.c
编译成功后生成可执行dnw(这一步在虚拟机下编译时出现了许多警告)
3 使用DNW下载
3.1 启动开发板,进入minicom,并将开发板和PC用USB电缆连接,此时用dmesg命令可以看到secbulk驱动加载:
[ 283.677772] usb 1-1: new full speed USB device using uhci_hcd and address 2
[ 284.084835] usb 1-1: configuration #1 chosen from 1 choice
[ 284.140430] secbulk:secbulk probing...
[ 284.140482] secbulk:bulk out endpoint found!
3.2 当出现“USB host is connected. Waiting a download.”时,在PC端Linux上用dnw工具写入要下载的文件
切换到root权限,执行dnw下载.
$./dnw /path/to/what/you/want/download
写入完成后提示成功
100% xxxxxxx bytes OK
4 提高下载速度
将secbulk.c中的
#define BULKOUT_BUFFER_SIZE 32
改为
#define BULKOUT_BUFFER_SIZE 512
可发现速度快了很多。
相关文档:
从
Linux 2.6
起引入了一套新的驱动管理和注册机制 :Platform_device
和 Platform_driver
。
Linux
中大部分的设备驱动,都可以使用这套机制 ,
设备用
Platform_device
表示,驱动用
Platform_driver
进行注册。
Linu ......
Linux下的定时器有两种,以下分别介绍:
1、alarm
如果不要求很精确的话,用alarm()和signal()就够了
unsigned int alarm(unsigned int seconds)
函数说明: alarm()用来设置信号SIGALRM在经过参数seconds指定的秒数后传送给目前的进程。如果参数seconds为0,则之前设置的闹钟会被取消,并将剩下的时间返回。
返回值: ......
For all those who are beginners in any linux(ubuntu) find hard to find the package files of their distro and end up in finding an source package(which is either in tar.gz or .gz).. so now people think how to install these source files…..
lets now see how would you be installing source files ......
Windows完成端口与Linux epoll技术简介
2009-09-16 09:13
WINDOWS完成端口编程
1、基本概念
2、WINDOWS完成端口的特点
3、完成端口(Completion Ports )相关数据结构和创建
4、完成端口线程的工作原理
5、Windows完成端口的实例代码
Linux的EPoll模型
1、为什么select落后
2、内核中提高I/O性能的新方法epoll
3 ......
//获取本机IP地址函数
QString GetLocalIp()
{
int sock_get_ip;
char ipaddr[50];
struct sockaddr_in *sin;
struct ifreq ifr_ip;
if ((sock_get_ip=socket(AF_INET, SOCK_STREAM, 0)) == -1)
{
printf("socket create failse...GetLocalIp!\n");
return ""; ......