Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to compile a kernel module for Raspberry pi?
    text
    copied!<p>I'm having trouble compiling a kernel module for a raspberry pi. I want to compile a "hello world" kernel module using the raspberry pi itself.</p> <p>I am using raspbian wheezy 3.6.11+.</p> <p>I tried following the directions at <a href="http://elinux.org/RPi_Kernel_Compilation">http://elinux.org/RPi_Kernel_Compilation</a>.</p> <p>Here is the Makefile I am using:</p> <pre><code>obj-m += hello-1.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 </code></pre> <p>Here is the source code for hello-1.c:</p> <pre><code>/* * hello-1.c - The simplest kernel module. */ #include &lt;linux/module.h&gt; /* Needed by all modules */ #include &lt;linux/kernel.h&gt; /* Needed for KERN_INFO */ int init_module(void) { printk(KERN_INFO "Hello world 1.\n"); /* * A non 0 return means init_module failed; module can't be loaded. */ return 0; } void cleanup_module(void) { printk(KERN_INFO "Goodbye world 1.\n"); } </code></pre> <p>Here's what I get when I try to make the project:</p> <pre><code>root@raspberrypi:/home/pi/hello-module# make make -C /lib/modules/3.6.11+/build M=/home/pi/hello-module modules make: *** /lib/modules/3.6.11+/build: No such file or directory. Stop. make: *** [all] Error 2 </code></pre> <p>I tried creating the build directory at /lib/modules/3.6.11+</p> <pre><code>make -C /lib/modules/3.6.11+/build M=/home/pi/hello-module 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: *** [all] Error 2 </code></pre> <p>I have GNU Make 3.81 and gcc (Debian 4.6.3-14+rpi1) 4.6.3 installed. I also installed the linux source using </p> <blockquote> <p>sudo apt-get install linux-source</p> </blockquote> <p>Any ideas on what I might do to get this to compile?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload