以garmin usb为例:
1)编译生成garmin_usb.ko文件,使用insmod命令安装模块
2)使用lsmod命令可查看内核已经安装好模块:garmin_usb
3)插入USB设备后,使用ls /dev,会发现多了skel0设备节点文件(该设备文件在代 码中使用device_create()自动产生,不需要再单独使用mknod命令产生)
4)编写应用程序,使用open、read、write来操作读写数据
注: device端需要有相应的端点描述符。否者在probe过程中会失败。
源码:
1. garmin_usb.c
/*
* USB Skeleton driver - 2.2
*
* Copyright (C) 2001-2004 Greg Kroah-Hartman (greg@kroah.com)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, version 2.
*
* This driver is based on the 2.6.3 version of drivers/usb/usb-skeleton.c
* but has been r