Friday, December 13, 2013

Linux kernel development articles - Intro

Hi,

Before I start posting tutorials on basic subjects I want to give a brief overview of what I plan to teach and talk about developing code for the Linux kernel in general.

As I said in a previous blog post, these articles will be of supplementary nature. You need to read an actual book (or better a few books) on Linux kernel. However seeing is believing as they say and I think it will be faster/easier for you if you take a look at the code I distribute.

Here are all the links to the sections of this howto:

There are a few topics I want to discuss beforehand.

Previous knowledge


I assume you already know how a CPU operates and know a good deal of C programming. You will need to be reading a book on Kernel development, I read and recommend LDD3 and Robert Love's Linux Kernel Development. You can use any other books too. I will tell you what you need to know about kernel in the beginning of each article.

We will be using virtual machines for testing environment so you need to be able to create a virtual machine and install Ubuntu on that (we won't use Ubuntu but if you can setup a virtual machine with Ubuntu I guess you will be alright). I will be assuming you are using a Linux test VM inside a Linux host. Of course other setups are possible, like two Linux VMs under Windows, one for testing and one for development/compiling. Ideally you should seperate your development and testing machines.

Finally you need to have an idea of how stuff works in low level for some topics, I will tell what you need to know when each topic arrives. These won't be deep subjects, just basic stuff you can look up on Wikipedia.

IDE or not


Unfortunately you can't use any IDE you want for Linux development, that is if you want to be able to navigate the code (for example opening the function definition by clicking on a function). The reason is Linux kernel is very large. For example Code::Blocks can't open it on most machines, it runs out of memory. Qt Creator has other kinds of problems, with C code and assembly and macros. So I recommend using Eclipse IDE, but in a seperate workspace directory which you can manipulate if you need to. Because it will create an index file of size about 3-4 GBs.

Linux kernel code contains its own kind of keywords which gcc understands but most likely which your IDE will take for errornous definitions. So instead of using an IDE you can use Vim (or your favourite text editor) with cscope. I won't go into details of using cscope but it does indexing similar to Eclipse (with a much smaller index file) and you can search function definitions etc. with it.

Also you can use free-electrons' online code browser in a similar manner outside of your code editor.

Testing


I will first write how to create our testing environment. You can use your own testing environment too if you have one. I will just write how to setup a Gentoo VM because that is the testing environment I use. I will also provide some scripts to send new kernels to the VM easily.

After that you should be able to compile and test my module codes in Github.

Rest we will see as I upload the articles. See you around if you are interested in learning Linux kernel development. Drop comments :)

No comments:

Post a Comment