22

I have been working in embedded OS like uCOS, ThreadX. While I have coded apps in Linux, now I’m planning to start learning Linux Kernel. I have few questions regarding the environment.

  1. Which is best distro, which has easy to use tools for kernel development? (so far I had used RHEL and Fedora. While I am comfortable with these, it also looks like Ubuntu has in-built scripts for easy kernel compilation like make_kpkg, etc)

  2. Can you describe the best setup for kernel debugging? While debugging other embedded OSes, I have used serial port to dump progress, JTAG, etc. Which kind of setup does the Linux kernel devs use? (Will my testbed PC with serial port is enough for my needs? If yes, how to configure the kernel to dump to serial port?) I'm planning to redirect kernel messages to serial console which will be read in my laptop.

  3. What tool is best for debugging and tracing kernel code? As mentioned earlier, is serial console the only way? Or any IDE/JTAG kind of interface exists for PC?

  • 3
    For #1, Linus himself uses Fedora, so that possibly says something. I don't know enough on this topic to really give an answer, but I'd be interested in what other people say. – jonescb Mar 16 '11 at 12:58
  • 1
    make_kpkg comes from Debian, which Ubuntu is based on and my fav distro ;) – Deleted Account Mar 16 '11 at 22:50
14

My personal flavor for Linux Kernel development is Debian. Now for your points:

  1. As you probably guessed Ubuntu doesn't bring anything new to the kernel to ease development afaik, apart from what's already available in Debian. For e.g. make_kpkg is a Debian feature and not Ubuntu. Here are some links to get you started on common Linux Kernel development tasks in Debian:

  2. The easiest way to do kernel debugging is using QEMU and GDB. Some links to get you started:

    Though, you should be aware that this method is not viable for certain scenarios like specific hardware issues debugging and such, for which you would be better of using physical serial debugging and real hardware. For this you can use KGDB(it works using ethernet too). KDB is also a good choice. Oh, and by the way, both KGDB and KDB have been merged into the Linux Kernel. More on those two here. Another cool method, which works marvelously for non-hardware related issues, is using the User-mode Linux Kernel. Running the Kernel in user-mode as any other process allows you to debug it just like any other program(examples). More on User-mode Linux here. UML is part of the Linux Kernel since 2.6.0 , thus you can build any official kernel version above that into UML mode by following these steps.

  3. See item 2. Unfortunately there is no ultimate best method here, since each tool/method has its pro's and con's.

| improve this answer | |
6

If you're developing for an embedded platform that's not based on i386 hardware, you'll need to cross-compile. The Emdebian project provides toolchains to develop for many architectures (ARM, m68k, MIPS and more) on PCs (i386 or amd64). That means under Debian, you can simply add the repositories and apt-get install the toolchain for the target(s) of your choice.

| improve this answer | |
3

JTAG probes do exist, but these are fairly expensive (and the companies building them have exclusive contracts). The best way to debug kernel code is to start it in kvm or qemu with gdbserver inside the emulation.

| improve this answer | |
  • Even better, use User Mode Linux. Linux as a regular userland process. – vonbrand Jan 18 '13 at 0:54
0

Essentially any mainline distribution should work fine for this (they use their own distribution to hack on it). Use whatever feels more confortable.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.