5

Is it possible to setup the Raspberry on the PC using somekind of emulator and then flash the result to an SD card?

So develop the code, test it and then create the SD card for the Pi and plug it in...

I forgot to mention that I'm using a Windows 7 PC, sorry...

4

The tool you are looking for is qemu. It is an emulator to support ARM1176 cpus.

  1. Install qemu
  2. $ mkdir my_qmeu && cd my_qmeu && wget http://xecdesign.com/downloads/linux-qemu/kernel-qemu
  3. move disk image to this directory
  4. ensure qemu-system-arm -cpu outputs arm1176
  5. Boot the OS to prepare configuration: 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 replace 2013-09-25-wheezy-raspbian.img with file name of the disk image.
  6. After the OS boots up, it will present you a prompt.
  7. Enter $ nano /etc/ld.so.preload. comment out the line /usr/lib/arm-linux-gnueabihf/libcofi_rpi.so
  8. Press ctrl-x then y then enter to save and exit.
  9. Type $ sudo nano /etc/udev/rules.d/90-qemu.rules and add following lines

    KERNEL=="sda", SYMLINK+="mmcblk0"

    KERNEL=="sda?", SYMLINK+="mmcblk0p%n"

    KERNEL=="sda2", SYMLINK+="root"

  10. Shutdown the emulator using $ halt

  11. Boot the full fledged OS: 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

Things to notice

  1. The disc image will only contain about 200MB of free space (if any at all) for you to play with, so don't expect to be able to install a full system. You can use dd to expand the image and then resize manually.
  2. You may see a few steps failing while the image boots. That's normal, since QEMU cannot emulate ALL of the hardware exactly. Double check that all the important steps are fine, but in general, this isn't something to worry about.
| improve this answer | |
  • Nice! Then I "just" have to figure out how to do this in windows 7 – Norfeldt Oct 31 '14 at 10:11
  • 1
    qemu is also available for windows – gmuraleekrishna Oct 31 '14 at 12:29
0

If you develop a program you later would like to run in the Raspberry it's enough have Linux in your PC. When your program works in the Linux PC you can just recompile it for ARM and will work right away (although slower).

| improve this answer | |

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.