Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can not send interrupt with panda target #93

Open
Moirai7 opened this issue Oct 29, 2021 · 3 comments
Open

can not send interrupt with panda target #93

Moirai7 opened this issue Oct 29, 2021 · 3 comments

Comments

@Moirai7
Copy link

Moirai7 commented Oct 29, 2021

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.

@mariusmue
Copy link
Member

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:
avatartwo/avatar-qemu@2de8b91

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!

@Moirai7
Copy link
Author

Moirai7 commented Nov 1, 2021

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.

@mariusmue
Copy link
Member

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: FirmWire/panda@8eb9767

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants