From dfa4a1f7ac68b93e3a921993bd888f10f4fc5480 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 30 Apr 2015 08:00:41 -0600 Subject: [PATCH] STM32 HUB: Fix more compilation errors when hub support is enabled --- arch/arm/src/efm32/Kconfig | 1 + arch/arm/src/efm32/efm32_usbhost.c | 10 ++++--- arch/arm/src/stm32/Kconfig | 2 ++ arch/arm/src/stm32/stm32_otgfshost.c | 10 ++++--- arch/arm/src/stm32/stm32_otghshost.c | 10 ++++--- configs/stm32f4discovery/README.txt | 42 +++++++++++++++++++++++++++- 6 files changed, 62 insertions(+), 13 deletions(-) diff --git a/arch/arm/src/efm32/Kconfig b/arch/arm/src/efm32/Kconfig index 317b87b528b..6684acf9baf 100644 --- a/arch/arm/src/efm32/Kconfig +++ b/arch/arm/src/efm32/Kconfig @@ -193,6 +193,7 @@ config EFM32_OTGFS bool "USB Full-Speed OTG" default n depends on EFM32_HAVE_OTGFS && EXPERIMENTAL + select USBHOST_HAVE_ASYNCH if USBHOST config EFM32_TIMER0 bool "TIMER0" diff --git a/arch/arm/src/efm32/efm32_usbhost.c b/arch/arm/src/efm32/efm32_usbhost.c index edc8babeea2..e0db982239f 100644 --- a/arch/arm/src/efm32/efm32_usbhost.c +++ b/arch/arm/src/efm32/efm32_usbhost.c @@ -199,6 +199,7 @@ struct efm32_chan_s sem_t waitsem; /* Channel wait semaphore */ volatile uint8_t result; /* The result of the transfer */ volatile uint8_t chreason; /* Channel halt reason. See enum efm32_chreason_e */ + uint8_t chidx; /* Channel index */ uint8_t epno; /* Device endpoint number (0-127) */ uint8_t eptype; /* See EFM32_USB_EPTYPE_* definitions */ uint8_t funcaddr; /* Device function address */ @@ -1031,7 +1032,7 @@ static int efm32_chan_waitsetup(FAR struct efm32_usbhost_s *priv, #ifdef CONFIG_USBHOST_ASYNCH static int efm32_chan_asynchsetup(FAR struct efm32_usbhost_s *priv, - FAR struct efm32_chan_s *chan. + FAR struct efm32_chan_s *chan, usbhost_asynch_t callback, FAR void *arg) { irqstate_t flags = irqsave(); @@ -1159,7 +1160,7 @@ static void efm32_chan_wakeup(FAR struct efm32_usbhost_s *priv, { /* Handle continuation of IN/OUT pipes */ - if (priv->in) + if (chan->in) { efm32_in_next(priv, chan); } @@ -1911,7 +1912,7 @@ static void efm32_in_next(FAR struct efm32_usbhost_s *priv, * endpoint type */ - ret = efm32_in_setup(priv, chidx); + ret = efm32_in_setup(priv, chan->chidx); if (ret >= 0) { return; @@ -2182,7 +2183,7 @@ static void efm32_out_next(FAR struct efm32_usbhost_s *priv, * endpoint type */ - ret = efm32_out_setup(priv, chidx); + ret = efm32_out_setup(priv, chan->chidx); if (ret >= 0) { return; @@ -4962,6 +4963,7 @@ static inline void efm32_sw_initialize(FAR struct efm32_usbhost_s *priv) for (i = 0; i < EFM32_MAX_TX_FIFOS; i++) { FAR struct efm32_chan_s *chan = &priv->chan[i]; + chan->chidx = i; sem_init(&chan->waitsem, 0, 0); } } diff --git a/arch/arm/src/stm32/Kconfig b/arch/arm/src/stm32/Kconfig index 9cfb2ab0acf..31927231ce8 100644 --- a/arch/arm/src/stm32/Kconfig +++ b/arch/arm/src/stm32/Kconfig @@ -1393,11 +1393,13 @@ config STM32_OTGFS bool "OTG FS" default n depends on STM32_HAVE_OTGFS + select USBHOST_HAVE_ASYNCH if USBHOST config STM32_OTGHS bool "OTG HS" default n depends on STM32_STM32F207 || STM32_STM32F40XX || STM32_STM32F429 + select USBHOST_HAVE_ASYNCH if USBHOST config STM32_PWR bool "PWR" diff --git a/arch/arm/src/stm32/stm32_otgfshost.c b/arch/arm/src/stm32/stm32_otgfshost.c index c5886c3c087..3b1b6396199 100644 --- a/arch/arm/src/stm32/stm32_otgfshost.c +++ b/arch/arm/src/stm32/stm32_otgfshost.c @@ -206,6 +206,7 @@ struct stm32_chan_s sem_t waitsem; /* Channel wait semaphore */ volatile uint8_t result; /* The result of the transfer */ volatile uint8_t chreason; /* Channel halt reason. See enum stm32_chreason_e */ + uint8_t chidx; /* Channel index */ uint8_t epno; /* Device endpoint number (0-127) */ uint8_t eptype; /* See OTGFS_EPTYPE_* definitions */ uint8_t funcaddr; /* Device function address */ @@ -1036,7 +1037,7 @@ static int stm32_chan_waitsetup(FAR struct stm32_usbhost_s *priv, #ifdef CONFIG_USBHOST_ASYNCH static int stm32_chan_asynchsetup(FAR struct stm32_usbhost_s *priv, - FAR struct stm32_chan_s *chan. + FAR struct stm32_chan_s *chan, usbhost_asynch_t callback, FAR void *arg) { irqstate_t flags = irqsave(); @@ -1164,7 +1165,7 @@ static void stm32_chan_wakeup(FAR struct stm32_usbhost_s *priv, { /* Handle continuation of IN/OUT pipes */ - if (priv->in) + if (chan->in) { stm32_in_next(priv, chan); } @@ -1916,7 +1917,7 @@ static void stm32_in_next(FAR struct stm32_usbhost_s *priv, * endpoint type */ - ret = stm32_in_setup(priv, chidx); + ret = stm32_in_setup(priv, chan->chidx); if (ret >= 0) { return; @@ -2187,7 +2188,7 @@ static void stm32_out_next(FAR struct stm32_usbhost_s *priv, * endpoint type */ - ret = stm32_out_setup(priv, chidx); + ret = stm32_out_setup(priv, chan->chidx); if (ret >= 0) { return; @@ -5007,6 +5008,7 @@ static inline void stm32_sw_initialize(FAR struct stm32_usbhost_s *priv) for (i = 0; i < STM32_MAX_TX_FIFOS; i++) { FAR struct stm32_chan_s *chan = &priv->chan[i]; + chan->chidx = i; sem_init(&chan->waitsem, 0, 0); } } diff --git a/arch/arm/src/stm32/stm32_otghshost.c b/arch/arm/src/stm32/stm32_otghshost.c index 431781cd348..b688e6bf778 100644 --- a/arch/arm/src/stm32/stm32_otghshost.c +++ b/arch/arm/src/stm32/stm32_otghshost.c @@ -206,6 +206,7 @@ struct stm32_chan_s sem_t waitsem; /* Channel wait semaphore */ volatile uint8_t result; /* The result of the transfer */ volatile uint8_t chreason; /* Channel halt reason. See enum stm32_chreason_e */ + uint8_t chidx; /* Channel index */ uint8_t epno; /* Device endpoint number (0-127) */ uint8_t eptype; /* See OTGHS_EPTYPE_* definitions */ uint8_t funcaddr; /* Device function address */ @@ -1036,7 +1037,7 @@ static int stm32_chan_waitsetup(FAR struct stm32_usbhost_s *priv, #ifdef CONFIG_USBHOST_ASYNCH static int stm32_chan_asynchsetup(FAR struct stm32_usbhost_s *priv, - FAR struct stm32_chan_s *chan. + FAR struct stm32_chan_s *chan, usbhost_asynch_t callback, FAR void *arg) { irqstate_t flags = irqsave(); @@ -1164,7 +1165,7 @@ static void stm32_chan_wakeup(FAR struct stm32_usbhost_s *priv, { /* Handle continuation of IN/OUT pipes */ - if (priv->in) + if (chan->in) { stm32_in_next(priv, chan); } @@ -1916,7 +1917,7 @@ static void stm32_in_next(FAR struct stm32_usbhost_s *priv, * endpoint type */ - ret = stm32_in_setup(priv, chidx); + ret = stm32_in_setup(priv, chan->chidx); if (ret >= 0) { return; @@ -2187,7 +2188,7 @@ static void stm32_out_next(FAR struct stm32_usbhost_s *priv, * endpoint type */ - ret = stm32_out_setup(priv, chidx); + ret = stm32_out_setup(priv, chan->chidx); if (ret >= 0) { return; @@ -5007,6 +5008,7 @@ static inline void stm32_sw_initialize(FAR struct stm32_usbhost_s *priv) for (i = 0; i < STM32_MAX_TX_FIFOS; i++) { FAR struct stm32_chan_s *chan = &priv->chan[i]; + chan->chidx = i; sem_init(&chan->waitsem, 0, 0); } } diff --git a/configs/stm32f4discovery/README.txt b/configs/stm32f4discovery/README.txt index 67dce3c7d3d..b3009480365 100644 --- a/configs/stm32f4discovery/README.txt +++ b/configs/stm32f4discovery/README.txt @@ -1490,7 +1490,17 @@ Where is one of the following: CONFIG_WINDOWS_CYGWIN=y : Using Cygwin CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y : CodeSourcery for Windows - 3. This example supports the PWM test (apps/examples/pwm) but this must + 3. To use this configuration with the STM32F4DIS-BB baseboard you + should: + + - Select the STM32F4DIS-BB baseboard in the board configuration + menu + - Disable UART2 and select USART6 in the STM32 peripheral selection + menu + - Select USART6 as the serial console at 115200 8N1 in the + Drivers menus + + 4. This example supports the PWM test (apps/examples/pwm) but this must be manually enabled by selecting: CONFIG_PWM=y : Enable the generic PWM infrastructure @@ -1674,6 +1684,36 @@ Where is one of the following: nsh> umount /mnt/stuff + 11. I used this configuration to test the USB hub class. I did this + testing with the following changes to the configuration (in addition + to those listed above for base USB host/mass storage class support): + + Drivers -> USB Host Driver Support + CONFIG_USBHOST_HUB=y : Enable the hub class + CONFIG_USBHOST_ASYNCH=y : Asynchonous I/O supported needed for hubs + + System Type -> USB host configuration + To be determined + + RTOS Features -> Work Queue Support + CONFIG_SCHED_LPWORK=y : Low priority queue support is needed + CONFIG_SCHED_LPNTHREADS=1 + CONFIG_SCHED_LPWORKSTACKSIZE=1024 + + NOTES: + + 1. It is necessary to perform work on the low-priority work queue + (vs. the high priority work queue) because deferred hub-related + work requires some delays and waiting that is not appropriate on + the high priority work queue. + + 2. Stack usage make increase when USB hub support is enabled because + the nesting depth of certain USB host class logic can increase. + + STATUS: + 2015-04-30 + Just beginning to test. + nxlines: ------ An example using the NuttX graphics system (NX). This example focuses on