Building Pi Modules Without Building the Kernel

Every now and then I get back to my Raspberry Pi, and realise that I have completely rebuilt my image. That makes it pretty hard to find my module building instructions, so here they are:

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

exit

Then my makefile for the actual module is

obj-m := kcrDriver.o

all:

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

clean:

$(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

What is particularly useful about this is that I don’t need to compile the entire kernel just to build my one module.

Advertisements

14 thoughts on “Building Pi Modules Without Building the Kernel

  1. Thomas Dean

    I had a problem with
    cd /lib/modules/3.6.11+/build
    then following commands failed
    I did
    cd /usr/src//linux-rpi-3.6.y/
    and everything worked fine.
    Don’t understand this – ls shows the same files in both places…
    I looked at several files and they are the same.
    It is almost like bash is not following the link properly. I created the link with ‘ln -s…’

    Strange.

    Reply
  2. Pingback: Making a Goat Webcam: Taming The TP-LINK TL-WDN3200 | Randy Builds Things

    1. hexelpdkk Post author

      Thanks for commenting. Did you update kernel using rpi-update, or are you just using the default? I have had a couple of people having issues withy these instructions, and occasionally try and find out why it works for most but not for all.

      Reply
  3. Pingback: Building the UT-100 driver on the Raspberry Pi – Servage Autoinstaller

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s