diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index e80598b1b..98794f249 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -2880,4 +2880,7 @@ mode 2. * configs/pic32mx7mmb/nsh/defconfig: MMC/SD card support is now enabled by default in the PIC32MX7 MMB board configuration. - + * configs/pic32mx7mmb/nsh/defconfig: Verified the USB Mass Storage + Class (MSC) using MMC/SD card as the logical unit. Updated the default + PIC32MX7 MMB board configuration so that USB and the mass storage class + are enabled by default. diff --git a/nuttx/TODO b/nuttx/TODO index b75691420..5c2be8d81 100644 --- a/nuttx/TODO +++ b/nuttx/TODO @@ -35,7 +35,7 @@ nuttx/ (3) AVR (arch/avr) (0) Intel x86 (arch/x86) (4) 8051 / MCS51 (arch/8051/) - (1) MIPS/PIC32 (arch/mips) + (2) MIPS/PIC32 (arch/mips) (1) Hitachi/Renesas SH-1 (arch/sh/src/sh1) (4) Renesas M16C/26 (arch/sh/src/m16c) (10) z80/z8/ez80 (arch/z80/) @@ -1442,6 +1442,7 @@ o MIPS/PIC32(arch/mips) ^^^^^^^^^^^^^^^^^^^^^ Title: PIC32 USB DRIVER DOES NOT WORK WITH MASS STORAGE CLASS + UPDATE: ** ONLY USING RAM DISK FOR EXPORTED VOLUME *** 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 @@ -1464,8 +1465,27 @@ o MIPS/PIC32(arch/mips) up and crashes with a bad stack. So far, I have no clue why this is failing. + UPDATE: This bug was recorded using the PIC32 Ethernet + Starter kit with a RAM disk (that board has no SD card slot). + Howevever, using the USB mass storage device with the + Mikroelektronika using a real SD card, there is no such + problem -- the mass storage device is quite stable. Status: Open - Priority: High + Priority: Originally, High BUT reduced to very Low based on the + UPDATED comments. + + Title: PIC32 USB MASS STORAGE DEVICE FAILS TO RE-CONNECT + Description: Found using configuration configs/pic32mx7mmb/nsh. + In this configuratin, the NSH 'msconn' command will connect the + mass storage device to the host; the 'msdis' command will + disconnect the device. The first 'msconn' works perfectly. + However, when attempting to re-connect, the second 'msconn' + command does not command properly: Windows reports an + unrecognized device. Apparently, some state is being properly + reset when the mass storage device is disconnected. Shouldn't + be hard to fix. + Status: Open + Priority: Medium o Hitachi/Renesas SH-1 (arch/sh/src/sh1) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/nuttx/configs/pic32-starterkit/README.txt b/nuttx/configs/pic32-starterkit/README.txt index bd04bc37f..4a58862f3 100644 --- a/nuttx/configs/pic32-starterkit/README.txt +++ b/nuttx/configs/pic32-starterkit/README.txt @@ -1171,31 +1171,5 @@ Where is one of the following: NOTE: This modification should be considered experimental. IN 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. - - Update. The following was added to the 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 + (There is a bug associated with this configuration listed in the + top-level TODO list). diff --git a/nuttx/configs/pic32mx7mmb/README.txt b/nuttx/configs/pic32mx7mmb/README.txt index 197602c7a..4d9e42d11 100644 --- a/nuttx/configs/pic32mx7mmb/README.txt +++ b/nuttx/configs/pic32mx7mmb/README.txt @@ -579,22 +579,49 @@ Where is one of the following: CONFIG_PIC32MX_SPI1=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. ------------------ - Several USB device configurations can be enabled and included - as NSH built-in built in functions. USB is *not* enabled by default. - - To use USB device, connect the starter kit to the host using a cable - with a Type-B micro-plug to the starter kit’s 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: + USB device support is enabled by default in this configuration. + The following settings are defined by default (and can be set + to 'n' to disabled USB device support). CONFIG_USBDEV=y : Enable basic 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 the following line in the appconfig file: @@ -603,6 +630,7 @@ Where is one of the following: 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_CDCACM=y : or the CDC/ACM serial driver (not both) @@ -613,12 +641,9 @@ Where is one of the following: and defining the following in your .config file: + CONFIG_USBMSC=n : Disable USB mass storage 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 is enabled by default in this configuration: @@ -714,34 +739,8 @@ Where is one of the following: NOTE: This modification should be considered experimental. IN 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. - - Update. The following was added to the 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 + (There is a bug associated with this configuration listed in the + top-level TODO list). Adding LCD and graphics support to the nsh configuration: -------------------------------------------------------- diff --git a/nuttx/configs/pic32mx7mmb/nsh/appconfig b/nuttx/configs/pic32mx7mmb/nsh/appconfig index ebad7a87f..3479fd504 100644 --- a/nuttx/configs/pic32mx7mmb/nsh/appconfig +++ b/nuttx/configs/pic32mx7mmb/nsh/appconfig @@ -33,15 +33,54 @@ # ############################################################################ +############################################################################ # Path to example in apps/examples containing the user_start entry point +############################################################################ CONFIGURED_APPS += examples/nsh +############################################################################ # The NSH application library +############################################################################ CONFIGURED_APPS += system/readline 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. # Uncomment netutils/ftpc to include an FTP client library # Uncomment netutils/ftpd to include an FTP server library @@ -58,8 +97,7 @@ CONFIGURED_APPS += netutils/telnetd 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/ftpd to include the FTP daemon example @@ -68,6 +106,16 @@ ifeq ($(CONFIG_NET),y) #CONFIGURED_APPS += examples/ftpd 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 ifeq ($(CONFIG_NX),y) diff --git a/nuttx/configs/pic32mx7mmb/nsh/defconfig b/nuttx/configs/pic32mx7mmb/nsh/defconfig index 9105e946e..8138fbd28 100644 --- a/nuttx/configs/pic32mx7mmb/nsh/defconfig +++ b/nuttx/configs/pic32mx7mmb/nsh/defconfig @@ -161,7 +161,7 @@ CONFIG_PIC32MX_FLASH=n CONFIG_PIC32MX_BMX=n CONFIG_PIC32MX_DMA=n CONFIG_PIC32MX_CHE=n -CONFIG_PIC32MX_USBDEV=n +CONFIG_PIC32MX_USBDEV=y CONFIG_PIC32MX_USBHOST=n CONFIG_PIC32MX_CAN1=n CONFIG_PIC32MX_CAN2=n @@ -868,7 +868,7 @@ CONFIG_INPUT_STMPE811=n # 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 @@ -1008,7 +1008,7 @@ CONFIG_CDCACM_CONSOLE=n # CONFIG_USBMSC_REMOVABLE # Select if the media is removable # -CONFIG_USBMSC=n +CONFIG_USBMSC=y CONFIG_USBMSC_EP0MAXPACKET=64 CONFIG_USBMSC_EPBULKOUT=1 CONFIG_USBMSC_EPBULKIN=2 diff --git a/nuttx/configs/pic32mx7mmb/src/pic32mx7mmb_internal.h b/nuttx/configs/pic32mx7mmb/src/pic32mx7mmb_internal.h index f44e04258..6c9987da9 100644 --- a/nuttx/configs/pic32mx7mmb/src/pic32mx7mmb_internal.h +++ b/nuttx/configs/pic32mx7mmb/src/pic32mx7mmb_internal.h @@ -41,6 +41,7 @@ ****************************************************************************/ #include +#include /**************************************************************************** * Pre-Processor Definitions