Sunday, May 10, 2015

Preparing a test VM - Compile and run a module

Hi,

This is the final post in preparing our test environment. We will write a code piece and run it in the VM. You must have finished previous sections (filesystem, kernel and QEMU) to be able to carry out the instructions in this one. After finishing this you should be able to compile and run your own kernel level code.

Preparing a test VM - QEMU

We have our kernel and our filesystem. Now we need to utilize virtualization to run our OS.

I will not talk about how virtualization or emulation works. However you need to know a few details.

When IT people think what virtualization technology is all about, they often think how host CPUs are shared between VMs and how various memory tricks work, like ballooning or taking memory snapshots. After that storage or network infrastructure and configuration comes to mind. And of course, live migration, which looks like pure magic the first time you see it work (if you have a cluster of hosts)

For kernel development we are interested in different kind of stuff. Most of the time we need only one machine with fixed amount of memory, fixed amount of disk space and just one virtual CPU.

Preparing a test VM - Kernel

In previous post I talked about preparing a filesystem with Gentoo. Today I will talk about compiling the Linux kernel.

In normal Gentoo setup you emerge (install like "apt-get install" in Ubuntu) the kernel from Gentoo repo and compile it on the machine you are installing Gentoo.

We will be doing something different. Using virtualization, we will feed the kernel binary files from the host to the VM. The main reason is we need the compiled kernel files in our development environment to compile modules for that kernel. Kernel source and the module files should be located in the same machine.

Preparing a test VM - Filesystem

Hello,

This will be the first of a five part how-to on using virtualization to create a testing environment. We need a separate test machine because we will be crashing the kernel most of the time and rebooting your computer each time will be hazardous for your computer and frustrating for you.

We will be using QEMU for virtualization and Gentoo for the guest operating system where our kernel code will run. I assume development will be done in the same machine which is the virtualization host. I will not cover the virt host/development environment, you can use any distro capable of running QEMU (and preferably kvm).

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:

Tuesday, December 10, 2013

Hello and welcome.


I have been writing about my develepment endeavours for sometime. I decided to share my articles from which other people may learn in a seperate blog. I will also move some of my old articles here too, after refining them into teaching materials.

I hope to write about kernel and system programming under Linux most of the time. I may also write about embedded Linux (hence the name "elinuxdev") too. I think I'll also need to write about how operating systems operate from time to time. Other than these I can share some development tips on Qt and SDL. Time will tell what other subjects I can carry here.

I am planning to begin with Linux kernel development tutorials. I am also a newbie myself, therefore don't expect anything beyond basic tutorials. They won't be much helpful as they are but I think they will be indispensable as supplementary resources.

The reason for that is there is no middle ground for writing kernel code. There are a lot of printk tutorials which does not accomplish anything useful. However if you want to do something useful and do it the right way you need to read quite a few chapters of a kernel development book. And that can be frustrating, reading all that stuff, unable to write a single line of code. You can't try to read a small and simple driver code because there exists none. Even the char driver example on LDD3 consists of multiple files and thousands of lines of code.

So what I hope to accomplish with kernel development articles is to illustrate some topics with code examples. To show people trying learn kernel level coding that it is possible.

Secondly I hope to write some articles on Linux kernel and operating system concepts for electronics engineers whom might be having difficulties moving from programming the CPUs directly to writing code for the colossal and monolithic code base that is the Linux kernel. In my country many electronics companies are trying to move to embedded Linux but having difficulties because they don't know what exactly an operating system does and which parts they should be making development on. My previous boss wanted me to prepare some resources on this but we never had the time. I think some articles on these subjects will be valuable to most companies who feel the need to start using embedded Linux.

So let's begin...