mxchi
Posts: 6
Joined: Sun Oct 21, 2012 5:13 pm

Build Kernel for qemu

Fri Nov 16, 2012 6:12 pm

Hi I try to run a virtual raspberry pi with Qemu.

I configure the build with the following commands

Code: Select all

export ARCH=arm
export CROSS_COMPILER=arm-linux-gnueabli-
make bcmrpi_defconfig
make -j 4 all
Then,I get a zip kernel image
zImage
and run the virtual machine with command

Code: Select all

qemu-system-arm 
 -M versatilepb 
 -cpu arm1176 -m 256 
 -kernel zImage
 -hda SDCard.img 
 -nographic 
 -append "root=/dev/sda2"
However, the virtual machine doesn't start up as expected, can some tell me which part is wrong?
Can somebody tell me how to run a virtual Pi properly?

Thanks a lot

User avatar
PIstolero
Posts: 101
Joined: Mon Jul 23, 2012 6:28 am
Location: paradise city, where the grass is green and the girls are pretty

Re: Build Kernel for qemu

Mon Nov 19, 2012 4:25 pm

Did you patch the kernel for qemu before you compile it?

mxchi
Posts: 6
Joined: Sun Oct 21, 2012 5:13 pm

Re: Build Kernel for qemu

Mon Nov 19, 2012 11:04 pm

PIstolero wrote:Did you patch the kernel for qemu before you compile it?
:shock: Is there a patch for qemu? would you show me the link please

User avatar
PIstolero
Posts: 101
Joined: Mon Jul 23, 2012 6:28 am
Location: paradise city, where the grass is green and the girls are pretty

Re: Build Kernel for qemu

Tue Nov 20, 2012 4:40 pm

Patch it for qemu with this:
http://xecdesign.com/downloads/linux-qe ... -arm.patch
The kernel has changed since this aptch was released so you will get this error message:

Code: Select all

patching file arch/arm/mach-versatile/Kconfig
patching file arch/arm/mm/Kconfig
Hunk #1 succeeded at 71 (offset -36 lines).
Hunk #2 succeeded at 89 (offset -36 lines).
Hunk #3 succeeded at 127 (offset -36 lines).
Hunk #4 succeeded at 135 (offset -36 lines).
Hunk #5 FAILED at 391.
1 out of 5 hunks FAILED -- saving rejects to file arch/arm/mm/Kconfig.rej
So you just have to patch hunk#5 from hand with an editor. It is important, else it will not work.

Don´t do "make bcmrpi_defconfig" but do "make ARCH=arm versatile_defconfig" because you are emulating a versatilePB
Then you have to add some things like ext4 support, SCSI controller support that it works in qemu.
I used this how-to, it is not up to date, you have to add some things like ext4 with make ARCH=arm menuconfig for raspbian and patch a file yourself (see above):
http://xecdesign.com/compiling-a-kernel/

P.S: Here you can a find a 3.2.27 and a 3.6.y kernel for qemu and raspbian from me:
http://www.raspberrypi.org/phpBB3/viewtopic.php?t=16081

Return to “Linux Kernel”