I want to try my hand at writing a linux driver. I am trying to set up my environment. My current kernel:
$ uname -r 4.10.0-37-generic
I then download the source code:
$ apt-get source linux-image-$(uname -r) Reading package lists... Done Picking 'linux' as source package instead of 'linux-image-4.10.0-37-generic' ...
I go to compile and modprobe my driver, it fails. Looking in dmesg, it shows:
version magic '4.10.17 SMP mod_unload ' should be '4.10.0-37-generic SMP mod_unload '
At this point, I'm confused. I go back to the source tree I downloaded, and when I run
$ make kernelversion 4.10.17
Ok, try two. Download kernel 4.10.17 and install it.
$ uname -r 4.10.17-041017-generic
version magic '4.10.17 SMP mod_unload ' should be '4.10.17-041017-generic SMP mod_unload
So maybe someone can help: what is the best and correct way for me to get a working kernel and matching source on ubuntu (well, xubuntu, but I don't think it should matter)? Do I need to get the code from kernel.org and build it from scratch? I kinda want to match the shipping Ubuntu kernel.