-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Disable VBUS sensing #1256
base: master
Are you sure you want to change the base?
Disable VBUS sensing #1256
Conversation
I've additionally tested Nucleo-F412ZG. It works as well (with 26ab78a reverted). Can anybody help me with the integration checks? It doesn't look like something related to my change and at the moment the details can't even be viewed (502 Bad Gateway). |
Jenkins is up again but the error message is very strange:
The code base does not contain a single reference to |
e142275
to
2b603ff
Compare
@manuelbl First of all thanks fro your work on this. Just curious is this "hid_usage_tables.h" could be solved, so to come closer to a honoured pull request? |
@karlp How can we progress the different USB related PRs? What kind of tests and reviews are needed? Who can perform them? Can we support you with the Jenkins problems? The error message mentioning |
the jenkins bugs are fucking crazy, I have no idea why why it fucks up here, but not locally, and not when I run in the same buildroot on the jenkins host. 😡 Generally though, it's been brought up before, and the "right" solution IMO, is an api option for vbus sensing, not hard decisions on or off. Of course, there's no great way of doing API options right now. At least, that's how I remember this last time I looked at it. |
Regarding Jenkins: The error message sounds as if the Regarding VBUS sensing: It certainly makes sense to have it configurable. But the default should be that VBUS sensing is not enabled as most hardware design lack the required wiring. And that's what this simple change achieves. So I think this change adds immediate value. More options can be added later. |
Hi I am barely any sort of expert here, but trying this patch with the weact f411 board, the usb port does at least get a reaction from the computer (it didn't before) but none of the Nucleof4 USB demos successfully run: USB Midi (which is what interests me the most)
I also tried CDC
|
This PR is probably not sufficient to fix all the current libopencm3 USB issues. I recommend to apply this entire list:
And make sure the clock configuration is suitable for USB operation. I have successfully tested it with a NUCELO-F411RE board (using the gadget0 and my own loopback test). |
@manuelbl thanks for that info. I merged all 4 and I get the same issue, sadly. I'm using this clock: rcc_clock_setup_pll(&rcc_hse_16mhz_3v3[RCC_CLOCK_3V3_84MHZ]); But I'm going to double check what the HSE actually is on the board because I don't trust the docs. |
Was the clock, actuallly 25Mhz HSE thank you so much!
|
@manuelbl so just that I get this right. USB specification requires a pullup to detect device presence. According to ST's USB design guidelines STM32F4 familiy is supposed to have this pullup embedded. |
This PR disables VBUS sensing. A side effect is that the internal pull-up resistor on D+ is always enabled. This setup is suitable for bus-powered devices as well as self-powered devices that don't need to turn off the USB peripheral for energy saving or other reasons. It's not suitable for host or OTG role, which isn't supported by libopencm3 anyway. Do you need the external pull-up resistor even when applying this PR? Or haven't you tried this PR yet? If you don't turn off VBUS sensing, you need to wire VBUS to PA9, possibly with a voltage divider. |
I haven't tested your PR yet. I'm not even sure if it is possible to custom build libopencm3 in PlatformIO. I'm kind of new to STM32 development using libopencm3 and after fighting cryptic makefiles and linker scripts for days I decided to go the easy way and use PlatformIO. |
The easiest approach is probably to add the below code after calling
|
Fixes #1119
Partially fixes #1073 (*).
So far, the USB OTG peripheral has been initialized with active VBUS sensing. This doesn't make much sense as the driver is a device mode only driver. It does not support host mode let alone switching between modes. Furthermore, VBUS sensing requires VBUS be routed to a specific pin.
The unfortunate side effect was that the USB OTG driver would not work with several F4 series chips, in particular F411CE and F446RE (probably all F446xx versions).
This pull request disables VBUS sensing and fixes the issues on the above chips (*). It covers both USB core ID 0x1200 and 0x2000.
The code has been successfully tested on:
The tests included my bulk endpoint speed test (source, sink, loopback) as well as gadget0. Note that three gadget0 tests fail on all boards, before the code changes, after the code changes and with boards using a different USB driver.
If anyone would like to use VBUS sensing, it can be easily activated after initializing the USB driver.
I also tried to include a Nucelo-L476RG board into the tests. However, it seems that libOpenCM3 thinks that all L4 series chips have a USB FS device peripheral, when in fact only L41xx through L46xx have while L47xx through L4Axx have an USB OTG peripheral. That's will be a separate issue...
(*) As mentioned in #1073, the F446RE additionally requires reverting 26ab78a.