On Tue, 2 Nov 2021 at 13:15, abhijeet inamdar <abhijeetinamdar3...@gmail.com> wrote: > > Hi, > > I have a hardware which I want to emulate on QEMU based on arm Cortex M3. I > tried to follow the examples like mps2 or stellaris. > > I'm finding it really hard to figure out how can I test the > devices/peripherals I add to the machine. As the binary which I have contains > all major protocols like UART, I2C, CAN, ADC, SPI....etc. and is it something > that untill and unless I implementation all these into my machine it won't > run(makes sense!). > > Is there any way here or how actually I have to approach this?
Start by working with a newer QEMU than 4.2. You should have a look at the stm32 board models we have -- they are fairly modern code that implements a model of an SoC with an assortment of devices. If you're lucky then your guest code doesn't want to really do anything with most of the devices beyond "just initialize it" and you can get away with using unimplemented-device stub devices or very-little-actually-implemented devices. Starting with the unimplemented-device stubs means you can turn on debug logging to see which of them the guest is actually accessing. For testing, there are a few options: (1) just try to get whatever your guest code is working (probably working a lot with the debugger to see how far you can get it to go) (2) find a different guest binary that does less hardware access to use while you're working on this (3) you can write unit tests as you go along that try to exercise features of the devices. As an example test, tests/qtest/cmsdk-apb-timer-test.c starts an mps3-an385 machine and tests one of its timer devices with a sequence of register accesses. -- PMM