I'm trying to build some kernel modules on RPI, the ismond work fine for some times, now the insmod command crash each time I try to insert a simple module. the kernel module compile without any error or warnings, and I'm not using any pointers. I used modprobe instedd of insmod and still getting same error

I got always this message, not matter what the kernel module contain

root@raspberrypi:/home/pi/test_gpio_driver# insmod gpio.ko 
Segmentation fault
Message from syslogd@raspberrypi at Jan  5 17:22:03 ...
 kernel:[  312.961379] Internal error: Oops: 5 [#1] PREEMPT ARM

Message from syslogd@raspberrypi at Jan  5 17:22:03 ...
 kernel:[  313.071855] Process insmod (pid: 2306, stack limit = 0xdb1d81b0)

Message from syslogd@raspberrypi at Jan  5 17:22:03 ...
 kernel:[  313.079360] Stack: (0xdb1d9e90 to 0xdb1da000)

Message from syslogd@raspberrypi at Jan  5 17:22:03 ...
 kernel:[  313.085167] 9e80:                                     bf0c413c c006d420 bf0c413c 00007fff

Message from syslogd@raspberrypi at Jan  5 17:22:03 ...
 kernel:[  313.096194] 9ea0: c006a6e4 dc803000 00000000 c006a7b0 00000000 bf0c4278 bf0c413c db1d8018

Message from syslogd@raspberrypi at Jan  5 17:22:03 ...
 kernel:[  313.107386] 9ec0: ddef4b40 bf0c4130 db1d9f60 db1d9f8c ffffffff db1d9f14 00000000 00000000

my kernel module

#include <linux/module.h>
#include <linux/init.h>
static int __init mymodule_init(void)
 printk ("My module worked!\n");
        return 0;
static void __exit mymodule_exit(void)
 printk ("Unloading my module.\n");
  • Does it work if you remove the request_irq and free_irq calls? – joan Jan 9 '15 at 17:42
  • no, even if i keep just the init and exit function with empty body, I got same error – mikmik Jan 9 '15 at 17:44

I also had a problem similar to yours and the solution was to use rpi-update to update the kernel and rpi-source.

So, steps:

  1. sudo rpi-update and when it's done, reboot the Raspi
  2. Install the rpi-source: sudo wget https://raw.githubusercontent.com/notro/rpi-source/master/rpi-source -O /usr/bin/rpi-source && sudo chmod +x /usr/bin/rpi-source && /usr/bin/rpi-source -q --tag-update
  3. You may need GCC 4.8 so:sudo apt-get install -y gcc-4.8 g++-4.8 and sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 20 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50 sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 20 sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50 You whould replace in the previous command the gcc-4.6 with your version of gcc
  4. Install ncurses-devel: sudo apt-get install libncurses5-dev; It's needed by rpi-source.
  5. Run rpi-source

This steps worked for me and I could compile and install a driver.

  • i followed those steps and still get same segmentation fault – mikmik Jan 18 '15 at 11:40

Are you sure there is no mismatch between the kernel you compiled for and the kernel you run? For example, you installed different Linux headers on you Raspberry with different version than your kernel. Possible solution HERE

  • I updated my kernel with rpi-update to 3.12.36+ and installed the source as indicated in raspberrypi.stackexchange.com/questions/15902/…, but the kernel didn't created /lib/modules/3.12.36+/build directory, so the available sources are obsolete (perhaps for 3.12.35+). with 3.12.35+I compile but get the segmentation fault error – mikmik Jan 18 '15 at 11:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.