I have had success following tutorials for developing kernel modules, running them on a Ubuntu 12.04 LTS virtual machine. Particularly the example in this tutorial works fine on Ubuntu on a 3.2.0 kernel. However when cross compiled for the current Raspbian kernel, the module does not remove the entry in /dev/
during rmmod
, leaving a device file that complains No such device or address
when used. All other aspects of the module seem to work correctly, including the removal of entries in sysfs.
The tutorial was developed for kernel version 3.0.3, so I cannot see this being an API difference between 3.1.9 and 3.2.0. Are there any Pi specific changes/workarounds that I should be aware of?
1 Answer
The kernel does not create device files.
The kernel creates and destroys the actual device, but something in userspace - typically either udev or you the sysadmin - must create/remove the device files.
Device files are ultimately just a handle for major/minor number pairs - you can give them any name you like. It's entirely possible to have a device file with no device, or a device with no device file.
-
I do know that. Maybe I should have stated that this points to a possible problem with udev. At any rate your answer does not answer the question. I clearly stated that the problem is that the device file is left behind (implying that either udev is not working or there is a nuancy of the API not being used correctly).– DylanAug 9, 2012 at 16:11
-
2My answer is to point out that removing the device file is not part of what the rmmod command does to the kernel and should not by itself be expected to do that. On some systems it may trigger device file removal, but that is actually done by a separate userspace process such as udev; if you wanted to ask a udev configuration question, then that is what you should have posted. You might start by comparing the applicable udev rules files on the two systems. Aug 9, 2012 at 16:53
-
Thank you, that was something which I previously found unclear. I have no experience of udev rules. I will look into this before posting a way of implementing the desired behaviour on the Pi.– DylanAug 9, 2012 at 17:29
device_create
/device_destroy
. I'm compiling on Ubuntu 12.04 LTS using arm-linux-gnueabi-gcc 4.6 from the Ubuntu repositories and the latest (as of yesterday) Raspberry Pi kernel. The device itself is running a fully up to date (including firmware) Raspbian "wheezy" distribution.dmesg
does not show any errors/warnings from the module.