vix
Posts: 3
Joined: Sun Oct 20, 2013 7:03 pm

SOLVED: Module driver - crash kernel by rmmod

Wed Oct 23, 2013 10:59 am

Hi!
This simple module source:

Code: Select all

#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/fs.h>

MODULE_LICENSE("Dual BSD/GPL");
MODULE_AUTHOR("author");
MODULE_DESCRIPTION("module description");
MODULE_VERSION("0.0");

unsigned char foo[8];
static dev_t dev;

//---------------------------------------------
static int __init led_init(void) 
{
  int ret;  
  ret = alloc_chrdev_region(&dev, 0, 1, "foo_device");
  
  if(ret) printk( KERN_ALERT "Unable to register module with error %d\n", ret);
  else    printk( KERN_ALERT "Device registered with number %08x (major:minor = %d:%d)\n", dev, MAJOR(dev), MINOR(dev));
   
  return ret;
}
//---------------------------------------------
static void __exit led_exit(void) 
{
  printk( KERN_ALERT "Try to unregister module...\n" );
  unregister_chrdev_region(dev, 1);
  printk( KERN_ALERT "Test module is unloaded!\n" );
} 
//---------------------------------------------
module_init(led_init);
module_exit(led_exit);
This is normally compiled and loaded with insmod.
But when i tried to rmmod, kernel was crashed:

Code: Select all

[email protected]:~/test$ sudo insmod test.ko
[ 1067.554098] Device registered with number 0f800000 (major:minor = 248:0)
[email protected]:~/test$ sudo rmmod test.ko
[ 1075.925955] Unable to handle kernel paging request at virtual address 0f800000
[ 1075.934973] pgd = dcf4c000
[ 1075.940372] [0f800000] *pgd=00000000
[ 1075.946363] Internal error: Oops: 80000005 [#1] PREEMPT ARM

Entering kdb (current=0xdcf3a4c0, pid 2503) Oops: (null)
due to oops @ 0xf800000

Why?
Last edited by vix on Thu Oct 24, 2013 7:28 am, edited 1 time in total.

vix
Posts: 3
Joined: Sun Oct 20, 2013 7:03 pm

Re: Module driver - crash kernel by rmmod

Thu Oct 24, 2013 7:27 am

Problem solved: i recompile kernel as descripted here: http://elinux.org/RPi_Kernel_Compilation
Very unfortunate that kernel built is not the same compiler that is included in the Raspbian.
I thank everyone for their help in solving the problem! ;)

sanchomuzax
Posts: 13
Joined: Tue Apr 09, 2013 9:36 pm

Re: Module driver - crash kernel by rmmod

Tue Nov 12, 2013 10:33 pm

vix wrote:Problem solved: i recompile kernel as descripted here: http://elinux.org/RPi_Kernel_Compilation
Very unfortunate that kernel built is not the same compiler that is included in the Raspbian.
I thank everyone for their help in solving the problem! ;)
Can you recompile the kernel if the Rpi's booting is halted?

I don't understand that how can I recompile it and copy to the SD without lost the older data.

Return to “Linux Kernel”