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

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderators: barthess, RoccoMarco

Altee
Posts: 8
Joined: Mon Oct 29, 2018 12:17 pm

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

Postby Altee » Thu Jan 10, 2019 6:01 pm

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,
Attachments
USB_HOST.7z
(33.76 KiB) Downloaded 7 times

User avatar
Giovanni
Site Admin
Posts: 11713
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 493 times
Been thanked: 418 times
Contact:

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

Postby Giovanni » Thu Jan 10, 2019 6:46 pm

Hi,

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

Giovanni

Altee
Posts: 8
Joined: Mon Oct 29, 2018 12:17 pm

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

Postby Altee » Fri Jan 11, 2019 11:01 am

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,

Altee
Posts: 8
Joined: Mon Oct 29, 2018 12:17 pm

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

Postby Altee » Sat Jan 12, 2019 8:57 pm

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,
Attachments
USB_HOST_STM32L4xx_20190112.7z
(28.96 KiB) Downloaded 5 times

User avatar
Giovanni
Site Admin
Posts: 11713
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 493 times
Been thanked: 418 times
Contact:

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

Postby Giovanni » Sat Jan 12, 2019 10:20 pm

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

Altee
Posts: 8
Joined: Mon Oct 29, 2018 12:17 pm

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

Postby Altee » Fri Feb 08, 2019 10:30 am

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.

User avatar
Giovanni
Site Admin
Posts: 11713
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 493 times
Been thanked: 418 times
Contact:

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

Postby Giovanni » Fri Feb 08, 2019 2:32 pm

Hi,

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

Giovanni


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 2 guests