2025-03-09 11:31 PM
Hello,
Has anyone used the USBX host code in AzRtos (not standalone)? The system seems very flaky, and when I looked into it, it seems the Variable: _ux_system_host in file ux_host_stack_initialize.c is never initialized.
/* Defined USBX host variables. */
UX_SYSTEM_HOST *_ux_system_host;
So the pointer to this structure = 0, which happens to be pointing at the memory location for the ITCMRAM
ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K
Was the intent to run USBX with no cache, and leave the _ux_system_host structure in the ITCM RAM, or am i missing some initialization routine?
Obviously, with this data structure in the ITCMRAM, it would explain why the system is flaky when the ICACHE is turned on. However, I'm still not able to get the USB_host up and running properly even with the icache off. (a lot of bus faults due to incorrect callback pointers in this structure)
The ST examples don't seem to run either. Any help would be greatly appreciated
Solved! Go to Solution.
2025-03-12 9:57 PM
Ok, I finished re-writing the Host Only and Device Only drivers, and it seems to be working properly now. The H7 works with a hub and multiple devices on the host side. I still have to test the Device side next week, but hopefully that will be a bit easier.
ST should update their middleware code so users don't have to go through all this pain.
2025-03-10 8:12 AM
Hi @matt-crc
Thank you for reporting the issue. To assist further in diagnosing and resolving this issue, Would you attach a full minimum project on reference board H747 disco or eval board to reproduce on my end?
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-03-11 2:41 PM
Hi @FBL
To replicate the problem on your hardware (STM32H747I-DISCO)
1- Create a new project, select example: (STM32H747I-DISCO) and example: Ux_Host_HUB_HID_MSC
2- open the Ux_Host_HUB_HID_MSC.ioc and add a peripheral: USB_OTG_FS amd make it "Device only"
3- goto "middleware and software" and select "x-cube-azrtos-H7"
4- on the top, tab, select "Software Packs" -> Select Components
5- Under components, Select UX_Device Cores" and UX Device Controllers
6- in the same screen select "Ux Device class HID core" and "Ux Device Class HID Keyboard"
7- save the .ioc file and it will generate the new code
8- Note: ONLY: In app_azure_rtos.c you will see 2 instances of USBx, one for the host, and the other for the Device
9- compile and run.... you will notice that the entire code is flakey because of the way the initialization code is defined... So all the main USB structures are not initialized like _ux_system, and _ux_system_host.
Let me know if you have any questions.
2025-03-12 5:07 AM
Hi @matt-crc with the last version of x-cube-azrtos-h7 the dual instance host/device is not supported.
please see this thread:
2025-03-12 10:54 AM
Thanks for the info... I finally got the USB initialization code re-written properly and it generates separate memory pools for the usb host and device using the two H7 USB interfaces. That way, I can still configure the hardware using the existing CubeMX GUI. I also found a hack for CubeMX, so it doesn't update the code for certain files that needed to be modified (outside of the "user comment" sections).
I'm currently in the process of testing the USB host side with a hub and multiple devices (keyb, mouse, Storage), and looking at the issue of the internal H7 USB state machine locking up (as described in the errata). I think we have a work-around for that and hope I can fix that issue in a couple of days.
Once I finish testing the Host side, I'll jump on the device side testing. It is currently compiled in and all resources allocated, but I still have to test and debug. I can enable device only, host only, and both device only and host only from the CubeMx GUI and it seems that the resources are all allocated properly now.
2025-03-12 9:57 PM
Ok, I finished re-writing the Host Only and Device Only drivers, and it seems to be working properly now. The H7 works with a hub and multiple devices on the host side. I still have to test the Device side next week, but hopefully that will be a bit easier.
ST should update their middleware code so users don't have to go through all this pain.