apps/examples/usbstorage can now be built as NSH built-in commands; configs/stm3210e-eval/nsh2 now uses these usb storage commands

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3812 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2011-07-22 20:12:50 +00:00
parent ac5d088623
commit 56de8b9f01
12 changed files with 202 additions and 69 deletions

View File

@ -1936,4 +1936,7 @@
ID and returns a handle that is now used at all other font interfaces
to specify which of the multiple fonts to use.
* arch/arm/src/lpc17xx/lpc17_syscon.h: Fix typo (reported by Li Zhuoyi).
* configs/stm3210e-eval/nsh2: Extended to support two new commands:
'msconn' will connect the USB mass storage device; 'msdis' will
disconnect the USB storage device.

View File

@ -19,7 +19,7 @@
</tr>
<tr>
<td align="center" valign="top" width="22">
<a href="NuttxDocumentation.html">
<a href="NuttXDocumentation.html">
<img height="20" width="20" src="favicon.ico">
</a>
</td>
@ -52,6 +52,7 @@
<li><a href="http://www.raztek-inc.com" target="main">Raztek Solutions</a></li>
<li><a href="http://www.2g-eng.com" target="top">2G Engineering</a></li>
<li><a href="http://isotel.eu/Home/" target="top">ISOTEL Research</a></li>
<li><a href="http://www.dspworks.in/" target="top">DSPWorks</a></li>
</tr>
<tr>
<td colspan="2" align="center" valign="top">

View File

@ -50,7 +50,7 @@
</tr>
<tr>
<td align="center" valign="top" width="22">
<a href="NuttxCommercial.html">
<a href="NuttXCommercial.html">
<img height="20" width="20" src="favicon.ico">
</a>
</td>

View File

@ -31,7 +31,7 @@
</tr>
<tr>
<td align="center" valign="top" width="22">
<a href="NuttxDocumentation.html">
<a href="NuttXDocumentation.html">
<img height="20" width="20" src="favicon.ico">
</a>
</td>
@ -51,7 +51,7 @@
</tr>
<tr>
<td align="center" valign="top" width="22">
<a href="NuttxCommercial.html">
<a href="NuttXCommercial.html">
<img height="20" width="20" src="favicon.ico">
</a>
</td>

View File

