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
git clone https://github.com/0xabu/qemu.git -b raspi
git submodule update --init dtc
sudo make install
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
[23:35:23] pietrushnic:rpi2_qemu $ sudo /sbin/fdisk -lu 2015-11-21-raspbian-jessie.img
Disk 2015-11-21-raspbian-jessie.img: 3.7 GiB, 3934257152 bytes, 7684096 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xea0e7380
Device Boot Start End Sectors Size Id Type
2015-11-21-raspbian-jessie.img1 8192 131071 122880 60M c W95 FAT32 (LBA)
2015-11-21-raspbian-jessie.img2 131072 7684095 7553024 3.6G 83 Linux
Check start of W95 FAT32 (LBA) partition. It is 8192. Sector size is 512.
So calculate offset in bytes 8192 * 512 = 4194304.
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.