PIC32 USB mass storage device works; USB and MSC are now enabled by default in the PIC32MX7 MMB configuration

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4801 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2012-06-03 20:05:44 +00:00
parent 6f976ec46b
commit 6c56cdeca7
5 changed files with 98 additions and 76 deletions

View File

@ -1171,31 +1171,5 @@ Where <subdir> is one of the following:
NOTE: This modification should be considered experimental. IN the NOTE: This modification should be considered experimental. IN the
little testing I have done with it, it appears functional. But the little testing I have done with it, it appears functional. But the
logic has not been stressed and there could still be lurking issues. logic has not been stressed and there could still be lurking issues.
(There is a bug associated with this configuration listed in the
Update. The following was added to the top-level TODO list: top-level TODO list).
Title: PIC32 USB DRIVER DOES NOT WORK WITH MASS STORAGE CLASS
Description: The PIC32 USB driver either crashes or hangs when used with
the mass storage class when trying to write files to the target
storage device. This usually works with debug on, but does not
work with debug OFF (implying some race condition?)
Here are some details of what I see in debugging:
1. The USB MSC device completes processing of a read request
and returns the read request to the driver.
2. Before the MSC device can even begin the wait for the next
driver, many packets come in at interrupt level. The MSC
device goes to sleep (on pthread_cond_wait) with all of the
read buffers ready (16 in my test case).
3. The pthread_cond_wait() does not wake up. This implies
a problem with pthread_con_wait(?). But in other cases,
the MSC device does wake up, but then immediately crashes
because its stack is bad.
4. If I force the pthread_cond_wait to wake up (by using
pthread_cond_timedwait instead), then the thread wakes
up and crashes with a bad stack.
So far, I have no clue why this is failing.
Status: Open
Priority: High

View File

