diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2013-09-06 13:07:29 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2013-09-06 13:07:29 -0600 |
commit | 1f978ce7a5066fbac3ec0f10095fc5946f457ab8 (patch) | |
tree | 4e6b4b7215cd44ecff710b710f9f8b914aba6516 | |
parent | 479fbfb6c4c17ae3520a4403fe68ea5939a74546 (diff) | |
download | nuttx-1f978ce7a5066fbac3ec0f10095fc5946f457ab8.tar.gz nuttx-1f978ce7a5066fbac3ec0f10095fc5946f457ab8.tar.bz2 nuttx-1f978ce7a5066fbac3ec0f10095fc5946f457ab8.zip |
SAMA5D3x-EK: Add support for USB MSC device on AT25 serial flash
-rw-r--r-- | apps/examples/usbmsc/usbmsc.h | 12 | ||||
-rw-r--r-- | apps/examples/usbstorage/Kconfig | 124 | ||||
-rw-r--r-- | nuttx/ChangeLog | 2 | ||||
-rw-r--r-- | nuttx/configs/sam3u-ek/src/up_usbmsc.c | 11 | ||||
-rw-r--r-- | nuttx/configs/sama5d3x-ek/README.txt | 105 | ||||
-rw-r--r-- | nuttx/configs/sama5d3x-ek/demo/defconfig | 53 | ||||
-rw-r--r-- | nuttx/configs/sama5d3x-ek/src/Makefile | 4 | ||||
-rw-r--r-- | nuttx/configs/sama5d3x-ek/src/sam_at25.c | 82 | ||||
-rw-r--r-- | nuttx/configs/sama5d3x-ek/src/sam_nsh.c | 28 | ||||
-rw-r--r-- | nuttx/configs/sama5d3x-ek/src/sam_usbmsc.c | 125 | ||||
-rw-r--r-- | nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h | 26 | ||||
-rw-r--r-- | nuttx/configs/sure-pic32mx/README.txt | 2 | ||||
-rw-r--r-- | nuttx/drivers/usbdev/Kconfig | 12 | ||||
-rw-r--r-- | nuttx/drivers/usbdev/usbmsc.c | 10 | ||||
-rw-r--r-- | nuttx/drivers/usbdev/usbmsc_scsi.c | 4 |
15 files changed, 374 insertions, 226 deletions
diff --git a/apps/examples/usbmsc/usbmsc.h b/apps/examples/usbmsc/usbmsc.h index bd66a2927..2ae796efc 100644 --- a/apps/examples/usbmsc/usbmsc.h +++ b/apps/examples/usbmsc/usbmsc.h @@ -72,13 +72,21 @@ # ifndef CONFIG_EXAMPLES_USBMSC_DEVMINOR3 # error "CONFIG_EXAMPLES_USBMSC_DEVMINOR2 for LUN=3" # endif -# ifndef CONFIG_EXAMPLES_USBMSC_DEVPATH2 -# error "CONFIG_EXAMPLES_USBMSC_DEVPATH2 for LUN=3" +# ifndef CONFIG_EXAMPLES_USBMSC_DEVPATH3 +# error "CONFIG_EXAMPLES_USBMSC_DEVPATH3 for LUN=3" # endif # if CONFIG_EXAMPLES_USBMSC_NLUNS > 3 # error "CONFIG_EXAMPLES_USBMSC_NLUNS must be {1,2,3}" # endif +# else +# undef CONFIG_EXAMPLES_USBMSC_DEVMINOR3 +# undef CONFIG_EXAMPLES_USBMSC_DEVPATH3 # endif +#else +# undef CONFIG_EXAMPLES_USBMSC_DEVMINOR2 +# undef CONFIG_EXAMPLES_USBMSC_DEVPATH2 +# undef CONFIG_EXAMPLES_USBMSC_DEVMINOR3 +# undef CONFIG_EXAMPLES_USBMSC_DEVPATH3 #endif /* Debug ********************************************************************/ diff --git a/apps/examples/usbstorage/Kconfig b/apps/examples/usbstorage/Kconfig deleted file mode 100644 index 1681b181f..000000000 --- a/apps/examples/usbstorage/Kconfig +++ /dev/null @@ -1,124 +0,0 @@ -# -# For a description of the syntax of this configuration file, -# see misc/tools/kconfig-language.txt. -# - -config EXAMPLES_USBMSC - bool "USB mass storage class example" - default n - ---help--- - Enable the USB mass storage class example - -if EXAMPLES_USBMSC - -config EXAMPLES_USBMSC_NLUNS - int "Number of LUNs" - default 1 - ---help--- - 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_USBMSC_DEVMINOR1 - int "LUN1 Minor Device Number" - default 0 - ---help--- - 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_USBMSC_DEVPATH1 - string "LUN1 Device Path" - default "/dev/mmcsd0" - ---help--- - The full path to the registered block driver. Default is - "/dev/mmcsd0" - -config EXAMPLES_USBMSC_DEVMINOR2 - int "LUN2 Minor Device Number" - default 1 - ---help--- - The minor device number of the block driver for the second LUN. For - example, N in /dev/mmcsdN. Used for registering the block driver. - Ignored if EXAMPLES_USBMSC_NLUNS < 2. Default is one. - -config EXAMPLES_USBMSC_DEVPATH2 - string "LUN2 Device Path" - default "/dev/mmcsd1" - ---help--- - The full path to the registered block driver. Ignored if - EXAMPLES_USBMSC_NLUNS < 2. Default is "/dev/mmcsd1" - -config EXAMPLES_USBMSC_DEVMINOR3 - int "LUN3 Minor Device Number" - default 2 - ---help--- - The minor device number of the block driver for the third LUN. For - example, N in /dev/mmcsdN. Used for registering the block driver. - Ignored if EXAMPLES_USBMSC_NLUNS < 2. Default is two. - -config EXAMPLES_USBMSC_DEVPATH3 - string "LUN3 Device Path" - default "/dev/mmcsd2" - ---help--- - The full path to the registered block driver. Ignored if - EXAMPLES_USBMSC_NLUNS < 2. Default is "/dev/mmcsd2" - -config EXAMPLES_USBMSC_DEBUGMM - bool "USB MSC MM Debug" - default n - ---help--- - Enables some debug tests to check for memory usage and memory leaks. - -config EXAMPLES_USBMSC_TRACEINIT - bool "USB Trace Initialization" - default n - depends on USBDEV_TRACE || DEBUG_USB - ---help--- - If USBDEV_TRACE is enabled (or DEBUG and DEBUG_USB), - then the example code will also manage the USB trace output. The - amount of trace output can be controlled this configuration value: - This setting will show USB initialization events - -config EXAMPLES_USBMSC_TRACECLASS - bool "USB Trace Class" - default n - depends on USBDEV_TRACE || DEBUG_USB - ---help--- - If USBDEV_TRACE is enabled (or DEBUG and DEBUG_USB), - then the example code will also manage the USB trace output. The - amount of trace output can be controlled this configuration value: - This setting will show USB class driver events - -config EXAMPLES_USBMSC_TRACETRANSFERS - bool "USB Trace Transfers" - default n - depends on USBDEV_TRACE || DEBUG_USB - ---help--- - If USBDEV_TRACE is enabled (or DEBUG and DEBUG_USB), - then the example code will also manage the USB trace output. The - amount of trace output can be controlled this configuration value: - This setting will show USB data transfer events - -config EXAMPLES_USBMSC_TRACECONTROLLER - bool "USB Trace Device Controller Events" - default n - depends on USBDEV_TRACE || DEBUG_USB - ---help--- - If USBDEV_TRACE is enabled (or DEBUG and DEBUG_USB), - then the example code will also manage the USB trace output. The - amount of trace output can be controlled this configuration value: - This setting will show USB device controller events - -config EXAMPLES_USBMSC_TRACEINTERRUPTS - bool "USB Trace Device Controller Interrupt Events" - default n - depends on USBDEV_TRACE || DEBUG_USB - ---help--- - If USBDEV_TRACE is enabled (or DEBUG and DEBUG_USB), - then the example code will also manage the USB trace output. The - amount of trace output can be controlled this configuration value: - This setting will show USB device controller interrupt-related events. - -endif - diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 0f05087c5..6fcb4f390 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -5512,4 +5512,6 @@ * net/uip/uip_tcpbacklog.c: Fix a major bug in the TCP/IP backlog initialization: Only the first backlog buffer was getting added to the free list. From Max Holtzberg (2013-9-6). + * configs/sama5d3x-ek/demo: Add support for USB MSC device on the + AT25 serial FLASH (untested) (2013-9-6). diff --git a/nuttx/configs/sam3u-ek/src/up_usbmsc.c b/nuttx/configs/sam3u-ek/src/up_usbmsc.c index d14a8f29e..0d58e2f45 100644 --- a/nuttx/configs/sam3u-ek/src/up_usbmsc.c +++ b/nuttx/configs/sam3u-ek/src/up_usbmsc.c @@ -62,15 +62,10 @@ # define CONFIG_EXAMPLES_USBMSC_DEVMINOR1 0 #endif -/* SLOT number(s) could depend on the board configuration */ +/* SLOT number(s) depends on the board configuration */ -#ifdef CONFIG_ARCH_BOARD_SAM3U10E_EVAL -# undef SAM_MMCSDSLOTNO -# define SAM_MMCSDSLOTNO 0 -#else - /* Add configuration for new SAM3U boards here */ -# error "Unrecognized SAM3U board" -#endif +#undef SAM_MMCSDSLOTNO +#define SAM_MMCSDSLOTNO 0 /* Debug ********************************************************************/ diff --git a/nuttx/configs/sama5d3x-ek/README.txt b/nuttx/configs/sama5d3x-ek/README.txt index 3f5a03caa..b2224010f 100644 --- a/nuttx/configs/sama5d3x-ek/README.txt +++ b/nuttx/configs/sama5d3x-ek/README.txt @@ -975,20 +975,105 @@ Configurations order to enable the AT25 FLASH chip select. You can then format the AT25 FLASH for a FAT file system and mount - the file system at /mnt/sdcard using these NSH commands: + the file system at /mnt/at25 using these NSH commands: nsh> mkfatfs /dev/mtdblock0 - nsh> mount -t vfat /dev/mtdblock0 /mnt/sdcard + nsh> mount -t vfat /dev/mtdblock0 /mnt/at25 Then you an use the FLASH as a normal FAT file system: - nsh> echo "This is a test" >/mnt/sdcard/atest.txt - nsh> ls -l /mnt/sdcard - /mnt/sdcard: + nsh> echo "This is a test" >/mnt/at25/atest.txt + nsh> ls -l /mnt/at25 + /mnt/at25: -rw-rw-rw- 16 atest.txt - nsh> cat /mnt/sdcard/atest.txt + nsh> cat /mnt/at25/atest.txt This is a test + 6. Support the USB high-speed EHCI device (UDPHS) driver is enabled. + These are the relevant NuttX configuration settings: + + Device Drivers -> USB Device Driver Support + CONFIG_USBDEV=y : Enable USB device support + CONFIG_USBDEV_DUALSPEED=y : Device support High and Full Speed + CONFIG_USBDEV_DMA=y : Device uses DMA + + System Type -> ATSAMA5 Peripheral Support + CONFIG_SAMA5_UDPHS=y : Enable UDPHS High Speed USB device + + Application Configuration -> NSH Library + CONFIG_NSH_ARCHINIT=y : NSH board-initialization + + The Mass Storage Class (MSC) class driver is seleced for use with + UDPHS: + + Device Drivers -> USB Device Driver Support + CONFIG_USBMSC=y : Enable the USB MSC class driver + CONFIG_USBMSC_EPBULKOUT=1 : Use EP1 for the BULK OUT endpoint + CONFIG_USBMSC_EPBULKIN=2 : Use EP2 for the BULK IN endpoint + + The following setting enables an example that can can be used to + control the CDC/ACM device. It will add two new NSH commands: + + a. msconn will connect the USB serial device and export the AT25 + to the the host, and + b. msdis which will disconnect the USB serial device. + + Application Configuration -> Examples: + CONFIG_EXAMPLES_USBMSC=y : Enable the USBMSC example + CONFIG_EXAMPLES_USBMSC_NLUNS=1 : One LUN + CONFIG_EXAMPLES_USBMSC_DEVMINOR1=0 : Minor device zero + CONFIG_EXAMPLES_USBMSC_DEVPATH1="/dev/mmcsd0" + : Use a single, LUN: The AT25 + : block driver. + + NOTE: To prevent file system corruption, make sure that the AT25 + is un-mounted *before* exporting the mass storage device to the host: + + nsh> umount /mnt + nsh> mscon + + The AT25 can be re-mount after the mass storage class is disconnected: + + nsh> msdis + nsh> mount -t vfat /dev/mtdblock0 /mnt/at25 + + The following features are *not* enabled in the demo configuration but + might be of some use to you: + + 7. Debugging USB Device. There is normal console debug output available + that can be enabled with CONFIG_DEBUG + CONFIG_DEBUG_USB. However, + USB device operation is very time critical and enabling this debug + output WILL interfere with the operation of the UDPHS. USB device + tracing is a less invasive way to get debug information: If tracing + is enabled, the USB device will save encoded trace output in in-memory + buffer; if the USB monitor is also enabled, that trace buffer will be + periodically emptied and dumped to the system logging device (the + serial console in this configuration): + + Device Drivers -> "USB Device Driver Support: + CONFIG_USBDEV_TRACE=y : Enable USB trace feature + CONFIG_USBDEV_TRACE_NRECORDS=256 : Buffer 256 records in memory + + Application Configuration -> NSH LIbrary: + CONFIG_NSH_USBDEV_TRACE=n : No builtin tracing from NSH + CONFIG_NSH_ARCHINIT=y : Automatically start the USB monitor + + Application Configuration -> System NSH Add-Ons: + CONFIG_SYSTEM_USBMONITOR=y : Enable the USB monitor daemon + CONFIG_SYSTEM_USBMONITOR_STACKSIZE=2048 : USB monitor daemon stack size + CONFIG_SYSTEM_USBMONITOR_PRIORITY=50 : USB monitor daemon priority + CONFIG_SYSTEM_USBMONITOR_INTERVAL=1 : Dump trace data every second + CONFIG_SYSTEM_USBMONITOR_TRACEINIT=y : Enable TRACE output + CONFIG_SYSTEM_USBMONITOR_TRACECLASS=y + CONFIG_SYSTEM_USBMONITOR_TRACETRANSFERS=y + CONFIG_SYSTEM_USBMONITOR_TRACECONTROLLER=y + CONFIG_SYSTEM_USBMONITOR_TRACEINTERRUPTS=y + + NOTE: If USB debug output is also enabled, both outpus will appear + on the serial console. However, the debug output will be + asynchronous with the trace output and, hence, difficult to + interpret. + hello: This configuration directory, performs the (almost) simplest of all possible examples: examples/hello. This just comes up, says hello @@ -1287,7 +1372,7 @@ Configurations volume when it is removed. But those callbacks are not used in this configuration. - 10) Support the USB low/full-speed OHCI host driver can be enabled by changing + 10. Support the USB low/full-speed OHCI host driver can be enabled by changing the NuttX configuration file as follows: System Type -> ATSAMA5 Peripheral Support @@ -1314,7 +1399,7 @@ Configurations multiple of the 48MHz needed for OHCI. The delay loop calibration values that are used will be off slightly because of this. - 10) Support the USB high-speed EHCI host driver can be enabled by changing + 11. Support the USB high-speed EHCI host driver can be enabled by changing the NuttX configuration file as follows. If EHCI is enabled by itself, then only high-speed devices can be supported. If OHCI is also enabled, then all low-, full-, and high speed devices should work. @@ -1341,8 +1426,8 @@ Configurations Application Configuration -> NSH Library CONFIG_NSH_ARCHINIT=y : NSH board-initialization - 10) Support the USB high-speed EHCI host driver can be enabled by changing - the NuttX configuration file as follows. If EHCI is enabled by itself, + 12. Support the USB high-speed EHCI device driver (UDPHS) can be enabled + by changing the NuttX configuration file as follows: Device Drivers -> USB Device Driver Support CONFIG_USBDEV=y : Enable USB device support diff --git a/nuttx/configs/sama5d3x-ek/demo/defconfig b/nuttx/configs/sama5d3x-ek/demo/defconfig index fb3b5585a..85eb8da94 100644 --- a/nuttx/configs/sama5d3x-ek/demo/defconfig +++ b/nuttx/configs/sama5d3x-ek/demo/defconfig @@ -147,7 +147,7 @@ CONFIG_SAMA5_SPI0=y CONFIG_SAMA5_DMAC0=y # CONFIG_SAMA5_DMAC1 is not set # CONFIG_SAMA5_UHPHS is not set -# CONFIG_SAMA5_UDPHS is not set +CONFIG_SAMA5_UDPHS=y # CONFIG_SAMA5_GMAC is not set # CONFIG_SAMA5_EMAC is not set # CONFIG_SAMA5_LCDC is not set @@ -172,6 +172,11 @@ CONFIG_SAMA5_SPI_DMA=y CONFIG_SAMA5_SPI_DMATHRESHOLD=4 # +# USB High Speed Device Controller driver (DCD) options +# +# CONFIG_UDPHS_SCATTERGATHER is not set + +# # External Memory Configuration # CONFIG_SAMA5_DDRCS=y @@ -410,7 +415,40 @@ CONFIG_USART1_2STOP=0 # CONFIG_USART1_OFLOWCONTROL is not set # CONFIG_SERIAL_IFLOWCONTROL is not set # CONFIG_SERIAL_OFLOWCONTROL is not set -# CONFIG_USBDEV is not set +CONFIG_USBDEV=y + +# +# USB Device Controller Driver Options +# +# CONFIG_USBDEV_ISOCHRONOUS is not set +CONFIG_USBDEV_DUALSPEED=y +CONFIG_USBDEV_SELFPOWERED=y +# CONFIG_USBDEV_BUSPOWERED is not set +CONFIG_USBDEV_MAXPOWER=100 +CONFIG_USBDEV_DMA=y +# CONFIG_USBDEV_DMAMEMORY is not set +# CONFIG_USBDEV_TRACE is not set + +# +# USB Device Class Driver Options +# +# CONFIG_USBDEV_COMPOSITE is not set +# CONFIG_PL2303 is not set +# CONFIG_CDCACM is not set +CONFIG_USBMSC=y +CONFIG_USBMSC_EP0MAXPACKET=64 +CONFIG_USBMSC_EPBULKOUT=1 +CONFIG_USBMSC_EPBULKIN=2 +CONFIG_USBMSC_NWRREQS=4 +CONFIG_USBMSC_NRDREQS=4 +CONFIG_USBMSC_BULKINREQLEN=512 +CONFIG_USBMSC_BULKOUTREQLEN=512 +CONFIG_USBMSC_VENDORID=0x00 +CONFIG_USBMSC_VENDORSTR="Nuttx" +CONFIG_USBMSC_PRODUCTID=0x00 +CONFIG_USBMSC_PRODUCTSTR="Mass Storage" +CONFIG_USBMSC_VERSIONNO=0x399 +# CONFIG_USBMSC_REMOVABLE is not set # CONFIG_USBHOST is not set # CONFIG_WIRELESS is not set @@ -593,7 +631,15 @@ CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y # CONFIG_EXAMPLES_UDP is not set # CONFIG_EXAMPLES_UIP is not set # CONFIG_EXAMPLES_USBSERIAL is not set -# CONFIG_EXAMPLES_USBMSC is not set +CONFIG_EXAMPLES_USBMSC=y +CONFIG_EXAMPLES_USBMSC_NLUNS=1 +CONFIG_EXAMPLES_USBMSC_DEVMINOR1=0 +CONFIG_EXAMPLES_USBMSC_DEVPATH1="/dev/mtdblock0" +CONFIG_EXAMPLES_USBMSC_DEVMINOR2=1 +CONFIG_EXAMPLES_USBMSC_DEVPATH2="/dev/mmcsd1" +CONFIG_EXAMPLES_USBMSC_DEVMINOR3=2 +CONFIG_EXAMPLES_USBMSC_DEVPATH3="/dev/mmcsd2" +# CONFIG_EXAMPLES_USBMSC_DEBUGMM is not set # CONFIG_EXAMPLES_USBTERM is not set # CONFIG_EXAMPLES_WATCHDOG is not set @@ -696,6 +742,7 @@ CONFIG_NSH_NESTDEPTH=3 # CONFIG_NSH_DISABLESCRIPT is not set # CONFIG_NSH_DISABLEBG is not set CONFIG_NSH_CONSOLE=y +# CONFIG_NSH_USBCONSOLE is not set # # USB Trace Support diff --git a/nuttx/configs/sama5d3x-ek/src/Makefile b/nuttx/configs/sama5d3x-ek/src/Makefile index a673b5a8a..b23b290d1 100644 --- a/nuttx/configs/sama5d3x-ek/src/Makefile +++ b/nuttx/configs/sama5d3x-ek/src/Makefile @@ -90,6 +90,10 @@ ifeq ($(CONFIG_NSH_ARCHINIT),y) CSRCS += sam_nsh.c endif +ifeq ($(CONFIG_USBMSC),y) +CSRCS += sam_usbmsc.c +endif + ifeq ($(CONFIG_ARCH_LEDS),y) CSRCS += sam_autoleds.c else diff --git a/nuttx/configs/sama5d3x-ek/src/sam_at25.c b/nuttx/configs/sama5d3x-ek/src/sam_at25.c index 637603ea2..f701688ae 100644 --- a/nuttx/configs/sama5d3x-ek/src/sam_at25.c +++ b/nuttx/configs/sama5d3x-ek/src/sam_at25.c @@ -78,57 +78,65 @@ int sam_at25_initialize(int minor) { FAR struct spi_dev_s *spi; FAR struct mtd_dev_s *mtd; + static bool initialized = false; int ret; - /* Get the SPI port driver */ + /* Have we already initialized? */ - spi = up_spiinitialize(AT25_PORT); - if (!spi) + if (!initialized) { - fdbg("ERROR: Failed to initialize SPI port %d\n", AT25_PORT); - return -ENODEV; - } + /* No.. Get the SPI port driver */ - /* Now bind the SPI interface to the AT25 SPI FLASH driver */ + spi = up_spiinitialize(AT25_PORT); + if (!spi) + { + fdbg("ERROR: Failed to initialize SPI port %d\n", AT25_PORT); + return -ENODEV; + } - mtd = at25_initialize(spi); - if (!mtd) - { - fdbg("ERROR: Failed to bind SPI port %d to the AT25 FLASH driver\n"); - return -ENODEV; - } + /* Now bind the SPI interface to the AT25 SPI FLASH driver */ + + mtd = at25_initialize(spi); + if (!mtd) + { + fdbg("ERROR: Failed to bind SPI port %d to the AT25 FLASH driver\n"); + return -ENODEV; + } #if defined(CONFIG_SAMA5_AT25_FTL) - /* And finally, use the FTL layer to wrap the MTD driver as a block driver */ + /* And finally, use the FTL layer to wrap the MTD driver as a block driver */ - ret = ftl_initialize(CONFIG_NSH_MMCSDMINOR, mtd); - if (ret < 0) - { - fdbg("ERROR: Initialize the FTL layer\n"); - return ret; - } + ret = ftl_initialize(CONFIG_NSH_MMCSDMINOR, mtd); + if (ret < 0) + { + fdbg("ERROR: Initialize the FTL layer\n"); + return ret; + } #elif defined(CONFIG_SAMA5_AT25_NXFFS) - /* Initialize to provide NXFFS on the MTD interface */ - - ret = nxffs_initialize(mtd); - if (ret < 0) - { - fdbg("ERROR: NXFFS initialization failed: %d\n", -ret); - return ret; - } - - /* Mount the file system at /mnt/at25 */ + /* Initialize to provide NXFFS on the MTD interface */ + + ret = nxffs_initialize(mtd); + if (ret < 0) + { + fdbg("ERROR: NXFFS initialization failed: %d\n", -ret); + return ret; + } + + /* Mount the file system at /mnt/at25 */ + + ret = mount(NULL, "/mnt/at25", "nxffs", 0, NULL); + if (ret < 0) + { + fdbg("ERROR: Failed to mount the NXFFS volume: %d\n", errno); + return ret; + } +#endif + /* Now we are intialized */ - ret = mount(NULL, "/mnt/at25", "nxffs", 0, NULL); - if (ret < 0) - { - fdbg("ERROR: Failed to mount the NXFFS volume: %d\n", errno); - return ret; + initialized = true; } -#endif - return OK; } diff --git a/nuttx/configs/sama5d3x-ek/src/sam_nsh.c b/nuttx/configs/sama5d3x-ek/src/sam_nsh.c index def866297..8594168de 100644 --- a/nuttx/configs/sama5d3x-ek/src/sam_nsh.c +++ b/nuttx/configs/sama5d3x-ek/src/sam_nsh.c @@ -56,34 +56,6 @@ * Pre-Processor Definitions ****************************************************************************/ -/* Configuration ************************************************************/ - -/* Assign minor device numbers. We basically ignore more of the NSH - * configuration here (NSH SLOTNO ignored completely; NSH minor extended - * to handle more devices. - */ - -#ifndef CONFIG_NSH_MMCSDMINOR -# define CONFIG_NSH_MMCSDMINOR 0 -#endif - -#ifdef HAVE_HSMCI_MTD - -# define HSMCI0_SLOTNO 0 -# define HSMCI1_SLOTNO 1 - -# ifdef CONFIG_SAMA5_HSMCI0 -# define HSMCI0_MINOR CONFIG_NSH_MMCSDMINOR -# define HSMCI1_MINOR (CONFIG_NSH_MMCSDMINOR+1) -# define AT25_MINOR (CONFIG_NSH_MMCSDMINOR+2) -# else -# define HSMCI1_MINOR CONFIG_NSH_MMCSDMINOR -# define AT25_MINOR (CONFIG_NSH_MMCSDMINOR+1) -# endif -#else -# define AT25_MINOR CONFIG_NSH_MMCSDMINOR -#endif - /* Debug ********************************************************************/ #ifdef CONFIG_CPP_HAVE_VARARGS diff --git a/nuttx/configs/sama5d3x-ek/src/sam_usbmsc.c b/nuttx/configs/sama5d3x-ek/src/sam_usbmsc.c new file mode 100644 index 000000000..c8abeae02 --- /dev/null +++ b/nuttx/configs/sama5d3x-ek/src/sam_usbmsc.c @@ -0,0 +1,125 @@ +/**************************************************************************** + * configs/sama5d3x-ek/src/up_usbmsc.c + * + * Copyright (C) 2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <gnutt@nuttx.org> + * + * Configure and register the SAM3U MMC/SD SDIO block driver. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <stdio.h> +#include <debug.h> +#include <errno.h> + +#include "sama5d3x-ek.h" + +#ifdef CONFIG_USBMSC + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/* Configuration ************************************************************/ + +#ifndef HAVE_AT25_MTD +# error AT25 Serial FLASH not supported +#endif + +#ifndef CONFIG_SAMA5_AT25_FTL +# error AT25 FTL support required (CONFIG_SAMA5_AT25_FTL) +# undef HAVE_AT25_MTD +#endif + +#ifndef CONFIG_EXAMPLES_USBMSC_DEVMINOR1 +# define CONFIG_EXAMPLES_USBMSC_DEVMINOR1 0 +#endif + +#if CONFIG_EXAMPLES_USBMSC_DEVMINOR1 != AT25_MINOR +# error Confusion in the assignment of minor device numbers +# undef HAVE_AT25_MTD +#endif + +/* Debug ********************************************************************/ + +#ifdef CONFIG_CPP_HAVE_VARARGS +# ifdef CONFIG_DEBUG +# define message(...) lowsyslog(__VA_ARGS__) +# define msgflush() +# else +# define message(...) printf(__VA_ARGS__) +# define msgflush() fflush(stdout) +# endif +#else +# ifdef CONFIG_DEBUG +# define message lowsyslog +# define msgflush() +# else +# define message printf +# define msgflush() fflush(stdout) +# endif +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: usbmsc_archinitialize + * + * Description: + * Perform architecture specific initialization + * + ****************************************************************************/ + +int usbmsc_archinitialize(void) +{ + /* Initialize the AT25 MTD driver */ + +#ifdef HAVE_AT25_MTD + int ret = sam_at25_initialize(AT25_MINOR); + if (ret < 0) + { + message("ERROR: sam_at25_initialize failed: %d\n", ret); + } + + return ret; +#else + return -ENODEV; +#endif +} + +#endif /* CONFIG_USBMSC */ diff --git a/nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h b/nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h index dbbba55fd..bfcb272f2 100644 --- a/nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h +++ b/nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h @@ -111,6 +111,32 @@ # undef CONFIG_SAMA5_AT25_NXFFS #endif +/* Assign minor device numbers. We basically ignore most of the NSH + * configuration here (NSH SLOTNO ignored completely; NSH minor extended + * to handle more devices). + */ + +#ifndef CONFIG_NSH_MMCSDMINOR +# define CONFIG_NSH_MMCSDMINOR 0 +#endif + +#ifdef HAVE_HSMCI_MTD + +# define HSMCI0_SLOTNO 0 +# define HSMCI1_SLOTNO 1 + +# ifdef CONFIG_SAMA5_HSMCI0 +# define HSMCI0_MINOR CONFIG_NSH_MMCSDMINOR +# define HSMCI1_MINOR (CONFIG_NSH_MMCSDMINOR+1) +# define AT25_MINOR (CONFIG_NSH_MMCSDMINOR+2) +# else +# define HSMCI1_MINOR CONFIG_NSH_MMCSDMINOR +# define AT25_MINOR (CONFIG_NSH_MMCSDMINOR+1) +# endif +#else +# define AT25_MINOR CONFIG_NSH_MMCSDMINOR +#endif + /* USB Host / USB Device */ /* Either CONFIG_SAMA5_UHPHS or CONFIG_SAMA5_UDPHS must be defined, or there is * no USB of any kind. diff --git a/nuttx/configs/sure-pic32mx/README.txt b/nuttx/configs/sure-pic32mx/README.txt index c3fbfc2fe..000f13c13 100644 --- a/nuttx/configs/sure-pic32mx/README.txt +++ b/nuttx/configs/sure-pic32mx/README.txt @@ -743,7 +743,7 @@ Where <subdir> is one of the following: CONFIG_USBMSC=y : Enables the USB MSC class Application Configuration->Examples: - CONFIG_EXAMPLES_USBSTORAGE=y : Enhables apps/examples/usbmsc + CONFIG_EXAMPLES_USBMSC=y : Enhables apps/examples/usbmsc 3. SD Card Support. diff --git a/nuttx/drivers/usbdev/Kconfig b/nuttx/drivers/usbdev/Kconfig index 56e45ccf8..f95ca0fa1 100644 --- a/nuttx/drivers/usbdev/Kconfig +++ b/nuttx/drivers/usbdev/Kconfig @@ -486,14 +486,14 @@ config USBMSC_EP0MAXPACKET config USBMSC_EPBULKOUT int "Bulk OUT endpoint number" - default 0 + default 2 ---help--- The logical 7-bit address of a hardware endpoints that support bulk OUT and IN operations config USBMSC_EPBULKIN int "Bulk IN endpoint number" - default 0 + default 3 ---help--- The logical 7-bit address of a hardware endpoints that support bulk OUT and IN operations @@ -522,17 +522,17 @@ config USBMSC_BULKOUTREQLEN maxpacket and ideally as large as a block device sector. config USBMSC_VENDORID - hex "Mass stroage Vendor ID" + hex "Mass storage Vendor ID" default 0x00 config USBMSC_VENDORSTR - string "Mass stroage vendor string" + string "Mass storage vendor string" default "Nuttx" ---help--- The vendor ID code/string config USBMSC_PRODUCTID - hex "Mass stroage Product ID" + hex "Mass storage Product ID" default 0x00 config USBMSC_PRODUCTSTR @@ -544,7 +544,7 @@ config USBMSC_VERSIONNO default "0x399" config USBMSC_REMOVABLE - bool "Mass stroage remove able" + bool "Mass storage remove able" default n ---help--- Select if the media is removable diff --git a/nuttx/drivers/usbdev/usbmsc.c b/nuttx/drivers/usbdev/usbmsc.c index 8dafbae5d..ee4f6da2d 100644 --- a/nuttx/drivers/usbdev/usbmsc.c +++ b/nuttx/drivers/usbdev/usbmsc.c @@ -922,7 +922,6 @@ int usbmsc_setconfig(FAR struct usbmsc_dev_s *priv, uint8_t config) #ifdef CONFIG_USBDEV_DUALSPEED FAR const struct usb_epdesc_s *epdesc; bool hispeed = (priv->usbdev->speed == USB_SPEED_HIGH); - uint16_t bulkmxpacket; #endif int i; int ret = 0; @@ -966,12 +965,11 @@ int usbmsc_setconfig(FAR struct usbmsc_dev_s *priv, uint8_t config) /* Configure the IN bulk endpoint */ #ifdef CONFIG_USBDEV_DUALSPEED - bulkmxpacket = USBMSC_BULKMAXPACKET(hispeed); - epdesc = USBMSC_EPBULKINDESC(hispeed); - ret = EP_CONFIGURE(priv->epbulkin, epdesc, false); + epdesc = USBMSC_EPBULKINDESC(hispeed); + ret = EP_CONFIGURE(priv->epbulkin, epdesc, false); #else - ret = EP_CONFIGURE(priv->epbulkin, - usbmsc_getepdesc(USBMSC_EPFSBULKIN), false); + ret = EP_CONFIGURE(priv->epbulkin, + usbmsc_getepdesc(USBMSC_EPFSBULKIN), false); #endif if (ret < 0) { diff --git a/nuttx/drivers/usbdev/usbmsc_scsi.c b/nuttx/drivers/usbdev/usbmsc_scsi.c index ff551871c..fbeb0f192 100644 --- a/nuttx/drivers/usbdev/usbmsc_scsi.c +++ b/nuttx/drivers/usbdev/usbmsc_scsi.c @@ -784,6 +784,8 @@ static inline int usbmsc_cmdstartstopunit(FAR struct usbmsc_dev_s *priv) if (ret == OK) { #ifndef CONFIG_USBMSC_REMOVABLE + FAR struct usbmsc_lun_s *lun = priv->lun; + /* This command is not valid if the media is not removable */ usbtrace(TRACE_CLSERROR(USBMSC_TRACEERR_NOTREMOVABLE), 0); @@ -806,8 +808,8 @@ static inline int usbmsc_cmdpreventmediumremoval(FAR struct usbmsc_dev_s *priv) { #ifdef CONFIG_USBMSC_REMOVABLE FAR struct scsicmd_preventmediumremoval_s *pmr = (FAR struct scsicmd_preventmediumremoval_s *)priv->cdb; - FAR struct usbmsc_lun_s *lun = priv->lun; #endif + FAR struct usbmsc_lun_s *lun = priv->lun; int ret; priv->u.alloclen = 0; |