简体   繁体   English

如何将依赖模块插入内核?

[英]How to insert dependent modules into Kernel?

I have a Parrot AR.Drone 2.0 running Ubuntu and I want to connect it to the single board computer using cable. 我有一个运行Ubuntu的Parrot AR.Drone 2.0,我想使用电缆将其连接到单板计算机。 There are no Ethernet ports on the drone so I decided to use USB-Ethernet adapter (D-Link DUB-E100). 无人机上没有以太网端口,因此我决定使用USB-以太网适配器(D-Link DUB-E100)。 After entering uname -a in the terminal I get the following line: 在终端中输入uname -a ,得到以下行:

Linux uclibc 2.6.32.9-g980dab2 #1 PREEMPT Mon Oct 6 11:50:23 CEST 2013 armv7l GNU/Linux

I followed this article and instead of module for wifi I used module for USB-Ethernet adapter. 我遵循本文,而不是将模块用于wifi,而是将模块用于USB-以太网适配器。

This how I edited Makefile: 这是我编辑Makefile的方法:

TARGET  = dub_e100
OBJS    = dub_e100.o
MDIR    = drivers/net/usb
KDIR    = /home/artemii/Downloads/linux

EXTRA_CFLAGS = -DEXPORT_SYMTAB
PWD = $(shell pwd)
DEST = /home/artemii/Downloads/linux/$(MDIR)

obj-m      := $(TARGET).o

default:
    make -C $(KDIR) SUBDIRS=$(PWD) modules

$(TARGET).o: $(OBJS)
    $(LD) $(LD_RFLAG) -r -o $@ $(OBJS)

install:
    su -c "cp -v $(TARGET).ko $(DEST) && /sbin/depmod -a"

clean:
    $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) clean

.PHONY: modules clean

-include $(KDIR)/Rules.make

After that I compiled the kernel with following lines: 之后,我用以下几行代码编译内核:

make
export ARCH=arm
export CROSS_COMPILE=arm-none-linux-gnueabi-
make 

Leter on I transfer generated 'dub_e100.ko' file into drone and ran the following command line: 我将Leter转移到生成的'dub_e100.ko'文件到无人机并运行以下命令行:

insmod dube100.ko

Terminal threw an error insmod: can't insert 'dub_e100.ko': unknown symbol in module, or unknown parameter . 终端抛出错误insmod: can't insert 'dub_e100.ko': unknown symbol in module, or unknown parameter Checking dmesg | 检查dmesg | tail gives: 尾巴给出:

usb 1-1:1.0: uevent
dub_e100: Unknown symbol mii_ethtool_sset
dub_e100: Unknown symbol mii_link_ok
dub_e100: Unknown symbol mii_nway_restart
dub_e100: Unknown symbol generic_mii_ioctl
dub_e100: Unknown symbol mii_ethtool_gset

I assume that adapter's module depends on mii module, so I generated mii.ko file with following makefile: 我假设适配器的模块取决于mii模块,因此我使用以下makefile生成了mii.ko文件:

TARGET  = dub_e100
OBJS    = dub_e100.o
MDIR    = drivers/net/usb
KDIR    = /home/artemii/Downloads/linux

EXTRA_CFLAGS = -DEXPORT_SYMTAB
PWD = $(shell pwd)
DEST = /home/artemii/Downloads/linux/$(MDIR)

obj-m      := $(TARGET).o
obj-m += mii.o

default:
    make -C $(KDIR) SUBDIRS=$(PWD) modules

$(TARGET).o: $(OBJS)
    $(LD) $(LD_RFLAG) -r -o $@ $(OBJS)

install:
    su -c "cp -v $(TARGET).ko $(DEST) && /sbin/depmod -a"

clean:
    $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) clean

.PHONY: modules clean

-include $(KDIR)/Rules.make

After that I consiquately run mii.ko and dube100.ko on the drone. 之后,我会在无人机上运行mii.kodube100.ko All the modules visible in lsmod . 所有模块在lsmod可见。 But after inserting the adapter to the drone it crushes and reboots. 但是,将适配器插入无人机后,它会挤压并重新启动。 After reboot this modules dessapiar from lsmod . 重新启动后,此模块将由lsmod dessapiar提供。 Is there something I am doing wrong? 我做错什么了吗? I might generated or ran modules improperly. 我可能生成或运行模块的方式不正确。

insmod does not handle module dependencies. insmod不处理模块依赖性。 It's manual page says: 它的手册页上说:

insmod is a trivial program to insert a module into the kernel. insmod是将模块插入内核的简单程序。 Most users will want to use modprobe(8) instead, which is more clever and can handle module dependencies. 大多数用户将改为使用modprobe(8) ,它更聪明并且可以处理模块依赖性。

Note that you may have to run depmod before the modprobe automatic dependency loading works as intended. 请注意,在modprobe自动依赖项加载按预期工作之前,您可能必须运行depmod

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM