avatar2
avatar2 copied to clipboard
can not send interrupt with panda target
Hi there,
I tried to enable interrupt and inject interrupt, but the message sent to QMPProocol shows:
{"id": 3, "error": {"class": "CommandNotFound", "desc": "The command avatar-armv7m-enable-irq has not been found"}} '{"id": 5, "error": {"class": "CommandNotFound", "desc": "The command avatar-armv7m-inject-irq has not been found"}}
Another error message is:
avatar.targets.PandaTarget0.ARMV7MInterruptProtocol.ERROR | Unable to create rx_queue: No queue exists with the specified name /avatar_v7m_irq_rx_queue
It seems even though PandaTarget inherits QEMUTarget, it doesn't support interrupts yet.
Hi,
This is correct, IRQ forwarding, as described in pretender, is currently only supported on avatar2's QemuTarget - which uses a more recent version of QEMU and has a bit of differences in the QMP protocol. To enable IRQ injection via avatar2, I see two ways forward:
1) Backport IRQ injection from QEMU/Pretender:
In essence, to support IRQ injection via QMP, a couple of things are required:
- Implement Interrupt Logic in hw/avatar
- Expose these methods to QMP
- Adjust build files to include the interrupt implementation.
You can see according changes in this commit of the qemu target, which would needed to be backported: https://github.com/avatartwo/avatar-qemu/commit/2de8b91f36f71584c34df899e8c2cc57fbad806f
I don't have the time to do this backport right now, but if you want to give it a try, we can try to get it upstreamed to panda's dev branch once this is ready.
2) Using Pandas Python APIs/PyPanda: Using PANDA's recent extension to their python APIs, I was able to implement interrupt directly from Python. This would require to use the PyPanda target, which provides additional performance in any case. I can try to upstream these patches, or make it at least available in my PANDA fork. For this, it would be good to know what target you are interferring with - is it a Cortex-M class device, or something else? Interrupts implementation do change, unfortunately.
Let me know which of these two ways you prefer!
Hi Marius,
Thank you for the quick reply! We are working on Cortex-M class devices. It would be very helpful if the PyPanda target could be used to inject interrupt.
I tried to backport the injection implements of QEMU, but it takes time to locate all dependencies. I will try it again with the commit log you provide.
Thanks again! I really appreciate your help.
Hi! We finally released FirmWire, which has a modified Panda version with irq-injection over pypanda. You can find over here: https://github.com/FirmWire/panda
The important commit is this one: https://github.com/FirmWire/panda/commit/8eb9767dab63cce9f82946afe98c52076304ae0c
In essence, you need to add irq-logic to the configurable machine, and then expose the important functions in the header-file via comments which will be parsed by pypanda. That is, in the header file, you need to add those function between the following block:
// BEGIN_PYPANDA_NEEDS_THIS -- do not delete this comment bc pypanda
// api autogen needs it. And don't put any compiler directives
// between this and END_PYPANDA_NEEDS_THIS except includes of other
// files in this directory that contain subsections like this one.
// from panda_api.c
[functions to expose]
// END_PYPANDA_NEEDS_THIS -- do not delete this comment!
Example for this can be found here: https://github.com/FirmWire/panda/blob/8eb9767dab63cce9f82946afe98c52076304ae0c/include/hw/avatar/configurable_machine.h