linux驱动makefile,linux安装u盘中的软件
大家好,关于linux驱动makefile很多朋友都还不太明白,今天小编就来为大家分享关于linux安装u盘中的软件的知识,希望对各位有所帮助!
linux的usb驱动
linux针对usb3.0的驱动程序是什么?
Linux*USB3.0xHCI驱动程序可从开放源代码社区获取。查看驱动是否生效:lsusb-t查看驱动是否集成到内核中:grep-ixhci/boot/config-$(uname-r)如果返回y则是集成到内核中,返回m则是编译为模块。
linux内核目录driver/usb/serial/option.c驱动请教?
arch下面是体系架构,以及平台相关文件:
比如,把arch/arm/config里面的s3c2410_defconfig,拷贝到内核根目录,命名为.config
再修改根目录Makefile,选择arm交叉编译工具,执行makemenuconfig就可以配置
你定义的内核,选择自己的驱动。
USB、TTY、LCD、网卡等驱动在不同的目录,建议先了解和熟悉linux目录树结构,
以及各自对应的功能。
比如/net目录是网络驱动,但是/driver/net/下面是网络相关的具体设备驱动。
假设你有两个网卡,一个是DM9000,一个是CS8900,在/driver/net/下面,对应两个目录,但是这两个设备驱动,都属于网卡驱动,在/net下面。
建议结合书本和代码,来一步一步学习。比如LDD等经典书籍。
怎么给u盘注入usb驱动?
1使用ISOTOUSB或者软碟通(UltraISO)制作Windows7原版安装盘(不要使用Ghost镜像制作,否则后续有可能会有报错)
2从Gigabyte的官方网站上下载“WindowsUSBInstallationTool”工具
3解压之下载的压缩包,在解压缩路径下右键以管理员方式运行“WindowsImageTool.exe”
4选择目标U盘,然后再选择需要补充的USB驱动
5点击“Start”按钮开始添加驱动,过程会比较长(与镜像大小和U盘写入速度有关,请耐心等待),实测超过30分钟。
6在创建结束后,就可以使用这个U盘在USB3.0接口上安装原生Windows7系统了。使用安装完补丁的U盘安装完系统USB3.0驱动会自动安装上。
7虽然,使用安装完补丁的U盘安装完系统USB3.0驱动会自动安装上,但是建议在系统安装完毕之后,还是需要更新一下最新的USB3.0的驱动。
怎么下载USB驱动器?
1、电脑品牌官网下载:打开电脑品牌官网,选择”服务支持“中的”驱动下载”选项,输入电脑型号信息,下载usb驱动2、驱动软件自动下载:安装驱动软件,点击硬件检测,软件会自动检测缺失的驱动程序,自动安装3、搜索引擎搜索:搜索关键字“电脑型号+usb驱动”,选择网页进行下载即可
linux嵌入式驱动开发,makefile到问题
首先说一下,你要编译驱动程序,不再是跟原本编译应用程序那样可以在当前目录下直接make就好。
因为编译内核驱动的时候,是要用到内核文件里的头文件,还有内核提供的接口函数,要借助于内核文件夹里的makefile来编译你写好的驱动源代码,如果按一般的操作,你就得把源代码放到内核文件夹指定的目录下,然后再在那个目录下得makefile里添加一些语句,比如obj-m什么的(把相应的驱动代码编译成模块),然后到内核文件夹的顶层目录make,生成相应的模块文件,就有你问题3的那一大堆东西,其中.ko就是要用到的。
把一些驱动编译成模块,和编译进内核的区别,你可以去了解下。。编译成模块用的是-m。
而为了方便你可以在任何目录下直接用make来编译驱动代码;就有以下这指令:
$(MAKE)-C$(KERNELDIR) M=$(PWD) modules
-C指定的就是内核文件夹所在的地方
M=当前路径
modules的,是和make联合起来的..make modules命令,这个命令你可以去查查。
.ko文件就是用insmod命令插入到内核中,在去添加相应的设备文件,就可以在内核里跑起来了。
如何编译一个linux下的驱动模块
本文记录我的第一个Linux设备驱动程序的编译过程。遇到问题的解决方法。
环境:2.4.18-14的内核,Linux内核源码:2.4.18。
Linux内核源码路径:/usr/src/linux(这个源码是从kernel.org网站download的2.4.18版本)
按照《linux设备驱动开发详解》一书中的步骤实现经典例子"hello,world!"的例子。
具体步骤如下:
=============================================
1.源码如下:
/*
* hello.c-- the example of printf"hello world!" in the screen of driver program
*/
#include<linux/init.h>
#include<linux/module.h>
MODULE_LICENSE("Dual BSD/GPL");/* declare the license of the module,it is necessary*/
static int hello_init(void)
{
printk(KERN_ALERT"Hello World enter!\n");
return 0;
}
static int hello_exit(void)
{
printk(KERN_ALERT"Hello world exit!\n");
}
module_init(hello_init);/* load the module*/
module_exit(hello_exit);/* unload the module*/
进入目录:
[root@Alex_linux/]#cd/work/jiakun_test/moduletest
[root@Alex_linux moduletest]# vi hello.c
然后拷入上面书上的源码。
2.编译代码:
1>.首先我在2.4内核的虚拟机上进行编译,编译过程如下:
[root@Alex_linux moduletest]#gcc-D__KERNEL__-I/usr/src/linux-DMODULE-Wall-O2-c-o hello.o hello.c
其中-I选项指定内河源码,也就是内核源码树路径。编译结果:
hello.c:1:22: net/sock.h: No such file or directory
hello.c: In function `hello_init':
hello.c:6: warning: implicit declaration of function `printk'
hello.c:6: `KERN_ALERT' undeclared(first use in this function)
hello.c:6:(Each undeclared identifier is reported only once
hello.c:6: for each function it appears in.)
hello.c:6: parse error before string constant
hello.c: In function `hello_exit':
hello.c:11: `KERN_ALERT' undeclared(first use in this function)
hello.c:11: parse error before string constant
hello.c: At top level:
hello.c:13: warning: type defaults to `int' in declaration of `module_init'
hello.c:13: warning: parameter names(without types) in function declaration
hello.c:13: warning: data definition has no type or storage class
hello.c:14: warning: type defaults to `int' in declaration of `module_exit'
hello.c:14: warning: parameter names(without types) in function declaration
hello.c:14: warning: data definition has no type or storage class
在网上查询有网友提示没有引入kernel.h
解决:vi hello.c
在第一行加入:#include<linux/kernel.h>
再次编译仍然报KERN_ALERT没有声明
修改编译条件-I,再次编译:
[root@Alex_linux moduletest]#gcc-D__KERNEL__-I/usr/src/linux-DMODULE-Wall-O2-c-o hello.o hello.c
[root@Alex_linux moduletest]#ls
hello.c hello.o Makefile
[root@Alex_linux moduletest]#
2>.接着我尝试在2.6内核的虚拟机上进行编译
编译过程如下:
[root@JiaKun moduletest]# ls
hello.c makefile
[root@JiaKun moduletest]# vi hello.c
[root@JiaKun moduletest]# make
make-C/mylinux/kernel/2.4.18-rmk7 M=/home/alex/test/moduletest modules
make:***/mylinux/kernel/2.4.18-rmk7: No such file or directory. Stop.
make:*** [modules] Error 2
[root@JiaKun moduletest]# vi makefile
[root@JiaKun moduletest]# make
make-C/usr/src/kernels/2.6.18-53.el5-i686 M=/home/alex/test/moduletest modules
make[1]: Entering directory `/usr/src/kernels/2.6.18-53.el5-i686'
scripts/Makefile.build:17:/home/alex/test/moduletest/Makefile: No such file or directory
make[2]:*** No rule to make target `/home/alex/test/moduletest/Makefile'. Stop.
make[1]:*** [_module_/home/alex/test/moduletest] Error 2
make[1]: Leaving directory `/usr/src/kernels/2.6.18-53.el5-i686'
make:*** [modules] Error 2
[root@JiaKun moduletest]# mv makefile Makefile
[root@JiaKun moduletest]# make
make-C/usr/src/kernels/2.6.18-53.el5-i686 M=/home/alex/test/moduletest modules
make[1]: Entering directory `/usr/src/kernels/2.6.18-53.el5-i686'
CC [M]/home/alex/test/moduletest/hello.o
Building modules, stage 2.
MODPOST
CC/home/alex/test/moduletest/hello.mod.o
LD [M]/home/alex/test/moduletest/hello.ko
make[1]: Leaving directory `/usr/src/kernels/2.6.18-53.el5-i686'
[root@JiaKun moduletest]# ls
hello.c hello.ko hello.mod.c hello.mod.o hello.o Makefile Module.symvers
3.执行代码,加载驱动模块:
2.4内核加载模块:
insmod./hello.o
但是此时并没有输出printk打印的信息。但是可以在/var/log/messages中看到打印的信息,这是由于KERN_ALERT优先级不够高。这里
需要修改为:KERN_EMERG。再次编译,加载模块即可以看到结果
2.6内核加载模块:
[root@JiaKun moduletest]# insmod hello.ko
[root@JiaKun moduletest]#
Message from syslogd@ at Sat Jul 26 19:52:44 2008...
JiaKun kernel: Hello, world
有的朋友可能会出现insmod命令找不到的错误,这可能有下面几个原因:
<1>你的系统没有安装module-init-tools工具,关于此问题,只需安装即可,但是一般装完系统是有这个命令的。
<2>环境变量没有添加导致不能使用该命令。使用echo$PATH即可查看PATH环境变量,发现没有/sbin这个路径,所以你当然不能使用insmod这个命令了。解决的方法很简单,只需在命令行输入:
PATH="$PATH:/sbin"即可添加。(insmod在/sbin这个目录下,你可以使用whereis insmod查看)。
<3> insmod这个命令需要在root权限下才能使用。
加载完成后你可以输入lsmod查看hello这个模块哦。
4.卸载驱动模块:rmmod hello.
加载模块后就可在屏幕上看到如下信息:Hello world enter.
卸载时就可在屏幕上看到如下信息:hello world exit.
[root@JiaKun moduletest]# rmmod hello.ko
[root@JiaKun moduletest]#
Message from syslogd@ at Sat Jul 26 19:52:58 2008...
JiaKun kernel: Goodbye, cruel world
另外,如果有多个文件,则按下列方式编写Makefile文件(file1.c、file2.c):
obj-m:= modulename.o
module-objs:= file1.o file2.o