diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index f700fda1b..99554146d 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -2540,4 +2540,6 @@ Starter Kit port. Added and verified the NuttShell (NSH) on the PIC32 Ethernet Starter Kit. I can now (finally) claim to have complete the basic port to this board. + * configs/pic32-startkit/nsh/up_usbdev, up_nsh.c, and up_usbterm.c: Verified + the USB (device) driver on the PIC32 Ethernet Starter Kit. diff --git a/nuttx/arch/mips/src/pic32mx/pic32mx-usbdev.c b/nuttx/arch/mips/src/pic32mx/pic32mx-usbdev.c index 57c386d80..a4261a6a2 100644 --- a/nuttx/arch/mips/src/pic32mx/pic32mx-usbdev.c +++ b/nuttx/arch/mips/src/pic32mx/pic32mx-usbdev.c @@ -3945,6 +3945,7 @@ static void pic32mx_hwreset(struct pic32mx_usbdev_s *priv) regval = pic32mx_getreg(PIC32MX_USB_PWRC); regval &= ~USB_PWRC_USBPWR; + pic32mx_putreg(regval, PIC32MX_USB_PWRC); /* Clear all of the buffer descriptor table (BDT) entries */ diff --git a/nuttx/configs/pic32-starterkit/README.txt b/nuttx/configs/pic32-starterkit/README.txt index 4ff113d7b..a27deecce 100644 --- a/nuttx/configs/pic32-starterkit/README.txt +++ b/nuttx/configs/pic32-starterkit/README.txt @@ -6,7 +6,7 @@ This README file discusses the port of NuttX to the Microchip PIC32 Ethernet Starter Kit (DM320004) with either 1) The Multimedia Expansion Board (MEB, DM320005), or - 2) The Starter Kit I/O Exansion Board + 2) The Starter Kit I/O Expansion Board See www.microchip.com for further information. @@ -48,7 +48,7 @@ The MEB adds: - CPLD for SPI and Chip Select configuration - Integrated 802.11 wireless connectivity -The Starter Kit I/O Exansion Board: +The Starter Kit I/O Expansion Board: Mostly just brings out all of the pins from the tiny Starter Kit connector. @@ -62,7 +62,7 @@ Contents Toolchains Creating Compatible NuttX HEX files Serial Console: MEB - Serial Console: Starter Kit I/O Exansion Board + Serial Console: Starter Kit I/O Expansion Board LEDs PIC32MX Configuration Options Configurations @@ -605,11 +605,11 @@ Serial Console: MEB 26 3.3V 28 GND -Serial Console: Starter Kit I/O Exansion Board -============================================== +Serial Console: Starter Kit I/O Expansion Board +=============================================== U1: - Ethernet Starter Kit Exansion I/O board + Ethernet Starter Kit Expansion I/O board --------------------------------------------- ------------------------- PIN Description J2 J1 J10/J11 --- ---------------------------------- ------------- ------------------ @@ -619,7 +619,7 @@ Serial Console: Starter Kit I/O Exansion Board 53 RF8/SCL3/SDO3/U1TX J2 pin 90 J11 pin 43 U2: - Ethernet Starter Kit Exansion I/O board + Ethernet Starter Kit Expansion I/O board --------------------------------------------- ------------------------- PIN Description J2 J1 J10/J11 --- ---------------------------------- ------------- ------------------ @@ -631,7 +631,7 @@ Serial Console: Starter Kit I/O Exansion Board J2 pin 110 J11 pin 46 U3: - Ethernet Starter Kit Exansion I/O board + Ethernet Starter Kit Expansion I/O board --------------------------------------------- ------------------------- PIN Description J2 J1 J10/J11 --- ---------------------------------- ------------- ------------------ @@ -646,7 +646,7 @@ Serial Console: Starter Kit I/O Exansion Board U6RX U4: - Ethernet Starter Kit Exansion I/O board + Ethernet Starter Kit Expansion I/O board --------------------------------------------- ------------------------- PIN Description J2 J1 J10/J11 --- ---------------------------------- ------------- ------------------ @@ -654,7 +654,7 @@ Serial Console: Starter Kit I/O Exansion Board 48 AETXD1/CN21/RD15/SCK3/U1RTS/U4TX Not available N/A U5: - Ethernet Starter Kit Exansion I/O board + Ethernet Starter Kit Expansion I/O board --------------------------------------------- ------------------------- PIN Description J2 J1 J10/J11 --- ---------------------------------- ------------- ------------------ @@ -986,6 +986,8 @@ Where is one of the following: nsh: ==== + Description. + ------------ This is the NuttShell (NSH) using the NSH startup logic at apps/examples/nsh. diff --git a/nuttx/configs/pic32-starterkit/nsh/defconfig b/nuttx/configs/pic32-starterkit/nsh/defconfig index 36a956edd..4f751a7cd 100644 --- a/nuttx/configs/pic32-starterkit/nsh/defconfig +++ b/nuttx/configs/pic32-starterkit/nsh/defconfig @@ -140,7 +140,10 @@ CONFIG_PIC32MX_OC4=n CONFIG_PIC32MX_OC5=n CONFIG_PIC32MX_I2C1=n CONFIG_PIC32MX_I2C2=n +CONFIG_PIC32MX_SPI1=n CONFIG_PIC32MX_SPI2=n +CONFIG_PIC32MX_SPI3=n +CONFIG_PIC32MX_SPI4=n CONFIG_PIC32MX_UART1=y CONFIG_PIC32MX_UART2=n CONFIG_PIC32MX_UART3=n @@ -993,7 +996,7 @@ CONFIG_NSH_DISABLEBG=n CONFIG_NSH_ROMFSETC=n CONFIG_NSH_CONSOLE=y CONFIG_NSH_TELNET=n -CONFIG_NSH_ARCHINIT=n +CONFIG_NSH_ARCHINIT=y CONFIG_NSH_IOBUFFER_SIZE=512 CONFIG_NSH_DHCPC=n CONFIG_NSH_NOMAC=n diff --git a/nuttx/configs/pic32-starterkit/ostest/defconfig b/nuttx/configs/pic32-starterkit/ostest/defconfig index ca70ab86e..b48bf042a 100644 --- a/nuttx/configs/pic32-starterkit/ostest/defconfig +++ b/nuttx/configs/pic32-starterkit/ostest/defconfig @@ -140,7 +140,10 @@ CONFIG_PIC32MX_OC4=n CONFIG_PIC32MX_OC5=n CONFIG_PIC32MX_I2C1=n CONFIG_PIC32MX_I2C2=n +CONFIG_PIC32MX_SPI1=n CONFIG_PIC32MX_SPI2=n +CONFIG_PIC32MX_SPI3=n +CONFIG_PIC32MX_SPI4=n CONFIG_PIC32MX_UART1=y CONFIG_PIC32MX_UART2=n CONFIG_PIC32MX_UART3=n diff --git a/nuttx/configs/pic32-starterkit/src/up_nsh.c b/nuttx/configs/pic32-starterkit/src/up_nsh.c index db6dc922e..830570c6c 100644 --- a/nuttx/configs/pic32-starterkit/src/up_nsh.c +++ b/nuttx/configs/pic32-starterkit/src/up_nsh.c @@ -55,32 +55,58 @@ /**************************************************************************** * Pre-Processor Definitions ****************************************************************************/ - /* Configuration ************************************************************/ +/* Assume that we have MMC/SD, USB host (and USB device) */ -/* PORT and SLOT number probably depend on the board configuration */ +#define CONFIG_NSH_HAVEMMCSD 1 +#define CONFIG_NSH_HAVEUSBHOST 1 -#ifdef CONFIG_ARCH_BOARD_SUREPIC32MX -# define CONFIG_NSH_HAVEMMCSD 1 -# define CONFIG_NSH_HAVEUSBHOST 1 -# if !defined(CONFIG_NSH_MMCSDSPIPORTNO) || CONFIG_NSH_MMCSDSPIPORTNO != 1 -# error "The PIC32 Starter Kit MMC/SD is on SPI2" +/* The PIC32 Ethernet Starter Kit does not have an SD slot on board. If one + * is added, then it must be specified by defining which SPI bus that it + * is connected on. + */ + +#ifndef CONFIG_PIC32MX_MMCSDSPIPORTNO +# undef CONFIG_NSH_HAVEMMCSD +#endif + +/* Make sure that the configuration will support the SD card */ + +#ifdef CONFIG_NSH_HAVEMMCSD + + /* Make sure that the NSH configuration uses the correct SPI */ + +# if !defined(CONFIG_NSH_MMCSDSPIPORTNO) +# define CONFIG_NSH_MMCSDSPIPORTNO CONFIG_PIC32MX_MMCSDSPIPORTNO +# elif CONFIG_NSH_MMCSDSPIPORTNO != CONFIG_PIC32MX_MMCSDSPIPORTNO +# warning "CONFIG_PIC32MX_MMCSDSPIPORTNO does not match CONFIG_NSH_MMCSDSPIPORTNO" # undef CONFIG_NSH_MMCSDSPIPORTNO -# define CONFIG_NSH_MMCSDSPIPORTNO 2 +# define CONFIG_NSH_MMCSDSPIPORTNO CONFIG_PIC32MX_MMCSDSPIPORTNO # endif + + /* Make sure that the NSH configuration uses the slot */ + # if !defined(CONFIG_NSH_MMCSDSLOTNO) || CONFIG_NSH_MMCSDSLOTNO != 0 -# error "The PIC32 Starter Kit has only one slot (0)" +# warning "The PIC32 Starter Kit has only one slot (0)" # undef CONFIG_NSH_MMCSDSLOTNO # define CONFIG_NSH_MMCSDSLOTNO 0 # endif -# ifndef CONFIG_PIC32MX_SPI2 + + /* Make sure that the correct SPI is enabled in the configuration */ + +# if CONFIG_PIC32MX_MMCSDSPIPORTNO == 1 && !defined(CONFIG_PIC32MX_SPI1) +# warning "CONFIG_PIC32MX_SPI1 is not enabled" +# undef CONFIG_NSH_HAVEMMCSD +# elif CONFIG_PIC32MX_MMCSDSPIPORTNO == 2 && !defined(CONFIG_PIC32MX_SPI2) # warning "CONFIG_PIC32MX_SPI2 is not enabled" # undef CONFIG_NSH_HAVEMMCSD +# elif CONFIG_PIC32MX_MMCSDSPIPORTNO == 3 && !defined(CONFIG_PIC32MX_SPI3) +# warning "CONFIG_PIC32MX_SPI3 is not enabled" +# undef CONFIG_NSH_HAVEMMCSD +# elif CONFIG_PIC32MX_MMCSDSPIPORTNO == 4 && !defined(CONFIG_PIC32MX_SPI4) +# warning "CONFIG_PIC32MX_SPI4 is not enabled" +# undef CONFIG_NSH_HAVEMMCSD # endif -#else -# error "Unrecognized board" -# undef CONFIG_NSH_HAVEMMCSD -# undef CONFIG_NSH_HAVEUSBHOST #endif /* Can't support MMC/SD features if mountpoints are disabled */ @@ -89,6 +115,8 @@ # undef CONFIG_NSH_HAVEMMCSD #endif +/* Select /dev/mmcsd0 if no other minor number is provided */ + #ifndef CONFIG_NSH_MMCSDMINOR # define CONFIG_NSH_MMCSDMINOR 0 #endif @@ -98,12 +126,14 @@ #ifdef CONFIG_USBHOST # ifndef CONFIG_PIC32MX_USBHOST # error "CONFIG_PIC32MX_USBHOST is not selected" +# undef CONFIG_NSH_HAVEUSBHOST # endif #endif #ifdef CONFIG_PIC32MX_USBHOST # ifndef CONFIG_USBHOST # warning "CONFIG_USBHOST is not selected" +# undef CONFIG_NSH_HAVEUSBHOST # endif #endif