@ -19,7 +19,7 @@
</tr>
<tr>
<td align="center" valign="top" width="22">
<a href="NuttxDocumentation.html">
<a href="NuttXDocumentation.html">
<img height="20" width="20" src="favicon.ico">
</a>
</td>
@ -43,7 +43,7 @@
</tr>
<tr>
<td align="center" valign="top" width="22">
<a href="NuttxCommercial.html">
<a href="NuttXCommercial.html">
<img height="20" width="20" src="favicon.ico">
</a>
</td>

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32/stm32_usbdev.c
*
* Copyright (C) 2009-2010 Gregory Nutt. All rights reserved.
* Copyright (C) 2009-2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* References:
@ -479,6 +479,8 @@ static int stm32_selfpowered(struct usbdev_s *dev, bool selfpowered);
static void stm32_reset(struct stm32_usbdev_s *priv);
static void stm32_hwreset(struct stm32_usbdev_s *priv);
static void stm32_hwsetup(struct stm32_usbdev_s *priv);
static void stm32_hwshutdown(struct stm32_usbdev_s *priv);
/****************************************************************************
* Private Data
@ -3310,33 +3312,13 @@ static void stm32_hwreset(struct stm32_usbdev_s *priv)
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: up_usbinitialize
* Description:
* Initialize the USB driver
* Input Parameters:
* None
*
* Returned Value:
* None
*
* Name: stm32_hwsetup
****************************************************************************/
void up_usbinitialize(void)
static void stm32_hwsetup(struct stm32_usbdev_s *priv)
{
/* For now there is only one USB controller, but we will always refer to
* it using a pointer to make any future ports to multiple USB controllers
* easier.
*/
struct stm32_usbdev_s *priv = &g_usbdev;
int epno;
usbtrace(TRACE_DEVINIT, 0);
stm32_checksetup();
/* Power the USB controller, put the USB controller into reset, disable
* all USB interrupts
*/
@ -3408,6 +3390,63 @@ void up_usbinitialize(void)
stm32_putreg(USB_CNTR_FRES, STM32_USB_CNTR);
up_mdelay(5);
}
/****************************************************************************
* Name: stm32_hwshutdown
****************************************************************************/
static void stm32_hwshutdown(struct stm32_usbdev_s *priv)
{
priv->usbdev.speed = USB_SPEED_UNKNOWN;
/* Disable all interrupts and force the USB controller into reset */
stm32_putreg(USB_CNTR_FRES, STM32_USB_CNTR);
/* Clear any pending interrupts */
stm32_putreg(0, STM32_USB_ISTR);
/* Disconnect the device / disable the pull-up */
stm32_usbpullup(&priv->usbdev, false);
/* Power down the USB controller */
stm32_putreg(USB_CNTR_FRES|USB_CNTR_PDWN, STM32_USB_CNTR);
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: up_usbinitialize
* Description:
* Initialize the USB driver
* Input Parameters:
* None
*
* Returned Value:
* None
*
****************************************************************************/
void up_usbinitialize(void)
{
/* For now there is only one USB controller, but we will always refer to
* it using a pointer to make any future ports to multiple USB controllers
* easier.
*/
struct stm32_usbdev_s *priv = &g_usbdev;
usbtrace(TRACE_DEVINIT, 0);
stm32_checksetup();
/* Power up the USB controller, but leave it in the reset state */
stm32_hwsetup(priv);
/* Attach USB controller interrupt handlers. The hardware will not be
* initialized and interrupts will not be enabled until the class device
@ -3456,39 +3495,25 @@ void up_usbuninitialize(void)
struct stm32_usbdev_s *priv = &g_usbdev;
irqstate_t flags;
flags = irqsave();
usbtrace(TRACE_DEVUNINIT, 0);
/* Disable and detach the USB IRQs */
up_disable_irq(STM32_IRQ_USBHPCANTX);
up_disable_irq(STM32_IRQ_USBLPCANRX0);
irq_detach(STM32_IRQ_USBHPCANTX);
irq_detach(STM32_IRQ_USBLPCANRX0);
if (priv->driver)
{
usbtrace(TRACE_DEVERROR(STM32_TRACEERR_DRIVERREGISTERED), 0);
usbdev_unregister(priv->driver);
}
flags = irqsave();
priv->usbdev.speed = USB_SPEED_UNKNOWN;
/* Put the hardware in an inactive state */
/* Disable and detach IRQs */
up_disable_irq(STM32_IRQ_USBHPCANTX);
up_disable_irq(STM32_IRQ_USBLPCANRX0);
irq_detach(STM32_IRQ_USBHPCANTX);
irq_detach(STM32_IRQ_USBLPCANRX0);
/* Disable all interrupts and force the USB controller into reset */
stm32_putreg(USB_CNTR_FRES, STM32_USB_CNTR);
/* Clear any pending interrupts */
stm32_putreg(0, STM32_USB_ISTR);
/* Disconnect the device / disable the pull-up */
stm32_usbpullup(&priv->usbdev, false);
/* Power down the USB controller */
stm32_putreg(USB_CNTR_FRES|USB_CNTR_PDWN, STM32_USB_CNTR);
stm32_hwshutdown(priv);
irqrestore(flags);
}
@ -3530,7 +3555,7 @@ int usbdev_register(struct usbdevclass_driver_s *driver)
/* First hook up the driver */
priv->driver = driver;
priv->driver = driver;
/* Then bind the class driver */
@ -3570,9 +3595,10 @@ int usbdev_register(struct usbdevclass_driver_s *driver)
* Name: usbdev_unregister
*
* Description:
* Un-register usbdev class driver.If the USB device is connected to a USB host,
* it will first disconnect(). The driver is also requested to unbind() and clean
* up any device state, before this procedure finally returns.
* Un-register usbdev class driver. If the USB device is connected to a
* USB host, it will first disconnect(). The driver is also requested to
* unbind() and clean up any device state, before this procedure finally
* returns.
*
****************************************************************************/
@ -3584,6 +3610,8 @@ int usbdev_unregister(struct usbdevclass_driver_s *driver)
*/
struct stm32_usbdev_s *priv = &g_usbdev;
irqstate_t flags;
usbtrace(TRACE_DEVUNREGISTER, 0);
#ifdef CONFIG_DEBUG
@ -3596,16 +3624,25 @@ int usbdev_unregister(struct usbdevclass_driver_s *driver)
/* Unbind the class driver */
flags = irqsave();
CLASS_UNBIND(driver, &priv->usbdev);
/* Disable USB controller interrupts */
/* Disable USB controller interrupts (but keep them attached) */
up_disable_irq(STM32_IRQ_USBHPCANTX);
up_disable_irq(STM32_IRQ_USBLPCANRX0);
/* Put the hardware in an inactive state. Then bring the hardware back up
* in the reset state.
*/
stm32_hwshutdown(priv);
stm32_hwsetup(priv);
/* Unhook the driver */
priv->driver = NULL;
irqrestore(flags);
return OK;
}

