-
Notifications
You must be signed in to change notification settings - Fork 46
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
CDC and HID don't seem to coexist properly (STM32F072) #12
Comments
Does the CDC interface (function really, but let's not get too technical) get detected though? How do you set the endpoint addresses? |
Yep, the CDC interface gets detected and functions. The string descriptors don't work properly (lsusb says error) but it does get detected and I can read from it. I set them as follows:
|
This part look ok. Does the HID interface work on its own? |
Yes if I comment out the CDC mount the HID interface gets detected fine. I have not tried to send data yet however. |
This works just fine for me, e.g. with the DebugDongle, so it's more likely that something specific to your implementation is the problem. |
It sends data fine as well. |
Hmm I wonder what it could be. I do have a USB Beagle 12 that I could do a bus dump with while it enumerates. Would that be of help? Yeah I used DebugDongle as an example actually. |
Ok this is weird... I reversed the mount order, and now the both work:
The strings still show (error) in lsusb output, but both interfaces work... |
Do you enable this flag: |
I do not. Here is my config:
|
Here is all the HID code:
Nothing obvious sticks out to me. |
BTW after I get this working I will send a PR for the Joystick additions I did to the HidReportDef project. |
I could only tell more with USB trace information available, otherwise I have no ideas. |
Hopefully the capture will help. It looks like the device replies with an invalid PID sequence during a setup transaction. You will see the rows marked "I" in the error column in the .csv. |
The only failure I see here is that the host fails to set the CDC line coding, and afterwards also fails to read the interface descriptor of the console_if (which it succeeded to read before). These are all functioning operations on my side, so I don't know what's exactly wrong with your setup. |
Huh, weird. Well it is working for now with just that issue. I think I will just ignore it for now. Should I close this or keep it open just in case I find something else? |
I have a patch to fix reading in console_if.c It wasn't "priming the pump" so to say.
|
It would make more sense to call |
Ahh yep! Fixed it to do that instead. |
Hrm I closed this but it is still an issue. Quite annoying I can't seem to get anywhere with it. :( CDC by itself sort of works, and the descriptors seem to come back OK depending on timing (If I do a lsusb too soon after enumeration getting the string descriptors will fail and the device thinks it is both self powered and bus powered). HID by itself works very well and has no issues. HID+CDC sort of works, but the descriptors don't all come back (for instance with only CDC or only HID I get the BOS descriptor, but with both I don't and none of the string descriptors work.) and for some reason the device reports itself as both Bus Powered AND Self Powered... Which makes no sense... CDC+HID shows up as a CDC/HID composite device but the HID driver can't probe it, and the descriptors are again wonky, and no working string descriptors. I've been trying to use a debugger to figure it out but the timing is very sensitive, so my sessions don't catch much if I want the device to actually enumerate... Is there some sort of link time ordering I need to adhere to, to get the descriptors to work right? Do you have any other suggestions I can try to get things working? I can probably send you a zip file of the code if you want to take a look... Maybe it is some weird issue with using the STM32CubeMX interface with your library? Do you have a NUCLEOF072RB? The code I have will run on that board. |
Did you try to run only the USB stack, disabling the rest of the system, to see if it's an interupt starvation issue? Using the Cube and especially HAL is not the best idea for actually functioning products. I don't have an F0 nucleo, but I have the next best thing, an F072 Discovery, which has the very same chip onboard, and has USB connection, so I can try your code if you send it to me. |
Yeah the HAL kinda sucks. I'm slowly porting away from it. I may just move completely to Rust-lang at the end of all this, not sure. I did try with my timer ISR disabled, and got the same results. I was thinking it could be interrupt starvation as well. Where is the best place to send the zip file? |
Maybe just push it to a private github repo and add me as collaborator. |
Ok sent you an invite. |
Hrm, how do I fix that. I have to admit I am not very good with git
submodules yet so I may have done something wrong.
I just sent a PR for the change I made. Hopefully that will at least get
your copy of the HidReportDef repo up to date with mine.
Thanks
…On Thu, May 16, 2019 at 3:42 AM IntergatedCircuits ***@***.***> wrote:
I couldn't fetch the HidReportDef commit because that wasn't published for
me.
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#12?email_source=notifications&email_token=AAR4P22ALBHUSVPAOEFOYRLPVUF6NA5CNFSM4HJMSFSKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVQ6ULY#issuecomment-492956207>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAR4P2Y74JVG45NOA7WXIWTPVUF6NANCNFSM4HJMSFSA>
.
|
It might have been something on my side as well, on Windows I'm struggling with git quite a lot as well. Anyway thanks for the PR, it's merged now. |
Does it build now?
…On Thu, May 16, 2019 at 1:19 PM IntergatedCircuits ***@***.***> wrote:
It might have been something on my side as well, on Windows I'm struggling
with git quite a lot as well. Anyway thanks for the PR, it's merged now.
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#12?email_source=notifications&email_token=AAR4P2YGJJQPSEBVUFNLN3DPVWJTVA5CNFSM4HJMSFSKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVSPTRY#issuecomment-493156807>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAR4P22YR4OYUCO6G7GR63DPVWJTVANCNFSM4HJMSFSA>
.
|
It does. There are some strange things being done here, why do you connect the USB and then disconnect-reconnect it after 1 second? Also why aren't the GPIOs initialized in the MSP callout? The attached zip contains patch files for these, please retry with this. I have no issues when using this and disabling other processing in interrupts. These would still not fix the underlying design issue that the ADC and I2C blocking operations are performed in interrupt context, while there is no reason they couldn't be done in thread mode (in |
I did the disconnect-reconnect as a workaround for the issue. It seems to
make the descriptors read properly after the soft disconnect and
reconnect.
Hrm I don't know how I missed the GPIO's not being initialized. That is
odd.
I will take a look at the zip file now.
Thanks for taking a look at it!
…On Thu, May 16, 2019 at 4:38 PM IntergatedCircuits ***@***.***> wrote:
It does. There are some strange things being done here, why do you connect
the USB and then disconnect-reconnect it after 1 second? Also why aren't
the GPIOs initialized in the MSP callout? The attached zip
<http://IC-review.zip> contains patch files for these, please retry with
this. I have no issues when using this and disabling other processing in
interrupts.
These would still not fix the underlying design issue that the ADC and I2C
blocking operations are performed in interrupt context, while there is no
reason they couldn't be done in thread mode (in main()). You could take a
look at the delay implementation of the STM32_XPD to see how system time
elapsing can be detected via polling (hint: COUNTFLAG bit in SysTick).
IC-review.zip
<https://github.com/IntergatedCircuits/USBDevice/files/3188923/IC-review.zip>
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#12?email_source=notifications&email_token=AAR4P24HYLU2P3EBROVOUILPVXA53A5CNFSM4HJMSFSKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVS74TA#issuecomment-493223500>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAR4P25DNEURO7P6VO2EMVDPVXA53ANCNFSM4HJMSFSA>
.
|
Ah, ok so the GPIO init is done all in one place. CubeMX put it all in
gpio.c and it gets called when MX_GPIO_Init() gets called.
Checking out the other changes now.
…On Thu, May 16, 2019 at 5:22 PM Mike Panetta ***@***.***> wrote:
I did the disconnect-reconnect as a workaround for the issue. It seems to
make the descriptors read properly after the soft disconnect and
reconnect.
Hrm I don't know how I missed the GPIO's not being initialized. That is
odd.
I will take a look at the zip file now.
Thanks for taking a look at it!
On Thu, May 16, 2019 at 4:38 PM IntergatedCircuits <
***@***.***> wrote:
> It does. There are some strange things being done here, why do you
> connect the USB and then disconnect-reconnect it after 1 second? Also why
> aren't the GPIOs initialized in the MSP callout? The attached zip
> <http://IC-review.zip> contains patch files for these, please retry with
> this. I have no issues when using this and disabling other processing in
> interrupts.
>
> These would still not fix the underlying design issue that the ADC and
> I2C blocking operations are performed in interrupt context, while there is
> no reason they couldn't be done in thread mode (in main()). You could
> take a look at the delay implementation of the STM32_XPD to see how system
> time elapsing can be detected via polling (hint: COUNTFLAG bit in SysTick).
>
> IC-review.zip
> <https://github.com/IntergatedCircuits/USBDevice/files/3188923/IC-review.zip>
>
> —
> You are receiving this because you modified the open/close state.
> Reply to this email directly, view it on GitHub
> <#12?email_source=notifications&email_token=AAR4P24HYLU2P3EBROVOUILPVXA53A5CNFSM4HJMSFSKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVS74TA#issuecomment-493223500>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AAR4P25DNEURO7P6VO2EMVDPVXA53ANCNFSM4HJMSFSA>
> .
>
|
I moved the USB init code around like in your patch and it still has an
issue with the descriptors not being reported correctly.
I applied the GPIO patch and it also made no difference. What versions of
newlib and GCC are you using? Maybe something is bad with the versions I
have since it seems to work for you and not for me.
…On Thu, May 16, 2019 at 5:32 PM Mike Panetta ***@***.***> wrote:
Ah, ok so the GPIO init is done all in one place. CubeMX put it all in
gpio.c and it gets called when MX_GPIO_Init() gets called.
Checking out the other changes now.
On Thu, May 16, 2019 at 5:22 PM Mike Panetta ***@***.***>
wrote:
> I did the disconnect-reconnect as a workaround for the issue. It seems
> to make the descriptors read properly after the soft disconnect and
> reconnect.
>
> Hrm I don't know how I missed the GPIO's not being initialized. That is
> odd.
>
> I will take a look at the zip file now.
>
> Thanks for taking a look at it!
>
>
>
> On Thu, May 16, 2019 at 4:38 PM IntergatedCircuits <
> ***@***.***> wrote:
>
>> It does. There are some strange things being done here, why do you
>> connect the USB and then disconnect-reconnect it after 1 second? Also why
>> aren't the GPIOs initialized in the MSP callout? The attached zip
>> <http://IC-review.zip> contains patch files for these, please retry
>> with this. I have no issues when using this and disabling other processing
>> in interrupts.
>>
>> These would still not fix the underlying design issue that the ADC and
>> I2C blocking operations are performed in interrupt context, while there is
>> no reason they couldn't be done in thread mode (in main()). You could
>> take a look at the delay implementation of the STM32_XPD to see how system
>> time elapsing can be detected via polling (hint: COUNTFLAG bit in SysTick).
>>
>> IC-review.zip
>> <https://github.com/IntergatedCircuits/USBDevice/files/3188923/IC-review.zip>
>>
>> —
>> You are receiving this because you modified the open/close state.
>> Reply to this email directly, view it on GitHub
>> <#12?email_source=notifications&email_token=AAR4P24HYLU2P3EBROVOUILPVXA53A5CNFSM4HJMSFSKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVS74TA#issuecomment-493223500>,
>> or mute the thread
>> <https://github.com/notifications/unsubscribe-auth/AAR4P25DNEURO7P6VO2EMVDPVXA53ANCNFSM4HJMSFSA>
>> .
>>
>
|
I use TrueStudio 9.0.0, and my Windows 10 machine as host. |
Another thing that you should try (and even change permanently), is that your application (practically your timer) is only started by the Init callback of the HID application, and it's stopped at Deinit. |
Ooo I like that idea. I will try that as well.
…On Sun, May 19, 2019 at 10:31 AM IntergatedCircuits < ***@***.***> wrote:
Another thing that you should try (and even change permanently), is that
your application (practically your timer) is only started by the Init
callback of the HID application, and it's stopped at Deinit.
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#12?email_source=notifications&email_token=AAR4P23YJUXGIWBDL6PFOMLPWFQDJA5CNFSM4HJMSFSKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVXDM5I#issuecomment-493762165>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAR4P2544G6OYWMH35V7Z33PWFQDJANCNFSM4HJMSFSA>
.
|
I got all my CDC issues fixed, so now I am moving on to the HID portion of my code. I have the hid device defined (it is a simple 2 axis joystick, the report desc is 57 bytes), but when I mount it and the CDC interface Linux can't properly detect the HID interface. If I comment out the mounting of the CDC interface the HID interface gets detected fine (I've not tried to send data yet).
Any suggestions on what I may have done wrong? I can post a gist of the HID code if you need, it is fairly short.
Unfortunately on this hardware I don't have access to the JTAG/SWD interface so I can't attach a debugger. :(
The text was updated successfully, but these errors were encountered: