I've downloaded the Raspbian image on this page. I'm trying to compile a kernel that can be used to boot the image within qemu.
I downloaded the Linux kernel source from kernel.org and ran:
make versatile_defconfig
make menuconfig
I then added the following features to the kernel:
- PCI support (CONFIG_PCI)
- SCSI Device Support (CONFIG_SCSI)
- SCSI Disk Support (CONFIG_BLK_DEV_SD)
- SYM53C8XX Version 2 SCSI Support (CONFIG_SCSI_SYM53C8XX_2)
- The Extended 3 (ext3) filesystem (CONFIG_EXT3_FS)
- The Extended 4 (ext4) filesystem (CONFIG_EXT4_FS)
I also loop mounted the disk image and:
- commented out
/etc/ld.so.preload
- adjusted
/etc/fstab
to use/dev/sda1
and/dev/sda2
I then unmounted the image and attempted to start the machine with:
qemu-system-arm \
-M versatilepb \
-m 256 \
-kernel linux-4.3/arch/arm/boot/zImage \
-hda 2015-09-24-raspbian-jessie.img \
-serial stdio \
-append "root=/dev/sda2 rootfstype=ext4 rw console=ttyAMA0"
The kernel was able to mount the filesystem but it immediately ran into some trouble:
Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000004
CPU: 0 PID: 1 Comm: init Not tainted 4.3.0 #1
Hardware name: ARM-Versatile PB
[<c001b5c0>] (unwind_backtrace) from [<c0017e18>] (show_stack+0x10/0x14)
[<c0017e18>] (show_stack) from [<c0069860>] (panic+0x84/0x1ec)
[<c0069860>] (panic) from [<c0025b98>] (do_exit+0x81c/0x850)
[<c0025b98>] (do_exit) from [<c0025c5c>] (do_group_exit+0x3c/0xb8)
[<c0025c5c>] (do_group_exit) from [<c002dfcc>] (get_signal+0x14c/0x59c)
[<c002dfcc>] (get_signal) from [<c001bf28>] (do_signal+0x84/0x3a0)
[<c001bf28>] (do_signal) from [<c0017a94>] (do_work_pending+0xb8/0xc8)
[<c0017a94>] (do_work_pending) from [<c0014f30>] (slow_work_pending+0xc/0x20)
---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000004
At first, I wondered if this wasn't related to SELinux. I tried booting the kernel with:
selinux=0 enforcing=0
...but it made absolutely no difference.
What am I doing wrong? And what does this error mean?
Updates
I have also tried the following, with no luck:
- I tried compiling with and without
CONFIG_VFP
enabled - I added
CONFIG_DEVTMPFS
andCONFIG_DEVTMPFS_MOUNT
- Applying this patch and enabling
CPU_V6
,CONFIG_MMC_BCM2835
, &CONFIG_MMC_BCM2835_DMA
- Using the
gcc-linaro-arm-linux-gnueabihf-raspbian
toolchain Compiling a simple C program with the toolchain and then passing its path to the kernel via
init=
works - leading me to believe there's a discrepancy between binary formatsfile <sample program>
:ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, for GNU/Linux 2.6.26, BuildID[sha1]=e5ec8884499c51b248df60aedddfc9acf72cdbd4, not stripped
file <file from the image>
:ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=3e92423821f3325f8cb0ec5d918a7a1c76bbd72c, stripped`
I compiled this simple C program with the toolchain:
<path>/arm-linux-gnueabihf-gcc --static simple.c -o simple
...and copied it to /root
in the image, changing the init=
boot parameter to /root/simple
. This gives me the following when booting:
Starting bash...
Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000004
It seems to be choking on the execv()
call.
cat .config | grep CONFIG_VFP
yieldsCONFIG_VFP=y
- seems like it is enabled.CONFIG_VFP
and it makes no difference.versatilepb
is an ARM926 CPU, which is older than the RPi's ARM1176, so Raspbian binaries may be using some other feature that isn't being emulated. From unixmen.com/emulating-raspbian-using-qemu, does-cpu arm1176
help?