我刚刚制作了我的第一个驱动模块,跟随LDD3的hello world模块.但遗憾的是遇到了这个错误:
insmod: error inserting './hello.ko': -1 Invalid module format.
Run Code Online (Sandbox Code Playgroud)
我在Ubuntu 11.04和我的环境中这样做:
$ uname -r
2.6.38-8-generic
Run Code Online (Sandbox Code Playgroud)
我得到这样的内核源代码:
sudo apt-cache search linux-source
linux-source - Linux kernel source with Ubuntu patches
linux-source-2.6.38 - Linux kernel source for version 2.6.38 with Ubuntu patches
$sudo apt-get install linux-source-2.6.38
Run Code Online (Sandbox Code Playgroud)
我的/ usr/src:
$ls /usr/src/
linux-headers-2.6.38-8 linux-source-2.6.38 vboxguest-5.0.10
linux-headers-2.6.38-8-generic linux-source-2.6.38.tar.bz2
Run Code Online (Sandbox Code Playgroud)
然后我编译内核
$sudo cp /boot/config-2.6.38-8-generic ./.config
$sudo make menuconfig -- load the .config file
$make
$make modules
Run Code Online (Sandbox Code Playgroud)
然后我编译我的内核模块
$make -C /usr/src/linux-source-2.6.38/linux-source-2.6.38 M=`pwd` modules
Run Code Online (Sandbox Code Playgroud)
使用Makefile:
obj-m := hello.o
Run Code Online (Sandbox Code Playgroud)
然后最后当我插入模块时: …
linux kernel-module linux-device-driver linux-kernel embedded-linux
我正在处理 IAR 项目,我的问题是 git 存储库可以忽略 IAR 项目中的哪个文件。所有项目设置文件和源文件混合在 git log 中非常无聊并且不利于版本控制,有人能提出好的建议吗?
太感谢了。