Error when loading cross compiled kernel module - linux

I have cross compiled a simple helloworld kernel module, the host is a x86 machine and the target an ARM board. When I do modprobe to install the module in the target i get this message:
FATAL: Could not load /lib/modules/3.14.0-xilinx-13567-g906a2c9-dirty/modules.dep: No such file or directory
I have make sure that the module is compiled with the same version as the target.
uname -a : 3.14.0-xilinx-13567-g906a2c9-dirty
modinfo: vermagic: 3.14.0-xilinx-13567-g906a2c9-dirty SMP preempt mod_unload modversions ARMv7 p2v8
What can be the problem? What does that error means?

Apparently, you are missing the file specifying module dependencies (generated at build time and installed with make module_install).
The simplest solution is, if your mdule does not have external dependencies, insert it with insmod rather than with modprobe.

Try to run:
depmod -a
on the ARM board.
it should solve your problem.

I would suggest the following steps.
Do insmod $module-name
Check the dmesg commands output. If you see the following message
version magic '3.14.0-xilinx-13567-g906a2c9-dirty xxxxxxxx' should be
'3.14.0-xilinx-13567-g906a2c9-dirty xxxxxxxxxx'
then the problem is because of the changes made to the kernel.
Commit the changes to the git repository and re-build the kernel.
Create a new kernel image and then boot the target with the updated kernel.

Related

Compile Kernel module on Chromebook

I am running an ARMv7 Chromebook with crouton. I would like to get CIFS shares mounted, but it appears that CIFS is not in the kernel. So I downloaded the same kernel version source as I am on, compiled the cifs.ko module, and attempted to load it. But I received this error:
# insmod cifs.ko
insmod: ERROR: could not insert module cifs.ko: Operation not permitted
The module is compiled as an ARM module, I checked with file:
# file cifs.kocifs.ko: ELF 32-bit LSB relocatable, ARM, version 1, BuildID[sha1]=e14d1772583fae478e2b113b57ce81c214e511af, not stripped
What gives?
Chromium OS does not allow adding kernel modules by default. Use this script to disable module locking. https://github.com/divx118/crouton-packages/blob/master/README.md
More information on modifying the Chromium OS kernel can be found here:
https://github.com/dnschneid/crouton/wiki/Build-kernel-headers-and-install-Virtualbox-(x86) Generally the entire crouton repository / wiki is a lot of help.

How to use kgdb over ethernet (kgdboe)?

i am using ubuntu 12.04 and kernel version is 3.12.6, i want to learn how to use kgdb to debug kernel. I didn't get much info. regarding kgdboe (kgdb over ethernet). I have compiled kernel and enabled kgdb in menuconfig, i have created kernel image using make bzImage on development machine and copied same on target machine, now problem is how to connect both target and development machine. i m not getting parameter set for kgbdoe. Plz help if anybody know how to use kgdb over ethernet
Have you read this:
https://www.kernel.org/pub/linux/kernel/people/jwessel/kgdb/ch03s04.html
?
You have to run debugged kernel with special options - like for example:
kgdbwait kgdbcon kgdboe=#192.168.248.76/,#192.168.242.24/00:11:22:33:44:55
and on debugging side you run following commands:
gdb
file vmlinux
target remote udp:192.168.248.76:6443
it has worked for me.
You can get the kgdboe source from here, build it and load it into your kernel:
make -C /lib/modules/$(uname -r)/build M=$(pwd)
sudo insmod kgdboe.ko
Then type 'dmesg' to see the load log and get instructions on connecting from gdb.

Cross compile FTDI VCP Driver for embedded linux arm