View File

@ -477,6 +477,7 @@ Where <subdir> is one of the following:
----------- ----------------------- --------------------------------
Built-in None apps/examples/nx
Apps apps/examples/nxhello
apps/examples/usbstorage
=========== ======================= ================================
* You will probably need to modify nsh/setenv.sh or nsh2/setenv.sh

View File

@ -45,5 +45,6 @@ CONFIGURED_APPS += nshlib
CONFIGURED_APPS += examples/nx
CONFIGURED_APPS += examples/nxhello
CONFIGURED_APPS += examples/usbstorage

View File

@ -321,12 +321,15 @@ CONFIG_HAVE_LIBM=n
# thread. Default: CONFIG_IDLETHREAD_STACKSIZE.
# CONFIG_SIG_SIGWORK - The signal number that will be used to wake-up
# the worker thread. Default: 4
# CONFIG_SCHED_WAITPID - Enable the waitpid() API
# CONFIG_SCHED_ATEXIT - Enabled the atexit() API
#
#CONFIG_APPS_DIR=
CONFIG_DEBUG=n
CONFIG_DEBUG_VERBOSE=n
CONFIG_DEBUG_GRAPHICS=n
CONFIG_DEBUG_LCD=n
CONFIG_DEBUG_USB=n
CONFIG_DEBUG_SYMBOLS=n
CONFIG_MM_REGIONS=1
CONFIG_ARCH_LOWPUTC=y
@ -352,6 +355,8 @@ CONFIG_SCHED_WORKPRIORITY=50
CONFIG_SCHED_WORKPERIOD=(50*1000)
CONFIG_SCHED_WORKSTACKSIZE=1024
CONFIG_SIG_SIGWORK=4
CONFIG_SCHED_WAITPID=y
CONFIG_SCHED_ATEXIT=n
#
# Settings for NXFLAT
@ -647,7 +652,7 @@ CONFIG_NET_RESOLV_ENTRIES=4
# CONFIG_USBDEV_TRACE_NRECORDS
# Number of trace entries to remember
#
CONFIG_USBDEV=n
CONFIG_USBDEV=y
CONFIG_USBDEV_ISOCHRONOUS=n
CONFIG_USBDEV_DUALSPEED=n
CONFIG_USBDEV_SELFPOWERED=y
@ -715,7 +720,7 @@ CONFIG_USBSER_TXBUFSIZE=512
# CONFIG_USBSTRG_REMOVABLE
# Select if the media is removable
#
CONFIG_USBSTRG=n
CONFIG_USBSTRG=y
CONFIG_USBSTRG_EP0MAXPACKET=64
CONFIG_USBSTRG_EPBULKOUT=2
CONFIG_USBSTRG_EPBULKIN=5
@ -1009,7 +1014,7 @@ CONFIG_EXAMPLES_NX_NOTIFYSIGNO=4
CONFIG_EXAMPLES_NX_EXTERNINIT=n
#
# Settings for examples/nx
# Settings for examples/nxhello
#
# CONFIG_EXAMPLES_NXHELLO_BUILTIN -- Build the NXHELLO example as a "built-in"
# that can be executed from the NSH command line
@ -1074,6 +1079,55 @@ CONFIG_EXAMPLES_NXIMAGE_YSCALE1p5=y
CONFIG_EXAMPLES_NXIMAGE_YSCALE2p0=n
CONFIG_EXAMPLES_NXIMAGE_EXTERNINIT=n
#
# Settings for examples/usbstorage
#
# CONFIG_EXAMPLES_USBSTRG_BUILTIN
# This example can be built as two NSH "built-in" commands if this option
# is selection: 'msconn' will connect the USB mass storage device; 'msdis'
# will disconnect the USB storage device.
# CONFIG_EXAMPLES_USBSTRG_NLUNS
# Defines the number of logical units (LUNs) exported by the USB storage
# driver. Each LUN corresponds to one exported block driver (or partition
# of a block driver). May be 1, 2, or 3. Default is 1.
# CONFIG_EXAMPLES_USBSTRG_DEVMINOR1
# The minor device number of the block driver for the first LUN. For
# example, N in /dev/mmcsdN. Used for registering the block driver. Default
# is zero.
# CONFIG_EXAMPLES_USBSTRG_DEVPATH1
# The full path to the registered block driver. Default is "/dev/mmcsd0"
# CONFIG_EXAMPLES_USBSTRG_DEVMINOR2 and CONFIG_EXAMPLES_USBSTRG_DEVPATH2
# Similar parameters that would have to be provided if CONFIG_EXAMPLES_USBSTRG_NLUNS
# is 2 or 3. No defaults.
# CONFIG_EXAMPLES_USBSTRG_DEVMINOR3 and CONFIG_EXAMPLES_USBSTRG_DEVPATH3
# Similar parameters that would have to be provided if CONFIG_EXAMPLES_USBSTRG_NLUNS
# is 3. No defaults.
#
# If CONFIG_USBDEV_TRACE is enabled (or CONFIG_DEBUG and CONFIG_DEBUG_USB), then
# the example code will also manage the USB trace output. The amount of trace output
# can be controlled using:
#
# CONFIG_EXAMPLES_USBSTRG_TRACEINIT
# Show initialization events
# CONFIG_EXAMPLES_USBSTRG_TRACECLASS
# Show class driver events
# CONFIG_EXAMPLES_USBSTRG_TRACETRANSFERS
# Show data transfer events
# CONFIG_EXAMPLES_USBSTRG_TRACECONTROLLER
# Show controller events
# CONFIG_EXAMPLES_USBSTRG_TRACEINTERRUPTS
# Show interrupt-related events.
#
CONFIG_EXAMPLES_USBSTRG_BUILTIN=y
CONFIG_EXAMPLES_USBSTRG_NLUNS=1
CONFIG_EXAMPLES_USBSTRG_DEVMINOR1=0
CONFIG_EXAMPLES_USBSTRG_DEVPATH1="/dev/mmcsd0"
CONFIG_EXAMPLES_USBSTRG_TRACEINIT=n
CONFIG_EXAMPLES_USBSTRG_TRACECLASS=n
CONFIG_EXAMPLES_USBSTRG_TRACETRANSFERS=n
CONFIG_EXAMPLES_USBSTRG_TRACECONTROLLER=n
CONFIG_EXAMPLES_USBSTRG_TRACEINTERRUPTS=n
#
# Stack and heap information
#

