On Thu, 24 Feb 2022 at 10:53, Ben Dooks <ben.dooks@codethink.co.uk> wrote:
I have been trying to get qom-get/qom-set scripts working to make an
virtual GPIO device on qemu-system-x86_64. I have a working TMP105
and I can see the MAX7310 being instantiated with the relevant Linux
devices showing up (i2c, gpio).
I can read the sensor from QEmu console:
(qemu) qom-get /machine/peripheral/sensor temperature
20000
(qemu) qom-set /machine/peripheral/sensor temperature 19000
(qemu) qom-get /machine/peripheral/sensor temperature
19000
When trying to get or set anything from the GPIO chip it doesn't
seem to be working. How do I get this working, I haven't found
any useful reference online and need some help:
(qemu) qom-set /machine/peripheral/gpio unnamed-gpio-out[0] 0
Error: Device '0' not found
(qemu) qom-set /machine/peripheral/gpio unnamed-gpio-in[0] 0
Error: Insufficient permission to perform this operation
The 'unnamed-gpio-out/in' properties are part of the mechanism by
which a QEMU machine model can connect up GPIO lines of devices it
creates (for instance, it might connect a device's outbound GPIO
line to a GPIO controller). They appear in the monitor
qom-set/qom-get APIs because they use the same underlying
infrastructure as user-settable properties, but you can't do
anything useful with them on the command line.
If you need to wire up a device's GPIO lines, you need to do
it in C code as part of the QEMU machine model implementation.
Put another way,
-device max7310,id=gpio,address=0x20
will work fine for "put a gpio controller at this i2c address,
so that guests that expect to be able to talk to one there
don't crash". You can't however actually wire up any of that
controller's GPIO lines to anything (emulated LEDs, other
devices, etc, etc).