I'm trying to cross compile the FTDI VCP Driver for my embedded arch linux arm machine. I downloaded the source files from http://www.ftdichip.com/Drivers/VCP.htm onto my host machine which is running kernel:
2.6.32-54-generic-pae
When running the Makefile, I get errors related to kernel headers, ie: asm/thread_info.h file not found. I realize that this means that my asm symlink is broken, so I tried linking it to
linux-headers-2.6.32-54/include/asm-generic
but the contents of that directory does not include thread_info.h either, which I'm trying to find.
Has anyone cross compiled the FTDI VCP Driver for embedded arch linux arm using Ubuntu as their host and can point me in the right direction? I'm new to building kernel modules and cross compiling and any help would be appreciated.
If anyone requires more information I'd be more than happy to add it.
make ARCH=arm menuconfig
Make and install modules: make modules and make modules_install
Don't forget: insmod usbserial.ko and insmod ftdi_sio.ko if you need to, and depmod -a to have them load after a power cycle.
Don't forget to include your cross compiling chains.
Basically u need cross-compile kernel in host x86 machine.
First check the source code is already configured and built if so.
make ARCH=arm menuconfig
window ll appear and enable ftdi in driver .
if source code is clean.
then u need to copy /proc/config.gz file from target machine to host and untar it.
copy to source top folder like `cp config .config'
make ARCH=arm menuconfig
and enable your driver
After this make ARCH=arm CROSS_COMPILE=<your tool chain> zImage
e.g make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- zImage
make ARCH=arm CROSS_COMPILE=<your tool chain> modules
e.g make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- modules
The FTDI "VCP" driver has been a part of the linux kernel for a good while now. You don't need to download anything, except for the kernel itself. As long as you can cross-compile your kernel, you're all set.

Cross compiling a kernel module: how to set configs right

I'm trying to cross-compile an external module for the Beaglebone (Linux, ARM).To avoid kernel version issues I grabbed a kernel tarball and cross-compiled for ARM with the CodeSourcery toolchain on the host machine (x86). Then I cross-compiled an external hello-world module with the exact same toolchain against the exact same kernel sources. I used this simple makefile:
obj-m += hello-1.o
all:
make -C /home/***/****/linux-3.2.0-beaglebone-20120411.00
M=$(PWD) modules
clean:
make -C /home/***/****/linux-3.2.0-beaglebone-20120411.00 M=$(PWD) clean
When I copy the ko-file over to target and try to insmod it I get: "insmod: error inserting 'hello-1.ko': -1 Invalid module format" which (from what I learned in this group and elsewhere) usually stems from conflicting kernel versions, and indeed uname -a on the target gives:
Linux beaglebone 3.2.18 #1 Wed May 30 14:21:54 CEST 2012 armv7l GNU/Linux
while modinfo hello-1.ko gives:
srcversion: 140276773A3090F6F33891F
depends:
vermagic: 3.2.0+ mod_unload modversions ARMv5 p2v8
So version 3.2.18 vs. 3.2.0+ (why the +?) and armv7l vs. ARMv5!
Does anyone know why I get different versions albeit I compiled against the same kernel-sources (maybe some configs)?
Any suggestions are appreciated!
best,
Chris
answer is, you should run 'the kernel you compiled on beagle board.
'+' means that you modified your source tree.
And finally make sure that you're using correct defconfig. 'make beagle_defconfig' should work.

Linux Kernel Module Error on Raspberry Pi

I have got one of the small raspberry pi computers, and i am having my first play with creating a kernel module. I have downloaded the source, and managed to compile my test module but when i try and load it i get this error:
insmod: error inserting 'hello.ko': -1 Invalid module format
and when i look in dmesg i see this error:
hello: version magic '3.1.9+ mod_unload modversions ARMv6 p2v8 ' should be '3.1.9+ mod_unload modversions ARMv6 '
Can anyone point me in the right direction, i'm not sure what its telling me?
Cheers
Luke
It sounds like the kernel source you downloaded does not match the kernel installed on your Pi.
Where did you download it from?
To get the correct source for your kernel type the following on the command line:
sudo apt-get install linux-source
This should download the correct kernel source for you kernel (it is a meta-package). You should now see a directory under /lib/modules/ that matches your kernel version (the version printed out when you type uname -r)
Recompile and link you code - make sure you pick up the correct kernel source by having a line like this in your Makefile:
all:
make -C /lib/modules/$(shell uname -r)/build M=${PWD} modules
You newly compiled .ko module should now match you kernel and insert without complaints.
Good luck!

Resources