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

arch/risc-v/bl808: Add courier system driver #12542

Merged
merged 2 commits into from
Jun 23, 2024

Conversation

henryrov
Copy link
Contributor

Summary

This change implements a system for allowing the D0 core (which runs NuttX) to receive forwarded interrupts from the M0 core (the peripheral / wireless core). This is implemented using the IPC interrupt: when the M0 core receives an interrupt, it sends an IPC notification to the D0 core containing the IRQ number. This triggers an ISR on D0, which takes the message and dispatches the appropriate ISR using virtual interrupt identifiers within NuttX.
Note: Currently, the boot system for NuttX on the BL808 depends on a piece of firmware originally meant for Linux support, named m0_lowload. The system described in this PR requires a somewhat modified version of this firmware to be flashed, which is available here.

Impact

This system makes it possible to implement BL808 peripheral drivers that depend on interrupts (e.g. UART, SPI, I2C) for peripherals that are attached to the M0 core, instead of being restricted to ones attached to D0 (e.g. UART3). As implemented, the courier should also be mostly transparent to these drivers, outside of applying the virtual IRQ number offset when defining constants for M0 IRQs (as done for BL808_IRQ_UART0, 1 and 2 in this PR).

Testing

I have been working on modifying the existing BL808 serial driver to add support for UARTs 0-2 , which depends on the courier system. The modified driver is currently functional, and successfully receives interrupts from UARTs attached to M0 via the courier, and responds to them using the same ISR as UART3. Further testing can be done by enabling logging when building m0_lowload_nuttx and monitoring UART0 (logging is disabled in the release build to free up UART0 for use in NuttX).

This change implements a system for allowing the D0 core (which runs NuttX) to receive forwarded interrupts from the M0 core. This makes it possible for drivers that rely on interrupts to work with peripherals attached to the M0 core.
@acassis acassis requested a review from lupyuen June 22, 2024 14:43
arch/risc-v/include/bl808/irq.h Outdated Show resolved Hide resolved
arch/risc-v/include/bl808/irq.h Outdated Show resolved Hide resolved
Copy link
Member

@lupyuen lupyuen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is super exciting, thank you so much! :-)

arch/risc-v/include/bl808/irq.h Outdated Show resolved Hide resolved
@henryrov
Copy link
Contributor Author

Thanks for the feedback! I've changed the comments in irq.h. I also realized that the numbers for NR_IRQs and for the if statements in bl808_irq.c were wrong, so I defined everything in terms of constants instead, which also makes things more readable.

@henryrov henryrov requested a review from lupyuen June 22, 2024 19:51
@xiaoxiang781216 xiaoxiang781216 merged commit 5a7cf6c into apache:master Jun 23, 2024
26 checks passed
@lupyuen
Copy link
Member

lupyuen commented Jun 24, 2024

@henryrov FYI there's a comment, I'm not sure if it might be relevant: https://x.com/madushan1000/status/1805123950495600675

You don't need IPC. There is a secondary interrupt controller connected to d0 which can get m0 irqs, when m0 gets an interrupt, it'll trigger a common interrupt in d0. Here is the linux driver openbouffalo/linux@1f8731e

As far as I can tell, you don't even have to have anything running in m0 for this to work.

I got USB working on d0 with this driver, sd card also works. I think someone also got additional uart ports working.

@henryrov
Copy link
Contributor Author

That's interesting, I couldn't find any documentation about this anywhere else. I'll try to implement this once the serial driver is ready, since it shouldn't affect any of the code for that.

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

Successfully merging this pull request may close these issues.

4 participants