0
votes

I have written a bare-metal program and i need flash/SD to storge my file system.

My option of the QEMU is "qemu-system-aarch64 -machine virt -cpu cortex-a57 -smp 1 -m 1G -nographic -serial mon:stdio -d in_asm,int,mmu -D ./qemu.log -kernel myimg.bin".

I dump the dts of QEMU(arm64) virt machine and these is only a PCIe bus and a cfi-flash. It seems that the cfi-flash is used for boot. And the PCIe is too complex to me.

I have known that devices which connected to system bus can not be dynamically instantiated by command line.

How can i add any flash/SD to the virt machine?

If it must add by PCIe, what should the command line be? Is there any PCIe bare-metal driver i can reference?

1

1 Answers

1
votes

You can't add more flash to the 'virt' board like this. Storage for a file system is generally done via virtio devices (usually the pci virtio-blk device, though you could probably also use virtio-scsi and an emulated scsi disk).

If you are writing a bare-metal program, then you can use the flash devices that are at address 0 and 0x04000000 if you like -- they are only used for bootup if you're booting the UEFI bios, which a bare-metal setup will not be doing. You can connect a backing file to them with "-drive if=pflash,..." options. I'm not sure these are really ideal for putting a filesystem on, but it depends on what you're doing with it, and it can be made to work. Both pflashes are 0x04000000 bytes in size.

For the virt board if you put anything into the first pflash device then the board will assume it is BIOS code and try to boot from it. To avoid this you can use the second pflash device. To put contents into the second pflash you'll need to add "unit=1" to the "-drive if=pflash,..." option.