Page 1 of 1

No interrupt generated on USB device connection while USB OTG_FS core is running as USB host only

Posted: Thu Jan 10, 2019 6:01 pm
by Altee
Hi,

I am testing the USBHv1 driver which, as I understood, is setting the USB OTG_FS core to run as USB host only. Unfortunately, no interrupt is generated when I plug a USB device into the user USB port on the following two ST boards: Discovery STM32F4259I-DISC1 (MCU STM32F429ZITx) and Nucleo-144 STM32L496ZG.

Hopefully, I put my hands on a Discovery STM32F4-Discovery board (MCU STM32F407VGTx), the one board on which the "USB_HOST" sample program was tested. On that board, the USBHv1 driver is working correctly since I got a host port interrupt (HPRTINT bit in OTG_FS_GINTSTS register) and the bit which tells that a USB device is connecting is set (PCDET bit in OTG_FS_HPRT register).

I modified the "USB_HOST" sample program in order to be able to switch quickly between the two Discovery boards (the one working and the one not working). I tried to compare the values of the relevant registers to my eyes (OTG_FS related registers, clock registers, NVIC registers, etc.) but did not find any main differences. I also checked that clocks were correctly set and did not find any issues between the two boards.

I join the source code of my modified "USB_HOST" program which contains the board files for STM32F4-Discovery and STM32F4259I-DISC1. You can just uncomment two lines in the makefile (one to include the board and one to define the linker script) to switch from one Discovery board to the other. I also added two threads to make the green and red LEDs flash when the program is running.

Do you have the possibility to test that program on the same boards as me ?

Thanks for the help,

Re: No interrupt generated on USB device connection while USB OTG_FS core is running as USB host only

Posted: Thu Jan 10, 2019 6:46 pm
by Giovanni
Hi,

Have you verified settings in board files? those are not tested with USBH and could require changes.

Giovanni

Re: No interrupt generated on USB device connection while USB OTG_FS core is running as USB host only

Posted: Fri Jan 11, 2019 11:01 am
by Altee
Hi Giovanni,

Thank you for making me recheck the board.h for the Discovery STM32F4259I-DISC1 board... In fact, pins used by OTG_FS are already used by other peripherals on that board (USART1 and LTDC). So OTG_FS cannot be used, but OTG_HS can ! Then I reconfigured the USBHv1 driver to use OTG_HS and I get interrupts when I plug a USB device.

Nevertheless, that doesn't explain why I don't get interrupts from OTG_FS core on Nucleo-144 STM32L496ZG board. And that board is much simpler to configure than the Discovery board. Unfortunately I don't have the Nucleo-144 board on hand and will have to recheck the board.h later...

Thanks again,

Re: No interrupt generated on USB device connection while USB OTG_FS core is running as USB host only

Posted: Sat Jan 12, 2019 8:57 pm
by Altee
Hi Giovanni,

I tried to simply migrate the project which is working for Discovery-STM32F4 board to Nucleo144-STM32L496ZG board. For that, I found the chconf.h, halconf.h and mcuconf.h files into the ".\demos\STM32\RT-STM32L496ZG-NUCLEO144" folder and board.h files into the ".\os\hal\boards\ST_NUCLEO144_L496ZG" folder (I copied that folder into my project). I changed the board.h file in order to be in the same configuration for USB OTG pinout as the one which is working on Discovery-STM32F4 board:
- GPIOA_USB_VBUS as input (previously set as analog) and ospeed set at high (previously set at low);
- GPIOA_USB_SOF as analog (previously set as alernate 10);
- ODR set to high (previously set at low) for GPIOA_USB_VBUS, GPIOA_USB_ID, GPIOA_USB_DM and GPIOA_USB_DP;
- setup the HSE and LSE clocks.

The project did not compile out of the box because of the switching from STMF4 to STML4 (several compilation errors like: "hal_usbh_debug.c:487:36: error: 'USART_TypeDef {aka struct <anonymous>}' has no member named 'SR'; did you mean 'ISR'?"). After solving the compilations errors in hal_usbh_debug.c, I ran the program and plugged a device in USB user port but no interruptions ! Finally I checked that PLLSAI1Q clock was driving USB at 48MHz, which is the case. So I am stuck and about to give up...

Could you please give it a try with the joined projet source code which is a port to Nucleo144-STM32L496ZG board ? I am using a clone of ChibiOS-RT and ChibiOS-Contrib done the 8th of January 2019 as you will see in the makefile.

Thanks,

Re: No interrupt generated on USB device connection while USB OTG_FS core is running as USB host only

Posted: Sat Jan 12, 2019 10:20 pm
by Giovanni
Hi,

When we ported the USB (device) driver to the L4 we had problems because a strange behavior of the OTG peripheral, we had to introduce workarounds in the driver, I don't know if the host mode driver could be affected in a similar way.

Your problem seems to be that the driver does not sense the connection of a device, probably it is still caused by GPIO settings.

I am not the author of the USBH driver so there is not much I could do except giving generic advice I never really had time to play with it. Code in the community repository is maintained by authors and/or volunteers.

Giovanni

Re: No interrupt generated on USB device connection while USB OTG_FS core is running as USB host only  Topic is solved

Posted: Fri Feb 08, 2019 10:30 am
by Altee
Hi Giovanni,

I finally found the reason for interrupts not being generated by the USB OTG_FS core on STM32L4 : it was linked to a bit called "VDDUSB USB supply valid" (USV) in "Power control register 2" (PWR_CR2). After setting this bit to one, I get the interrupts as on the boards equipped with STM32F4 MCU.

Thanks for your help one more time.

Re: No interrupt generated on USB device connection while USB OTG_FS core is running as USB host only

Posted: Fri Feb 08, 2019 2:32 pm
by Giovanni
Hi,

Thanks for finding, I need to understand how/where to handle this in the code.

Giovanni