3

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?

  • Seems to be udev issue. I believe the devixe file is created by udev not manually, right? It would be good if you specify which distribution are you using. Sharing source code of driver is also a good idea. – Krzysztof Adamski Aug 9 '12 at 15:05
  • The full source is on the page in the link in the question. The device file is created/destroyed using 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. – Dylan Aug 9 '12 at 15:19
  • I am also using the kernel config as extracted from /proc/config.gz on the device. – Dylan Aug 9 '12 at 15:21
  • Also, dmesg does not show any errors/warnings from the module. – Dylan Aug 9 '12 at 15:23
3

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). – Dylan Aug 9 '12 at 16:11
  • 2
    My 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. – Chris Stratton Aug 9 '12 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. – Dylan Aug 9 '12 at 17:29

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.