In the process of planning system testing for one of my clients I found that someone from Microsoft published patches with BCM2836 support to QEMU mailing list. I thought it is very interesting, because if it is possible to setup emulated Raspberry Pi many use cases can be tested faster and in more automatic way. For example checking how application behave when running on more then one device at once, testing massive deployment process, stress testing and finally speed up debug-fix-test process.

So it looks like making RPi 2 working in emulated environment can add a lot of value to some products. In email Andrew mention github repo, which I would like to try in this post

Get QEMU and compile

Prepare to boot

QEMU requires kernel and device tree file to be given as parameters, because of that we have to extract those pieces from existing Raspbian image.

Get kernel and device tree

Check start of W95 FAT32 (LBA) partition. It is 8192. Sector size is 512. So calculate offset in bytes 8192 * 512 = 4194304.

Then if you try to boot 2015-11-21 Rapbian with 0xabu code:

You will experience kernel crash:

To avoid this crash you have to comment /etc/ld.so.preload.

Changing ld.so.preload

First calculate offset in bytes to Raspbian root filesystem partition. According to fdisk output above partition starts with sector 131072, so offset would be 512*131072=67108864.

Use your favourite editor to change tmp/etc/ld.so.preload. Note that you have to edit as superuser. Content of file should looks like this:

Sync and umount partition:

Final booting

Summary

There are many problem with existing setup, but from my experience this is best approach and code that I saw during last years. Also it looks like this code is backed by huge corporation so it looks like they see value in providing this code to wide community. Rapid delivery of those patches probably would not be possible without previous work to which Andrew point in his email. It would be great to see community engagement in this effort.