compiling module


31 posts   Page 1 of 2   1, 2
by bullwinkle » Sat Feb 23, 2013 9:57 am
hello

I'm having trouble trying to figure out what is going on related to updating a driver module....(BTW, novice linux skills)

I have a webcam that is not working properly and the vendor indicates that a patch needs to be applied to gspca.c (gspca_main.ko)

With the wheezy version I have 3.2.27+ #250 but it does not have all the required files like the headers and gspca.c that I need. I've installed the headers for 3.2.27 and source files plus a Module.symvers that I found from around Oct 15/2012.

I've managed to apply the patch, make the new gspca_main.ko file but I can't load the file with either modprobe or insmod. The -f option does not help.

I'm getting "gspca_main: no symbol version for module layout" when trying to load and an Exec format error

I guess the problem is because the main wheezy version is sligthly different than 3.2.27. I'v looked at this post http://www.raspberrypi.org/phpBB3/viewtopic.php?f=66&t=26616, but I can't make the link to how all this should hang together.

I'm lost so any help would be great.

thanks

files:
https://github.com/raspberrypi/firmware/blob/6ec9dba23aad0a835c568237e694c488d9fe5e09/extra/Module.symvers
https://github.com/raspberrypi/linux/tarball/rpi-3.2.27
Posts: 85
Joined: Wed Jan 09, 2013 12:14 pm
by rurwin » Sat Feb 23, 2013 10:02 am
Try updating the kernel with rpi-update. It may be that you do not have up-to-date kernel sources that match the kernel you are running.
User avatar
Forum Moderator
Forum Moderator
Posts: 2903
Joined: Mon Jan 09, 2012 3:16 pm
by bullwinkle » Sat Feb 23, 2013 10:57 am
Hi "rurwin" and thanks for the reply ..

so if I understand correctly the procedure to compile a module like gspca_main should be

rpi-update
get the headers for the version (i guess this will now be 3.6.11+ ) <= from where ??
install headers
update gspca.c file
rmmode gspca_main
make
modprobe gspca_main

I've been really struggling with this as I can't really understand how to get the kernal and the headers to line up.
Posts: 85
Joined: Wed Jan 09, 2013 12:14 pm
by Spid » Sat Feb 23, 2013 11:24 am
May I presume you are trying to get a WebCam recognised if so what does lsusb recognise the chipset as ?
I will always assume you are running Raspbian for desktop and Raspbmc for XMBC !
Posts: 525
Joined: Sat Jan 19, 2013 12:47 pm
by rurwin » Sat Feb 23, 2013 11:36 am
You get the headers from the github repository for the foundations kernel release, which rpi-update uses.

There's a wrinkle in that it may not be the current top version that you need. Somewhere plugwash posted a description of what was necessary, but I can't find it. Something about finding the short git release tag on the running kernel, and then checking out that commit from github.
User avatar
Forum Moderator
Forum Moderator
Posts: 2903
Joined: Mon Jan 09, 2012 3:16 pm
by bullwinkle » Sat Feb 23, 2013 12:11 pm
Hi "Spid" , thanks for the reply.

lsusb ; /dev/video0 ; and modinfo all bring back the results I need. so no problem there I assume. The camera shows up in VLC and Qv4l2 - it is just not working properly.

@ rurwin, => I'll see if I can find that post from plugwash, because I think this point i'm stuck on. I am surprised that i can't get the correct headers / etc for the 3.2.27+ release? or if I upgrade the corresponding files for 3.6.11?

