Handle USB CLEAR_FEATURE#18
Conversation
|
Thank you for tracking this down! Actually it looks like I must support set and clear of Halt state for all endpoints, strictly speaking. So I may as well do that. I will report back with the result of implementing that, so you can test it. |
|
@keirf good call, this was only working every other command as is. The reset requires carefully setting up the double buffering, I don't think there's an easy way to do it, but here is an attempt for you to consider. Also and seperately handle DTR. |
|
That's a lot of code, though it definitely looks plausible, how tested is it or is it imported from another project? |
|
It's based on the existing usbd_configure_ep ( greaseweazle-firmware/src/usb/hw_usbd.c Line 194 in 75bd97a It definitely needs to be tested on the existing platforms (Linux, Windows, Mac?) because FreeBSD was awkward here. I also only have the at32f4 target but the others are compile tested. |
|
Okay gotcha, I think actually this should be Regarding DTR support -- was that necessary or a nice to have? It kind of feels sensible, but the sort of change that can create unexpected problems in specific configurations... |
|
The DTR helps when the commands are severed, where ClearComms in the client didn't get a chance to run. Probably never seen before, I think it is correct, but not strictly necessary with the other change since it is unlikely in the normal flow outside of this platform triggering the breakage. |
|
Could you please test branch named |
|
@keirf it gets stuck Unlike the master branch it never responds to the first command after replug, no commands get through. I need some rest before I can dig back in. |
|
No worries I've clearly just broken your code by ripping chunks out of it ;) It's obviously a pain that I don't have a testbed that issues these CLEAR_FEATURE requests. Possibly I should add some stress testing of it to greaseweazle-testbed, which is the factory test for Greaseweazle: I could add more protocol tests in a "dev test" version of that project. Then I could see that out-of-the-box Greaseweazle doesn't work, then see that it works with your patch, and furthermore test that I don't regress things when I muck with the code. It would also let me test your patch on other Greaseweazle boards where let's be honest it's quite likely there are still problems as this stuff is almost impossible to get right outside of a hack-compile-test loop. By the way what |
|
PS I am also happy to send you a tester board for Greaseweazle. I have a small box of them, and they are of little use to most people! |
|
Oh and another obvious option for me I suppose would be to try out FreeBSD in a VM with USB passthrough |
- Restore full double buffer reset - Restore bd->count_0/count1 reset - Use usbd_configure_ep's SW_BUF state - Use IRQ protection from usbd_configure_ep
|
Yeah a passthru VM should work. Note that our py-serial is currently broken so I have a temporary workaround in the py-greaseweazle: https://github.com/freebsd/freebsd-ports/blob/main/sysutils/py-greaseweazle/files/patch-src-greaseweazle-tools-util.py#L6. You will need something similar if you just check out the python code and build it yourself. This will be fixed soonish so I didn't bother with a PR, local ports patch to workaround until then. I added one followup commit on top of yours to this PR. I think the first 3 items are critical, the IRQ protection might not be necessary here but matches the donor code. All the other files changes look fine to me. |
|
Do you think the strategy of aligning clear_stall with configure_ep is a generally good one? Perhaps that could mean we share code, and could be a strategy applied to all three usb-peripheral implementations.... I think perhaps only buffer allocations would need to be skipped? Which endpoints are you seeing having the clear feature request applied to them? |
|
I don't think there's a great opportunity. Might be able to save a tiny bit of code on the dbl_buf branches but the reset is subtly different than init overall. If you see something more minimal I can test again. wIndex 0x0002 (host to device, bulk data) and 0x0083 (device to host, bulk data) |
The current firmware hangs after the first gw run, because umodem(9) sends a CLEAR_FEATURE. I think this is an appropriate fix.