Forum Discussion
FabriceNs
New Contributor
1 month agoUSB Device Issue on Cyclone V / HPS
Hello, Please find below a description of the USB issue we are experiencing with our Cyclone V / HPS board. To test our USB interface, we integrated the TinyUSB library into our existing firmware a...
TruHy
New Contributor
13 days ago@FabricNS
Please ignore above issue that wasn't it.
I played some more with the tinyusb code and finally found the problem. It seems the old dwc2 USB controller receive fifo size must be set to a minimum of 119 words. The fix is to edit the tinyusb/src/portable/synopsys/dwc2/dcd_dwc2.c file at the function calc_device_grxfsiz().
The original code is:
TU_ATTR_ALWAYS_INLINE static inline uint16_t calc_device_grxfsiz(uint16_t largest_ep_size, uint8_t ep_count) {
return (uint16_t)(13 + 1 + 2 * ((largest_ep_size / 4) + 1) + 2 * ep_count);
}I changed it to this:
TU_ATTR_ALWAYS_INLINE static inline uint16_t calc_device_grxfsiz(uint16_t largest_ep_size, uint8_t ep_count) {
// Altera Cyclone V SoC DWC2 bug, the minimum grzfsiz is 119 words, i.e. 4*119 = 476 bytes
#if defined(TUP_USBIP_DWC2_CV) && TU_CHECK_MCU(OPT_MCU_CV)
uint16_t words = (uint16_t)(13 + 1 + 2 * ((largest_ep_size / 4) + 1) + 2 * ep_count);
if(words < 119) words = 119;
return words;
#else
return (uint16_t)(13 + 1 + 2 * ((largest_ep_size / 4) + 1) + 2 * ep_count);
#endif
}You will also need to add OPT_MCU_CV into tinyusb/src/common/tusb_mcu.h:
......
//--------------------------------------------------------------------+
// Geehy
//--------------------------------------------------------------------+
#elif TU_CHECK_MCU(OPT_MCU_APM32F0XX)
#define TUP_USBIP_FSDEV
#define TUP_USBIP_FSDEV_APM32
#define CFG_TUSB_FSDEV_PMA_SIZE 1024u
//--------------------------------------------------------------------+
// Altera Cyclone V SoC
//--------------------------------------------------------------------+
#elif TU_CHECK_MCU(OPT_MCU_CV)
#define TUP_USBIP_DWC2
#define TUP_USBIP_DWC2_CV
#define TUP_DCD_ENDPOINT_MAX 16
#endifand also ensure to set it in your tusb_config.h:
#ifndef CFG_TUSB_MCU
#define CFG_TUSB_MCU OPT_MCU_CV
#endif
SueC_Altera
Contributor
10 days agoThanks for posting the resolution! I'm glad you figured it out.
Sue