以模块方式加载驱动

为了调试驱动方便,准备让驱动以模块的方式加载,这样就不用重复地烧写整个系统了。

但是在给uclinux选上以模块方式加载支持后:

  │ │   [*] Enable loadable module support                   │ │

  │ │   [ ]   Set version information on all module symbols  │ │

  │ │   [*]   Kernel module loader                           │ │

编译过程就出错了:

make CFLAGS="-D__KERNEL__ -I/home/work1/uClinux-dist-server/linux-2.4.x/include  -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fno-common -pipe -fno-builtin -D__linux__ -DNO_MM -mapcs-32  -mtune=arm7tdmi -mshort-load-bytes -msoft-float -gdwarf-2" -C  drivers

make[2]: Entering directory `/home/work1/uClinux-dist-server/linux-2.4.x/drivers'

make -C block

make[3]: Entering directory `/home/work1/uClinux-dist-server/linux-2.4.x/drivers/block'

make all_targets

make[4]: Entering directory `/home/work1/uClinux-dist-server/linux-2.4.x/drivers/block'

make[4]: *** 没有规则可以创建"ll_rw_blk.o"需要的目标"DAC960.c"。 停止。

make[4]: Leaving directory `/home/work1/uClinux-dist-server/linux-2.4.x/drivers/block'

make[3]: *** [first_rule] 错误 2

make[3]: Leaving directory `/home/work1/uClinux-dist-server/linux-2.4.x/drivers/block'

make[2]: *** [_subdir_block] 错误 2

make[2]: Leaving directory `/home/work1/uClinux-dist-server/linux-2.4.x/drivers'

make[1]: *** [_dir_drivers] 错误 2

make[1]: Leaving directory `/home/work1/uClinux-dist-server/linux-2.4.x'

make: *** [linux] 错误 1

打开linux-2.4.x/drivers/block/Makefile,发现Makefile里两处指定的都是大写的DAC960.c,而linux-2.4.x/drivers/block/下的这两个文件名都是小写的。后来看了看linux-2.6.18的内核,发现他们是把dac960.c和dac960.h改成了DAC960.c和DAC960.h。

修改后编译又见异常:

make[4]: Entering directory `/home/work1/uClinux-dist-server/linux-2.4.x/drivers/char'

arm-elf-gcc -D__KERNEL__ -I/home/work1/uClinux-dist-server/linux-2.4.x/include  -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fno-common -pipe -fno-builtin -D__linux__ -DNO_MM -mapcs-32  -mtune=arm7tdmi -mshort-load-bytes -msoft-float -gdwarf-2  -nostdinc -iwithprefix include -DKBUILD_BASENAME=serial_core_44b0x  -c -o serial_core_44b0x.o serial_core_44b0x.c

serial_core_44b0x.c:2244: parse error before `this_object_must_be_defined_as_export_objs_in_the_Makefile'

serial_core_44b0x.c:2244: warning: type defaults to `int' in declaration of `this_object_must_be_defined_as_export_objs_in_the_Makefile'

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] 错误 1

make[4]: Leaving directory `/home/work1/uClinux-dist-server/linux-2.4.x/drivers/char'

make[3]: *** [first_rule] 错误 2

make[3]: Leaving directory `/home/work1/uClinux-dist-server/linux-2.4.x/drivers/char'

make[2]: *** [_subdir_char] 错误 2

make[2]: Leaving directory `/home/work1/uClinux-dist-server/linux-2.4.x/drivers'

make[1]: *** [_dir_drivers] 错误 2

make[1]: Leaving directory `/home/work1/uClinux-dist-server/linux-2.4.x'

make: *** [linux] 错误 1

按照提示”this_object_must_be_defined_as_export_objs_in_the_Makefile”检查了一下linux-2.4.x/drivers/char/Makefile,发现是export-objs列表里少了serial_core_44b0x.o,加上后即可编译通过。 

模块的加载和卸除需要用到insmod和rmmod,所以还需要将busybox里的这两个工具选上。之后就可以用“insmod 模块名”和“rmmod 模块名”来加载和卸除模块了。

— EOF —

《以模块方式加载驱动》有18个想法

  1. hello there and thank porlssax you for your info – I’ve certainly picked up anything new from right here. I did however expertise a few technical points using this web site, since I experienced to reload the web site a lot of times previous to I could get it to load correctly. I had been wondering if your hosting is OK? Not that I’m complaining, but sluggish loading instances times will very frequently affect your placement in google and can damage your high quality score if ads and marketing with Adwords. Anyway I’m adding this RSS to my e-mail and can look out for a lot more of your respective exciting content. Ensure that you update this again soon..

  2. Useful info. Lucky me I found your web site accidentally, and I am shocked why this accident didn’t took place in advance! I bookmarked it.

  3. Howdy very nice web site!! Guy .. Excellent .. Amazing .. I’ll bookmark your site and take the feeds also? I am happy to seek out a lot of useful info here within the post, we want develop more techniques in this regard, thank you for sharing. . . . . .|

  4. Excellent article! We are linking to this particularly great content on our website. Keep up the good writing.|

  5. This design is wicked! You certainly know how to keep a reader entertained. Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Excellent job. I really enjoyed what you had to say, and more than that, how you presented it. Too cool!

  6. Alleine hunderte verschiedene Plakate sind den letzten 36 Jahren produziert worden und lagern mittlerweile im benachbarten Gorleben Archiv Lüchow.

发表评论

电子邮件地址不会被公开。 必填项已用*标注