4

I'm trying to get a webcam working with my Raspberry Pi
How do I install webcam firmware on the Raspberry Pi?

I found a possible way of doing this with gspca.

So I downloaded the file and unzipped it.
http://moinejf.free.fr/gspca-2.15.19.tar.gz

I followed the instructions in this answer (replacing with my version number 3.6.11+)
https://raspberrypi.stackexchange.com/a/1304/3027

And now I'm trying to run the makefile that I unzipped but I get this error and my googling has been fruitless so far.

root@WebCamEthernet:/home/pi/Downloads/gspca-2.15.19# make
make -C /lib/modules/3.6.11+/build M=/home/pi/Downloads/gspca-2.15.19/build modules
make[1]: Entering directory `/lib/modules/3.6.11+/build'
make[1]: *** No rule to make target `modules'.  Stop.
make[1]: Leaving directory `/lib/modules/3.6.11+/build'
make: *** [modules] Error 2

Here is the makefile.

KVER=$(shell uname -r)
KSRC=/lib/modules/$(KVER)/build
KGSPCADIR=/lib/modules/$(KVER)/kernel/drivers/media/video/gspca

all: modules

modules:
    $(MAKE) -C $(KSRC) M=$(PWD)/build modules

gspca_%::
    $(MAKE) -C $(KSRC) M=$(PWD)/build gspca_main.ko $@

install:
    rm -f $(KGSPCADIR)/gspca*.ko $(KGSPCADIR)/*/gspca*.ko \
            $(KGSPCADIR)/gspca*.gz $(KGSPCADIR)/*/gspca*.gz; \
    install -c -m 0644 build/*.ko $(KGSPCADIR)/; \
    depmod

# local development
dist:
    ln -s . gspca-$(VERSION); \
    files=`ls gspca-$(VERSION)/build/*.c | fgrep -v .mod.c`; \
    tar -zcvf gspca-$(VERSION).tar.gz \
            gspca-$(VERSION)/Makefile \
            gspca-$(VERSION)/README \
            gspca-$(VERSION)/build/Makefile \
            gspca-$(VERSION)/build/gspca.h.orig \
            gspca-$(VERSION)/build/*.h \
            $$files; \
    rm gspca-$(VERSION)
.PHONY: dist driver install update modules

I'm not sure what is going on. What does this error mean?

Biff MaGriff
  • 291
  • 2
  • 4
  • 14

4 Answers4

5

/lib/modules/NN.NN.NN/build is conventionally a soft link to the kernel source tree used to build the modules (often /usr/src/linux-NN.NN.NN). [The 'N' there and in the rest of this post means an actual version number, not a literal N.]

It would appear you are using 3.6.11+ ? Make SURE this is the case.

uname -r

If it's actually 3.2.27+, then use that source below. If it really is 3.6.11+, I'm curious as to how you ended up with that (since having a used source tree may save you a lot of time and I don't think anything ships with it pre-compiled).

Anyway, if you don't have such a tree, you can download a "clean" one:

I copied these links from here. I've used the 3.6.11 on the pi so they should be good. Put the tarball in /usr/src and extract:

tar -xzf rpi-3.[N.N].tar.gz

Now, if the directory created is "rpi-3.2.27":

rm /lib/modules/3.2.27/build
rm /lib/modules/3.2.27/src
ln -s /usr/src/3.2.27 /lib/modules/3.2.27/build
ln -s /usr/src/3.2.27 /lib/modules/3.2.27/src

This creates the link needed to access the kernel source to build your module. Unfortunately, this might involve building various kernel bits. You need to include the current kernel config:1

cp /proc/config.gz /usr/src/[name of source directory]/
cd /usr/src/[directory]
gunzip config.gz
mv config .config

Now you can try your module build. As mentioned, this will involve building bits in the source tree. I used a cross-compiler on a desktop to build a kernel for the pi, but I suspect if you have to do it on the pi itself this could take a long time -- like dinner, a movie, and take the long way home time. So, if you do have a 3.6.11 tree around that you've already used to build your current kernel, use that instead, since it will contain any relevant bits and pieces.


1. If you can't find /proc/config.gz, try sudo modprobe configs and look again.

goldilocks
  • 58,859
  • 17
  • 112
  • 227
  • Awesome, can't wait to try this at home today. I have no idea how I got 3.6.11+, I've run a lot of various linux commands from various websites on this PI. That is just the version number my pi says when I log in from SSH. – Biff MaGriff Mar 04 '13 at 16:53
3

We had the very same problem, and it turned out that '$(PWD)/build' directory, '/lib/modules/4.8.0-53-generic/build' on my laptop, is empty, but this build folder must be a shortcut of '/usr/src/linux-headers-4.8.0-53-generic' directory, therefore we built such shortcut manually and finally it started working perfectly.

  • note: linux-headers-4.8.0-53-generic is my kernel's header's name!
  • you must have linux-headers installed on your system.
farnaz
  • 31
  • 1
1

First you need to ensure you have the kernel headers installed in the device, you can check using ls -l /usr/src/linux-headers-$(uname -r) , if you don't see any files in the output you need toinstall the rpi headers for the kernel. You can download it using sudo apt install raspberrypi-kernel-headers.

If you already have the the said headers installed you can try reinstlling that by sudo apt install raspberrypi-kernel-headers --reinstall

Even if that doesn't work you need to see if the folder is a symlink to the other folder and follow the instructions to create a symlink to the actual location of the headers

Iamdiv007
  • 11
  • 2
0

I spent two days in this problem. I had to upgrade the OS using this link

sudo apt dist-upgrade -y 
sudo rpi-update 
sudo apt update sudo apt
dist-upgrade
M.Hefny
  • 111
  • 4