@ -579,22 +579,49 @@ Where <subdir> is one of the following:
CONFIG_PIC32MX_SPI1=y CONFIG_PIC32MX_SPI1=y
CONFIG_NSH_ARCHINIT=y CONFIG_NSH_ARCHINIT=y
The SD card can be mounted from the NSH command line as follows:
nsh> mount -t vfat /dev/mmcsd0 /mnt/sdcard
nsh> ls -l /mnt/sdcard
/mnt/sdcard:
-rw-rw-rw- 16 ATEST.TXT
-rw-rw-rw- 21170 TODO
-rw-rw-rw- 22 ANOTHER.TXT
-rw-rw-rw- 22 HI2148.TXT
-rw-rw-rw- 16 HiFromNotePad.txt
USB Configurations. USB Configurations.
------------------ ------------------
Several USB device configurations can be enabled and included USB device support is enabled by default in this configuration.
as NSH built-in built in functions. USB is *not* enabled by default. The following settings are defined by default (and can be set
to 'n' to disabled USB device support).
To use USB device, connect the starter kit to the host using a cable
with a Type-B micro-plug to the starter kits micro-A/B port J5, located
on the bottom side of the starter kit. The other end of the cable
must have a Type-A plug. Connect it to a USB host. Jumper JP2 should be
removed.
All USB device configurations require the following basic setup in
your NuttX configuration file to enable USB device support:
CONFIG_USBDEV=y : Enable basic USB device support CONFIG_USBDEV=y : Enable basic USB device support
CONFIG_PIC32MX_USBDEV=y : Enable PIC32 USB device support CONFIG_PIC32MX_USBDEV=y : Enable PIC32 USB device support
CONFIG_USBMSC=y : USB supports a mass storage device.
In this configuration, NSH will support the following commands:
msconn : Connect the mass storage device, exportint the SD
card as the USB mass storage logical unit.
msdis : Disconnect the USB mass storage device
NOTE: The SD card should *not* be mounted under NSH *and* exported
by the mass storage device!!! That can result in corruption of the
SD card format. This is the sequence of commands that you should
used to work the the SD card safely:
mount -t vfat /dev/mmcsd0 /mnt/sdcard : Mount the SD card initially
...
umount /mnt/sdcard : Unmount the SD card before connecting
msconn : Connect the USB MSC
...
msdis : Disconnect the USB MSC
mount -t vfat /dev/mmcsd0 /mnt/sdcard : Re-mount the SD card
...
Other USB other device configurations can be enabled and
included as NSH built-in built in functions.
examples/usbterm - This option can be enabled by uncommenting examples/usbterm - This option can be enabled by uncommenting
the following line in the appconfig file: the following line in the appconfig file:
@ -603,6 +630,7 @@ Where <subdir> is one of the following:
And by enabling one of the USB serial devices: And by enabling one of the USB serial devices:
CONFIG_USBMSC=n : Disable USB mass storage device.
CONFIG_PL2303=y : Enable the Prolifics PL2303 emulation CONFIG_PL2303=y : Enable the Prolifics PL2303 emulation
CONFIG_CDCACM=y : or the CDC/ACM serial driver (not both) CONFIG_CDCACM=y : or the CDC/ACM serial driver (not both)
@ -613,12 +641,9 @@ Where <subdir> is one of the following:
and defining the following in your .config file: and defining the following in your .config file:
CONFIG_USBMSC=n : Disable USB mass storage device.
CONFIG_CDCACM=y : Enable the CDCACM device CONFIG_CDCACM=y : Enable the CDCACM device
examples/usbstorage - There are some hooks in the appconfig file
to enable the USB mass storage device. However, this device cannot
work until support for the SD card is also incorporated.
Networking Configurations. Networking Configurations.
-------------------------- --------------------------
Networking is enabled by default in this configuration: Networking is enabled by default in this configuration:
@ -714,34 +739,8 @@ Where <subdir> is one of the following:
NOTE: This modification should be considered experimental. IN the NOTE: This modification should be considered experimental. IN the
little testing I have done with it, it appears functional. But the little testing I have done with it, it appears functional. But the
logic has not been stressed and there could still be lurking issues. logic has not been stressed and there could still be lurking issues.
(There is a bug associated with this configuration listed in the
Update. The following was added to the top-level TODO list: top-level TODO list).
Title: PIC32 USB DRIVER DOES NOT WORK WITH MASS STORAGE CLASS
Description: The PIC32 USB driver either crashes or hangs when used with
the mass storage class when trying to write files to the target
storage device. This usually works with debug on, but does not
work with debug OFF (implying some race condition?)
Here are some details of what I see in debugging:
1. The USB MSC device completes processing of a read request
and returns the read request to the driver.
2. Before the MSC device can even begin the wait for the next
driver, many packets come in at interrupt level. The MSC
device goes to sleep (on pthread_cond_wait) with all of the
read buffers ready (16 in my test case).
3. The pthread_cond_wait() does not wake up. This implies
a problem with pthread_con_wait(?). But in other cases,
the MSC device does wake up, but then immediately crashes
because its stack is bad.
4. If I force the pthread_cond_wait to wake up (by using
pthread_cond_timedwait instead), then the thread wakes
up and crashes with a bad stack.
So far, I have no clue why this is failing.
Status: Open
Priority: High
Adding LCD and graphics support to the nsh configuration: Adding LCD and graphics support to the nsh configuration:
-------------------------------------------------------- --------------------------------------------------------

View File

