Re:Write your first Linux kernel module
by mschuster91 on Saturday May 31, 2014 @02:04PM
(#7826682)
> Very often it's just people who want to have a 7-segment LED display show the number of unread emails, or get a soundcard running, something along these lines.
7-seg LEDs are best controlled by a microcontroller attached via USB or a USB-RS232 interface, as next to no one ships a parallel printer port. Soundcards these days usually all already have kernel drivers, I haven't heard of any modern chip without.
And USB stuff is best developed in userspace with libusb, it's way easier...
And for them it's completely ok that there's a race-condition that might crash their machine if the kernel-module is unloaded just at the instant where the USB plug is removed -- that's something to learn, once the general grasp of how kernel-code with it's myriad of callbacks and hierarchies of subsystems has been reached.
Most crashes also will be catched by the Kernel and will leave you with nothing more than a
in your dmesg, and maybe a dead "insmod" process in your process table. Make a note of the call trace, sync, reboot (maybe hard, using the magic sysrq key) and you are off for the next round of debugging. Try it, it's fun. Also there's kgdb which you can use when your bugs aren't that obvious.I never had serious data loss (maybe the freshly compiled .o files will have 0-size, if I was in too much of a hurry to insmod ./my_module.ko. And even if, it will teach you to have an easily restorable development machine.
(I triggered the oops with...)