perhaps they are out there, i just can't find them
...stuck in hole and digging deeper :(

thanks again
Posts: 85
Joined: Wed Jan 09, 2013 12:14 pm
by Cloudcentric » Sat Feb 23, 2013 12:32 pm
Just a thought in the Raspbian "wheezy" repository is guvcview had you tried this software ?

http://guvcview.sourceforge.net/
I know everything about nothing"
Posts: 982
Joined: Fri Sep 14, 2012 9:13 am
by bullwinkle » Sat Feb 23, 2013 12:45 pm
Hello Cloudcentric

yep, tried them all including mplayer.

my issue is not really about the players, but the fact that I don't really understand how to update a RPI kernal module.
I've read a lot of posts about this, but I'm missing something somehow

cheers
Posts: 85
Joined: Wed Jan 09, 2013 12:14 pm
by bullwinkle » Sat Feb 23, 2013 4:40 pm
So,
i found some headers files for 3.2.27+ from this post
viewtopic.php?p=206493#p206493

but to be honest, I'm not sure what i should be doing next because I don't see the source 3.2.27+ files in here.

ugh :cry:
Posts: 85
Joined: Wed Jan 09, 2013 12:14 pm
by plugwash » Sat Feb 23, 2013 8:13 pm
Read the changelog for the package, that gets you a git commit id for the raspberrypi/firmware repository. Now read the file extra/git_hash from the commit you found and you will get a commit id for the raspberrypi/linux repository.
Forum Moderator
Forum Moderator
Posts: 2178
Joined: Wed Dec 28, 2011 11:45 pm
by bullwinkle » Sun Feb 24, 2013 7:36 am
ok -thanks for the update plugwash.

in the mean-time, I ended up recompliing the kernal (Zzzz....Zzzz....Zzz) and was able to update my driver and load it properly

I'll follow up on your point to better understand how this works plus learn how to cross-compile on a faster machine
Posts: 85
Joined: Wed Jan 09, 2013 12:14 pm
by hexelpdkk » Sun Feb 24, 2013 8:39 am
Having hit this a few times, I wrote up some (poor) instructions on getting the right bits to build a module without rebuilding the whole kernel here: http://paulspiblog.wordpress.com/2013/0 ... he-kernel/
It was really just for personal consumption, but could save you a bit of time, and avoid cross compiling.
User avatar
Posts: 128
Joined: Fri Feb 24, 2012 4:40 pm
by bullwinkle » Sun Feb 24, 2013 4:30 pm
Hi and thanks for the instructions.

They are clear and concise and kind of similar to what I was doing.
I'll try it out and let you know if I notice anything...

cheers,
Posts: 85
Joined: Wed Jan 09, 2013 12:14 pm
by bullwinkle » Mon Feb 25, 2013 6:31 am
Hi again,

ok so I did this twice following the instructions closely and everything works up to the point where I load the recompiled driver.

What I did ...
as root....
test loading the existing "shipped driver" gspca_main.ko
Code: Select all
modprobe gspca_main

Driver loaded ok ...so now unload the driver
Code: Select all
rmmod gspca_main

Driver unloaded ok
Follow the instruction on the web noted by hexelpdkk
http://paulspiblog.wordpress.com/2013/0 ... he-kernel/
touch the gspca.c file, run make and then install my new driver
Code: Select all
cd /usr/src/linux-rpi-3.6.y/drivers/media/video/gspca/
touch gspca.c
make
mv /lib/modules/3.6.11+/kernel/drivers/media/video/gspca/gspca_main.ko /lib/modules/3.6.11+/kernel/drivers/media/video/gspca/gspca_main.original
mv gspca_main.ko /lib/modules/3.6.11+/kernel/drivers/media/video/gspca/gspca_main.ko

everything is good so far, but not when i try
Code: Select all
modprobe gspca_main

it returns an error..
ERROR: could not insert 'gspca_main': Unknown symbol in module, or unknown parameter (see dmesg)

I've also tried insmod gspca_main.ko and the -f option.
I'm thinking that the problem is with "make" process rather than the headers/source but not really sure

thanks for any comments or hints
Posts: 85
Joined: Wed Jan 09, 2013 12:14 pm
by rurwin » Mon Feb 25, 2013 7:28 am
bullwinkle wrote:ERROR: could not insert 'gspca_main': Unknown symbol in module, or unknown parameter (see dmesg)

What does dmesg say?
User avatar
Forum Moderator
Forum Moderator
Posts: 2903
Joined: Mon Jan 09, 2012 3:16 pm
by hexelpdkk » Mon Feb 25, 2013 7:37 am
As a stab in the dark, whilst waiting for dmesg results, what kernel are you running? My instructions will get the kernel source and symbols from the foundation latest kernel. If you aren't running that, then use rpi-update to get the latest one.
User avatar
Posts: 128
Joined: Fri Feb 24, 2012 4:40 pm
by bullwinkle » Mon Feb 25, 2013 8:06 am
Hi both,

dmesg wasn't showing anything, and in fact on the second run I had cleared it with
Code: Select all
dmseg -c
.
after the modprobe gspca_main, I checked dmesg and it was empty;

For the kernal is is a fresh install of 2013-02-09-wheezy-raspbian.zip pulled from the download page.

I will run the rpi-update tonight when i get home and report back

thanks
Posts: 85
Joined: Wed Jan 09, 2013 12:14 pm
by bullwinkle » Mon Feb 25, 2013 9:24 pm
Hi folks

no luck with the suggest steps using the rpi-update. Here is the list of my steps

Code: Select all
sudo apt-get update
sudo wget http://goo.gl/1BOfJ -O /usr/bin/rpi-update && sudo chmod +x /usr/bin/rpi-update
sudo chmod +x /usr/bin/rpi-update
sudo rpi-update
sudo apt-get install git-core
sudo rpi-update
sudo reboot
wget https://github.com/raspberrypi/linux/archive/rpi-3.6.y.tar.gz
tar xvfz rpi-3.6.y.tar.gz
su
mv linux-rpi-3.6.y /usr/src
ln -s /usr/src/linux-rpi-3.6.y /lib/modules/3.6.11+/build
cd /lib/modules/3.6.11+/build
make mrproper
gzip -dc /proc/config.gz > .config
make modules_prepare
wget https://github.com/raspberrypi/firmware/raw/master/extra/Module.symvers
mv linux-rpi-3.6.y /usr/src
ln -s /usr/src/linux-rpi-3.6.y /lib/modules/3.6.11+/build
cd /lib/modules/3.6.11+/build
make mrproper
gzip -dc /proc/config.gz > .config
make modules_prepare
wget https://github.com/raspberrypi/firmware/raw/master/extra/Module.symvers
cd /usr/src/linux-rpi-3.6.y/drivers/media/video/gspca/
modprobe gspca_main
lsusb
modinfo
lsmod
rmmod gspca_main
lsmod
touch gspca.c
cd /usr/src/linux-rpi-3.6.y/
make drivers/media/video/gspca/gspca_main.ko
mv /lib/modules/3.6.11+/kernel/drivers/media/video/gspca/gspca_main.ko /lib/modules/3.6.11+/kernel/drivers/media/video/gspca/gspca_main.original
cd /usr/src/linux-rpi-3.6.y/drivers/media/video/gspca/
mv gspca_main.ko /lib/modules/3.6.11+/kernel/drivers/media/video/gspca/gspca_main.ko
modprobe gspca_main
ERROR: could not insert 'gspca_main': Exec format error
Code: Select all
dmesg
[ 351.644280] gspca_main: no symbol version for module_layout

not sure what the issue is. I appreciate the support on this
Posts: 85
Joined: Wed Jan 09, 2013 12:14 pm
by hexelpdkk » Mon Feb 25, 2013 9:56 pm
I wonder if it is the make line that is incorrect. My makefile used the following:

Code: Select all
$(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules


i.e. it is specifically using the modules target here, so maybe something like

Code: Select all
cd /usr/src/linux-rpi-3.6.y/drivers/media/video/gspca/
make -C /lib/modules/3.6.11+/build M=/usr/src/linux-rpi-3.6.y/drivers/media/video/gspca/ modules
User avatar
Posts: 128
Joined: Fri Feb 24, 2012 4:40 pm
by bullwinkle » Tue Feb 26, 2013 6:37 am
good morning...

I tried the make command as you noted and it still comes back with the error.
ERROR: could not insert 'gspca_main': Unknown symbol in module, or unknown parameter (see dmesg)
(note that I cleared out all versions of gspca_main.ko on my pi, plus issues a "touch gspca.c"


these are the last entries in dmesg
[ 193.140402] Linux media interface: v0.10
[ 193.157713] Linux video capture interface: v2.00

which look like dependencies as the enteries were not there before i issued the make command.
Posts: 85
Joined: Wed Jan 09, 2013 12:14 pm
by hexelpdkk » Tue Feb 26, 2013 7:49 pm
When I tried to compile just this module, dmesg output has this:
Code: Select all
[ 1432.790852] gspca_main: Unknown symbol v4l2_ctrl_poll (err 0)
[ 1432.790894] gspca_main: Unknown symbol video_ioctl2 (err 0)
[ 1432.790942] gspca_main: Unknown symbol v4l2_device_put (err 0)
[ 1432.791053] gspca_main: Unknown symbol v4l2_fh_open (err 0)
[ 1432.791097] gspca_main: Unknown symbol v4l2_ctrl_handler_setup (err 0)
[ 1432.791142] gspca_main: Unknown symbol video_devdata (err 0)
[ 1432.791199] gspca_main: Unknown symbol v4l2_fh_release (err 0)
[ 1432.791233] gspca_main: Unknown symbol v4l2_ctrl_subscribe_event (err 0)
[ 1432.791262] gspca_main: Unknown symbol video_unregister_device (err 0)
[ 1432.791297] gspca_main: Unknown symbol v4l2_ctrl_s_ctrl (err 0)
[ 1432.791325] gspca_main: Unknown symbol v4l2_device_disconnect (err 0)
[ 1432.791364] gspca_main: Unknown symbol v4l2_device_register (err 0)
[ 1432.791406] gspca_main: Unknown symbol __video_register_device (err 0)
[ 1432.791446] gspca_main: Unknown symbol v4l2_ctrl_g_ctrl (err 0)
[ 1432.791468] gspca_main: Unknown symbol v4l2_ctrl_handler_free (err 0)
[ 1432.791489] gspca_main: Unknown symbol v4l2_device_unregister (err 0)
[ 1432.791536] gspca_main: Unknown symbol video_device_release_empty (err 0)
[ 1432.791566] gspca_main: Unknown symbol v4l2_event_unsubscribe (err 0)

Then looking in /lib/modules/3.6.11+/kernel/drivers/video, there don't seem to be many modules there.
Maybe move up a level into video, and build everything there to get the video for linux modules.
User avatar
Posts: 128
Joined: Fri Feb 24, 2012 4:40 pm
by bullwinkle » Wed Feb 27, 2013 6:45 am
Hi

no luck -
root@raspberrypi:~# modprobe gspca_main
ERROR: could not insert 'gspca_main': Exec format error
dmesg reports
[ 292.745003] gspca_main: no symbol version for module_layout

I'm going to take some time to read up on the Make and Dependencies process. When I compile the whole kernel, I can load the driver so I know it works! Somehow I need to identify all the required dependencies for gspca_main and make sure they are compiled as well.
Posts: 85
Joined: Wed Jan 09, 2013 12:14 pm
by tomdean » Sun Mar 03, 2013 4:41 am
I had a problem in setting this up.

Rather than
cd /lib/modules/3.6.11+/build

I had to
cd /usr/src/linux-rpi-3.6.y

Tom Dean
Posts: 8
Joined: Tue Feb 19, 2013 4:02 am
by bullwinkle » Sun Mar 03, 2013 8:17 pm
thanks tomdean for the tip

I'll give it a go and see what happens.

I've tried a few different options over the last few days and not had any luck so far.
Posts: 85
Joined: Wed Jan 09, 2013 12:14 pm
by blackdot » Thu Mar 21, 2013 4:19 pm
I have exactly same problem. I re-compiled whole kernel once-again to have proper Module.symvers, which was needed during compilation of newer version of gspca driver (http://moinejf.free.fr/gspca-2.15.18.tar.gz).

Now when I try to use my compiled module directly from kernel source or newer driver, I have same error (no symbol version for module_layout).
I tried to use myself compiled videodev.ko and media.ko modules. Same error...

My last idea is to compile whole kernel and modules, install it and maybe then, I will be able to use newer versions of gspca driver...
User avatar
Posts: 6
Joined: Sat May 12, 2012 8:48 pm