@ -33,15 +33,54 @@
# #
############################################################################ ############################################################################
############################################################################
# Path to example in apps/examples containing the user_start entry point # Path to example in apps/examples containing the user_start entry point
############################################################################
CONFIGURED_APPS += examples/nsh CONFIGURED_APPS += examples/nsh
############################################################################
# The NSH application library # The NSH application library
############################################################################
CONFIGURED_APPS += system/readline CONFIGURED_APPS += system/readline
CONFIGURED_APPS += nshlib CONFIGURED_APPS += nshlib
############################################################################
# USB device configurations
############################################################################
ifeq ($(CONFIG_PIC32MX_USBDEV),y)
# USB Mass Storage Class device configurations
ifeq ($(CONFIG_USBMSC),y)
CONFIGURED_APPS += examples/usbstorage
else
# USB CDC/ACM serial device configurations
ifeq ($(CONFIG_CDCACM),y)
# Comment out to enable the examples/usbterm built-in
CONFIGURED_APPS += examples/cdcacm
# Uncomment the following to enable the examples/usbterm built-in
# CONFIGURED_APPS += examples/usbterm
#else
# Prolifics PL2303 emulation configurations
ifeq ($(CONFIG_PL2303),y)
# Uncomment the following to enable the examples/usbterm built-in
# CONFIGURED_APPS += examples/usbterm
endif # CONFIG_PL2303
endif # CONFIG_CDCACM
endif # CONFIG_USBMSC
endif # CONFIG_PIC32MX_USBDEV
############################################################################
# Networking configurations
############################################################################
# Networking libraries. # Networking libraries.
# Uncomment netutils/ftpc to include an FTP client library # Uncomment netutils/ftpc to include an FTP client library
# Uncomment netutils/ftpd to include an FTP server library # Uncomment netutils/ftpd to include an FTP server library
@ -58,8 +97,7 @@ CONFIGURED_APPS += netutils/telnetd
endif endif
endif endif
# Applications configured as an NX built-in commands # Networking applications configured as an NX built-in commands
# Uncomment examples/ftpc to include the FTP client example # Uncomment examples/ftpc to include the FTP client example
# Uncomment examples/ftpd to include the FTP daemon example # Uncomment examples/ftpd to include the FTP daemon example
@ -68,6 +106,16 @@ ifeq ($(CONFIG_NET),y)
#CONFIGURED_APPS += examples/ftpd #CONFIGURED_APPS += examples/ftpd
endif endif
############################################################################
# Other Applications that can be configured as an NX built-in commands
############################################################################
# The I2C tool
ifeq ($(CONFIG_I2C),y)
CONFIGURED_APPS += system/i2c
endif
# Uncomment to select a graphics example # Uncomment to select a graphics example
ifeq ($(CONFIG_NX),y) ifeq ($(CONFIG_NX),y)

View File

@ -161,7 +161,7 @@ CONFIG_PIC32MX_FLASH=n
CONFIG_PIC32MX_BMX=n CONFIG_PIC32MX_BMX=n
CONFIG_PIC32MX_DMA=n CONFIG_PIC32MX_DMA=n
CONFIG_PIC32MX_CHE=n CONFIG_PIC32MX_CHE=n
CONFIG_PIC32MX_USBDEV=n CONFIG_PIC32MX_USBDEV=y
CONFIG_PIC32MX_USBHOST=n CONFIG_PIC32MX_USBHOST=n
CONFIG_PIC32MX_CAN1=n CONFIG_PIC32MX_CAN1=n
CONFIG_PIC32MX_CAN2=n CONFIG_PIC32MX_CAN2=n
@ -868,7 +868,7 @@ CONFIG_INPUT_STMPE811=n
# CONFIG_USBDEV_TRACE_NRECORDS # CONFIG_USBDEV_TRACE_NRECORDS
# Number of trace entries to remember # Number of trace entries to remember
# #
CONFIG_USBDEV=n CONFIG_USBDEV=y
CONFIG_USBDEV_ISOCHRONOUS=n CONFIG_USBDEV_ISOCHRONOUS=n
CONFIG_USBDEV_DUALSPEED=n CONFIG_USBDEV_DUALSPEED=n
CONFIG_USBDEV_SELFPOWERED=y CONFIG_USBDEV_SELFPOWERED=y
@ -1008,7 +1008,7 @@ CONFIG_CDCACM_CONSOLE=n
# CONFIG_USBMSC_REMOVABLE # CONFIG_USBMSC_REMOVABLE
# Select if the media is removable # Select if the media is removable
# #
CONFIG_USBMSC=n CONFIG_USBMSC=y
CONFIG_USBMSC_EP0MAXPACKET=64 CONFIG_USBMSC_EP0MAXPACKET=64
CONFIG_USBMSC_EPBULKOUT=1 CONFIG_USBMSC_EPBULKOUT=1
CONFIG_USBMSC_EPBULKIN=2 CONFIG_USBMSC_EPBULKIN=2

View File

@ -41,6 +41,7 @@
****************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <nuttx/compiler.h>
/**************************************************************************** /****************************************************************************
* Pre-Processor Definitions * Pre-Processor Definitions