STMicroelectronics / STM32CubeU5

Full Firmware Package for the STM32U5 series: HAL+LL drivers, CMSIS, BSP, MW, plus a set of Projects (examples and demos) running on all boards provided by ST (Nucleo, Evaluation and Discovery Kits).
Other
116 stars 61 forks source link

USBX Host examples - general issue #30

Closed tdjastrzebski closed 4 months ago

tdjastrzebski commented 10 months ago

There are several USBX Host examples built for STM32U5x9J-DK board (STM32U5A9J-DK MB1829, others?) https://github.com/STMicroelectronics/STM32CubeU5/tree/main/Projects/STM32U5x9J-DK/Applications/USBX

The little problem is that this board doses NOT have UCPD source capability so it cannot power the attached devices, unless non-standard power config is used. That is: 2nd JP4 jumper in 5V_UCPD position, current flows through Q1 internal diode (Imax=1.4A only!) with significant 0.4V voltage drop at 1A, or powered USB hub is used. Definitely, not the best board selection for this kind of examples. According to README, examples have been tested with non-officially-existent (!) STM32U599J-DK board, but luckily the attached IOC file contains STM32U5A9J config. README does not clearly state whether or not USB hub is required or a single device, e.g. mouse, can be connected directly. Perhaps not, but it is unclear.

I think it would make much more sense to build USBX Host examples for the B-U585I-IOT02A (MB1551) board which has both UCPD sink and source capability and is more cost-effective than STM32U575I-EV board.

tdjastrzebski commented 9 months ago

Another board which could be used for USBX Host example is NUCLEO-U5A5ZJ-Q. At least it can be configured to provide USB power (SB8-10) and, unlike B-U585I-IOT02A, contains MCU which has high speed transmitter (HS_OTG). Although high speed transmission is rarely required, this USB IP substantially differs from the previous version so example would be welcomed.

pauleffect90 commented 7 months ago

I have a u5a5 nucleo board and I stand in complete awe at how much of a joke this line of MCUs is. Maybe they leaned a little too much on interns or cheap off-shore 50-a-dime programmers, maybe they're simply in over their heads, I've no clue - but I've yet to encounter this much of a mess in 10y working as an embedded engineer.

image One would expect the value of PLLN to be 16 / 1 * 80 = 1280Mhz. Nope, it's 1328 Mhz. No wonder I couldn't even send a "hello world" string over UART. My clocks were all messed up by CubeMx - latest version. This only happens for U5A5.

As for the USB Host, 0 examples. There's actually no single USB HS example in the entire U5 repository. Because it's not an important peripheral and neither a complex one.

Id like to say Im surprised but I got to chat with some ST engineers at embedded world last years and they had no clue whatsoever what even the most basic features of U5 mean - like the RAMCFG tab.

I had hoped to port an F4 project over to U5. Guess I'll be going with an NXP.

tdjastrzebski commented 7 months ago

@pauleffect90, Do you mean Embedded World in Nuremberg? I had the same impression, but I thought maybe they were not allowed to give full details until the release day. Nevertheless, ST is a company which is yet to realize that time to market matters a lot to their customers and these days the main factor is SOFTWARE, not hardware. Did anyone ever see HAL test suite? It speaks a lot for itself. As for the USB: over two months ago I found obvious and super easy to fix HAL issue https://github.com/STMicroelectronics/STM32CubeU5/issues/31 (list item 1) which prevents compilations. This one is no-brainer, but it is not fixed in just released version 1.4 :/ Also, check out this one: Why OTG_HS USB/USBX Host on STM32U5Axx just does not work? (2) No ST response. Apparently, there are serious issue with new USB, probably including hardware which support is not allowed to confirm. I would not be surprised to see "class action" filed in US since we are talking about faulty product and lost money. Speaking of support, probably some smart VP had an idea of self-supporting community. This person envisioned highly skilled (and usually paid) engineers spending time in forums and sharing their hard earned knowledge for badges, points and titles following an example of several compensated individuals. This is how detached from reality one can be. UCPD is not problem free: https://github.com/STMicroelectronics/cmsis_device_u5/issues/1 I confirm problems with just released CubeMX. In my case it complains about unspecified PWR config. In my opinion, U5 has been released too early, in rush, perhaps so corporate bonuses could be paid. I evaluate alternatives, including recent TI MPUs. At least, they have first-class customer support.

pauleffect90 commented 7 months ago

@tdjastrzebski yep, thats the event I was talking about. And actually no, it was released for quite some time at that point. I had a development board with U5 for ages. Also counter-intuitive, you release a new MCU line and you set up booths showing off that MCU and the dudes working at ST don't know the first thing about it? One could expect this level of professionalism (or lack thereof) from some nameless startup, but a 16 billion company?! 16 mf billion dollars?! Back to the matter at hand, I use CMake (or plain make) + CLion to compile most of my software. I can't start any single example provided by Cube mx (examples tab). Every single one complains about bad instructions or what not. I mean ok, I can roll my sleeves and debug away, but the question is: why should I? A piece of example software means "hey, get this thing, it's written by US, it WORKS, get familiar with OUR product, now roll out your OWN". If it doesn't work, what am I supposed to do? Lose myself in 1000s of pages worth of application notes and tens of thousands of lines of code, bug hunting? Or maybe I'll just abandon ST altogether and chose someone that respects my company as a client and our time (which translates to $$$). I've spent 48h on the U5A5 and I haven't been able to so much as connect an USB device to my board, let alone actually begin writing the driver. Anyway, I'll check out your link (i'll try to give this joke one more chance). And to reciprocate, try NXP's RT 595. Cortex m33 (max 275mhz) + GPU + Cadence DSP (max 275 mhz) + 5MB sram with a power consumption of ~ 30 mW @ 196 mhz.

