Skip to content

Conversation

Noxime
Copy link

@Noxime Noxime commented Apr 28, 2025

Do not merge before fixing the executor issue!

The driver works for the most part, except you must for some reason use the arch-spin executor to make it work. Perhaps something is wrong in the interrupts? I have no experience with embassy executor internals or the USB peripheral itself, so any help would be appreciated.

@andelf Do you have any ideas?

Closes #79

The driver works for the most part, except you must for some reason
use the arch-spin executor to make it work. Perhaps something is
wrong in the interrupts?

Do not merge in the current form!
// It needs some buffers for building the descriptors.
let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256];
let mut msos_descriptor = [0; 256];
Copy link

Choose a reason for hiding this comment

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

If no msos descriptor is used, this buffer should be [0; 0]

Copy link

@HaoboGu HaoboGu left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@romainreignier romainreignier left a comment

Choose a reason for hiding this comment

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

Thanks for these changes.

I have tested the example on a CH32V203C8T6 board (WeActStudio).

It works as expected but to work without the WCH-Link connected, I had to comment the println! statement otherwise it enumerates but picocom was stuck on connection.

Once the minor comments are addressed, this can be merged.
I think that the use of arch-spin is not blocking.

config.manufacturer = Some("Embassy");
config.product = Some("USB-serial example");
config.serial_number = Some("12345678");
config.max_power = 100;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the default value, this line can be omitted.

config.product = Some("USB-serial example");
config.serial_number = Some("12345678");
config.max_power = 100;
config.max_packet_size_0 = 64;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the default value, this line can be omitted.

// It needs some buffers for building the descriptors.
let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256];
let mut msos_descriptor = [0; 256];
Copy link
Contributor

Choose a reason for hiding this comment

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

This variable is not used, this line can be omitted.

bind_interrupts!(struct Irqs {
USB_LP_CAN1_RX0 => hal::usbd::InterruptHandler<hal::peripherals::USBD>;
});

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add a comment that the println! lines should be commented to work properly without a probe connected.

@moore
Copy link

moore commented Jul 7, 2025

Is anyone working on getting this merged? I could probably pick it up some time this month if @Noxime dose not have time to finish getting it merged.

@Codetector1374
Copy link
Member

the use of arch-spin is intentional we can't use the riscv arch because it uses wfi which is not really compatible with the usb peripheral (broken HW implementation on WCH's part, I have discussed this with their support engineer)

If anyone want to get the conflicts / small fixes resolved I would be happy to get this merged.

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.

USBD peripheral driver
5 participants