The example code (UX_HOST_CLASS_VIDEO_EL_MG_AP_SK-S7G2) for the USBX Host Class Video Module with the SK-S7G2 works fine with a USBX pool memory size of 32768 bytes. The USB camera can be connected and disconnected any times, and the change is properly detected every time. However, the module guide recommends a USBX pool memory size of 40960 bytes, and in case additional host classes are needed to be included into the project it should even be higher. Changing the pool memory size to 40960 bytes, or higher, creates the following problem:
Does anyone have any idea of why increasing the pool memory size above 32768 bytes with the USBX video module causes the USBX stack to malfunction? Thanks in advance!
Software version: e2 studio 2022-04 with SSP v2.2.0
I'm not an expert with Synergy devices but have you also considered the clock configuration as discussed in this thread:
JBIf this response, or one provided by another user, answers your question, please verify the answer. Thank you!Renesas Engineering Community Moderatorhttps://community.renesas.com/https://academy.renesas.com/https://en-support.renesas.com/knowledgeBase/
Thank you for your reply! I have seen those discussions but they are unfortunately not related to this problem. Those are related to the fact that external crystals or crystal oscillators have much higher frequency stability than the internal semiconductor oscillator, which is especially critical for the high speed USB communication. Both my custom designed board and the SK-S7G2 board have external high accuracy crystal oscillators and are indeed used correctly in the configuration.
One of the reasons why this thread is about the SK-S7G2 board with the provided Renesas USBX video example, instead of my custom design and custom application, is that many developers have the SK-S7G2 development board to give it a try. The SK-S7G2 have its own BSP where the necessary pins and clocks are preconfigured. One only needs the USBX video module guide and the example code, which exhibits the same problem that I am facing. If someone find the reason then I could perhaps apply that to my custom project.
Just a few words about my application: I have a custom designed board where both USB ports of the S7G2 MCU is used as host. The High-Speed USB is for the UVC camera and the Full-Speed USB port is for CDC-ACM communication with a salve device. My problem is that the camera module makes the USBX stack to malfunction and the communication with the CDC_ACM device is lost too. However, individually they work fine so it would be logical to exclude hardware issues. But I need them both to function simultaneously.
I have done further experiments with this and I will try to get back soon.
This is a follow up and a suggested workaround for the problem.
The USBX host class video seems to behave in four different ways, depending on the amount of USBX pool memory size:
1. Too low USBX pool memory size: ThreadX throws an error message about insufficient memory.
2. Low USBX pool memory: ThreadX gives no error message but the USBX fails to detect any device.
3. Right amount of USBX pool memory (30 - 32 KB): Everything works fine, one can attach and detach the USB device as many times as needed. This is the amount of memory one wants to find.
4. Too much USBX pool memory: The UVC camera enumerates the first time it is connected but fails to disconnect, and any subsequent connection and disconnection is not detected. The USBX host seems to have crashed.
The right amount of USBX pool memory for the USB host class video depends on which other host class it may coexist with. For a CDC-ACM host class combined with UVC host class the right amount of USBX pool memory is 47 KB exactly. Anything more or less will make the UVC host class to malfunction.
To find the right amount of USBX pool memory size one can make a binary search and observe the UVC host class behaviour according to the above mentioned states.
The isochronous transfer mode of the host class on the USB_HS must be disabled for the USB_FS to work. The USBX host class video module guide is wrong about that, it is mostly not needed or recommended for most USB cameras. Instead use bulk transfer as default.
This solves the problem for my application, where both the UVC host class on the USB_HS and the CDC-ACM host class on the USB_FS works fine now. It works properly and I can attach and detach any device and any number of times.
I only consider this as a workaround for the problem and would highly appreciate if someone could give a proper explanation to the problem, or explain how one could recompile it from the source to work correctly with any sufficient amount of USBX pool memory size.