Skip to content
This repository has been archived by the owner on Feb 17, 2024. It is now read-only.

USB Device #40

Merged
merged 20 commits into from
Apr 24, 2023
Merged

USB Device #40

merged 20 commits into from
Apr 24, 2023

Conversation

r4gus
Copy link
Contributor

@r4gus r4gus commented Apr 12, 2023

I've ported the usb bulk example (found in the rp2040 datasheet) to Zig. The Rust implementation of Cliff Biffle with all the comments helped a lot (I copied most of the comments; he did a great job explaining the code).

This is WIP but @MasterQ32 suggested that I open a draft PR.

The device code already works (see loop-back example); I'm currently working on raw HID support.

You can get some USB debug output over UART

@r4gus
Copy link
Contributor Author

r4gus commented Apr 12, 2023

Related to issue #39

@r4gus
Copy link
Contributor Author

r4gus commented Apr 13, 2023

The usb_hid.zig example now shows up as potential FIDO authenticator device, i.e., seems like one can configure a raw hid device, but there are still issues:

  1. Wireshark tells me that the configuration descriptor is malformed
  2. lsusb -v tells me that the report descriptors are ** UNAVAILABLE ** (but wireshark doesn't complain so maybe this is fine)
  3. Setup request nr 6 is missing (device enumeration will hang for a few seconds)
$ fido2-token -L
/dev/hidraw1: vendor=0xcafe, product=0x0001 (Raspberry Pi Pico Test Device) <-- yay :)

@r4gus
Copy link
Contributor Author

r4gus commented Apr 15, 2023

One can now use the pico as (raw hid) device. I'll further play with it over the weekend and try to use the CTAPHID protocol with the device impl.

@MasterQ32 @mattnite let me know what you think

@mattnite
Copy link
Contributor

mattnite commented Apr 16, 2023

This is amazing! One request though, could you please move reusable USB code to this repo? https://github.com/ZigEmbeddedGroup/usb, that way we can take this work and use it on other devices. Add it as a submodule for now, later we'll use the zig package manager.

@r4gus
Copy link
Contributor Author

r4gus commented Apr 17, 2023

This is amazing! One request though, could you please move reusable USB code to this repo? https://github.com/ZigEmbeddedGroup/usb, that way we can take this work and use it on other devices. Add it as a submodule for now, later we'll use the zig package manager.

How do you want me to pass the usb module to the hal module (within addEmbeddedExecutable)? Should I add a []*Modules field to EmbeddedExecutableOptions and then add all modules passed as dependencies to hal?

@r4gus
Copy link
Contributor Author

r4gus commented Apr 17, 2023

Never mind, hal/usb wont depend on the usb module. Mistakes on my part

Code will be added to the microzig repo directly

@mattnite
Copy link
Contributor

I think microzig needs updating and then this is ready to go

@mattnite mattnite marked this pull request as ready for review April 24, 2023 14:45
@mattnite mattnite merged commit 812fb44 into ZigEmbeddedGroup:main Apr 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants