Hardware Reference
In-Depth Information
Why Is This Kernel Special?
You might have noticed that we have not pointed you to the hack in this topic ( Hack
#22 ) that covers building a custom kernel for booting on the Raspberry Pi. This is
intentional, because that kernel will not work on qemu_ . Qemu emulates a wide range
of hardware environments, but the exact hardware found in the Raspberry Pi is not
yet one of them.
The kernel-qemu file uses the closest match available in qemu and provides the
same level of ARM optimization and runtime support. This allows you to use almost
everything in your Raspberry Pi Linux distribution userspace as is. The most no-
table exception is the videocore libraries (and any applications which use them).
Because qemu has no BCM2835 system-on-chip hardware emulation, these ap-
plications will fail to operate properly in qemu emulation.
Create a directory to work in, and put a copy of your distro's image and kernel-qemu
in it. The rest of this example will use the Pidora 18 image ( pidora-18-r1c.img ) and
qemu as that directory, though you can replicate these instructions for other distros
and of course name your directories whatever you like.
Run file on the image:
$ file pidora-18-r1c.img
pidora-18-r1c.img: x86 boot sector; partition 1: ID=0xc, active, starthead
32, startsector 2048, 102400 sectors; partition 2: ID=0x83, starthead 32,
startsector 104448 , 3389858 sectors, code offset 0xb8
Take the startsector number from partition 2 (bold in the previous output) and mul-
tiply it by 512 to use as the offset number when you mount the image:
$ sudo mount qemu/pidora-18-r1c.img -o offset=53477376 /mnt/pidora
Now open /mnt/pidora/etc/ld.so.preload in a text editor and comment out the one
line you find there by adding a # in front of it and saving the file. You can now unmount:
$ sudo umount /mnt/pidora
And you're ready to start Pidora in QEMU:
$ qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -
serial stdio -append "root=/dev/sda2 panic=1" -hda pidora-18-r1c.img
These are the options you're setting:
-kernel
You're telling it to use the kernel-qemu kernel file you downloaded. If you created
your own, specify its name+/path+ here instead.
 
Search WWH ::




Custom Search