1 Preface
By default, the Ubuntu system is not installed kernel source (only header files). This can be verified by looking at the /usr/src directory, as shown in the following illustration:
This is not easy to write drivers, so it is best to install a source code.
2 installation Kernel source code
Depending on the hints in reference [1], you can view the available source packages by following these commands:
sudo apt-cache search Linux-source
The results are as follows:
Visible from the above figure, only linux-source-3.13.0 is available for download and there are Ubuntu patches. Next you can download and install the above source code through the following commands:
sudo apt-get install linux-source-3.13.0
Upon completion, there will be more linux-source-3.13.0 and linux-source-3.13.0.tar.bz2in the /usr/src directory, where LINUX-SOURCE-3.13.0.TAR.BZ2 is a soft link whose real source code is in the linux-source-3.13.0 directory (the directory also contains Debian-related content),
At this point, you also need to decompress the above linux-source-3.13.0.tar.bz2 with the following command:
sudo tar-axvf linux-source-3.13.0.tar.bz2
The extracted files will remain in the
linux-source-3.13.0directory, merging with the files in it.
reference materials
[Write my first driver under 1]ubuntu