View File

@ -2,7 +2,7 @@
* config/stm3210e_eval/src/up_nsh.c
* arch/arm/src/board/up_nsh.c
*
* Copyright (C) 2009 Gregory Nutt. All rights reserved.
* Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@ -190,7 +190,7 @@ int nsh_archinitialize(void)
return -ENODEV;
}
/* Now bind the SPI interface to the MMC/SD driver */
/* Now bind the SDIO interface to the MMC/SD driver */
message("nsh_archinitialize: Bind SDIO to the MMC/SD driver, minor=%d\n",
CONFIG_NSH_MMCSDMINOR);

View File

@ -1,7 +1,7 @@
/****************************************************************************
* configs/stm3210e-eval/src/up_usbstrg.c
*
* Copyright (C) 2009 Gregory Nutt. All rights reserved.
* Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Configure and register the STM32 MMC/SD SDIO block driver.
@ -50,6 +50,8 @@
#include "stm32_internal.h"
/* There is nothing to do here if SDIO support is not selected. */
#ifdef CONFIG_STM32_SDIO
/****************************************************************************
@ -107,6 +109,12 @@
int usbstrg_archinitialize(void)
{
/* If examples/usbstrg is built as an NSH command, then SD slot should
* already have been initized in nsh_archinitialize() (see up_nsh.c). In
* this case, there is nothing further to be done here.
*/
#ifndef CONFIG_EXAMPLES_USBSTRG_BUILTIN
FAR struct sdio_dev_s *sdio;
int ret;
@ -124,7 +132,7 @@ int usbstrg_archinitialize(void)
return -ENODEV;
}
/* Now bind the SPI interface to the MMC/SD driver */
/* Now bind the SDIO interface to the MMC/SD driver */
message("usbstrg_archinitialize: "
"Bind SDIO to the MMC/SD driver, minor=%d\n",
@ -147,6 +155,9 @@ int usbstrg_archinitialize(void)
*/
sdio_mediachange(sdio, true);
#endif /* CONFIG_EXAMPLES_USBSTRG_BUILTIN */
return OK;
}

View File