tdjastrzebski commented 7 months ago

@pauleffect90 I think ST is just not a solution for startups and small companies. I believe that they have dedicated first-class support, but only for selected large players who probably pay substantial support fees. I tried to open support request once. It was closed after several months due to no response - ST response. Seriously, that was the reason system provided in email. That would even be OK if they did not skillfully pretend to be something else misleading lots of engineers like us. What we experience then is simply a clash between hard reality and false expectations ST marketing professionally creates. I am probably going to finish my current project with ST. It is delayed almost a year, costed way more than estimated, I had to write own I2C/SMBus driver from scratch. Along the way found lots of HAL bugs and many RMxxxx documentation mistakes I do not even bother to report (where?). Overall, it is a terrible experience and hard lesson learned I hope not to repeat ever again. Definitely next time I will at least try NXP and/or TI - thank you. I got USB-C working as a host using modified Nucleo-U5A5ZJ-Q board. The main problem (and solution) I described in ST forum here. For build I use my custom tool cppbuild - fast, simple and very effective. It does full dependency analysis to decide which unmodified file needs to be rebuilt, but this version is not published yet. Sample project with full VS Code config is available here.

pauleffect90 commented 7 months ago

I got USB-C working as a host using modified Nucleo-U5A5ZJ-Q board Could I perhaps trouble you with sharing your solution? I must confess, coming from a crunch period of ~ 2 years, I am at my wits end, my brain simply refuses to function normally.

found lots of HAL bugs I know what you mean. It's less like programming and more like a "brute force" experience. Try adding a delay. Hmm, maybe deinitializing and reinitializing will work. Oh, this only works if... so on, and so forth. And hunting for bugs in a 5000 line file chaotically written (or maybe generated?) by an intern is anything but fun (and you can tell it's sub-par code by the broken english comments). I won't even go into identical if-else branches or the general bloatware feel of the code.

All in all, I managed to port the entire F4 project to the aforementioned NXP in less than one week (including some custom UVC drivers). In one week I still haven't managed to plug a damned usb device into this board. :))

tdjastrzebski commented 7 months ago

https://github.com/tdjastrzebski/Nucleo-U5A5ZJ-USBX Just keep in mind board needs to provide USB-C power. SB8-10 need to be shorten, additional JP6 jumper in 5V_USB_C position is required.

pauleffect90 commented 7 months ago

I left a private message for you on the st community forum for you. Thanks again for all your help.

nickterry commented 5 months ago

Has anyone managed to build a USBX HOST application for the [B-U585I-IOT02A]? As noted above the SDK's [STM32Cube_FW_U5_V1.4.0] for this board contain NO Host USB examples. It does contain Host examples for other evaluation boards.

Is it possible to retarget any of the HOST examples included for the other boards in the SDK to the B-U585I-IOT02A in some straight-forward manner?

I want to use the USB port to talk to a modem which should be simple enough if I had chosen to design the board based on one of the other evaluation boards but, sadly, I picked the B-U585I-IOT02A as my starting point and only recently found out there are no HOST examples I can make use of to get going.

The log above shows that this topic has been moved to a ToDo list. Is there any likelihood this will get resolved in the near future?

ALABSTM commented 4 months ago

Dear all,

Please excuse this delayed reply.

@tdjastrzebski and @pauleffect90, regarding the host examples provided for boards such as the STM32U5A9J-DK, they are provided only as reference. Indeed, such boards are sink devices by default and, hence, do not support the VBUS Drive feature.

This is indicated in the README.md files in a note, as shown below:

https://github.com/STMicroelectronics/STM32CubeU5/blob/c8fcb26ff629cf7c2a3b2c60e6121625eaa5ca2d/Projects/STM32U5x9J-DK/Applications/USBX/Ux_Host_CDC_ACM/README.md?plain=1#L118-L124

https://github.com/STMicroelectronics/STM32CubeU5/blob/c8fcb26ff629cf7c2a3b2c60e6121625eaa5ca2d/Projects/STM32U5G9J-DK2/Applications/USBX/Ux_Host_HID/README.md?plain=1#L116-L122

@nickterry, the host examples provided for some boards can be tailored to run on other boards as indicated in the README.md files too.

https://github.com/STMicroelectronics/STM32CubeU5/blob/c8fcb26ff629cf7c2a3b2c60e6121625eaa5ca2d/Projects/STM32U5x9J-DK/Applications/USBX/Ux_Host_CDC_ACM/README.md?plain=1#L91-L92

I hope this shades more light on your questions. Please allow me to close this thread. Thank you for your comprehension.

With regards,