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

Usb breaking change #607

Merged
merged 24 commits into from
Dec 23, 2024
Merged

Usb breaking change #607

merged 24 commits into from
Dec 23, 2024

Conversation

bunnie
Copy link
Member

@bunnie bunnie commented Dec 23, 2024

This is an integration of the USB stack that is meant to break the old usb-device-xous code, with the intention that cramium-soc targets would rename the included crate to refer to usb-cramium. The two crates retain the same lib API, but because the underlying implementations are so vastly different a decision was made to diverge the code bases, at least for now, to simplify the debug and bring-up process on the new hardware.

so processes other than swap can use it
- disable IRQs on departure
- put EV enable outside of the HAL function
this is necessary because we need all HAL calls to be finished
before an interrupt happens to avoid locking problems
so that we can share app uart with other processes that need it for debug
the uart in the shared library is claimed by the first process
that touches it, so prints in the shared library at early boot have
to be carefully configured
we have to allocate the virtual page in our process space before
we can use the debug UART.
This commit turns the USB stack inside out and puts
the handler in a protected IRQ section so that it can't be
interrupted during event processing.
the UsbBus implementation is being totally rewritten for the
inside-out IRQ protected scheme.

we can now get past some preliminaries in the link protocol
(i.e., address setting and the first config descriptor), but
a long way to go still in debugging.
used for debugging some IRQ issues
this one just sends a string as if typed on a keyboard.
realizing a bunch of stuff like the stack expects you to enqueue
the OUT receiver with calls to read() that happen to block, fixing
max packet size that can be different for in and out end points,
and handling quirks of the core when sending setup packets longer than
64 bytes.
we're going to strip out the USB cramium support from this crate
eventually because it has migrated to a stand-alone crate

the hardware model is just too different to keep the two branches
in sync: one allows interrupts to be delegated to userspace, the other
requires the interrupts to happen all in the locked handler context
due to timing assumptions of the core.

the problem with the interrupt handler context is that panics
are really hard to debug - you can't actually send a panic message
from an interrupt context, because there is no IPC when the
handler is running. Normally we try to keep the handlers as
minimal as possible, but in this case we can't due to hardware
assumptions.
also clean up some debug statements and add a TODO list
programs should now use the usb-cramium crate for a USB
stack. It preserves the `lib` API, so you /should/ be able to
integrate it seamlessly by just renaming crates between
the two.
@bunnie bunnie merged commit c3f5b81 into main Dec 23, 2024
2 checks passed
@bunnie bunnie deleted the usb-breaking-change branch December 23, 2024 16:58
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.

1 participant