How to add new QEMU machine types without modifying the mainline source code?
Asked Answered
M

2

7

Can a new machine type be added for qemu-system-arm -M <MachineType> without having to recompile qemu or write code? Are there docs to do this? I would like to be able to emulate raspberry pi and pandaboard using qemu.

I know that meego's fork of qemu supports pandaboard, but I am trying to stick with the main stream qemu that I can manage from the apt-get package manager. the main stream qemu now supports beagleboard rev C and beagleboard xm that were previously supported only in the meego fork.

Midlothian answered 18/10, 2012 at 22:40 Comment(1)
If all you want is a Raspberry Pi emulator, then it already exists: pilotlogic.com/sitejoom/index.php/forum/…Larvicide
A
4

without having to recompile qemu or write code?

No. There must be some code doing the device specific emulation, like for example the way the Raspberry Pi or the Pandaboard implement video output. This is not a matter of just a few config files.

Arnaldo answered 18/10, 2012 at 22:42 Comment(4)
Thank you. But do you happen to know any docs / guides on doing this? I tried to search though the code to find the way beagleboard is handled and got lost. I was hoping I could look through the raspberry Pi technical docs and try to figure some solution.Midlothian
@LordLoh: Well, it boils down to taking the target system's schematic, figuring out how each periphial is connected (i.e. in which memory area it ends up). Also you must read the used CPUs documentation, regarding it's periphials. If the target CPU is already present in the QEmu sources, then you just have to adjust the memory mappings and add emulation for external periphials. If the used CPU is not present yet, well, then you must add emulation for all internal periphials as well. CPU means a particular chip BTW. It's not just about architecture when it comes to embedded systems.Arnaldo
@LordLoh.: PC systems are more or less standardized. Everything happens to be very similar. BIOS or UEFI are always at the same address, all HDD controllers talk ATA or AHCI and behave more or less the same. The PCI bus always maps into the same memory regions. This is why you can just put a CD with a operating system in your PC and it will install. Embedded systems OTOH are very specific. And before you can run a OS kernel on it, you must add certain code to it, making it run on that particular board. This is called a Board Support Package (BSP). Essentially you've to create an "inverse" BSP.Arnaldo
I figured out after a while that I will not only have to emulate the processor (which I believe is already built into qemu), but also all the peripherals on the board (which is most likely not built into qemu). Thanks for the explanation.Midlothian
D
1

I've been able to emulate the Pi with -M versatilepb: https://raspberrypi.stackexchange.com/questions/165/emulation-on-a-linux-pc/53991#53991 and -M raspi2 has was later added in QEMU 2.6.

Maybe this feature is feasible to implement, see my experience with adding a new platform device: How to add a new device in QEMU source code?

There, I only needed to add a single line to attach a new device to versatilepb:

sysbus_create_simple("lkmc_platform_device", 0x101e9000, pic[18]);

so maybe we could have a config file containing lines of type:

type    name                  regid        irq
sysbus  lkmc_platform_device  0x101e9000   18

Related: out-of-tree devices: How to create out-of-tree QEMU devices?

Devinne answered 9/7, 2017 at 9:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.