I'm running through the amazing Baking Pi tutorials, which actually convinced me to buy an rPi in the first place. I realize I (obviously) can't emulate the "status" light, but I read all of those documents and think I have a good idea of what's happening.

Now that I've gotten to the "screen" portions, I should be able to emulate those programs with qemu, right? I realize that I need to already have something like Raspbian (which according to the tutorial should be on an SD card), but how should I best expand the img file to replace the kernel.img file with my own?

Obviously, I've already tried something along the lines of qemu -kernel kernel.img -cpu arm1176 -m 256 -M versatilepb -serial stdio with no luck because it's obviously missing the bootloader.

Any ideas? Suggestions? I really appreciate the help!

If anyone was curious without wanting to dig through the lessons, here's the relevant excerpt: "To install your operating system, first of all get a Raspberry PI SD card which has an operating system installed already. If you browse the files in the SD card, you should see one called kernel.img. Rename this file to something else, such as kernel_linux.img. Then, copy the file kernel.img that make generated onto the SD Card. You've just replaced the existing operating system with your own. To switch back, simply delete your kernel.img file, and rename the other one back to kernel.img. I find it is always helpful to keep a backup of you original Raspberry Pi operating system, in case you need it again." src

UPDATE I think I'm getting a little closer, but still with no luck. I had to mount the raspbian image in two phases, one for the main partition, and once for the boot partition (mount -o loop,offset=$((122880 * 512)) rasbian.img /mnt/img && mount -o loop,offset=$((8192 * 512)) rasbian.img /mnt/img/boot).

I then went to /mnt/img/boot renamed kernel.img, and cp'd my own kernel.img to the dir. It took me a while to realize that when I unmounted /mnt/img it wasn't saving my files back to the img (duh).

My next course of action was to repack the mount with mkisofs -o test.img /mnt/img which took quite a bit of time only to result in qemu crashing when running the command aforementioned. Any other suggestions?

  • So to clarify, you have made your own custom kernel, and you want to replace the linux kernel inside of a Raspbian build?
    – John
    Jun 26, 2013 at 2:50
  • @John yes! at least that's how interpreted the instructions in OK01 Jun 26, 2013 at 3:36

2 Answers 2


Ok so this might be a lot easier than I first thought. I thought replacing the kernel would involve replacing more than just the .img file but apparently thats it.

Before you start, make sure you have an SD card that has Raspberry Pi installed correctly.

Step 1

Put the SD card into your computer and open then boot partition


access the /boot directory from the Raspberry Pi

Step 2

Rename the current kernel to something else, like linux_kernel.img

Step 3

Copy your custom kernel into the /boot folder and name it kernel.img


Reboot your pi with your fingers crossed.

from:http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/ok01.html (header 7 Pi Time near the bottom)

and one final note:

making frequent backups is a good habit when screwing with the kernel

  • 2
    Sorry for not being terribly clear, but I'm looking to emulate the Pi with qemu until my real hardware gets here Jun 26, 2013 at 3:49
  • it should still work, just replace the /boot/kernel.img file with the file you compiled from the assembly code, just make sure you keep the name kernel.img
    – John
    Jun 26, 2013 at 3:52
  • I don't have anywhere to mount the img to in order to access the /boot directory. My SD card is in the mail too, haha Jun 26, 2013 at 3:56
  • inside of the emulator, open up a terminal window in xWindows (I think it has to be root). Then navigate to /boot/
    – John
    Jun 26, 2013 at 3:59
  • okay! great! I actually just turned off my rig for the night, but I'll definitely have to try it tomorrow morning, thank you! Jun 26, 2013 at 4:01

There's a nice explanation about emulating Raspberry Pi with QEMU available:


Or there's another one, including the pictures!!


Please, read 'em and follow 'em and ask questions if it does not work.

  • I actually was following this tutorial. I can get Raspbian to boot just fine, but I'm having trouble completing the next step, which involves changing the kernel.img in the boot sector of raspbian.img Jun 27, 2013 at 12:19

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.