linuxyoctoqemuflash-memory

How to Enable M25P80 Flash Device Emulation on QEMU x86_x64


I am trying to enable the ST M25P80 emulator on QEMU (Linux) for access using MTD/mtd-utils: The ST M25P80 allows you to emulate all SPI flash devices based on the m25p80 command set

During QEMU startup, I do not see any of these devices being called-out, so I'm assuming that I have to manually enable them somehow. I am running on x86, so no device tree or u-boot. I also don't have access to Kconfig for the hardware emulators since I'm running an older version of QEMU.

Mostly stuck on how to enable the m25p80 emulator and how to "connect" it to the MTD subsystem.

The ultimate goal is to use the mtd subsystem to communicate over an emulated SPI interface to the M25P80 emulator to do basic tasks (read, write, lock, etc..).

I am still relatively new to QEMU/Linux so I apologize if I did not characterize this correctly. Any help is greatly appreciated.

I tried booting QEMU with an mtd device (not specifically M25p80) according to these instructions


Solution

  • QEMU doesn't support letting you create that kind of device for an x86-64 guest. The M25P80 device emulation is an SPI device, which must be connected to a controller which has an SSI bus. All the emulated SSI controllers in QEMU are hardwired into board models, mostly Arm ones. There is no "SSI controller on a PCI card" or similar model which would let you plug a controller into an x86-64 machine type and then plug the M25P80 into that controller.

    This is a specific case of a more general aspect of QEMU's design: it is not a "bag of lego bricks" set of device models that you can then freely connect together however you like. It's a set of models of specific machine types (eg x86 PC, Arm board using an aspeed SoC). Some of those machine types support particular kinds of pluggable devices, like the way the PC machine type supports pluggable PCI devices. But as an end-user the only flexibility you have is plugging in the pluggable device types to machine types that support that device type. There is an analogy with real hardware -- if you own a PC, you can plug in a new PCI graphics card, but you don't typically try to solder new chips onto the motherboard.