@ -303,9 +303,6 @@ CONFIG_HAVE_LIBM=n
# CONFIG_SDCLONE_DISABLE. Disable cloning of all socket
# desciptors by task_create() when a new task is started. If
# set, all sockets will appear to be closed in the new task.
# CONFIG_NXFLAT. Enable support for the NXFLAT binary format.
# This format will support execution of NuttX binaries located
# in a ROMFS filesystem (see examples/nxflat).
# CONFIG_SCHED_WORKQUEUE. Create a dedicated "worker" thread to
# handle delayed processing from interrupt handlers. This feature
# is required for some drivers but, if there are not complaints,
@ -350,13 +347,29 @@ CONFIG_SEM_NNESTPRIO=0
CONFIG_FDCLONE_DISABLE=n
CONFIG_FDCLONE_STDIO=n
CONFIG_SDCLONE_DISABLE=y
CONFIG_NXFLAT=n
CONFIG_SCHED_WORKQUEUE=y
CONFIG_SCHED_WORKPRIORITY=50
CONFIG_SCHED_WORKPERIOD=(50*1000)
CONFIG_SCHED_WORKSTACKSIZE=1024
CONFIG_SIG_SIGWORK=4
#
# Settings for NXFLAT
#
# CONFIG_NXFLAT. Enable support for the NXFLAT binary format.
# This format will support execution of NuttX binaries located
# in a ROMFS filesystem (see examples/nxflat).
# CONFIG_NXFLAT_DUMPBUFFER. Dump a most buffers that NXFFLAT deals
# with. CONFIG_DEBUG, CONFIG_DEBUG_VERBOSE, and
# CONFIG_DEBUG_BINFMT have to be defined or
# CONFIG_NXFLAT_DUMPBUFFER does nothing.
# CONFIG_SYMTAB_ORDEREDBYNAME. Select if the system symbol table
# is ordered by symbol name
#
CONFIG_NXFLAT=n
CONFIG_NXFLAT_DUMPBUFFER=n
CONFIG_SYMTAB_ORDEREDBYNAME=y
#
# The following can be used to disable categories of
# APIs supported by the OS. If the compiler supports
@ -728,6 +741,9 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3
#
# Settings for apps/nshlib
#
# CONFIG_NSH_BUILTIN_APPS - Support external registered,
# "named" applications that can be executed from the NSH
# command line (see apps/README.txt for more information).
# CONFIG_NSH_FILEIOSIZE - Size of a static I/O buffer
# CONFIG_NSH_STRERROR - Use strerror(errno)
# CONFIG_NSH_LINELEN - Maximum length of one command line
@ -737,6 +753,8 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3
# CONFIG_NSH_DISABLEBG - Disable background commands
# CONFIG_NSH_ROMFSETC - Use startup script in /etc
# CONFIG_NSH_CONSOLE - Use serial console front end
# CONFIG_NSH_CONDEV - Select the serial device used to support
# the NSH console. Default: stdin and stdout
# CONFIG_NSH_TELNET - Use telnetd console front end
# CONFIG_NSH_ARCHINIT - Platform provides architecture
# specific initialization (nsh_archinitialize()).
@ -759,6 +777,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3
# CONFIG_NSH_FATNSECTORS - FAT FS number of sectors
# CONFIG_NSH_FATMOUNTPT - FAT FS mountpoint
#
CONFIG_NSH_BUILTIN_APPS=n
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_STRERROR=n
CONFIG_NSH_LINELEN=64
@ -768,6 +787,7 @@ CONFIG_NSH_DISABLESCRIPT=n
CONFIG_NSH_DISABLEBG=n
CONFIG_NSH_ROMFSETC=n
CONFIG_NSH_CONSOLE=y
#CONFIG_NSH_CONDEV="/dev/ttyS1"
CONFIG_NSH_TELNET=n
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_IOBUFFER_SIZE=512
@ -818,6 +838,10 @@ CONFIG_EXAMPLES_USBSERIAL_TRACEINTERRUPTS=n
#
# Settings for examples/usbstorage
#
# CONFIG_EXAMPLES_USBSTRG_BUILTIN
# This example can be built as two NSH "built-in" commands if this option
# is selection: 'msconn' will connect the USB mass storage device; 'msdis'
# will disconnect the USB storage device.
# CONFIG_EXAMPLES_USBSTRG_NLUNS
# Defines the number of logical units (LUNs) exported by the USB storage
# driver. Each LUN corresponds to one exported block driver (or partition
@ -850,6 +874,7 @@ CONFIG_EXAMPLES_USBSERIAL_TRACEINTERRUPTS=n
# CONFIG_EXAMPLES_USBSTRG_TRACEINTERRUPTS
# Show interrupt-related events.
#
CONFIG_EXAMPLES_USBSTRG_BUILTIN=n
CONFIG_EXAMPLES_USBSTRG_NLUNS=1
CONFIG_EXAMPLES_USBSTRG_DEVMINOR1=0
CONFIG_EXAMPLES_USBSTRG_DEVPATH1="/dev/mmcsd0"