本站网址: YippeeSoft开心软件

本文链接: 20071018 uclinux insmod

20071018 uclinux insmod
http://www.yippeesoft.com

可加载内核驱动程序的开发步骤一般分为3步:
①采用uClinux V2.4.26以后的稳定版本进行内核编译,在编译时让内核支持动态加载;
②可加载内核模块驱动程序及对驱动访问的程序的编写及编译,方法见前面的几篇;
③把驱动程序及测试程序通过FTP传到目标板中用命令行工具安装。

开发步骤。
1. uClinux内核的配置
     在uClinux-dist下运行make menuconfig,选择 Kernel/Library/Defaults Selection,然后选择 Customize Kernel Settings (NEW) 及它后面的那个Customize(因为加上这个后才会有busybox这个选项),退出并保存。接着会自动进入下一个编译界面,然后选上loadable module,退出后又进入下一个配置画面,进入busybox,选上:insmod,lsmod,rmmod。
2.重新编译内核
         make dep
         make clean
         make lib_only(可以仅1次,不必要每次都来)
         make user_only(每次修改过您的应用程序之后,这一步后面的都必须重来)
         make romfs
         make image
         make
3.下载内核到板子上,可以用imi命令查看编译的内核是否正确,下载后运行,不代参数执行insmod,lsmod,rmmod命令能够得到正常的错误提示。
4. 正确设置网络IP地址,使uClinux的目标板和开发用主机能够互相用TFTP访问.下载驱动和测试程序。
由于文件系统是read-only filesystem,而动态加载时需要自己手动mknod,所以就换个目录吧,我用的是/var.

/var>insmod xiuled.o
/var>mknod xiuled c 231 0
/var>chmod 777 xiuled
/var>./testled

http://blog.iyi.cn/hily/archives/2006/11/linuxmoddriver.html

make[4]: Entering directory `/home/sf/duoyewu/uClinux-IST/linux-2.4.x/drivers/block\’
make[4]: *** No rule to make target `DAC960.c\’, needed by `ll_rw_blk.o\’.  Stop.

 Block devices  —>     <M> Mylex DAC960/DAC1100 PCI RAID Controller support

 编译出现

serial_core_44b0x.c:2244: warning: data definition has no type or storage class
serial_core_44b0x.c:2245: parse error before `this_object_must_be_defined_as_export_objs_in_the_Makefile\’
serial_core_44b0x.c:2245: warning: type defaults to `int\’ in declaration of `this_object_must_be_defined_as_export_objs_in_the_Makefile\’
serial_core_44b0x.c:2245: warning: data definition has no type or storage class
serial_core_44b0x.c:2246: parse error before `this_object_must_be_defined_as_export_objs_in_the_Makefile\’
serial_core_44b0x.c:2246: warning: type defaults to `int\’ in declaration of `this_object_must_be_defined_as_export_objs_in_the_Makefile\’
serial_core_44b0x.c:2246: warning: data definition has no type or storage class
serial_core_44b0x.c:2247: parse error before `this_object_must_be_defined_as_export_objs_in_the_Makefile\’
serial_core_44b0x.c:2247: warning: type defaults to `int\’ in declaration of `this_object_must_be_defined_as_export_objs_in_the_Makefile\’
serial_core_44b0x.c:2247: warning: data definition has no type or storage class
serial_core_44b0x.c:2248: parse error before `this_object_must_be_defined_as_export_objs_in_the_Makefile\’
serial_core_44b0x.c:2248: warning: type defaults to `int\’ in declaration of `this_object_must_be_defined_as_export_objs_in_the_Makefile\’
serial_core_44b0x.c:2248: warning: data definition has no type or storage class
make[4]: *** [serial_core_44b0x.o] Error 1

在char\\MAKEFILE export-objs里面  serial_core_44b0x.o

最后出现
&leftsign;standard input&rightsign;: Assembler messages:
&leftsign;standard input&rightsign;:2626: Warning: .space repeat count is zero, ignored
make[3]: *** [DAC960.o] Error 1
make[3]: Leaving directory `/home/sf/duoyewu/uClinux-IST/linux-2.4.x/drivers/block\’

再把DAC960去除

OK~

允许
# insmod
BusyBox v0.60.4 (2007.10.19-06:53+0000) multi-call binary

Usage: insmod [OPTION]… MODULE [symbol=value]…

但是:

# insmod your_file
Using your_file
Warning: loading your_file will taint the kernel: no license
  See Unhandled fault: external abort on linefetch (F4) at 0×00000001
fault-common.c(97): start_code=0xc3ff040, start_stack=0xc434f30)
http://www.tux.org/lkml/#export-tainted for information about tainted modules
EMT trap

  
FAQ Loadable modules are supported on all stable uClinux targets.

In order to make it work you should ensure that module support is enabled in the kernel config and that you have the busybox "insmod" command enabled as an absolute minimum.

If you are building your own module outside the linux kernel you should build a kernel module first to see what command line flags are needed for the compiler to produce a working loadable module. Try enabling a filesystem like cramfs as a module to see how it is built by the linux build system, then build your module the same way.

The uClinux-dist takes care of building modules and installing them into the romfs if you have kernel modules enabled.

原创文章,转载请注明: 转载自YippeeSoft开心软件

本文链接地址: 20071018 uclinux insmod

历史博文

标签:, , ,