summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-08-21 20:14:42 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-08-21 20:14:42 +0000
commit58a7ace0aba39add28e5b565657b1f4788ccbd57 (patch)
treeb6c6f09bb241692d6e373d294a77490f72f7fa6c
parent9cfd924bbadfbf8501fde3a08545526d5d19a0b3 (diff)
downloadnuttx-58a7ace0aba39add28e5b565657b1f4788ccbd57.tar.gz
nuttx-58a7ace0aba39add28e5b565657b1f4788ccbd57.tar.bz2
nuttx-58a7ace0aba39add28e5b565657b1f4788ccbd57.zip
Several more bug fixes for STM32 OTG FS host driver
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5044 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--nuttx/arch/arm/src/lpc17xx/lpc17_usbhost.c12
-rw-r--r--nuttx/arch/arm/src/stm32/stm32_otgfshost.c38
-rw-r--r--nuttx/configs/stm3220g-eval/README.txt4
-rw-r--r--nuttx/configs/stm3220g-eval/nsh/defconfig3
-rwxr-xr-xnuttx/configs/stm3240g-eval/README.txt4
-rwxr-xr-xnuttx/configs/stm32f4discovery/README.txt4
-rw-r--r--nuttx/drivers/usbhost/usbhost_enumerate.c4
-rw-r--r--nuttx/include/nuttx/usb/usbhost.h14
8 files changed, 56 insertions, 27 deletions
diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_usbhost.c b/nuttx/arch/arm/src/lpc17xx/lpc17_usbhost.c
index 17a14fea8..154b953b7 100644
--- a/nuttx/arch/arm/src/lpc17xx/lpc17_usbhost.c
+++ b/nuttx/arch/arm/src/lpc17xx/lpc17_usbhost.c
@@ -1,9 +1,9 @@
/*******************************************************************************
* arch/arm/src/lpc17xx/lpc17_usbhost.c
*
- * Copyright (C) 2010-2011 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2010-2012 Gregory Nutt. All rights reserved.
* Authors: Rafael Noronha <rafael@pdsolucoes.com.br>
- * Gregory Nutt <spudmonkey@racsa.co.cr>
+ * Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -1898,7 +1898,7 @@ static int lpc17_epfree(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep)
* Some hardware supports special memory in which request and descriptor data can
* be accessed more efficiently. This method provides a mechanism to allocate
* the request/descriptor memory. If the underlying hardware does not support
- * such "special" memory, this functions may simply map to malloc.
+ * such "special" memory, this functions may simply map to kmalloc.
*
* This interface was optimized under a particular assumption. It was assumed
* that the driver maintains a pool of small, pre-allocated buffers for descriptor
@@ -1952,7 +1952,7 @@ static int lpc17_alloc(FAR struct usbhost_driver_s *drvr,
* Some hardware supports special memory in which request and descriptor data can
* be accessed more efficiently. This method provides a mechanism to free that
* request/descriptor memory. If the underlying hardware does not support
- * such "special" memory, this functions may simply map to free().
+ * such "special" memory, this functions may simply map to kfree().
*
* Input Parameters:
* drvr - The USB host driver instance obtained as a parameter from the call to
@@ -1988,7 +1988,7 @@ static int lpc17_free(FAR struct usbhost_driver_s *drvr, FAR uint8_t *buffer)
* Some hardware supports special memory in which larger IO buffers can
* be accessed more efficiently. This method provides a mechanism to allocate
* the request/descriptor memory. If the underlying hardware does not support
- * such "special" memory, this functions may simply map to malloc.
+ * such "special" memory, this functions may simply map to kmalloc.
*
* This interface differs from DRVR_ALLOC in that the buffers are variable-sized.
*
@@ -2036,7 +2036,7 @@ static int lpc17_ioalloc(FAR struct usbhost_driver_s *drvr,
* Some hardware supports special memory in which IO data can be accessed more
* efficiently. This method provides a mechanism to free that IO buffer
* memory. If the underlying hardware does not support such "special" memory,
- * this functions may simply map to free().
+ * this functions may simply map to kfree().
*
* Input Parameters:
* drvr - The USB host driver instance obtained as a parameter from the call to
diff --git a/nuttx/arch/arm/src/stm32/stm32_otgfshost.c b/nuttx/arch/arm/src/stm32/stm32_otgfshost.c
index e6ea2de06..7eb2313a4 100644
--- a/nuttx/arch/arm/src/stm32/stm32_otgfshost.c
+++ b/nuttx/arch/arm/src/stm32/stm32_otgfshost.c
@@ -49,6 +49,7 @@
#include <debug.h>
#include <nuttx/arch.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/usb/usb.h>
#include <nuttx/usb/usbhost.h>
@@ -89,6 +90,8 @@
* want to do that?
* CONFIG_STM32_USBHOST_REGDEBUG - Enable very low-level register access
* debug. Depends on CONFIG_DEBUG.
+ * CONFIG_STM32_USBHOST_PKTDUMP - Dump all incoming and outgoing USB
+ * packets. Depends on CONFIG_DEBUG.
*/
/* Pre-requistites (partial) */
@@ -119,6 +122,7 @@
#ifndef CONFIG_DEBUG
# undef CONFIG_STM32_USBHOST_REGDEBUG
+# undef CONFIG_STM32_USBHOST_PKTDUMP
#endif
/* HCD Setup *******************************************************************/
@@ -253,6 +257,12 @@ static void stm32_putreg(uint32_t addr, uint32_t value);
static inline void stm32_modifyreg(uint32_t addr, uint32_t clrbits,
uint32_t setbits);
+#ifdef CONFIG_STM32_USBHOST_PKTDUMP
+# define stm32_pktdump(m,b,n) lib_dumpbuffer(m,b,n)
+#else
+# define stm32_pktdump(m,b,n)
+#endif
+
/* Semaphores ******************************************************************/
static void stm32_takesem(sem_t *sem);
@@ -1298,6 +1308,8 @@ static void stm32_gint_wrpacket(FAR struct stm32_usbhost_s *priv,
uint32_t fifo;
int buflen32;
+ stm32_pktdump("Sending", buffer, buflen);
+
/* Get the number of 32-byte words associated with this byte size */
buflen32 = (buflen + 3) >> 2;
@@ -1958,6 +1970,8 @@ static inline void stm32_gint_rxflvlisr(FAR struct stm32_usbhost_s *priv)
*dest++ = stm32_getreg(fifo);
}
+ stm32_pktdump("Received", priv->chan[chidx].buffer, bcnt);
+
/* Manage multiple packet transfers */
priv->chan[chidx].buffer += bcnt;
@@ -2924,7 +2938,7 @@ static int stm32_epfree(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep)
* Some hardware supports special memory in which request and descriptor data can
* be accessed more efficiently. This method provides a mechanism to allocate
* the request/descriptor memory. If the underlying hardware does not support
- * such "special" memory, this functions may simply map to malloc.
+ * such "special" memory, this functions may simply map to kmalloc.
*
* This interface was optimized under a particular assumption. It was assumed
* that the driver maintains a pool of small, pre-allocated buffers for descriptor
@@ -2958,12 +2972,15 @@ static int stm32_alloc(FAR struct usbhost_driver_s *drvr,
/* There is no special memory requirement */
- alloc = (FAR uint8_t *)malloc(*maxlen);
+ alloc = (FAR uint8_t *)kmalloc(*maxlen);
if (!alloc)
{
return -ENOMEM;
}
+ /* Return the allocated buffer */
+
+ *buffer = alloc;
return OK;
}
@@ -2974,7 +2991,7 @@ static int stm32_alloc(FAR struct usbhost_driver_s *drvr,
* Some hardware supports special memory in which request and descriptor data can
* be accessed more efficiently. This method provides a mechanism to free that
* request/descriptor memory. If the underlying hardware does not support
- * such "special" memory, this functions may simply map to free().
+ * such "special" memory, this functions may simply map to kfree().
*
* Input Parameters:
* drvr - The USB host driver instance obtained as a parameter from the call to
@@ -2995,7 +3012,7 @@ static int stm32_free(FAR struct usbhost_driver_s *drvr, FAR uint8_t *buffer)
/* There is no special memory requirement */
DEBUGASSERT(drvr && buffer);
- free(buffer);
+ kfree(buffer);
return OK;
}
@@ -3006,7 +3023,7 @@ static int stm32_free(FAR struct usbhost_driver_s *drvr, FAR uint8_t *buffer)
* Some hardware supports special memory in which larger IO buffers can
* be accessed more efficiently. This method provides a mechanism to allocate
* the request/descriptor memory. If the underlying hardware does not support
- * such "special" memory, this functions may simply map to malloc.
+ * such "special" memory, this functions may simply map to kmalloc.
*
* This interface differs from DRVR_ALLOC in that the buffers are variable-sized.
*
@@ -3035,12 +3052,15 @@ static int stm32_ioalloc(FAR struct usbhost_driver_s *drvr,
/* There is no special memory requirement */
- alloc = (FAR uint8_t *)malloc(buflen);
+ alloc = (FAR uint8_t *)kmalloc(buflen);
if (!alloc)
{
return -ENOMEM;
}
+ /* Return the allocated buffer */
+
+ *buffer = alloc;
return OK;
}
@@ -3051,7 +3071,7 @@ static int stm32_ioalloc(FAR struct usbhost_driver_s *drvr,
* Some hardware supports special memory in which IO data can be accessed more
* efficiently. This method provides a mechanism to free that IO buffer
* memory. If the underlying hardware does not support such "special" memory,
- * this functions may simply map to free().
+ * this functions may simply map to kfree().
*
* Input Parameters:
* drvr - The USB host driver instance obtained as a parameter from the call to
@@ -3072,7 +3092,7 @@ static int stm32_iofree(FAR struct usbhost_driver_s *drvr, FAR uint8_t *buffer)
/* There is no special memory requirement */
DEBUGASSERT(drvr && buffer);
- free(buffer);
+ kfree(buffer);
return OK;
}
@@ -3161,7 +3181,7 @@ static int stm32_ctrlin(FAR struct usbhost_driver_s *drvr,
/* Handle the status OUT phase */
priv->chan[priv->ep0out].outdata1 ^= true;
- ret = stm32_ctrl_senddata(priv, buffer, buflen);
+ ret = stm32_ctrl_senddata(priv, NULL, 0);
if (ret == OK)
{
break;
diff --git a/nuttx/configs/stm3220g-eval/README.txt b/nuttx/configs/stm3220g-eval/README.txt
index ad049ea4c..a25db07a5 100644
--- a/nuttx/configs/stm3220g-eval/README.txt
+++ b/nuttx/configs/stm3220g-eval/README.txt
@@ -689,7 +689,9 @@ STM3220G-EVAL-specific Configuration Options
want to do that?
CONFIG_STM32_USBHOST_REGDEBUG - Enable very low-level register access
debug. Depends on CONFIG_DEBUG.
-
+ CONFIG_STM32_USBHOST_PKTDUMP - Dump all incoming and outgoing USB
+ packets. Depends on CONFIG_DEBUG.
+
Configurations
==============
diff --git a/nuttx/configs/stm3220g-eval/nsh/defconfig b/nuttx/configs/stm3220g-eval/nsh/defconfig
index a6c4db254..5a3dd6643 100644
--- a/nuttx/configs/stm3220g-eval/nsh/defconfig
+++ b/nuttx/configs/stm3220g-eval/nsh/defconfig
@@ -1047,6 +1047,8 @@ CONFIG_USBDEV_TRACE_NRECORDS=128
# want to do that?
# CONFIG_STM32_USBHOST_REGDEBUG - Enable very low-level register access
# debug. Depends on CONFIG_DEBUG.
+# CONFIG_STM32_USBHOST_PKTDUMP - Dump all incoming and outgoing USB
+# packets. Depends on CONFIG_DEBUG.
#
CONFIG_USBHOST=n
# ONFIG_STM32_OTGFS_RXFIFO_SIZE
@@ -1054,6 +1056,7 @@ CONFIG_USBHOST=n
#CONFIG_STM32_OTGFS_PTXFIFO_SIZE
CONFIG_STM32_OTGFS_SOFINTR=n
CONFIG_STM32_USBHOST_REGDEBUG=n
+CONFIG_STM32_USBHOST_PKTDUMP=n
#
# USB Serial Device Configuration
diff --git a/nuttx/configs/stm3240g-eval/README.txt b/nuttx/configs/stm3240g-eval/README.txt
index c8c1fdfa7..5f942819c 100755
--- a/nuttx/configs/stm3240g-eval/README.txt
+++ b/nuttx/configs/stm3240g-eval/README.txt
@@ -852,7 +852,9 @@ STM3240G-EVAL-specific Configuration Options
want to do that?
CONFIG_STM32_USBHOST_REGDEBUG - Enable very low-level register access
debug. Depends on CONFIG_DEBUG.
-
+ CONFIG_STM32_USBHOST_PKTDUMP - Dump all incoming and outgoing USB
+ packets. Depends on CONFIG_DEBUG.
+
Configurations
==============
diff --git a/nuttx/configs/stm32f4discovery/README.txt b/nuttx/configs/stm32f4discovery/README.txt
index a1fe2c356..e7dc57353 100755
--- a/nuttx/configs/stm32f4discovery/README.txt
+++ b/nuttx/configs/stm32f4discovery/README.txt
@@ -905,7 +905,9 @@ STM32F4Discovery-specific Configuration Options
want to do that?
CONFIG_STM32_USBHOST_REGDEBUG - Enable very low-level register access
debug. Depends on CONFIG_DEBUG.
-
+ CONFIG_STM32_USBHOST_PKTDUMP - Dump all incoming and outgoing USB
+ packets. Depends on CONFIG_DEBUG.
+
Configurations
==============
diff --git a/nuttx/drivers/usbhost/usbhost_enumerate.c b/nuttx/drivers/usbhost/usbhost_enumerate.c
index 7ab055b57..36bfa20d1 100644
--- a/nuttx/drivers/usbhost/usbhost_enumerate.c
+++ b/nuttx/drivers/usbhost/usbhost_enumerate.c
@@ -1,8 +1,8 @@
/*******************************************************************************
* drivers/usbhost/usbhost_enumerate.c
*
- * Copyright (C) 2011 Gregory Nutt. All rights reserved.
- * Authors: Gregory Nutt <spudmonkey@racsa.co.cr>
+ * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
+ * Authors: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/nuttx/include/nuttx/usb/usbhost.h b/nuttx/include/nuttx/usb/usbhost.h
index c68cb4712..b28db9551 100644
--- a/nuttx/include/nuttx/usb/usbhost.h
+++ b/nuttx/include/nuttx/usb/usbhost.h
@@ -1,7 +1,7 @@
/************************************************************************************
* include/nuttx/usb/usbhost.h
*
- * Copyright (C) 2010-2011 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2010-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* References:
@@ -284,7 +284,7 @@
* Some hardware supports special memory in which request and descriptor data can
* be accessed more efficiently. This method provides a mechanism to allocate
* the request/descriptor memory. If the underlying hardware does not support
- * such "special" memory, this functions may simply map to malloc.
+ * such "special" memory, this functions may simply map to kmalloc.
*
* This interface was optimized under a particular assumption. It was assumed
* that the driver maintains a pool of small, pre-allocated buffers for descriptor
@@ -317,7 +317,7 @@
* Some hardware supports special memory in which request and descriptor data can
* be accessed more efficiently. This method provides a mechanism to free that
* request/descriptor memory. If the underlying hardware does not support
- * such "special" memory, this functions may simply map to free().
+ * such "special" memory, this functions may simply map to kfree().
*
* Input Parameters:
* drvr - The USB host driver instance obtained as a parameter from the call to
@@ -342,7 +342,7 @@
* Some hardware supports special memory in which larger IO buffers can
* be accessed more efficiently. This method provides a mechanism to allocate
* the request/descriptor memory. If the underlying hardware does not support
- * such "special" memory, this functions may simply map to malloc.
+ * such "special" memory, this functions may simply map to kmalloc.
*
* This interface differs from DRVR_ALLOC in that the buffers are variable-sized.
*
@@ -371,7 +371,7 @@
* Some hardware supports special memory in which IO data can be accessed more
* efficiently. This method provides a mechanism to free that IO buffer
* memory. If the underlying hardware does not support such "special" memory,
- * this functions may simply map to free().
+ * this functions may simply map to kfree().
*
* Input Parameters:
* drvr - The USB host driver instance obtained as a parameter from the call to
@@ -615,7 +615,7 @@ struct usbhost_driver_s
* be accessed more efficiently. The following methods provide a mechanism
* to allocate and free the transfer descriptor memory. If the underlying
* hardware does not support such "special" memory, these functions may
- * simply map to malloc and free.
+ * simply map to kmalloc and kfree.
*
* This interface was optimized under a particular assumption. It was assumed
* that the driver maintains a pool of small, pre-allocated buffers for descriptor
@@ -630,7 +630,7 @@ struct usbhost_driver_s
/* Some hardware supports special memory in which larger IO buffers can
* be accessed more efficiently. This method provides a mechanism to allocate
* the request/descriptor memory. If the underlying hardware does not support
- * such "special" memory, this functions may simply map to malloc.
+ * such "special" memory, this functions may simply map to kmalloc.
*
* This interface differs from DRVR_ALLOC in that the buffers are variable-sized.
*/