-
Notifications
You must be signed in to change notification settings - Fork 11
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
Fix USB Host issues #42
Conversation
Memory usage change @ 88edfed
Click for full report table
Click for full report CSV
|
Memory usage change @ 864f722
Click for full report table
Click for full report CSV
|
Memory usage change @ 1a82f91
Click for full report table
Click for full report CSV
|
Looks good to me but I'd love if @alrvid could take a look too |
I guess the GIGA define should be used instead of ARC_USB_FULL_SIZE, I have no idea how this may effect other boards it is only tested with the GIGA. |
Memory usage change @ 2d7534e
Click for full report table
Click for full report CSV
|
Memory usage change @ 61ccb56
Click for full report table
Click for full report CSV
|
Add setEnumeratingDeviceIndex to IUSBEnumerator.h
Memory usage change @ dba021e
Click for full report table
Click for full report CSV
|
Manually merged, thank you so much! Everything works wonderfully from my tests! |
Nice one. I'm at the moment trying to track down an issue with hubs. If you have a bulk device and an interrupt device connected, if you request async data from the bulk device (after data received) and the interrupt device within a ms of each of each other there is a chance that the interrupt device data will never be received, so rxhandler not called, next request not made so dead from that point. Hopefully I can find the issue, it seems to be deep down, either in the STM code or maybe the TransferDescriptor stuff. It is illusive at the moment. When I find it I will put in another PR... |
@facchinm @AndrewCapon - I also have a partial fix that works for USB LS devices that are connected directly. So far I don't have the low speed devices working with HUBs, but that may be related to the issues that Andrew mentioned. So for example I have extended Keyboard and Mouse classes that are working (as well as some tablets and likewise @mjs513 also has some game controllers working as well. |
Hi Andrew - sorry take so long to get back but had to take my little one (7 year old yorkie) to get teeth removed so a bit out of it until she gets back here. anyway here are a couple of the controllers:
2, with the one clone that doesn;t work, i.e., no data is output, am seeing the debug info and it is using the driver:
|
As in Yorkie dog? Hope she is fine. I'm guessing these joysticks all work with the other joystickEX driver? |
I was playing some more with the problem child keyboard, and still not talking. Wasted a little time this morning hacking up the dbg.h file as I found the output of the full pathnames was making it harder to see the information. Did a quick and dirty version:
I also have added some more debug outputs in the hub code, that gives you additional information... So the last run looked like:
|
Looks like that setaddress failing totally screws it, I wonder why that is failing? |
To answer your questions. Yes, Thanks and Yes :) When I am in a better frame of mind going to look at code maybe some piece we haven;t implemented yet is the hang up. |
Andrew - Kurt Decided to try different Hubs just to see if that may be an issue. The one I am currently using is a UGREEN USB3.0 4 port hub I am using unpowered. Tried a Amazon Basic USB3 hub and its giving me issues about not being able to read the device descriptor. A anker USB3 hub seems to work as well. |
So do they all work with some hubs? If not: I'm guessing it is changes to https://github.com/AndrewCapon/Arduino_USBHostMbed5/tree/USBHostMulti that are causing the problems. The code I put in for the driver stuff is as far as I can see does exactly the same as the joystickEX code when initialising. Can you change USBHostConf.h and give it a go with these settings:
I also pushed a new version of https://github.com/AndrewCapon/USBHostMulti that fixes the false error log about init on HID devices. |
Sorry went off to town... Will play more with HUB. Somethings I am seeing in the code versus the Teensy code and the like, is maybe some of the set/clear feature values are not correct and/or sent. Like clear the suspended state, etc. Will be try out changes in this area and see if it helps |
I think the HUB code is extremely dodgy, I can still get it in states with disconnecting and connecting devices where it just dies silently. I wouldn't call it reliable. A total rewrite might be in order. |
I will try to go through it and compare it versus USBHost_t36 as well as USBHost Shield 2 code... Edit: As well as USB 2.0 Spec chapter 11... |
Things I have noticed with the Hub code:
The code to stop the NAK flooding does at least fix the issue where the hub dies and no interrupt requests are running. I'm not sure if this is to do with the two hubs I have tried, one does seem more reliable than the other in general. |
Morning Andrew Anyway did a dump of the output from @KurtE 's ls branch and looked at it compared to the current multi branch. Here are the 2 outputs - didn't see anything but maybe you all will: the only thing i didn't see is where setspeed was being called? but that may just be a debug issue. hope it helps |
Hi Mike, Sorry, been a bit busy today. Need to look at those logs in more detail in the morning... Cheers Andy |
Hi Mike, If you get some time can you test like this:
Then set in `USBHostConf.h"
If this works it shows my haphazard merge of Kurts low speed code is ok. Then try:
If this works it shows the new code with retransmit works. Then we will be in a better place for working things out (maybe!) As it is a HID device that is failing is there anything special that needs to be done to init these, I could only see init stuff for the xbox and switch controllers? I do have a SpaveNavigator to test with but the Giga can't power it and all my powered hubs are in use, I may order one for amazon today... |
Morning Andrew or afternoon To answer your questions: Wouldn't worry about space navigator for now. I have one someplace but not sure where :) Now for the more complicated things.
and it didn't work. For the DS4 clone it connected and once out of maybe 5 times of hitting restart it would work. The Teiros one connects but again no data. Teiros_failed.txt Out of curiosity I did attach the xbox360 w/wireless adapter - it did connect and did display data but, had an issue with set rumbling, would work for a bit (on off) but then get stuck in the on position. Just as a FYI |
mmm, something must be really arsed up :) I expected with |
Andrew - There are 3 sketches in the examples for the joysticks and gamepads (ds4, etc). I tried the joystick sketch with the Logitech 3d joystick with and without the hub with the settings that your recommended. With it attached to the hub it fails to connect and run. When plugged in directly to the giga it works no issues. Here is the dump when attached to the hub: when attached directly to the Giga: Maybe a clue |
Right. So without the hub: Does this also work:
And if that works, does the Arduino project you have converted from https://github.com/AndrewCapon/USBHostMulti work without the hub? |
Hi Andrew
Using the gamepad sketch from @KurtE's library:
Xbox360w: Works Now for using Multi without the hub with the sketch you have:
Xbox360w: Works /************************************************************************************/
Xbox360w: Fails
SpaceNavMouse: Works |
Hi Mike, Sorry for delay: a combination of back pain and PlatformIO updating itself and arseing everything up. I have pushed some new code to https://github.com/AndrewCapon/Arduino_USBHostMbed5/tree/USBHostMulti this allows us to disable the few bits of code I added that are different to Kurts branch when It is all setup to go, with So no need to change USBHostConf.h Can you test Xbox360w with the sketch from Kurts lib with this code and without a hub when you get some time. Cheers Andy |
Hi Andrew Getting closer and closer :) |
Sorry not keeping up too well. Arm problems... Playing with the hub code, although probably it for today... I think there are issues in timing and threads and the like... Here is connection with keyboard with internal HUB on Micromod: <style> </style>
Here is a current run on the GIGA <style> </style>
|
Not so good as we have disabled all the new code :) There are two defines in USBHostConfig:
Does that still work? If so:
Does that still work? |
I think you might well be right about timing, I have noticed printfs changing things. So with the GIGA stuff, the last set_address is failing, and that's the device? |
Also I'm having a GIGA/USB free Christmas now for a few days :) So you guys have a really nice Christmas, maybe Santa will bring us some working USB code, I did send a letter to him. All the best Andy |
Merry Christmas Andrew - enjoy the time
Works
Works. PS tested with the DS4 Clone and it works as well. Since I like punisment also tried with the SpaceNavCompact and it worked as well. Out of curiosity tested with this config
360w: WORKS |
Happy new year guys.
Well that makes no sense to me at all :) With those settings it should have been the same as before, the only difference is that Kurts debug messages are there now. I wonder if it is a timing issue. Does it work if you turn the USB debug messages off? |
Happy New Year Andrew - Anyway will try testing again later today - still early here and just having 1st cup coffee. Not to fear will get back to it soon :) |
Hi Andrew and Kurt
the one joystick (Ds4 clone) would not enumerate With this
I get the ds4 clone working again. One note is that the spacenav mouse and logitech joysticks don't seem to work from the hub but does work if plugged directly into the usbhost port on the giga. |
Happy new year all... Sorry taking things slowly right now. Debug messages: Locally I changed the printing of the detailed stuff to debug level > 4 to reduce it: like:
Locally my hub code is probably completely busted... At least it still does not like my keyboard... Finding issues, where debug output looked like jiberish, but I believe is two different places output to debug at same time. Not sure if ISR and Thread or two threads... But I think that is a clue to some of the underlying issues. That is some of the code is run from the USBHostHub::rxHandler() I think there could be confusion going on, And one undoing or trying to redo what the other one is... |
Code to fix the issues currently with the USB Host code.
Enable with
ARC_USB_FULL_SIZE=1
Use the HAL to handle the entire transfer.
Stop the NAKs flooding the cpu.
Stop the CHHs flooding the cpu.
Only retry if no data has already been received for transfer.