Skip to content

Comments

Add Raw Gadget-based backend#164

Open
xairy wants to merge 9 commits intogreatscottgadgets:mainfrom
xairy:rawgadget-v2
Open

Add Raw Gadget-based backend#164
xairy wants to merge 9 commits intogreatscottgadgets:mainfrom
xairy:rawgadget-v2

Conversation

@xairy
Copy link
Contributor

@xairy xairy commented Jun 26, 2025

Add a backed based on Raw Gadget. This backend allows running Facedancer on any Linux-based board with a functional USB Device Controller.

This PR is an updated version of #160 by @akvadrako with fixes from me. I kept the patches by @akvadrako separate to allow recording the contribution. (You can also find the unsqashed changes that I made here to see the patch-by-patch changes.)

From the Raw Gadget side, this is ready to be reviewed and merged. There are still a few TODOs in the implementation, but addressing those will be easier once we have the proxy fixes from #162 merged.

From the backend API side, the main question to be addressed: Since handle_data_requested() can block when proxying, calling it from service_irqs() does not seem like a good option. Thus, the Raw Gadget backend spawns a separate thread for calling it. Is this OK? How do other backends handle this blocking?

Running the tests with both the Dummy UDC and on a Raspberry Pi 4 (with the dwc2 UDC) works (except for occasional timeouts, but that's expected). All examples also appear to work.

Proxying does not yet work, as it requires some changes from #162 (but it does work for some devices when this PR is rebased onto #162.)

Closes #15.

@xairy xairy force-pushed the rawgadget-v2 branch 2 times, most recently from 5f18514 to 589f611 Compare June 29, 2025 23:47
@xairy xairy mentioned this pull request Jun 30, 2025
xairy and others added 9 commits July 2, 2025 18:45
request.reply() expects the bytes type.
Slower backend impementations (e.g. Raw Gadget) need some time to process
the bulk OUT transfers performed in the tests and record their size.

Wait for a bit before checking such transfers in tests.
Stress and Transfers tests reset the device state (including the expected
endpoint transfer length) only after changing the interface altsetting
(which should restart endpoint transfers with the new length).

This causes a problem in the case when the backend schedules an endpoint
transfer with the old transfer length before the new one gets set.

Reset the device state before changing the interface altsetting.
Drop the log message printed before the Hydradancer backend checked whether
the environment supports it.
The backend_name could be None, so annotate it appropriately.

Co-developed-by: Andrey Konovalov <andreyknvl@gmail.com>
The device argument corresponds to the backend device that should be
used when emulating USB devices, not to the device being emulated.

Thus, drop the USBDevice annotation.

Co-developed-by: Andrey Konovalov <andreyknvl@gmail.com>
This is the latest version of the Raw Gadget backend implementation by
@akvadrako sent in greatscottgadgets#160 (with a few minor changes dropped or separated
into other patches).

The patch that follows contains fixes for that implementation.

Co-developed-by: Andrey Konovalov <andreyknvl@gmail.com>
This patch contains assorted fixes and improvements for the implementation
from greatscottgadgets#160.
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.

Support gadget api

3 participants