I had similar issues and I finally got this working last night, on OS X 10.8.5 with QEMU v2.2.0, after working on/off for two weeks.
Preamble
I was prompted by the question, Can I program for Arduino without having a real board?, to try to use a real emulator, such as QEMU, as suggested by zmo, in a comment to Anindo Ghosh's answer.
I thought that I would relate my experience here.
I set this up on a MacBook Pro, running 10.8. (Mountain Lion). I quickly found the link Installing QEMU on OS X1. Yes, I know is seems to be related to the Pi, but bear with me. After a quick browse, it was clear what was required.
First step was to set up the Mac with the correct environment. This required, in the following order:
- Xcode;
- Xcode command line tools;
- homebrew;
- a compiler, and finally;
- qemu itself
Details
Going into each step in detail
- Xcode - I used 5.1, from the Apple site [link?]
- The command line tools were downloaded from within Xcode, from Tools
-> Downloads.
- Homebrew was installed in the terminal, using the following command
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
There was a failed download at first, due to the Thai telephone network dropping, which required a messy cleanup. But running the command again worked.
- Then
brew doctor, at first complaining that I had a case sensitive file system, threw up a requirement for Quartz 2.7.7, I
had 2.7.4 installed evidently. This I downloaded, rebooted, ran
brew doctor again. It was still complaining, but this time because
I had Quartz 2.6.3 installed! I gave up at that point and moved on.
- Selecting the QEMU build required these two commands
cd /usr/local/ # Or wherever you installed Homebrew.
git checkout 2b7b4b3 Library/Formula/qemu.rb
- Then installing
gcc, which I left to run its course.
brew install https://raw.github.com/Homebrew/homebrew-dupes/master/apple-gcc42.rb
- Then install
pkg-config
brew install pkg-config
- And finally (!) QEMU
brew install qemu --env=std --cc=gcc-4.2
Then unfortunately that page's instructions failed me as the links to the zImage and rootfs files on dropbox had been killed, due to over subscription, so I had to find another method. I decided to sleep on it, as I was getting irritated by now.
Then following morning, after a not so refreshing sleep, I found the link, QEMU – Emulating Raspberry Pi the easy way (Linux or Windows!)1 which, pretty much enabled me to carry on from where I left off.
- Downloading the PI images from the Raspberry PI downloads page
- Downloading the linux kernel (which required
brew install wget beforehand):
wget http://xecdesign.com/downloads/linux-qemu/kernel-qemu
- Verifying qemu's available emulation modes:
qemu-system-arm -cpu ?
- First boot
qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw init=/bin/bash" -hda 2013-09-25-wheezy-raspbian.img
This resulted in a cycle of SCSI errors,
ABORT, DEVICE RESET, BUS RESET, HOST RESET, sym0: SCSI BUS has been
reset, HOST RESET, Device offlined
and so on, cycling through ever increasing SCSI device IDs, n, (scsi 0:0:*n*:0). n = {0, 1, 2... 6, 8, 9... 15} 7 was skipped as it is presumably the host controller.

It would cycle up to SCSI ID=14,

with the console in the QEMU window eventually crashing, at SCSI ID=15,

leaving the following error in the terminal from which it was run.
snowserv:local user$ qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw init=/bin/bash" -hda ~/Documents/PI\:Arduino/Lapdock/Raspberry\ PI\ Disk\ Images/2015-02-16-raspbian-wheezy.img
Uncompressing Linux... done, booting the kernel.
pflash_write: Unimplemented flash cmd sequence (offset 00000000, wcycle 0x0 cmd 0x0 value 0xf000f0)
pflash_write: Unimplemented flash cmd sequence (offset 00000000, wcycle 0x0 cmd 0x0 value 0xf0)
snowserv:local user$
I tried the same command prefixed with sudo, but the same issue occurred.
I thought that the issue was the root=/dev/sda2. Copying the Raspbian image locally didn't help (it had been on a separate partition). Looking at the comments on the web page, a number of people were getting the same SCSI errors.
It appeared to be an issue with the version of QEMU. I was using 1.1.50
qemu-system-arm --version
After some to-ing and fro-ing, I found the newer version, 2.2.0
I checked out fce79940eb
git checkout fce79940eb Library/Formula/qemu.rb
Unlinked the older version
brew unlink qemu
Install new checked out version
brew install qemu --env=std --cc=gcc-4.2
And running the first boot command
qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw init=/bin/bash" -hda 2013-09-25-wheezy-raspbian.img
this time resulted in the expected command prompt.
I ran through the suggested edits of /etc/ld.so.preload and /etc/udev/rules.d/90-qemu.rules, without any issues arising.
However, I was unable to halt, shutdown or reboot the Pi. The errors received were
init: /run/initctl: No such file or directory

I ended up doing a hard reboot, by just quitting the QEMU app.
In the terminal were a lot of
coreaudio: Could not lock voice for audioDeviceIOProc
Reason: Invalid argument
errors logged. Probably from failed beeps arising from failed shutdowns.
I repeated the first boot, as a google2 suggested that the init issue could be solved simply by just a hard boot, but I still had the start up errors, and the halt errors.

There was a "better" way of shutting down though, as I was given the tip (see below) that
reboot -f
worked.
In an attempt to lose the init errors, after some more googling3, I ran the following commands:
mkfifo /dev/initctl
but, predictably, it was not persistent, and didn't fix shutdown.
mkfifo /run/initctl
which was persistent, but didn't fix the shutdown.
I encountered henje on Super User having the same issue. From shutdown: /run/initctl: No such file or directory
Thx for the reboot -f. Good tip. After further googling, a hard
reboot is supposed to fix the issue, but it hasn't. I have also run
mkfifo /run/initctl which stops the No such file or directory
error, but still doesn't shut the system down. I now get init:
timeout opening/writing control channel /run/initctl. I have compared
the /run/initctl just created, with the one on my working RPi, and
they look identical: prw------- 1 root root 0 Jan 1 1970
/run/initctl.
I carried on regardless, and ran the proper boot command, the same as the first boot, minus the init=/bin/bash
qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" -hda 2013-09-25-wheezy-raspbian.img
It booted, apparently without issue, into the raspi-config screen. I changed the hostname and pi user's password. Then hit Finish and agreed to the restart, the QEMU just exited, appearing to die, the window vanished.
I ran the same proper boot command again
qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" -hda 2013-09-25-wheezy-raspbian.img
command again. It booted to normal text console login. Logged in, ran startx, X can up. Ran sudo shutdown-h now. System shutdown without mishap, leaving System halted message. Although the CPU was left running at 100%, and the window did not close. I had to close it manually.
Ran same proper boot command again, it booted OK. It does run fsck each boot, so I am not sure if that is indicative of the halt not working correctly, or whether Raspbian does that anyway on each boot. However, upon sudo halt, I see the message
[ ok ] Unmounting local file systems...done.
so I assume that it is OK and normal.
I hope that this (rambling) tale, helps someone else.
1 There is way too much info to attempt to summarise, in case of link death.
2 According to can't reboot debian and systemd-sysv, sysvinit: problems rebooting when switching between systemd-sysv and sysvinit
3 According to I got a error flag "init: /dev/initctl: no such file"