Page 1 of 1
Giga devices GD32F405 USB Device
Posted: Mon Jan 17, 2022 3:06 pm
by Tabulous
Currently running Chibios on a Giga devices GD32F405(STM32F4xx). Virtually everything works apart from the USB FS Device.
It looks to start enumerating but windows then show error as device not known.
Having spoken the GD FAE Manager, they say this
"In most cases, the configuration order of USB FIFO needs to be modified. ST's USB library refreshes FIFO first, then configures it. GD's USB must be configured with USB FIFO before refreshing. The order in which FIFOs are refreshed and configured applies to OTG devices and HOST."
Just wondering if anyone else has any other knowledge of this ?
Re: Giga devices GD32F405 USB Device
Posted: Wed Feb 02, 2022 4:48 pm
by Tabulous
Still trying to get to the bottom of this issue
if i comment out these two asserts
osalDbgAssert(!usbGetReceiveStatusI(usbp, ep), "already receiving");
osalDbgAssert(!usbGetTransmitStatusI(usbp, ep), "already transmitting");
and in usb_lld_start i put a break point on otg_core_reset(usbp);
hitting the break point means the system halts at the break point, when continues is pressed the USB CDC will work....
Now if remove the break point and run the system, USB CDC errors.
Seems this otgp->GCCFG = GCCFG_INIT_VALUE; needs time
Re: Giga devices GD32F405 USB Device
Posted: Wed Feb 02, 2022 7:45 pm
by Giovanni
Probably it is a race condition, that driver needed insertion of small delays in the past. Probably the OTG is configured a bit differently on this device.
Giovanni
Re: Giga devices GD32F405 USB Device
Posted: Thu Feb 03, 2022 11:25 am
by Tabulous
Giovanni wrote:Probably it is a race condition, that driver needed insertion of small delays in the past. Probably the OTG is configured a bit differently on this device.
Giovanni
do you have any recommendations to help debug this ?
Re: Giga devices GD32F405 USB Device
Posted: Thu Feb 03, 2022 11:40 am
by Giovanni
Adding small delays or try to slow down the core using -O0 or a lower clock.
That OTG IP is hard to use.
Giovanni
Re: Giga devices GD32F405 USB Device
Posted: Fri Apr 22, 2022 5:17 am
by russian
Tabulous wrote:do you have any recommendations to help debug this ?
Did you get this to work?
Re: Giga devices GD32F405 USB Device
Posted: Thu Apr 28, 2022 8:54 am
by Tabulous
russian wrote:Tabulous wrote:do you have any recommendations to help debug this ?
Did you get this to work?
Sort of but only by adding delays which makes the enumeration slow, i would really like to get to the route cause and fix it correctly, but just not had the time.
Re: Giga devices GD32F405 USB Device
Posted: Thu Apr 28, 2022 12:13 pm
by Tabulous
this is what i found works. Adding a delay here if MCU type is GD32.
Code: Select all
static void otg_polled_delay(rtcnt_t cycles)
{
rtcnt_t start = chSysGetRealtimeCounterX();
rtcnt_t end = start + cycles;
do
{
__asm("");
WWDG->CR = ( 127 );
WWDG->SR = ( 000 );
}
while (chSysIsCounterWithinX(chSysGetRealtimeCounterX(), start, end));
}
static void otg_core_reset(USBDriver *usbp) {
stm32_otg_t *otgp = usbp->otg;
osalSysPolledDelayX(32);
if(systemGetMcuType() == APP_MCU_GD32F)
{
otg_polled_delay(25000000);
}
/* Core reset and delay of at least 3 PHY cycles.*/
otgp->GRSTCTL = GRSTCTL_CSRST;
while ((otgp->GRSTCTL & GRSTCTL_CSRST) != 0)
;
osalSysPolledDelayX(18);
/* Wait AHB idle condition.*/
while ((otgp->GRSTCTL & GRSTCTL_AHBIDL) == 0)
;
}