summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2015-02-22 08:47:09 -0600
committerGregory Nutt <gnutt@nuttx.org>2015-02-22 08:47:09 -0600
commitfccbe4f3c5594f8104b4c54b998c120a9a43834b (patch)
tree44d1abdf8a1fd2fa7c0cc224fa46e2ea869d4106
parent2f194dab8ddc45e82c3b2cf0a9f73ab89851cefc (diff)
downloadnuttx-fccbe4f3c5594f8104b4c54b998c120a9a43834b.tar.gz
nuttx-fccbe4f3c5594f8104b4c54b998c120a9a43834b.tar.bz2
nuttx-fccbe4f3c5594f8104b4c54b998c120a9a43834b.zip
Add basic board support for the PIC32MZ (can't build yet of course because there is not yet any PIC32MZ support)
-rw-r--r--nuttx/configs/pic32mz-starterkit/Kconfig7
-rw-r--r--nuttx/configs/pic32mz-starterkit/README.txt187
-rw-r--r--nuttx/configs/pic32mz-starterkit/include/board.h218
-rw-r--r--nuttx/configs/pic32mz-starterkit/nsh/Make.defs115
-rw-r--r--nuttx/configs/pic32mz-starterkit/nsh/defconfig993
-rwxr-xr-xnuttx/configs/pic32mz-starterkit/nsh/setenv.sh66
-rw-r--r--nuttx/configs/pic32mz-starterkit/scripts/c32-release.ld318
-rw-r--r--nuttx/configs/pic32mz-starterkit/scripts/mips-release.ld318
-rw-r--r--nuttx/configs/pic32mz-starterkit/src/.gitignore2
-rw-r--r--nuttx/configs/pic32mz-starterkit/src/Makefile93
-rw-r--r--nuttx/configs/pic32mz-starterkit/src/pic32mz-starterkit.h211
-rw-r--r--nuttx/configs/pic32mz-starterkit/src/pic32mz_autoleds.c217
-rw-r--r--nuttx/configs/pic32mz-starterkit/src/pic32mz_boot.c115
-rw-r--r--nuttx/configs/pic32mz-starterkit/src/pic32mz_bringup.c132
-rw-r--r--nuttx/configs/pic32mz-starterkit/src/pic32mz_nsh.c71
-rw-r--r--nuttx/configs/pic32mz-starterkit/src/pic32mz_spi.c222
-rw-r--r--nuttx/configs/pic32mz-starterkit/src/pic32mz_userleds.c147
17 files changed, 3432 insertions, 0 deletions
diff --git a/nuttx/configs/pic32mz-starterkit/Kconfig b/nuttx/configs/pic32mz-starterkit/Kconfig
new file mode 100644
index 000000000..d637320bc
--- /dev/null
+++ b/nuttx/configs/pic32mz-starterkit/Kconfig
@@ -0,0 +1,7 @@
+#
+# For a description of the syntax of this configuration file,
+# see misc/tools/kconfig-language.txt.
+#
+
+if ARCH_BOARD_PIC32MZ_STARTERKIT
+endif
diff --git a/nuttx/configs/pic32mz-starterkit/README.txt b/nuttx/configs/pic32mz-starterkit/README.txt
new file mode 100644
index 000000000..cafec5b83
--- /dev/null
+++ b/nuttx/configs/pic32mz-starterkit/README.txt
@@ -0,0 +1,187 @@
+configs/pic32mz-starterkit README
+===============================
+
+This README file discusses the port of NuttX to the Microchip PIC32MZ
+Embedded Connectivity (EC) Starter Kit. There are two configurations of the
+starter kit:
+
+ 1) The PIC32MZ Embedded Connectivity Starter Kit based on the
+ PIC32MZ2048ECH144-I/PH chip (DM320006), and
+ 2) The PIC32MZ Embedded Connectivity Starter Kit based on the
+ PIC32MZ2048ECM144-I/PH w/Crypto Engine (DM320006-C)
+
+See www.microchip.com for further information.
+
+Key features of the PIC32MZ Starter Kit include;
+
+ * On-board crystal or oscillator for precision microcontroller clocking
+ (24 MHz).
+ * 32 kHz oscillator for RTCC and Timer1 (optional).
+ * Three push button switches for user-defined inputs.
+ * Three user-defined indicator LEDs.
+ * USB Type A receptacle connectivity for PIC32 host-based applications.
+ * USB Type micro-AB receptacle for OTG and USB device connectivity for
+ PIC32 OTG/device-based applications.
+ * Daughter board connectors for flexible Ethernet PHY options.
+ * 50 MHz Ethernet PHY oscillator.
+ * External 4 GB SQI memory for expanded memory applications.
+ * PIC24FJ256GB106 USB microcontroller for on-board debugging.
+ * USB connectivity for on-board debugger communications.
+ * Regulated +3.3V power supply for powering the starter kit through USB or
+ expansion board.
+ * Connector for various expansion boards.
+
+The PIC32MZ starter kit comes complete with a LAN8740 PHY daughter board.
+
+Contents
+========
+
+ On Board Debug Support
+ Creating Compatible NuttX HEX files
+ Serial Console
+ LEDs
+ Configurations
+
+On Board Debug Support
+======================
+
+ The starter kit includes a PIC24FJ256GB106 USB microcontroller that
+ provides debugger connectivity over USB. The PIC24FJ256GB106 is hard-wired
+ to the PIC32 device to provide protocol translation through the I/O pins
+ of the PIC24FJ256GB106 to the ICSP™ pins of the PIC32 device.
+
+ If MPLAB® REAL ICE™ or MPLAB ICD 3 is used with the starter kit,
+ disconnect the onboard debugger from the PIC32 device by removing the
+ jumper JP2. When the on-board debugger is required, replace the jumper
+ JP2. When the jumper JP2 is installed, pin 1 must be connected to pin 3
+ and pin 2 must be connected to pin 4.
+
+Creating Compatible NuttX HEX files
+===================================
+
+ Intel Hex Format Files:
+ -----------------------
+
+ When NuttX is built it will produce two files in the top-level NuttX
+ directory:
+
+ 1) nuttx - This is an ELF file, and
+ 2) nuttx.hex - This is an Intel Hex format file. This is controlled by
+ the setting CONFIG_INTELHEX_BINARY in the .config file.
+
+ The PICkit tool wants an Intel Hex format file to burn into FLASH. However,
+ there is a problem with the generated nutt.hex: The tool expects the nuttx.hex
+ file to contain physical addresses. But the nuttx.hex file generated from the
+ top-level make will have address in the KSEG0 and KSEG1 regions.
+
+ tools/pic32mx/mkpichex:
+ ----------------------
+
+ There is a simple tool in the NuttX tools/pic32mx directory that can be
+ used to solve both issues with the nuttx.hex file. But, first, you must
+ build the tool:
+
+ cd tools/pic32mx
+ make
+
+ Now you will have an excecutable file call mkpichex (or mkpichex.exe on
+ Cygwin). This program will take the nutt.hex file as an input, it will
+ convert all of the KSEG0 and KSEG1 addresses to physical address, and
+ it will write the modified file, replacing the original nuttx.hex.
+
+ To use this file, you need to do the following things:
+
+ . ./setenv.sh # Source setenv.sh. Among other this, this script
+ # will add the NuttX tools/pic32mx directory to your
+ # PATH variable
+ make # Build nuttx and nuttx.hex
+ mkpichex $PWD # Convert addresses in nuttx.hex. $PWD is the path
+ # to the top-level build directory. It is the only
+ # required input to mkpichex.
+
+Serial Console
+==============
+
+To be provided
+
+LEDs and Buttons
+================
+
+ LEDs
+ ----
+ The PIC32MZ Ethernet Starter kit has 3 user LEDs labelled LED1-3 on the
+ board:
+
+ PIN LED Notes
+ --- ----- -------------------------
+ RH0 LED1 High illuminates (RED)
+ RH1 LED3 High illuminates (YELLOW)
+ RH2 LED2 High illuminates (GREEN)
+
+ If CONFIG_ARCH_LEDS is defined, then NuttX will control these LEDs as
+ follows:
+
+ ON OFF
+ ------------------------- ---- ---- ---- ---- ---- ----
+ LED1 LED2 LED3 LED1 LED2 LED3
+ ------------------------- ---- ---- ---- ---- ---- ----
+ LED_STARTED 0 OFF OFF OFF --- --- ---
+ LED_HEAPALLOCATE 1 ON OFF N/C --- --- ---
+ LED_IRQSENABLED 2 OFF ON N/C --- --- ---
+ LED_STACKCREATED 3 ON ON N/C --- --- ---
+ LED_INIRQ 4 N/C N/C ON N/C N/C OFF
+ LED_SIGNAL 4 N/C N/C ON N/C N/C OFF
+ LED_ASSERTION 4 N/C N/C ON N/C N/C OFF
+ LED_PANIC 5 ON N/C N/C OFF N/C N/C
+
+ Buttons
+ -------
+
+ The PIC32MZ Ethernet Starter kit has 3 user push buttons labelled SW1-3 on
+ the board:
+
+ PIN LED Notes
+ ---- ---- -------------------------
+ RB12 SW1 Active-low
+ RB13 SW2 Active-low
+ RB14 SW3 Active-low
+
+ The switches do not have any debounce circuitry and require internal pull-
+ up resistors. When Idle, the switches are pulled high (+3.3V), and they
+ are grounded when pressed.
+
+Configurations
+==============
+
+Each PIC32MZ configuration is maintained in a sub-directory and can be
+selected as follow:
+
+ cd tools
+ ./configure.sh pic32mz-starterkit/<subdir>
+ cd -
+ . ./setenv.sh
+
+Where <subdir> is one of the following:
+
+ nsh:
+
+ This is the NuttShell (NSH) using the NSH startup logic at
+ apps/examples/nsh.
+
+ NOTES:
+
+ 1. This configuration uses the mconf-based configuration tool. To
+ change this configurations using that tool, you should:
+
+ a. Build and install the kconfig-mconf tool. See nuttx/README.txt
+ and misc/tools/
+
+ b. Execute 'make menuconfig' in nuttx/ in order to start the
+ reconfiguration process.
+
+ 2. Serial Output
+
+ The OS test produces all of its test output on the serial console.
+ This configuration has UART1 enabled as a serial console. I have
+ been unable to get this UART work on the MEB. But on the Expansion
+ I/O board, this maps to RX = J11 pin 41 and TX = J11 pin 43
diff --git a/nuttx/configs/pic32mz-starterkit/include/board.h b/nuttx/configs/pic32mz-starterkit/include/board.h
new file mode 100644
index 000000000..1bc4f48a3
--- /dev/null
+++ b/nuttx/configs/pic32mz-starterkit/include/board.h
@@ -0,0 +1,218 @@
+/****************************************************************************
+ * configs/pic32mz-starterkit/include/board.h
+ *
+ * Copyright (C) 2015 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __CONFIGS_SURE_PIC32MZ_INCLUDE_BOARD_H
+#define __CONFIGS_SURE_PIC32MZ_INCLUDE_BOARD_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#ifndef __ASSEMBLY__
+# include <stdbool.h>
+#endif
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+/* Configuration ************************************************************/
+
+/* Clocking *****************************************************************/
+/* Crystal frequencies */
+
+#define BOARD_POSC_FREQ 8000000 /* Primary OSC XTAL frequency (8MHz) */
+#define BOARD_SOSC_FREQ 32768 /* Secondary OSC XTAL frequency (32.768KHz) */
+
+/* Oscillator modes */
+
+#define BOARD_FNOSC_POSCPLL 1 /* Use primary oscillator w/PLL */
+#define BOARD_POSC_HSMODE 1 /* High-speed crystal (HS) mode */
+
+/* PLL configuration and resulting CPU clock.
+ * CPU_CLOCK = ((POSC_FREQ / IDIV) * MULT) / ODIV
+ */
+
+#define BOARD_PLL_INPUT BOARD_POSC_FREQ
+#define BOARD_PLL_IDIV 2 /* PLL input divider */
+#define BOARD_PLL_MULT 20 /* PLL multiplier */
+#define BOARD_PLL_ODIV 1 /* PLL output divider */
+
+#define BOARD_CPU_CLOCK 80000000 /* CPU clock (80MHz = 8MHz * 20 / 2) */
+
+/* USB PLL configuration.
+ * USB_CLOCK = ((POSC_XTAL / IDIV) * 24) / 2
+ */
+
+#define BOARD_UPLL_IDIV 2 /* USB PLL divider (revisit) */
+#define BOARD_USB_CLOCK 48000000 /* USB clock (8MHz / 2) * 24 / 2) */
+
+/* Peripheral clock is divided down from CPU clock.
+ * PBCLOCK = CPU_CLOCK / PBDIV
+ */
+
+#define BOARD_PBDIV 2 /* Peripheral clock divisor (PBDIV) */
+#define BOARD_PBCLOCK 40000000 /* Peripheral clock (PBCLK = 80MHz/2) */
+
+/* Watchdog pre-scaler (re-visit) */
+
+#define BOARD_WD_ENABLE 0 /* Watchdog is disabled */
+#define BOARD_WD_PRESCALER 8 /* Watchdog pre-scaler */
+
+/* Ethernet MII clocking.
+ *
+ * The clock divider used to create the MII Management Clock (MDC). The MIIM
+ * module uses the SYSCLK as an input clock. According to the IEEE 802.3
+ * Specification this should be no faster than 2.5 MHz. However, some PHYs
+ * support clock rates up to 12.5 MHz.
+ */
+
+#define BOARD_EMAC_MIIM_DIV 32 /* Ideal: 80MHz/32 = 2.5MHz */
+
+/* LED definitions **********************************************************/
+/* LED Configuration ********************************************************/
+/* The PIC32MZ Ethernet Starter kit has 3 user LEDs labelled LED1-3 on the
+ * board:
+ *
+ * PIN LED Notes
+ * --- ----- -------------------------
+ * RH0 LED1 High illuminates (RED)
+ * RH1 LED3 High illuminates (YELLOW)
+ * RH2 LED2 High illuminates (GREEN)
+ */
+
+/* LED index values for use with pic32mz_setled() */
+
+#define PIC32MZ_STARTERKIT_LED1 0
+#define PIC32MZ_STARTERKIT_LED2 1
+#define PIC32MZ_STARTERKIT_LED3 2
+#define PIC32MZ_STARTERKIT_NLEDS 3
+
+/* LED bits for use with pic32mz_setleds() */
+
+#define PIC32MZ_STARTERKIT_LED1_BIT (1 << PIC32MZ_STARTERKIT_LED1)
+#define PIC32MZ_STARTERKIT_LED2_BIT (1 << PIC32MZ_STARTERKIT_LED2)
+#define PIC32MZ_STARTERKIT_LED3_BIT (1 << PIC32MZ_STARTERKIT_LED3)
+
+/* If CONFIG_ARCH_LEDs is defined, then NuttX will control the 3 LEDs
+ * on board the Ethernet Starter Kit. The following definitions
+ * describe how NuttX controls the LEDs:
+ *
+ * ON OFF
+ * ------------------------- ---- ---- ---- ---- ---- ----
+ * LED1 LED2 LED3 LED1 LED2 LED3
+ * ------------------------- ---- ---- ---- ---- ---- ----
+ * LED_STARTED 0 OFF OFF OFF --- --- ---
+ * LED_HEAPALLOCATE 1 ON OFF N/C --- --- ---
+ * LED_IRQSENABLED 2 OFF ON N/C --- --- ---
+ * LED_STACKCREATED 3 ON ON N/C --- --- ---
+ * LED_INIRQ 4 N/C N/C ON N/C N/C OFF
+ * LED_SIGNAL 4 N/C N/C ON N/C N/C OFF
+ * LED_ASSERTION 4 N/C N/C ON N/C N/C OFF
+ * LED_PANIC 5 ON N/C N/C OFF N/C N/C
+ */
+
+#define LED_STARTED 0
+#define LED_HEAPALLOCATE 1
+#define LED_IRQSENABLED 2
+#define LED_STACKCREATED 3
+#define LED_INIRQ 4
+#define LED_SIGNAL 4
+#define LED_ASSERTION 4
+#define LED_PANIC 5
+
+#define LED_NVALUES 6
+
+/* Switch definitions *******************************************************/
+/* The PIC32MZ Ethernet Starter kit has 3 user push buttons labelled SW1-3
+ * on the board:
+ *
+ * PIN LED Notes
+ * ---- ---- -------------------------
+ * RB12 SW1 Active-low
+ * RB13 SW2 Active-low
+ * RB14 SW3 Active-low
+ *
+ * The switches do not have any debounce circuitry and require internal pull-
+ * up resistors. When Idle, the switches are pulled high (+3.3V), and they
+ * are grounded when pressed.
+ */
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+#ifndef __ASSEMBLY__
+
+/****************************************************************************
+ * Inline Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+#ifdef __cplusplus
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/****************************************************************************
+ * Name: pic32mz_ledinit and pic32mz_setled
+ *
+ * Description:
+ * If CONFIG_ARCH_LEDS is defined, then NuttX will control the on-board
+ * LEDs. If CONFIG_ARCH_LEDS is not defined, then the following interfaces
+ * are available to control the LEDs from user applications.
+ *
+ ****************************************************************************/
+
+#ifndef CONFIG_ARCH_LEDS
+void pic32mz_ledinit(void);
+void pic32mz_setled(int led, bool ledon);
+void pic32mz_setleds(uint8_t ledset);
+#endif
+
+#undef EXTERN
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __ASSEMBLY__ */
+#endif /* __CONFIGS_SURE_PIC32MZ_INCLUDE_BOARD_H */
diff --git a/nuttx/configs/pic32mz-starterkit/nsh/Make.defs b/nuttx/configs/pic32mz-starterkit/nsh/Make.defs
new file mode 100644
index 000000000..51a963586
--- /dev/null
+++ b/nuttx/configs/pic32mz-starterkit/nsh/Make.defs
@@ -0,0 +1,115 @@
+############################################################################
+# configs/pic32mz-starterkit/nsh/Make.defs
+#
+# Copyright (C) 2015 Gregory Nutt. All rights reserved.
+# Author: Gregory Nutt <gnutt@nuttx.org>
+#
+# 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.
+#
+############################################################################
+
+include ${TOPDIR}/.config
+include ${TOPDIR}/tools/Config.mk
+include ${TOPDIR}/arch/mips/src/mips32/Toolchain.defs
+
+ifeq ($(CONFIG_MIPS32_TOOLCHAIN_GNU_ELF),y)
+LDSCRIPT = mips-release.ld
+endif
+
+ifeq ($(CONFIG_MIPS32_TOOLCHAIN_PINGUINOW),y)
+LDSCRIPT = mips-release.ld
+endif
+
+ifeq ($(CONFIG_MIPS32_TOOLCHAIN_MICROCHIPW),y)
+LDSCRIPT = c32-release.ld
+endif
+
+ifeq ($(CONFIG_MIPS32_TOOLCHAIN_MICROCHIPW_LITE),y)
+LDSCRIPT = c32-release.ld
+endif
+
+ifeq ($(WINTOOL),y)
+ # Windows-native toolchains
+ DIRLINK = $(TOPDIR)/tools/copydir.sh
+ DIRUNLINK = $(TOPDIR)/tools/unlink.sh
+ MKDEP = $(TOPDIR)/tools/mknulldeps.sh
+ ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}"
+ ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}"
+ ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)}"
+else
+ # Linux/Cygwin-native toolchain
+ MKDEP = $(TOPDIR)/tools/mkdeps.sh
+ ARCHINCLUDES = -I. -isystem $(TOPDIR)/include
+ ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx
+ ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)
+endif
+
+CC = $(CROSSDEV)gcc
+CXX = $(CROSSDEV)g++
+CPP = $(CROSSDEV)gcc -E
+LD = $(CROSSDEV)ld
+AR = $(CROSSDEV)ar rcs
+NM = $(CROSSDEV)nm
+OBJCOPY = $(CROSSDEV)objcopy
+OBJDUMP = $(CROSSDEV)objdump
+
+ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
+ ARCHOPTIMIZATION = -g
+endif
+
+ifneq ($(CONFIG_DEBUG_NOOPT),y)
+ ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer
+endif
+
+ARCHCFLAGS = -fno-builtin
+ARCHCXXFLAGS = -fno-builtin -fno-exceptions
+ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow
+ARCHWARNINGSXX = -Wall -Wshadow
+ARCHDEFINES =
+
+CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
+CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS)
+CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
+CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
+CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES)
+AFLAGS = $(CFLAGS) -D__ASSEMBLY__
+
+NXFLATLDFLAGS1 = -r -d -warn-common
+NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-gotoff.ld -no-check-sections
+LDNXFLATFLAGS = -e main -s 2048
+
+OBJEXT = .o
+LIBEXT = .a
+EXEEXT =
+
+
+HOSTCC = gcc
+HOSTINCLUDES = -I.
+HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -g -pipe
+HOSTLDFLAGS =
+
diff --git a/nuttx/configs/pic32mz-starterkit/nsh/defconfig b/nuttx/configs/pic32mz-starterkit/nsh/defconfig
new file mode 100644
index 000000000..16920c833
--- /dev/null
+++ b/nuttx/configs/pic32mz-starterkit/nsh/defconfig
@@ -0,0 +1,993 @@
+#
+# Automatically generated file; DO NOT EDIT.
+# Nuttx/ Configuration
+#
+
+#
+# Build Setup
+#
+# CONFIG_EXPERIMENTAL is not set
+# CONFIG_DEFAULT_SMALL is not set
+# CONFIG_HOST_LINUX is not set
+# CONFIG_HOST_OSX is not set
+CONFIG_HOST_WINDOWS=y
+# CONFIG_HOST_OTHER is not set
+# CONFIG_WINDOWS_NATIVE is not set
+CONFIG_WINDOWS_CYGWIN=y
+# CONFIG_WINDOWS_MSYS is not set
+# CONFIG_WINDOWS_OTHER is not set
+
+#
+# Build Configuration
+#
+# CONFIG_APPS_DIR="../apps"
+CONFIG_BUILD_FLAT=y
+# CONFIG_BUILD_2PASS is not set
+
+#
+# Binary Output Formats
+#
+# CONFIG_RRLOAD_BINARY is not set
+CONFIG_INTELHEX_BINARY=y
+# CONFIG_MOTOROLA_SREC is not set
+# CONFIG_RAW_BINARY is not set
+# CONFIG_UBOOT_UIMAGE is not set
+
+#
+# Customize Header Files
+#
+# CONFIG_ARCH_STDINT_H is not set
+# CONFIG_ARCH_STDBOOL_H is not set
+# CONFIG_ARCH_MATH_H is not set
+# CONFIG_ARCH_FLOAT_H is not set
+# CONFIG_ARCH_STDARG_H is not set
+
+#
+# Debug Options
+#
+# CONFIG_DEBUG is not set
+# CONFIG_ARCH_HAVE_HEAPCHECK is not set
+# CONFIG_ARCH_HAVE_STACKCHECK is not set
+# CONFIG_DEBUG_SYMBOLS is not set
+CONFIG_ARCH_HAVE_CUSTOMOPT=y
+# CONFIG_DEBUG_NOOPT is not set
+# CONFIG_DEBUG_CUSTOMOPT is not set
+CONFIG_DEBUG_FULLOPT=y
+
+#
+# System Type
+#
+# CONFIG_ARCH_ARM is not set
+# CONFIG_ARCH_AVR is not set
+# CONFIG_ARCH_HC is not set
+CONFIG_ARCH_MIPS=y
+# CONFIG_ARCH_RGMP is not set
+# CONFIG_ARCH_SH is not set
+# CONFIG_ARCH_SIM is not set
+# CONFIG_ARCH_X86 is not set
+# CONFIG_ARCH_Z16 is not set
+# CONFIG_ARCH_Z80 is not set
+CONFIG_ARCH="mips"
+CONFIG_ARCH_FAMILY="mips32"
+CONFIG_ARCH_CHIP="pic32mz"
+CONFIG_ARCH_CHIP_PIC32MZ=y
+CONFIG_ARCH_MIPS32=y
+
+#
+# MIPS32 Configuration Options
+#
+# CONFIG_MIPS32_TOOLCHAIN_GNU_ELF is not set
+# CONFIG_MIPS32_TOOLCHAIN_MICROCHIPW is not set
+CONFIG_MIPS32_TOOLCHAIN_MICROCHIPW_LITE=y
+# CONFIG_MIPS32_TOOLCHAIN_PINGUINOW is not set
+# CONFIG_MIPS32_FRAMEPOINTER is not set
+
+#
+# PIC32MX Configuration Options
+#
+# CONFIG_ARCH_CHIP_PIC32MX110F016B is not set
+# CONFIG_ARCH_CHIP_PIC32MX110F016C is not set
+# CONFIG_ARCH_CHIP_PIC32MX110F016D is not set
+# CONFIG_ARCH_CHIP_PIC32MX120F032B is not set
+# CONFIG_ARCH_CHIP_PIC32MX120F032C is not set
+# CONFIG_ARCH_CHIP_PIC32MX120F032D is not set
+# CONFIG_ARCH_CHIP_PIC32MX130F064B is not set
+# CONFIG_ARCH_CHIP_PIC32MX130F064C is not set
+# CONFIG_ARCH_CHIP_PIC32MX130F064D is not set
+# CONFIG_ARCH_CHIP_PIC32MX150F128B is not set
+# CONFIG_ARCH_CHIP_PIC32MX150F128C is not set
+# CONFIG_ARCH_CHIP_PIC32MX150F128D is not set
+# CONFIG_ARCH_CHIP_PIC32MX210F016B is not set
+# CONFIG_ARCH_CHIP_PIC32MX210F016C is not set
+# CONFIG_ARCH_CHIP_PIC32MX210F016D is not set
+# CONFIG_ARCH_CHIP_PIC32MX220F032B is not set
+# CONFIG_ARCH_CHIP_PIC32MX220F032C is not set
+# CONFIG_ARCH_CHIP_PIC32MX220F032D is not set
+# CONFIG_ARCH_CHIP_PIC32MX230F064B is not set
+# CONFIG_ARCH_CHIP_PIC32MX230F064C is not set
+# CONFIG_ARCH_CHIP_PIC32MX230F064D is not set
+# CONFIG_ARCH_CHIP_PIC32MX250F128B is not set
+# CONFIG_ARCH_CHIP_PIC32MX250F128C is not set
+# CONFIG_ARCH_CHIP_PIC32MX250F128D is not set
+# CONFIG_ARCH_CHIP_PIC32MX320F032H is not set
+# CONFIG_ARCH_CHIP_PIC32MX320F064H is not set
+# CONFIG_ARCH_CHIP_PIC32MX320F128H is not set
+# CONFIG_ARCH_CHIP_PIC32MX320F128L is not set
+# CONFIG_ARCH_CHIP_PIC32MX340F128H is not set
+# CONFIG_ARCH_CHIP_PIC32MX340F256H is not set
+# CONFIG_ARCH_CHIP_PIC32MX340F512H is not set
+# CONFIG_ARCH_CHIP_PIC32MX340F128L is not set
+# CONFIG_ARCH_CHIP_PIC32MX360F256L is not set
+# CONFIG_ARCH_CHIP_PIC32MX360F512L is not set
+# CONFIG_ARCH_CHIP_PIC32MX420F032H is not set
+# CONFIG_ARCH_CHIP_PIC32MX440F128H is not set
+# CONFIG_ARCH_CHIP_PIC32MX440F128L is not set
+# CONFIG_ARCH_CHIP_PIC32MX440F256H is not set
+# CONFIG_ARCH_CHIP_PIC32MX440F512H is not set
+# CONFIG_ARCH_CHIP_PIC32MX460F256L is not set
+# CONFIG_ARCH_CHIP_PIC32MX460F512L is not set
+# CONFIG_ARCH_CHIP_PIC32MX534F064H is not set
+# CONFIG_ARCH_CHIP_PIC32MX534F064L is not set
+# CONFIG_ARCH_CHIP_PIC32MX564F064H is not set
+# CONFIG_ARCH_CHIP_PIC32MX564F064L is not set
+# CONFIG_ARCH_CHIP_PIC32MX564F128H is not set
+# CONFIG_ARCH_CHIP_PIC32MX564F128L is not set
+# CONFIG_ARCH_CHIP_PIC32MX575F256H is not set
+# CONFIG_ARCH_CHIP_PIC32MX575F256L is not set
+# CONFIG_ARCH_CHIP_PIC32MX575F512H is not set
+# CONFIG_ARCH_CHIP_PIC32MX575F512L is not set
+# CONFIG_ARCH_CHIP_PIC32MX664F064H is not set
+# CONFIG_ARCH_CHIP_PIC32MX664F064L is not set
+# CONFIG_ARCH_CHIP_PIC32MX664F128H is not set
+# CONFIG_ARCH_CHIP_PIC32MX664F128L is not set
+# CONFIG_ARCH_CHIP_PIC32MX675F256H is not set
+# CONFIG_ARCH_CHIP_PIC32MX675F256L is not set
+# CONFIG_ARCH_CHIP_PIC32MX675F512H is not set
+# CONFIG_ARCH_CHIP_PIC32MX675F512L is not set
+# CONFIG_ARCH_CHIP_PIC32MX695F512H is not set
+# CONFIG_ARCH_CHIP_PIC32MX695F512L is not set
+# CONFIG_ARCH_CHIP_PIC32MX764F128H is not set
+# CONFIG_ARCH_CHIP_PIC32MX764F128L is not set
+# CONFIG_ARCH_CHIP_PIC32MX775F256H is not set
+# CONFIG_ARCH_CHIP_PIC32MX775F256L is not set
+# CONFIG_ARCH_CHIP_PIC32MX775F512H is not set
+# CONFIG_ARCH_CHIP_PIC32MX775F512L is not set
+# CONFIG_ARCH_CHIP_PIC32MX795F512H is not set
+CONFIG_ARCH_CHIP_PIC32MX795F512L=y
+# CONFIG_ARCH_CHIP_PIC32MX1 is not set
+# CONFIG_ARCH_CHIP_PIC32MX2 is not set
+# CONFIG_ARCH_CHIP_PIC32MX3 is not set
+# CONFIG_ARCH_CHIP_PIC32MX4 is not set
+# CONFIG_ARCH_CHIP_PIC32MX5 is not set
+# CONFIG_ARCH_CHIP_PIC32MX6 is not set
+CONFIG_ARCH_CHIP_PIC32MX7=y
+# CONFIG_PIC32MX_MVEC is not set
+CONFIG_PIC32MX_T1=y
+
+#
+# PIC32MX Peripheral Support
+#
+# CONFIG_PIC32MX_WDT is not set
+# CONFIG_PIC32MX_T2 is not set
+# CONFIG_PIC32MX_T3 is not set
+# CONFIG_PIC32MX_T4 is not set
+# CONFIG_PIC32MX_T5 is not set
+# CONFIG_PIC32MX_IC1 is not set
+# CONFIG_PIC32MX_IC2 is not set
+# CONFIG_PIC32MX_IC3 is not set
+# CONFIG_PIC32MX_IC4 is not set
+# CONFIG_PIC32MX_IC5 is not set
+# CONFIG_PIC32MX_OC1 is not set
+# CONFIG_PIC32MX_OC2 is not set
+# CONFIG_PIC32MX_OC3 is not set
+# CONFIG_PIC32MX_OC4 is not set
+# CONFIG_PIC32MX_OC5 is not set
+# CONFIG_PIC32MX_I2C1 is not set
+# CONFIG_PIC32MX_I2C2 is not set
+# CONFIG_PIC32MX_I2C3 is not set
+# CONFIG_PIC32MX_I2C4 is not set
+# CONFIG_PIC32MX_I2C5 is not set
+# CONFIG_PIC32MX_SPI1 is not set
+# CONFIG_PIC32MX_SPI2 is not set
+# CONFIG_PIC32MX_SPI3 is not set
+# CONFIG_PIC32MX_SPI4 is not set
+CONFIG_PIC32MX_UART1=y
+# CONFIG_PIC32MX_UART2 is not set
+# CONFIG_PIC32MX_UART3 is not set
+# CONFIG_PIC32MX_UART4 is not set
+# CONFIG_PIC32MX_UART5 is not set
+# CONFIG_PIC32MX_UART6 is not set
+# CONFIG_PIC32MX_ADC is not set
+# CONFIG_PIC32MX_PMP is not set
+# CONFIG_PIC32MX_CM1 is not set
+# CONFIG_PIC32MX_CM2 is not set
+# CONFIG_PIC32MX_CM3 is not set
+# CONFIG_PIC32MX_RTCC is not set
+# CONFIG_PIC32MX_DMA is not set
+# CONFIG_PIC32MX_FLASH is not set
+# CONFIG_PIC32MX_USBDEV is not set
+# CONFIG_PIC32MX_USBHOST is not set
+# CONFIG_PIC32MX_CAN1 is not set
+# CONFIG_PIC32MX_CAN2 is not set
+# CONFIG_PIC32MX_ETHERNET is not set
+# CONFIG_PIC32MX_CTMU is not set
+
+#
+# PIC32MX Peripheral Interrupt Priorities
+#
+CONFIG_PIC32MX_CTPRIO=16
+CONFIG_PIC32MX_CS0PRIO=16
+CONFIG_PIC32MX_CS1PRIO=16
+CONFIG_PIC32MX_INT0PRIO=16
+CONFIG_PIC32MX_INT1PRIO=16
+CONFIG_PIC32MX_INT2PRIO=16
+CONFIG_PIC32MX_INT3PRIO=16
+CONFIG_PIC32MX_INT4PRIO=16
+CONFIG_PIC32MX_T1PRIO=16
+CONFIG_PIC32MX_UART1PRIO=16
+
+#
+# Device Configuration 0 (DEVCFG0)
+#
+CONFIG_PIC32MX_DEBUGGER=2
+CONFIG_PIC32MX_ICESEL=1
+CONFIG_PIC32MX_PROGFLASHWP=0xff
+CONFIG_PIC32MX_BOOTFLASHWP=1
+CONFIG_PIC32MX_CODEWP=1
+
+#
+# Device Configuration 1 (DEVCFG1)
+#
+
+#
+# Device Configuration 3 (DEVCFG3)
+#
+CONFIG_PIC32MX_USBIDO=0
+CONFIG_PIC32MX_VBUSIO=0
+# CONFIG_PIC32MX_WDENABLE is not set
+CONFIG_PIC32MX_FETHIO=0
+CONFIG_PIC32MX_FMIIEN=0
+
+#
+# Architecture Options
+#
+# CONFIG_ARCH_NOINTC is not set
+CONFIG_ARCH_VECNOTIRQ=y
+# CONFIG_ARCH_DMA is not set
+CONFIG_ARCH_HAVE_IRQPRIO=y
+# CONFIG_ARCH_L2CACHE is not set
+# CONFIG_ARCH_HAVE_COHERENT_DCACHE is not set
+# CONFIG_ARCH_HAVE_ADDRENV is not set
+# CONFIG_ARCH_NEED_ADDRENV_MAPPING is not set
+CONFIG_ARCH_HAVE_VFORK=y
+# CONFIG_ARCH_HAVE_MMU is not set
+# CONFIG_ARCH_HAVE_MPU is not set
+# CONFIG_ARCH_NAND_HWECC is not set
+# CONFIG_ARCH_HAVE_EXTCLK is not set
+# CONFIG_ARCH_IRQPRIO is not set
+CONFIG_ARCH_STACKDUMP=y
+# CONFIG_ENDIAN_BIG is not set
+# CONFIG_ARCH_IDLE_CUSTOM is not set
+CONFIG_ARCH_HAVE_RAMFUNCS=y
+# CONFIG_ARCH_RAMFUNCS is not set
+# CONFIG_ARCH_HAVE_RAMVECTORS is not set
+
+#
+# Board Settings
+#
+CONFIG_BOARD_LOOPSPERMSEC=7245
+# CONFIG_ARCH_CALIBRATION is not set
+
+#
+# Interrupt options
+#
+CONFIG_ARCH_HAVE_INTERRUPTSTACK=y
+CONFIG_ARCH_INTERRUPTSTACK=0
+# CONFIG_ARCH_HAVE_HIPRI_INTERRUPT is not set
+
+#
+# Boot options
+#
+# CONFIG_BOOT_RUNFROMEXTSRAM is not set
+CONFIG_BOOT_RUNFROMFLASH=y
+# CONFIG_BOOT_RUNFROMISRAM is not set
+# CONFIG_BOOT_RUNFROMSDRAM is not set
+# CONFIG_BOOT_COPYTORAM is not set
+
+#
+# Boot Memory Configuration
+#
+CONFIG_RAM_START=0xa0000000
+CONFIG_RAM_SIZE=131072
+# CONFIG_ARCH_HAVE_SDRAM is not set
+
+#
+# Board Selection
+#
+CONFIG_ARCH_BOARD_PIC32MZ_STARTERKIT=y
+# CONFIG_ARCH_BOARD_PIC32MX7MMB is not set
+# CONFIG_ARCH_BOARD_CUSTOM is not set
+CONFIG_ARCH_BOARD="pic32mz-starterkit"
+
+#
+# Common Board Options
+#
+CONFIG_ARCH_HAVE_LEDS=y
+CONFIG_ARCH_LEDS=y
+CONFIG_NSH_MMCSDMINOR=0
+CONFIG_NSH_MMCSDSLOTNO=0
+
+#
+# Board-Specific Options
+#
+
+#
+# RTOS Features
+#
+CONFIG_DISABLE_OS_API=y
+# CONFIG_DISABLE_POSIX_TIMERS is not set
+# CONFIG_DISABLE_PTHREAD is not set
+# CONFIG_DISABLE_SIGNALS is not set
+# CONFIG_DISABLE_MQUEUE is not set
+# CONFIG_DISABLE_ENVIRON is not set
+
+#
+# Clocks and Timers
+#
+CONFIG_USEC_PER_TICK=10000
+# CONFIG_SYSTEM_TIME64 is not set
+# CONFIG_CLOCK_MONOTONIC is not set
+# CONFIG_JULIAN_TIME is not set
+CONFIG_START_YEAR=2012
+CONFIG_START_MONTH=3
+CONFIG_START_DAY=7
+CONFIG_MAX_WDOGPARMS=2
+CONFIG_PREALLOC_WDOGS=8
+CONFIG_WDOG_INTRESERVE=1
+CONFIG_PREALLOC_TIMERS=4
+
+#
+# Tasks and Scheduling
+#
+# CONFIG_INIT_NONE is not set
+CONFIG_INIT_ENTRYPOINT=y
+# CONFIG_INIT_FILEPATH is not set
+CONFIG_USER_ENTRYPOINT="nsh_main"
+CONFIG_RR_INTERVAL=200
+CONFIG_TASK_NAME_SIZE=0
+CONFIG_MAX_TASKS=16
+# CONFIG_SCHED_HAVE_PARENT is not set
+CONFIG_SCHED_WAITPID=y
+
+#
+# Pthread Options
+#
+# CONFIG_MUTEX_TYPES is not set
+CONFIG_NPTHREAD_KEYS=4
+
+#
+# Performance Monitoring
+#
+# CONFIG_SCHED_CPULOAD is not set
+# CONFIG_SCHED_INSTRUMENTATION is not set
+
+#
+# Files and I/O
+#
+CONFIG_DEV_CONSOLE=y
+# CONFIG_FDCLONE_DISABLE is not set
+# CONFIG_FDCLONE_STDIO is not set
+CONFIG_SDCLONE_DISABLE=y
+CONFIG_NFILE_DESCRIPTORS=8
+CONFIG_NFILE_STREAMS=8
+CONFIG_NAME_MAX=32
+# CONFIG_PRIORITY_INHERITANCE is not set
+
+#
+# RTOS hooks
+#
+# CONFIG_BOARD_INITIALIZE is not set
+# CONFIG_SCHED_STARTHOOK is not set
+# CONFIG_SCHED_ATEXIT is not set
+# CONFIG_SCHED_ONEXIT is not set
+
+#
+# Signal Numbers
+#
+CONFIG_SIG_SIGUSR1=1
+CONFIG_SIG_SIGUSR2=2
+CONFIG_SIG_SIGALARM=3
+CONFIG_SIG_SIGCONDTIMEDOUT=16
+
+#
+# POSIX Message Queue Options
+#
+CONFIG_PREALLOC_MQ_MSGS=4
+CONFIG_MQ_MAXMSGSIZE=32
+
+#
+# Work Queue Support
+#
+# CONFIG_SCHED_WORKQUEUE is not set
+# CONFIG_SCHED_HPWORK is not set
+# CONFIG_SCHED_LPWORK is not set
+
+#
+# Stack and heap information
+#
+CONFIG_IDLETHREAD_STACKSIZE=2048
+CONFIG_USERMAIN_STACKSIZE=2048
+CONFIG_PTHREAD_STACK_MIN=256
+CONFIG_PTHREAD_STACK_DEFAULT=2048
+# CONFIG_LIB_SYSCALL is not set
+
+#
+# Device Drivers
+#
+CONFIG_DISABLE_POLL=y
+CONFIG_DEV_NULL=y
+# CONFIG_DEV_ZERO is not set
+# CONFIG_LOOP is not set
+
+#
+# Buffering
+#
+# CONFIG_DRVR_WRITEBUFFER is not set
+# CONFIG_DRVR_READAHEAD is not set
+# CONFIG_RAMDISK is not set
+# CONFIG_CAN is not set
+# CONFIG_ARCH_HAVE_PWM_PULSECOUNT is not set
+# CONFIG_PWM is not set
+# CONFIG_ARCH_HAVE_I2CRESET is not set
+# CONFIG_I2C is not set
+# CONFIG_SPI is not set
+# CONFIG_I2S is not set
+# CONFIG_TIMER is not set
+# CONFIG_RTC is not set
+# CONFIG_WATCHDOG is not set
+# CONFIG_ANALOG is not set
+# CONFIG_AUDIO_DEVICES is not set
+# CONFIG_VIDEO_DEVICES is not set
+# CONFIG_BCH is not set
+# CONFIG_INPUT is not set
+# CONFIG_LCD is not set
+CONFIG_MMCSD=y
+CONFIG_MMCSD_NSLOTS=1
+# CONFIG_MMCSD_READONLY is not set
+# CONFIG_MMCSD_MULTIBLOCK_DISABLE is not set
+CONFIG_MMCSD_MMCSUPPORT=y
+CONFIG_MMCSD_HAVECARDDETECT=y
+# CONFIG_ARCH_HAVE_SDIO is not set
+# CONFIG_ARCH_HAVE_SDIOWAIT_WRCOMPLETE is not set
+CONFIG_MTD=y
+
+#
+# MTD Configuration
+#
+# CONFIG_MTD_PARTITION is not set
+# CONFIG_MTD_SECT512 is not set
+# CONFIG_MTD_BYTE_WRITE is not set
+# CONFIG_MTD_CONFIG is not set
+
+#
+# MTD Device Drivers
+#
+# CONFIG_MTD_NAND is not set
+# CONFIG_RAMMTD is not set
+# CONFIG_MTD_AT24XX is not set
+# CONFIG_MTD_AT25 is not set
+# CONFIG_MTD_AT45DB is not set
+# CONFIG_MTD_M25P is not set
+# CONFIG_MTD_SMART is not set
+# CONFIG_MTD_RAMTRON is not set
+# CONFIG_MTD_SST25 is not set
+# CONFIG_MTD_SST25XX is not set
+# CONFIG_MTD_SST39FV is not set
+# CONFIG_MTD_W25 is not set
+# CONFIG_EEPROM is not set
+# CONFIG_PIPES is not set
+# CONFIG_PM is not set
+# CONFIG_POWER is not set
+# CONFIG_SENSORS is not set
+# CONFIG_SERCOMM_CONSOLE is not set
+CONFIG_SERIAL=y
+# CONFIG_DEV_LOWCONSOLE is not set
+# CONFIG_16550_UART is not set
+# CONFIG_ARCH_HAVE_UART is not set
+# CONFIG_ARCH_HAVE_UART0 is not set
+CONFIG_ARCH_HAVE_UART1=y
+# CONFIG_ARCH_HAVE_UART2 is not set
+# CONFIG_ARCH_HAVE_UART3 is not set
+# CONFIG_ARCH_HAVE_UART4 is not set
+# CONFIG_ARCH_HAVE_UART5 is not set
+# CONFIG_ARCH_HAVE_UART6 is not set
+# CONFIG_ARCH_HAVE_UART7 is not set
+# CONFIG_ARCH_HAVE_UART8 is not set
+# CONFIG_ARCH_HAVE_SCI0 is not set
+# CONFIG_ARCH_HAVE_SCI1 is not set
+# CONFIG_ARCH_HAVE_USART0 is not set
+# CONFIG_ARCH_HAVE_USART1 is not set
+# CONFIG_ARCH_HAVE_USART2 is not set
+# CONFIG_ARCH_HAVE_USART3 is not set
+# CONFIG_ARCH_HAVE_USART4 is not set
+# CONFIG_ARCH_HAVE_USART5 is not set
+# CONFIG_ARCH_HAVE_USART6 is not set
+# CONFIG_ARCH_HAVE_USART7 is not set
+# CONFIG_ARCH_HAVE_USART8 is not set
+# CONFIG_ARCH_HAVE_OTHER_UART is not set
+
+#
+# USART Configuration
+#
+CONFIG_MCU_SERIAL=y
+CONFIG_STANDARD_SERIAL=y
+# CONFIG_SERIAL_IFLOWCONTROL is not set
+# CONFIG_SERIAL_OFLOWCONTROL is not set
+CONFIG_ARCH_HAVE_SERIAL_TERMIOS=y
+# CONFIG_SERIAL_TERMIOS is not set
+CONFIG_UART1_SERIAL_CONSOLE=y
+# CONFIG_OTHER_SERIAL_CONSOLE is not set
+# CONFIG_NO_SERIAL_CONSOLE is not set
+
+#
+# UART1 Configuration
+#
+CONFIG_UART1_RXBUFSIZE=256
+CONFIG_UART1_TXBUFSIZE=256
+CONFIG_UART1_BAUD=115200
+CONFIG_UART1_BITS=8
+CONFIG_UART1_PARITY=0
+CONFIG_UART1_2STOP=0
+# CONFIG_UART1_IFLOWCONTROL is not set
+# CONFIG_UART1_OFLOWCONTROL is not set
+# CONFIG_USBDEV is not set
+# CONFIG_USBHOST is not set
+# CONFIG_WIRELESS is not set
+
+#
+# System Logging Device Options
+#
+
+#
+# System Logging
+#
+# CONFIG_RAMLOG is not set
+# CONFIG_SYSLOG_CONSOLE is not set
+
+#
+# Networking Support
+#
+# CONFIG_ARCH_HAVE_NET is not set
+# CONFIG_ARCH_HAVE_PHY is not set
+# CONFIG_NET is not set
+
+#
+# Crypto API
+#
+# CONFIG_CRYPTO is not set
+
+#
+# File Systems
+#
+
+#
+# File system configuration
+#
+# CONFIG_DISABLE_MOUNTPOINT is not set
+# CONFIG_FS_AUTOMOUNTER is not set
+# CONFIG_DISABLE_PSEUDOFS_OPERATIONS is not set
+CONFIG_FS_READABLE=y
+CONFIG_FS_WRITABLE=y
+# CONFIG_FS_NAMED_SEMAPHORES is not set
+CONFIG_FS_MQUEUE_MPATH="/var/mqueue"
+# CONFIG_FS_RAMMAP is not set
+CONFIG_FS_FAT=y
+CONFIG_FAT_LCNAMES=y
+CONFIG_FAT_LFN=y
+CONFIG_FAT_MAXFNAME=32
+# CONFIG_FS_FATTIME is not set
+# CONFIG_FAT_DMAMEMORY is not set
+# CONFIG_FS_NXFFS is not set
+# CONFIG_FS_ROMFS is not set
+# CONFIG_FS_SMARTFS is not set
+# CONFIG_FS_BINFS is not set
+# CONFIG_FS_PROCFS is not set
+
+#
+# System Logging
+#
+# CONFIG_SYSLOG is not set
+# CONFIG_SYSLOG_TIMESTAMP is not set
+
+#
+# Graphics Support
+#
+# CONFIG_NX is not set
+
+#
+# Memory Management
+#
+# CONFIG_MM_SMALL is not set
+CONFIG_MM_REGIONS=1
+# CONFIG_ARCH_HAVE_HEAP2 is not set
+# CONFIG_GRAN is not set
+
+#
+# Audio Support
+#
+# CONFIG_AUDIO is not set
+
+#
+# Binary Loader
+#
+# CONFIG_BINFMT_DISABLE is not set
+# CONFIG_BINFMT_EXEPATH is not set
+# CONFIG_NXFLAT is not set
+# CONFIG_ELF is not set
+CONFIG_BUILTIN=y
+# CONFIG_PIC is not set
+# CONFIG_SYMTAB_ORDEREDBYNAME is not set
+
+#
+# Library Routines
+#
+
+#
+# Standard C Library Options
+#
+CONFIG_STDIO_BUFFER_SIZE=64
+CONFIG_STDIO_LINEBUFFER=y
+CONFIG_NUNGET_CHARS=2
+CONFIG_LIB_HOMEDIR="/"
+# CONFIG_LIBM is not set
+# CONFIG_NOPRINTF_FIELDWIDTH is not set
+# CONFIG_LIBC_FLOATINGPOINT is not set
+# CONFIG_LIBC_IOCTL_VARIADIC is not set
+CONFIG_LIB_RAND_ORDER=1
+# CONFIG_EOL_IS_CR is not set
+# CONFIG_EOL_IS_LF is not set
+# CONFIG_EOL_IS_BOTH_CRLF is not set
+CONFIG_EOL_IS_EITHER_CRLF=y
+# CONFIG_LIBC_EXECFUNCS is not set
+CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=1024
+CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=2048
+# CONFIG_LIBC_STRERROR is not set
+# CONFIG_LIBC_PERROR_STDOUT is not set
+CONFIG_LIBC_TMPDIR="/tmp"
+CONFIG_LIBC_MAX_TMPFILE=32
+CONFIG_ARCH_LOWPUTC=y
+# CONFIG_LIBC_LOCALTIME is not set
+CONFIG_LIB_SENDFILE_BUFSIZE=512
+# CONFIG_ARCH_ROMGETC is not set
+# CONFIG_ARCH_OPTIMIZED_FUNCTIONS is not set
+
+#
+# Non-standard Library Support
+#
+# CONFIG_LIB_KBDCODEC is not set
+# CONFIG_LIB_SLCDCODEC is not set
+
+#
+# Basic CXX Support
+#
+# CONFIG_C99_BOOL8 is not set
+# CONFIG_HAVE_CXX is not set
+
+#
+# Application Configuration
+#
+
+#
+# Built-In Applications
+#
+CONFIG_BUILTIN_PROXY_STACKSIZE=1024
+
+#
+# Examples
+#
+# CONFIG_EXAMPLES_BUTTONS is not set
+# CONFIG_EXAMPLES_CAN is not set
+# CONFIG_EXAMPLES_CONFIGDATA is not set
+# CONFIG_EXAMPLES_CPUHOG is not set
+# CONFIG_EXAMPLES_DHCPD is not set
+# CONFIG_EXAMPLES_ELF is not set
+# CONFIG_EXAMPLES_FTPC is not set
+# CONFIG_EXAMPLES_FTPD is not set
+# CONFIG_EXAMPLES_HELLO is not set
+# CONFIG_EXAMPLES_HELLOXX is not set
+# CONFIG_EXAMPLES_JSON is not set
+# CONFIG_EXAMPLES_HIDKBD is not set
+# CONFIG_EXAMPLES_KEYPADTEST is not set
+# CONFIG_EXAMPLES_IGMP is not set
+# CONFIG_EXAMPLES_MM is not set
+# CONFIG_EXAMPLES_MODBUS is not set
+# CONFIG_EXAMPLES_MOUNT is not set
+# CONFIG_EXAMPLES_NRF24L01TERM is not set
+CONFIG_EXAMPLES_NSH=y
+# CONFIG_EXAMPLES_NULL is not set
+# CONFIG_EXAMPLES_NX is not set
+# CONFIG_EXAMPLES_NXTERM is not set
+# CONFIG_EXAMPLES_NXFFS is not set
+# CONFIG_EXAMPLES_NXFLAT is not set
+# CONFIG_EXAMPLES_NXHELLO is not set
+# CONFIG_EXAMPLES_NXIMAGE is not set
+# CONFIG_EXAMPLES_NXLINES is not set
+# CONFIG_EXAMPLES_NXTEXT is not set
+# CONFIG_EXAMPLES_OSTEST is not set
+# CONFIG_EXAMPLES_PIPE is not set
+# CONFIG_EXAMPLES_POSIXSPAWN is not set
+# CONFIG_EXAMPLES_QENCODER is not set
+# CONFIG_EXAMPLES_RGMP is not set
+# CONFIG_EXAMPLES_ROMFS is not set
+# CONFIG_EXAMPLES_SENDMAIL is not set
+# CONFIG_EXAMPLES_SERIALBLASTER is not set
+# CONFIG_EXAMPLES_SERIALRX is not set
+# CONFIG_EXAMPLES_SERLOOP is not set
+# CONFIG_EXAMPLES_SLCD is not set
+# CONFIG_EXAMPLES_SMART_TEST is not set
+# CONFIG_EXAMPLES_SMART is not set
+# CONFIG_EXAMPLES_TCPECHO is not set
+# CONFIG_EXAMPLES_TELNETD is not set
+# CONFIG_EXAMPLES_THTTPD is not set
+# CONFIG_EXAMPLES_TIFF is not set
+# CONFIG_EXAMPLES_TOUCHSCREEN is not set
+# CONFIG_EXAMPLES_WEBSERVER is not set
+# CONFIG_EXAMPLES_USBSERIAL is not set
+# CONFIG_EXAMPLES_USBTERM is not set
+# CONFIG_EXAMPLES_WATCHDOG is not set
+
+#
+# Graphics Support
+#
+# CONFIG_TIFF is not set
+# CONFIG_GRAPHICS_TRAVELER is not set
+
+#
+# Interpreters
+#
+# CONFIG_INTERPRETERS_BAS is not set
+# CONFIG_INTERPRETERS_FICL is not set
+# CONFIG_INTERPRETERS_PCODE is not set
+# CONFIG_INTERPRETERS_MICROPYTHON is not set
+
+#
+# Network Utilities
+#
+
+#
+# Networking Utilities
+#
+# CONFIG_NETUTILS_CODECS is not set
+# CONFIG_NETUTILS_FTPC is not set
+# CONFIG_NETUTILS_FTPD is not set
+# CONFIG_NETUTILS_JSON is not set
+# CONFIG_NETUTILS_SMTP is not set
+# CONFIG_NETUTILS_TFTPC is not set
+# CONFIG_NETUTILS_THTTPD is not set
+# CONFIG_NETUTILS_NETLIB is not set
+# CONFIG_NETUTILS_WEBCLIENT is not set
+
+#
+# FreeModBus
+#
+# CONFIG_MODBUS is not set
+
+#
+# NSH Library
+#
+CONFIG_NSH_LIBRARY=y
+
+#
+# Command Line Configuration
+#
+CONFIG_NSH_READLINE=y
+# CONFIG_NSH_CLE is not set
+CONFIG_NSH_LINELEN=64
+# CONFIG_NSH_DISABLE_SEMICOLON is not set
+CONFIG_NSH_CMDPARMS=y
+CONFIG_NSH_MAXARGUMENTS=6
+CONFIG_NSH_ARGCAT=y
+CONFIG_NSH_NESTDEPTH=3
+# CONFIG_NSH_DISABLEBG is not set
+CONFIG_NSH_BUILTIN_APPS=y
+
+#
+# Disable Individual commands
+#
+# CONFIG_NSH_DISABLE_ADDROUTE is not set
+# CONFIG_NSH_DISABLE_CAT is not set
+# CONFIG_NSH_DISABLE_CD is not set
+# CONFIG_NSH_DISABLE_CP is not set
+# CONFIG_NSH_DISABLE_CMP is not set
+# CONFIG_NSH_DISABLE_DD is not set
+# CONFIG_NSH_DISABLE_DF is not set
+# CONFIG_NSH_DISABLE_DELROUTE is not set
+# CONFIG_NSH_DISABLE_ECHO is not set
+# CONFIG_NSH_DISABLE_EXEC is not set
+# CONFIG_NSH_DISABLE_EXIT is not set
+# CONFIG_NSH_DISABLE_FREE is not set
+# CONFIG_NSH_DISABLE_GET is not set
+# CONFIG_NSH_DISABLE_HELP is not set
+# CONFIG_NSH_DISABLE_HEXDUMP is not set
+# CONFIG_NSH_DISABLE_IFCONFIG is not set
+# CONFIG_NSH_DISABLE_KILL is not set
+# CONFIG_NSH_DISABLE_LOSETUP is not set
+# CONFIG_NSH_DISABLE_LS is not set
+# CONFIG_NSH_DISABLE_MB is not set
+# CONFIG_NSH_DISABLE_MKDIR is not set
+# CONFIG_NSH_DISABLE_MKFATFS is not set
+# CONFIG_NSH_DISABLE_MKFIFO is not set
+# CONFIG_NSH_DISABLE_MKRD is not set
+# CONFIG_NSH_DISABLE_MH is not set
+# CONFIG_NSH_DISABLE_MOUNT is not set
+# CONFIG_NSH_DISABLE_MW is not set
+# CONFIG_NSH_DISABLE_PS is not set
+# CONFIG_NSH_DISABLE_PUT is not set
+# CONFIG_NSH_DISABLE_PWD is not set
+# CONFIG_NSH_DISABLE_RM is not set
+# CONFIG_NSH_DISABLE_RMDIR is not set
+# CONFIG_NSH_DISABLE_SET is not set
+# CONFIG_NSH_DISABLE_SH is not set
+# CONFIG_NSH_DISABLE_SLEEP is not set
+# CONFIG_NSH_DISABLE_TEST is not set
+# CONFIG_NSH_DISABLE_UMOUNT is not set
+# CONFIG_NSH_DISABLE_UNSET is not set
+# CONFIG_NSH_DISABLE_USLEEP is not set
+# CONFIG_NSH_DISABLE_WGET is not set
+# CONFIG_NSH_DISABLE_XD is not set
+
+#
+# Configure Command Options
+#
+CONFIG_NSH_CMDOPT_DF_H=y
+CONFIG_NSH_CODECS_BUFSIZE=128
+CONFIG_NSH_CMDOPT_HEXDUMP=y
+CONFIG_NSH_FILEIOSIZE=512
+
+#
+# Scripting Support
+#
+# CONFIG_NSH_DISABLESCRIPT is not set
+# CONFIG_NSH_DISABLE_ITEF is not set
+# CONFIG_NSH_DISABLE_LOOPS is not set
+
+#
+# Console Configuration
+#
+CONFIG_NSH_CONSOLE=y
+# CONFIG_NSH_ALTCONDEV is not set
+CONFIG_NSH_ARCHINIT=y
+
+#
+# NxWidgets/NxWM
+#
+
+#
+# Platform-specific Support
+#
+# CONFIG_PLATFORM_CONFIGDATA is not set
+
+#
+# System Libraries and NSH Add-Ons
+#
+
+#
+# Custom Free Memory Command
+#
+# CONFIG_SYSTEM_FREE is not set
+
+#
+# EMACS-like Command Line Editor
+#
+# CONFIG_SYSTEM_CLE is not set
+
+#
+# CU Minimal Terminal
+#
+# CONFIG_SYSTEM_CUTERM is not set
+
+#
+# FLASH Program Installation
+#
+# CONFIG_SYSTEM_INSTALL is not set
+
+#
+# FLASH Erase-all Command
+#
+# CONFIG_SYSTEM_FLASH_ERASEALL is not set
+
+#
+# Intel HEX to binary conversion
+#
+# CONFIG_SYSTEM_HEX2BIN is not set
+
+#
+# I2C tool
+#
+
+#
+# INI File Parser
+#
+# CONFIG_SYSTEM_INIFILE is not set
+
+#
+# NxPlayer media player library / command Line
+#
+
+#
+# RAM test
+#
+# CONFIG_SYSTEM_RAMTEST is not set
+
+#
+# readline()
+#
+CONFIG_SYSTEM_READLINE=y
+CONFIG_READLINE_ECHO=y
+
+#
+# P-Code Support
+#
+
+#
+# PHY Tool
+#
+
+#
+# Power Off
+#
+# CONFIG_SYSTEM_POWEROFF is not set
+
+#
+# RAMTRON
+#
+# CONFIG_SYSTEM_RAMTRON is not set
+
+#
+# SD Card
+#
+# CONFIG_SYSTEM_SDCARD is not set
+
+#
+# Sudoku
+#
+# CONFIG_SYSTEM_SUDOKU is not set
+
+#
+# Sysinfo
+#
+# CONFIG_SYSTEM_SYSINFO is not set
+
+#
+# Temperature
+#
+
+#
+# VI Work-Alike Editor
+#
+# CONFIG_SYSTEM_VI is not set
+
+#
+# Stack Monitor
+#
+
+#
+# USB CDC/ACM Device Commands
+#
+
+#
+# USB Composite Device Commands
+#
+
+#
+# USB Mass Storage Device Commands
+#
+
+#
+# USB Monitor
+#
+
+#
+# Zmodem Commands
+#
+# CONFIG_SYSTEM_ZMODEM is not set
diff --git a/nuttx/configs/pic32mz-starterkit/nsh/setenv.sh b/nuttx/configs/pic32mz-starterkit/nsh/setenv.sh
new file mode 100755
index 000000000..4f8b724d0
--- /dev/null
+++ b/nuttx/configs/pic32mz-starterkit/nsh/setenv.sh
@@ -0,0 +1,66 @@
+#!/bin/bash
+# configs/pic32mz-starterkit/nsh/setenv.sh
+#
+# Copyright (C) 2015 Gregory Nutt. All rights reserved.
+# Author: Gregory Nutt <gnutt@nuttx.org>
+#
+# 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.
+#
+
+if [ "$_" = "$0" ] ; then
+ echo "You must source this script, not run it!" 1>&2
+ exit 1
+fi
+
+if [ -z "${PATH_ORIG}" ]; then export PATH_ORIG="${PATH}"; fi
+
+WD=`pwd`
+if [ ! -x "setenv.sh" ]; then
+ echo "This script must be executed from the top-level NuttX build directory"
+ exit 1
+fi
+
+# This is the Cygwin path to the location where I installed the MicroChip
+# PIC32MZ toolchain under windows. This is *not* the default install
+# location so you will probably have to edit this. You will also have
+# to edit this if you install a different version of if you install
+# the Linux PIC32MZ toolchain as well
+export TOOLCHAIN_PREBIN="/cygdrive/c/MicroChip/mplabc32/v1.12/bin":
+
+# This is where I have the Pinquino toolchain installed
+# Careful with the ordering in the PATH variable... there is an incompatible
+# version of make in this directory too!
+#export TOOLCHAIN_POSTBIN=:"/cygdrive/c/pinguino-11/compilers/p32/bin"
+
+# This is the path to the tools subdirectory
+export PIC32TOOL_DIR="${WD}/tools/pic32mz"
+
+# Add the path to the toolchain to the PATH varialble
+export PATH="${TOOLCHAIN_PREBIN}${PIC32TOOL_DIR}:/sbin:/usr/sbin:${PATH_ORIG}${TOOLCHAIN_POSTBIN}"
+
+echo "PATH : ${PATH}"
diff --git a/nuttx/configs/pic32mz-starterkit/scripts/c32-release.ld b/nuttx/configs/pic32mz-starterkit/scripts/c32-release.ld
new file mode 100644
index 000000000..b385bc21a
--- /dev/null
+++ b/nuttx/configs/pic32mz-starterkit/scripts/c32-release.ld
@@ -0,0 +1,318 @@
+/****************************************************************************
+ * configs/pic32mz-starterkit/nsh/ld.script
+ *
+ * Copyright (C) 2015 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
+ *
+ * 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.
+ *
+ ****************************************************************************/
+/* Memory Regions ***********************************************************/
+
+MEMORY
+{
+ /* The PIC32MZ2048ECH144 and PIC32MZ2048ECM144 chips have has 2048Kb of
+ * program FLASH at physical address 0x1d000000 but is always accessed
+ * at KSEG0 address 0x9d00:0000
+ */
+
+ kseg0_progmem (rx) : ORIGIN = 0x9d000000, LENGTH = 2048K
+
+ /* The PIC32MZ2048ECH144 and PIC32MZ2048ECM144 chips have 160Kb of boot
+ * FLASH at physical address 0x1fc00000. The initial reset vector is in
+ * KSEG1, but all other accesses are in KSEG0.
+ *
+ * REGION PHYSICAL KSEG SIZE
+ * DESCRIPTION START ADDR (BYTES)
+ * ------------- ---------- ------ ----------------------
+ * Exceptions:*
+ * Reset 0x1fc00000 KSEG1 512 512
+ * TLB Refill 0x1fc00200 KSEG1 256 768
+ * Cache Error 0x1fc00300 KSEG1 128 896
+ * Others 0x1fc00380 KSEG1 128 1024 (1Kb)
+ * Interrupt 0x1fc00400 KSEG1 128 1152
+ * JTAG 0x1fc00480 KSEG1 16 1168
+ * Exceptions 0x1fc00490 KSEG0 8192-1168 8192 (4Kb)
+ * Debug code 0x1fc02000 KSEG1 4096-16 12272
+ * DEVCFG3-0 0x1fc0ff40 KSEG1 16 12288 (12Kb)
+ *
+ * Exceptions assume:
+ *
+ * STATUS: BEV=0/1 and EXL=0
+ * CAUSE: IV=1
+ * JTAG: ProbEn=0
+ * And multi-vector support disabled
+ */
+
+ kseg1_reset (rx) : ORIGIN = 0xbfc00000, LENGTH = 384
+ kseg1_genexcpt (rx) : ORIGIN = 0xbfc00180, LENGTH = 128
+ kseg1_ebexcpt (rx) : ORIGIN = 0xbfc00200, LENGTH = 128
+ kseg1_bevexcpt (rx) : ORIGIN = 0xbfc00380, LENGTH = 128
+ kseg1_intexcpt (rx) : ORIGIN = 0xbfc00400, LENGTH = 128
+ kseg1_dbgexcpt (rx) : ORIGIN = 0xbfc00480, LENGTH = 16
+ kseg0_bootmem (rx) : ORIGIN = 0x9fc00490, LENGTH = 8192-1168
+ kseg1_dbgcode (rx) : ORIGIN = 0xbfc02000, LENGTH = 4096-16
+ kseg1_devcfg (r) : ORIGIN = 0x1fc0ff40, LENGTH = 192
+
+ /* The The PIC32MZ2048ECH144 and PIC32MZ2048ECM144 chips have has 512Kb
+ * of data memory at physical address 0x00000000. Since the PIC32MZ
+ * has no data cache, this memory is always accessed through KSEG1.
+ *
+ * When used with MPLAB, we need to set aside 512 bytes of memory
+ * for use by MPLAB.
+ */
+
+ kseg1_datamem (w!x) : ORIGIN = 0xa0000200, LENGTH = 512K - 512
+}
+
+OUTPUT_FORMAT("elf32-tradlittlemips")
+OUTPUT_ARCH(pic32mz)
+ENTRY(__start)
+
+SECTIONS
+{
+ /* Boot FLASH sections */
+
+ .reset :
+ {
+ KEEP (*(.reset))
+ } > kseg1_reset
+
+ /* Exception handlers. The following is assumed:
+ *
+ * STATUS: BEV=1 and EXL=0
+ * CAUSE: IV=1
+ * JTAG: ProbEn=0
+ * And multi-vector support disabled
+ *
+ * In that configuration, the vector locations become:
+ *
+ * Reset, Soft Reset bfc0:0000
+ * TLB Refill bfc0:0200
+ * Cache Error bfc0:0300
+ * All others bfc0:0380
+ * Interrupt bfc0:0400
+ * EJTAG Debug bfc0:0480
+ */
+
+ /* KSEG1 exception handler "trampolines" */
+
+ .gen_excpt :
+ {
+ KEEP (*(.gen_excpt))
+ } > kseg1_genexcpt
+
+ .ebase_excpt :
+ {
+ KEEP (*(.ebase_excpt))
+ } > kseg1_ebexcpt
+
+ .bev_excpt :
+ {
+ KEEP (*(.bev_excpt))
+ } > kseg1_bevexcpt
+
+ .int_excpt :
+ {
+ KEEP (*(.int_excpt))
+ } > kseg1_intexcpt
+
+ .dbg_excpt = ORIGIN(kseg1_dbgexcpt);
+
+ .start :
+ {
+ /* KSEG0 Reset startup logic */
+
+ *(.start)
+
+ /* KSEG0 exception handlers */
+
+ *(.nmi_handler)
+ *(.bev_handler)
+ *(.int_handler)
+ } > kseg0_bootmem
+
+ .dbg_code = ORIGIN(kseg1_dbgcode);
+
+ .devcfg :
+ {
+ KEEP (*(.devcfg))
+ } > kseg1_devcfg
+
+ /* Program FLASH sections */
+
+ .text :
+ {
+ _stext = ABSOLUTE(.);
+ *(.text .text.*)
+ *(.stub)
+ KEEP (*(.text.*personality*))
+ *(.gnu.linkonce.t.*)
+ *(.gnu.warning)
+ *(.mips16.fn.*)
+ *(.mips16.call.*)
+
+ /* Read-only data is included in the text section */
+
+ *(.rodata .rodata.*)
+ *(.rodata1)
+ *(.gnu.linkonce.r.*)
+
+ /* Small initialized constant global and static data */
+
+ *(.sdata2 .sdata2.*)
+ *(.gnu.linkonce.s2.*)
+
+ /* Uninitialized constant global and static data */
+
+ *(.sbss2 .sbss2.*)
+ *(.gnu.linkonce.sb2.*)
+ _etext = ABSOLUTE(.);
+ } > kseg0_progmem
+
+ /* Initialization data begins here in progmem */
+
+ _data_loaddr = LOADADDR(.data);
+
+ .eh_frame_hdr : { *(.eh_frame_hdr) }
+ .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }
+
+ /* RAM functions are positioned at the beginning of RAM so that
+ * they can be guaranteed to satisfy the 2Kb alignment requirement.
+ */
+
+/* This causes failures if there are no RAM functions
+ .ramfunc ALIGN(2K) :
+ {
+ _sramfunc = ABSOLUTE(.);
+ *(.ramfunc .ramfunc.*)
+ _eramfunc = ABSOLUTE(.);
+ } > kseg1_datamem AT > kseg0_progmem
+
+ _ramfunc_loadaddr = LOADADDR(.ramfunc);
+ _ramfunc_sizeof = SIZEOF(.ramfunc);
+ _bmxdkpba_address = _sramfunc - ORIGIN(kseg1_datamem) ;
+ _bmxdudba_address = LENGTH(kseg1_datamem) ;
+ _bmxdupba_address = LENGTH(kseg1_datamem) ;
+*/
+
+ .data :
+ {
+ _sdata = ABSOLUTE(.);
+ *(.data .data.*)
+ *(.gnu.linkonce.d.*)
+ KEEP (*(.gnu.linkonce.d.*personality*))
+ *(.data1)
+ } > kseg1_datamem AT > kseg0_progmem
+
+ .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }
+ _gp = ALIGN(16) + 0x7FF0 ;
+
+ .got :
+ {
+ *(.got.plt) *(.got)
+ } > kseg1_datamem AT > kseg0_progmem
+
+ .sdata :
+ {
+ *(.sdata .sdata.* .gnu.linkonce.s.*)
+ } > kseg1_datamem AT > kseg0_progmem
+
+ .lit8 :
+ {
+ *(.lit8)
+ } > kseg1_datamem AT > kseg0_progmem
+
+ .lit4 :
+ {
+ *(.lit4)
+ _edata = ABSOLUTE(.);
+ } >kseg1_datamem AT>kseg0_progmem
+
+ .sbss :
+ {
+ _sbss = ABSOLUTE(.);
+ *(.dynsbss)
+ *(.sbss .sbss.* .gnu.linkonce.sb.*)
+ *(.scommon)
+ } >kseg1_datamem
+
+ .bss :
+ {
+ *(.dynbss)
+ *(.bss .bss.*)
+ *(.gnu.linkonce.b.*)
+ *(COMMON)
+ _ebss = ABSOLUTE(.);
+ } > kseg1_datamem
+
+ /* Stabs debugging sections */
+
+ .stab 0 : { *(.stab) }
+ .stabstr 0 : { *(.stabstr) }
+ .stab.excl 0 : { *(.stab.excl) }
+ .stab.exclstr 0 : { *(.stab.exclstr) }
+ .stab.index 0 : { *(.stab.index) }
+ .stab.indexstr 0 : { *(.stab.indexstr) }
+ .comment 0 : { *(.comment) }
+
+ /* DWARF debug sections */
+ /* DWARF 1 */
+
+ .debug 0 : { *(.debug) }
+ .line 0 : { *(.line) }
+
+ /* GNU DWARF 1 extensions */
+
+ .debug_srcinfo 0 : { *(.debug_srcinfo) }
+ .debug_sfnames 0 : { *(.debug_sfnames) }
+
+ /* DWARF 1.1 and DWARF 2 */
+
+ .debug_aranges 0 : { *(.debug_aranges) }
+ .debug_pubnames 0 : { *(.debug_pubnames) }
+
+ /* DWARF 2 */
+
+ .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
+ .debug_abbrev 0 : { *(.debug_abbrev) }
+ .debug_line 0 : { *(.debug_line) }
+ .debug_frame 0 : { *(.debug_frame) }
+ .debug_str 0 : { *(.debug_str) }
+ .debug_loc 0 : { *(.debug_loc) }
+ .debug_macinfo 0 : { *(.debug_macinfo) }
+
+ /* SGI/MIPS DWARF 2 extensions */
+
+ .debug_weaknames 0 : { *(.debug_weaknames) }
+ .debug_funcnames 0 : { *(.debug_funcnames) }
+ .debug_typenames 0 : { *(.debug_typenames) }
+ .debug_varnames 0 : { *(.debug_varnames) }
+
+ /DISCARD/ : { *(.note.GNU-stack) }
+}
diff --git a/nuttx/configs/pic32mz-starterkit/scripts/mips-release.ld b/nuttx/configs/pic32mz-starterkit/scripts/mips-release.ld
new file mode 100644
index 000000000..94ed775a4
--- /dev/null
+++ b/nuttx/configs/pic32mz-starterkit/scripts/mips-release.ld
@@ -0,0 +1,318 @@
+/****************************************************************************
+ * configs/pic32mz-starterkit/nsh/ld.script
+ *
+ * Copyright (C) 2015 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
+ *
+ * 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.
+ *
+ ****************************************************************************/
+/* Memory Regions ***********************************************************/
+
+MEMORY
+{
+ /* The PIC32MZ2048ECH144 and PIC32MZ2048ECM144 chips have has 2048Kb of
+ * program FLASH at physical address 0x1d000000 but is always accessed
+ * at KSEG0 address 0x9d00:0000
+ */
+
+ kseg0_progmem (rx) : ORIGIN = 0x9d000000, LENGTH = 2048K
+
+ /* The PIC32MZ2048ECH144 and PIC32MZ2048ECM144 chips have 160Kb of boot
+ * FLASH at physical address 0x1fc00000. The initial reset vector is in
+ * KSEG1, but all other accesses are in KSEG0.
+ *
+ * REGION PHYSICAL KSEG SIZE
+ * DESCRIPTION START ADDR (BYTES)
+ * ------------- ---------- ------ ----------------------
+ * Exceptions:*
+ * Reset 0x1fc00000 KSEG1 512 512
+ * TLB Refill 0x1fc00200 KSEG1 256 768
+ * Cache Error 0x1fc00300 KSEG1 128 896
+ * Others 0x1fc00380 KSEG1 128 1024 (1Kb)
+ * Interrupt 0x1fc00400 KSEG1 128 1152
+ * JTAG 0x1fc00480 KSEG1 16 1168
+ * Exceptions 0x1fc00490 KSEG0 8192-1168 8192 (4Kb)
+ * Debug code 0x1fc02000 KSEG1 4096-16 12272
+ * DEVCFG3-0 0x1fc0ff40 KSEG1 16 12288 (12Kb)
+ *
+ * Exceptions assume:
+ *
+ * STATUS: BEV=0/1 and EXL=0
+ * CAUSE: IV=1
+ * JTAG: ProbEn=0
+ * And multi-vector support disabled
+ */
+
+ kseg1_reset (rx) : ORIGIN = 0xbfc00000, LENGTH = 384
+ kseg1_genexcpt (rx) : ORIGIN = 0xbfc00180, LENGTH = 128
+ kseg1_ebexcpt (rx) : ORIGIN = 0xbfc00200, LENGTH = 128
+ kseg1_bevexcpt (rx) : ORIGIN = 0xbfc00380, LENGTH = 128
+ kseg1_intexcpt (rx) : ORIGIN = 0xbfc00400, LENGTH = 128
+ kseg1_dbgexcpt (rx) : ORIGIN = 0xbfc00480, LENGTH = 16
+ kseg0_bootmem (rx) : ORIGIN = 0x9fc00490, LENGTH = 8192-1168
+ kseg1_dbgcode (rx) : ORIGIN = 0xbfc02000, LENGTH = 4096-16
+ kseg1_devcfg (r) : ORIGIN = 0x1fc0ff40, LENGTH = 192
+
+ /* The The PIC32MZ2048ECH144 and PIC32MZ2048ECM144 chips have has 512Kb
+ * of data memory at physical address 0x00000000. Since the PIC32MZ
+ * has no data cache, this memory is always accessed through KSEG1.
+ *
+ * When used with MPLAB, we need to set aside 512 bytes of memory
+ * for use by MPLAB.
+ */
+
+ kseg1_datamem (w!x) : ORIGIN = 0xa0000200, LENGTH = 512K - 512
+}
+
+OUTPUT_FORMAT("elf32-littlemips")
+OUTPUT_ARCH(mips)
+ENTRY(__start)
+
+SECTIONS
+{
+ /* Boot FLASH sections */
+
+ .reset :
+ {
+ KEEP (*(.reset))
+ } > kseg1_reset
+
+ /* Exception handlers. The following is assumed:
+ *
+ * STATUS: BEV=1 and EXL=0
+ * CAUSE: IV=1
+ * JTAG: ProbEn=0
+ * And multi-vector support disabled
+ *
+ * In that configuration, the vector locations become:
+ *
+ * Reset, Soft Reset bfc0:0000
+ * TLB Refill bfc0:0200
+ * Cache Error bfc0:0300
+ * All others bfc0:0380
+ * Interrupt bfc0:0400
+ * EJTAG Debug bfc0:0480
+ */
+
+ /* KSEG1 exception handler "trampolines" */
+
+ .gen_excpt :
+ {
+ KEEP (*(.gen_excpt))
+ } > kseg1_genexcpt
+
+ .ebase_excpt :
+ {
+ KEEP (*(.ebase_excpt))
+ } > kseg1_ebexcpt
+
+ .bev_excpt :
+ {
+ KEEP (*(.bev_excpt))
+ } > kseg1_bevexcpt
+
+ .int_excpt :
+ {
+ KEEP (*(.int_excpt))
+ } > kseg1_intexcpt
+
+ .dbg_excpt = ORIGIN(kseg1_dbgexcpt);
+
+ .start :
+ {
+ /* KSEG0 Reset startup logic */
+
+ *(.start)
+
+ /* KSEG0 exception handlers */
+
+ *(.nmi_handler)
+ *(.bev_handler)
+ *(.int_handler)
+ } > kseg0_bootmem
+
+ .dbg_code = ORIGIN(kseg1_dbgcode);
+
+ .devcfg :
+ {
+ KEEP (*(.devcfg))
+ } > kseg1_devcfg
+
+ /* Program FLASH sections */
+
+ .text :
+ {
+ _stext = ABSOLUTE(.);
+ *(.text .text.*)
+ *(.stub)
+ KEEP (*(.text.*personality*))
+ *(.gnu.linkonce.t.*)
+ *(.gnu.warning)
+ *(.mips16.fn.*)
+ *(.mips16.call.*)
+
+ /* Read-only data is included in the text section */
+
+ *(.rodata .rodata.*)
+ *(.rodata1)
+ *(.gnu.linkonce.r.*)
+
+ /* Small initialized constant global and static data */
+
+ *(.sdata2 .sdata2.*)
+ *(.gnu.linkonce.s2.*)
+
+ /* Uninitialized constant global and static data */
+
+ *(.sbss2 .sbss2.*)
+ *(.gnu.linkonce.sb2.*)
+ _etext = ABSOLUTE(.);
+ } > kseg0_progmem
+
+ /* Initialization data begins here in progmem */
+
+ _data_loaddr = LOADADDR(.data);
+
+ .eh_frame_hdr : { *(.eh_frame_hdr) }
+ .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }
+
+ /* RAM functions are positioned at the beginning of RAM so that
+ * they can be guaranteed to satisfy the 2Kb alignment requirement.
+ */
+
+/* This causes failures if there are no RAM functions
+ .ramfunc ALIGN(2K) :
+ {
+ _sramfunc = ABSOLUTE(.);
+ *(.ramfunc .ramfunc.*)
+ _eramfunc = ABSOLUTE(.);
+ } > kseg1_datamem AT > kseg0_progmem
+
+ _ramfunc_loadaddr = LOADADDR(.ramfunc);
+ _ramfunc_sizeof = SIZEOF(.ramfunc);
+ _bmxdkpba_address = _sramfunc - ORIGIN(kseg1_datamem) ;
+ _bmxdudba_address = LENGTH(kseg1_datamem) ;
+ _bmxdupba_address = LENGTH(kseg1_datamem) ;
+*/
+
+ .data :
+ {
+ _sdata = ABSOLUTE(.);
+ *(.data .data.*)
+ *(.gnu.linkonce.d.*)
+ KEEP (*(.gnu.linkonce.d.*personality*))
+ *(.data1)
+ } > kseg1_datamem AT > kseg0_progmem
+
+ .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }
+ _gp = ALIGN(16) + 0x7FF0 ;
+
+ .got :
+ {
+ *(.got.plt) *(.got)
+ } > kseg1_datamem AT > kseg0_progmem
+
+ .sdata :
+ {
+ *(.sdata .sdata.* .gnu.linkonce.s.*)
+ } > kseg1_datamem AT > kseg0_progmem
+
+ .lit8 :
+ {
+ *(.lit8)
+ } > kseg1_datamem AT > kseg0_progmem
+
+ .lit4 :
+ {
+ *(.lit4)
+ _edata = ABSOLUTE(.);
+ } >kseg1_datamem AT>kseg0_progmem
+
+ .sbss :
+ {
+ _sbss = ABSOLUTE(.);
+ *(.dynsbss)
+ *(.sbss .sbss.* .gnu.linkonce.sb.*)
+ *(.scommon)
+ } >kseg1_datamem
+
+ .bss :
+ {
+ *(.dynbss)
+ *(.bss .bss.*)
+ *(.gnu.linkonce.b.*)
+ *(COMMON)
+ _ebss = ABSOLUTE(.);
+ } > kseg1_datamem
+
+ /* Stabs debugging sections */
+
+ .stab 0 : { *(.stab) }
+ .stabstr 0 : { *(.stabstr) }
+ .stab.excl 0 : { *(.stab.excl) }
+ .stab.exclstr 0 : { *(.stab.exclstr) }
+ .stab.index 0 : { *(.stab.index) }
+ .stab.indexstr 0 : { *(.stab.indexstr) }
+ .comment 0 : { *(.comment) }
+
+ /* DWARF debug sections */
+ /* DWARF 1 */
+
+ .debug 0 : { *(.debug) }
+ .line 0 : { *(.line) }
+
+ /* GNU DWARF 1 extensions */
+
+ .debug_srcinfo 0 : { *(.debug_srcinfo) }
+ .debug_sfnames 0 : { *(.debug_sfnames) }
+
+ /* DWARF 1.1 and DWARF 2 */
+
+ .debug_aranges 0 : { *(.debug_aranges) }
+ .debug_pubnames 0 : { *(.debug_pubnames) }
+
+ /* DWARF 2 */
+
+ .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
+ .debug_abbrev 0 : { *(.debug_abbrev) }
+ .debug_line 0 : { *(.debug_line) }
+ .debug_frame 0 : { *(.debug_frame) }
+ .debug_str 0 : { *(.debug_str) }
+ .debug_loc 0 : { *(.debug_loc) }
+ .debug_macinfo 0 : { *(.debug_macinfo) }
+
+ /* SGI/MIPS DWARF 2 extensions */
+
+ .debug_weaknames 0 : { *(.debug_weaknames) }
+ .debug_funcnames 0 : { *(.debug_funcnames) }
+ .debug_typenames 0 : { *(.debug_typenames) }
+ .debug_varnames 0 : { *(.debug_varnames) }
+
+ /DISCARD/ : { *(.note.GNU-stack) }
+}
diff --git a/nuttx/configs/pic32mz-starterkit/src/.gitignore b/nuttx/configs/pic32mz-starterkit/src/.gitignore
new file mode 100644
index 000000000..726d936e1
--- /dev/null
+++ b/nuttx/configs/pic32mz-starterkit/src/.gitignore
@@ -0,0 +1,2 @@
+/.depend
+/Make.dep
diff --git a/nuttx/configs/pic32mz-starterkit/src/Makefile b/nuttx/configs/pic32mz-starterkit/src/Makefile
new file mode 100644
index 000000000..e306024b6
--- /dev/null
+++ b/nuttx/configs/pic32mz-starterkit/src/Makefile
@@ -0,0 +1,93 @@
+############################################################################
+# configs/pic32mz-starterkit/src/Makefile
+#
+# Copyright (C) 2015 Gregory Nutt. All rights reserved.
+# Author: Gregory Nutt <gnutt@nuttx.org>
+#
+# 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.
+#
+############################################################################
+
+-include $(TOPDIR)/Make.defs
+
+CFLAGS += -I$(TOPDIR)/sched
+
+ASRCS =
+CSRCS = pic32mz_boot.c pic32mz_bringup.c pic32mz_leds.c pic32mz_spi.c
+
+ifeq ($(CONFIG_ARCH_LEDS),y)
+CSRCS += pic32mz_autoleds.c
+else
+CSRCS += pic32mz_userleds.c
+endif
+
+ifeq ($(CONFIG_NSH_ARCHINIT),y)
+CSRCS += pic32mz_nsh.c
+endif
+
+AOBJS = $(ASRCS:.S=$(OBJEXT))
+COBJS = $(CSRCS:.c=$(OBJEXT))
+
+SRCS = $(ASRCS) $(CSRCS)
+OBJS = $(AOBJS) $(COBJS)
+
+ARCH_SRCDIR = $(TOPDIR)/arch/$(CONFIG_ARCH)/src
+ifeq ($(WINTOOL),y)
+ CFLAGS += -I "${shell cygpath -w $(ARCH_SRCDIR)/chip}" \
+ -I "${shell cygpath -w $(ARCH_SRCDIR)/common}" \
+ -I "${shell cygpath -w $(ARCH_SRCDIR)/mips32}"
+else
+ CFLAGS += -I$(ARCH_SRCDIR)/chip -I$(ARCH_SRCDIR)/common -I$(ARCH_SRCDIR)/mips32
+endif
+
+all: libboard$(LIBEXT)
+
+$(AOBJS): %$(OBJEXT): %.S
+ $(call ASSEMBLE, $<, $@)
+
+$(COBJS) $(LINKOBJS): %$(OBJEXT): %.c
+ $(call COMPILE, $<, $@)
+
+libboard$(LIBEXT): $(OBJS)
+ $(call ARCHIVE, $@, $(OBJS))
+
+.depend: Makefile $(SRCS)
+ $(Q) $(MKDEP) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
+ $(Q) touch $@
+
+depend: .depend
+
+clean:
+ $(call DELFILE, libboard$(LIBEXT))
+ $(call CLEAN)
+
+distclean: clean
+ $(call DELFILE, Make.dep)
+ $(call DELFILE, .depend)
+
+-include Make.dep
diff --git a/nuttx/configs/pic32mz-starterkit/src/pic32mz-starterkit.h b/nuttx/configs/pic32mz-starterkit/src/pic32mz-starterkit.h
new file mode 100644
index 000000000..cc31afe9b
--- /dev/null
+++ b/nuttx/configs/pic32mz-starterkit/src/pic32mz-starterkit.h
@@ -0,0 +1,211 @@
+/****************************************************************************
+ * configs/pic32mz-starterkit/src/pic32mz-starterkit.h
+ *
+ * Copyright (C) 2015 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __CONFIGS_PIC32MZ_STARTERKIT_SRC_PIC32MZ_STARTERKIT_H
+#define __CONFIGS_PIC32MZ_STARTERKIT_SRC_PIC32MZ_STARTERKIT_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+/* Configuration ************************************************************/
+/* Assume that we have MMC/SD */
+
+#define PIC32MZ_HAVE_MMCSD 1
+
+/* 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_PIC32MZ_MMCSDSPIPORTNO
+# undef PIC32MZ_HAVE_MMCSD
+#endif
+
+#define PIC32MZ_MMCSDSPIPORTNO CONFIG_PIC32MZ_MMCSDSPIPORTNO
+#define PIC32MZ_MMCSDSLOTNO 0
+#define PIC32MZ_MMCSDMINOR 0
+
+/* Assume /dev/mmcsd0 */
+
+#define PIC32MZ_MMCSDMINOR 0
+
+/* Can't support MMC/SD features if mountpoints are disabled */
+
+#if defined(CONFIG_DISABLE_MOUNTPOINT)
+# undef PIC32MZ_HAVE_MMCSD
+#endif
+
+/* Make sure that the NSH configuration will support the SD card */
+
+#if defined(PIC32MZ_HAVE_MMCSD) && defined(CONFIG_NSH_ARCHINIT)
+
+ /* Make sure that the NSH configuration uses the correct SPI */
+
+# if !defined(CONFIG_NSH_MMCSDSPIPORTNO)
+# define CONFIG_NSH_MMCSDSPIPORTNO PIC32MZ_MMCSDSPIPORTNO
+# elif CONFIG_NSH_MMCSDSPIPORTNO != PIC32MZ_MMCSDSPIPORTNO
+# warning "CONFIG_PIC32MZ_MMCSDSPIPORTNO does not match CONFIG_NSH_MMCSDSPIPORTNO"
+# undef CONFIG_NSH_MMCSDSPIPORTNO
+# define CONFIG_NSH_MMCSDSPIPORTNO PIC32MZ_MMCSDSPIPORTNO
+# endif
+
+ /* Make sure that the NSH configuration uses the slot */
+
+# if !defined(CONFIG_NSH_MMCSDSLOTNO) || CONFIG_NSH_MMCSDSLOTNO != 0
+# warning "The PIC32 Starter Kit has only one slot (0)"
+# undef CONFIG_NSH_MMCSDSLOTNO
+# define CONFIG_NSH_MMCSDSLOTNO 0
+# endif
+
+ /* Make sure that the correct SPI is enabled in the configuration */
+
+# if PIC32MZ_MMCSDSPIPORTNO == 1 && !defined(CONFIG_PIC32MZ_SPI1)
+# warning "CONFIG_PIC32MZ_SPI1 is not enabled"
+# undef PIC32MZ_HAVE_MMCSD
+# elif PIC32MZ_MMCSDSPIPORTNO == 2 && !defined(CONFIG_PIC32MZ_SPI2)
+# warning "CONFIG_PIC32MZ_SPI2 is not enabled"
+# undef PIC32MZ_HAVE_MMCSD
+# elif PIC32MZ_MMCSDSPIPORTNO == 3 && !defined(CONFIG_PIC32MZ_SPI3)
+# warning "CONFIG_PIC32MZ_SPI3 is not enabled"
+# undef PIC32MZ_HAVE_MMCSD
+# elif PIC32MZ_MMCSDSPIPORTNO == 4 && !defined(CONFIG_PIC32MZ_SPI4)
+# warning "CONFIG_PIC32MZ_SPI4 is not enabled"
+# undef PIC32MZ_HAVE_MMCSD
+# endif
+
+ /* Use the minor number selected in the NSH configuratino */
+
+# ifdef CONFIG_NSH_MMCSDMINOR
+# define PIC32MZ_MMCSDMINOR CONFIG_NSH_MMCSDMINOR
+# endif
+#endif
+
+/* LEDs *********************************************************************/
+/* The PIC32 starter kit has 3 user LEDs
+ *
+ * PIN LED Notes
+ * --- ----- -------------------------
+ * RH0 LED1 High illuminates (RED)
+ * RH1 LED3 High illuminates (YELLOW)
+ * RH2 LED2 High illuminates (GREEN)
+ */
+
+#define GPIO_LED_1 (GPIO_OUTPUT|GPIO_VALUE_ZERO|GPIO_PORTH|GPIO_PIN0)
+#define GPIO_LED_2 (GPIO_OUTPUT|GPIO_VALUE_ZERO|GPIO_PORTH|GPIO_PIN1)
+#define GPIO_LED_3 (GPIO_OUTPUT|GPIO_VALUE_ZERO|GPIO_PORTN|GPIO_PIN2)
+
+/* The PIC32MZ Ethernet Starter kit has 3 user push buttons labelled SW1-3
+ * on the board:
+ *
+ * PIN LED Notes
+ * ---- ---- -------------------------
+ * RB12 SW1 Active-low
+ * RB13 SW2 Active-low
+ * RB14 SW3 Active-low
+ *
+ * The switches do not have any debounce circuitry and require internal pull-
+ * up resistors. When Idle, the switches are pulled high (+3.3V), and they
+ * are grounded when pressed.
+ */
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+#ifndef __ASSEMBLY__
+
+/****************************************************************************
+ * Inline Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+#ifdef __cplusplus
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/************************************************************************************
+ * Name: pic32mz_spiinitialize
+ *
+ * Description:
+ * Called to configure SPI chip select GPIO pins for the PCB Logic board.
+ *
+ ************************************************************************************/
+
+#if defined(CONFIG_PIC32MZ_SPI2)
+void weak_function pic32mz_spiinitialize(void);
+#endif
+
+/************************************************************************************
+ * Name: pic32mz_ledinit
+ *
+ * Description:
+ * Configure on-board LEDs if LED support has been selected.
+ *
+ ************************************************************************************/
+
+#ifdef CONFIG_ARCH_LEDS
+void pic32mz_ledinit(void);
+#endif
+
+/****************************************************************************
+ * Name: pic32mz_bringup
+ *
+ * Description:
+ * Bring up board features
+ *
+ ****************************************************************************/
+
+int pic32mz_bringup(void);
+
+#undef EXTERN
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __ASSEMBLY__ */
+#endif /* __CONFIGS_PIC32MZ_STARTERKIT_SRC_PIC32MZ_STARTERKIT_H */
diff --git a/nuttx/configs/pic32mz-starterkit/src/pic32mz_autoleds.c b/nuttx/configs/pic32mz-starterkit/src/pic32mz_autoleds.c
new file mode 100644
index 000000000..b0188f5fb
--- /dev/null
+++ b/nuttx/configs/pic32mz-starterkit/src/pic32mz_autoleds.c
@@ -0,0 +1,217 @@
+/****************************************************************************
+ * configs/pic32mz-starterkit/src/pic32mz_leds.c
+ *
+ * Copyright (C) 2015 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
+ *
+ * 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 <stdint.h>
+#include <stdbool.h>
+#include <debug.h>
+
+#include <arch/board/board.h>
+
+#include "chip.h"
+#include "up_arch.h"
+#include "up_internal.h"
+
+#include "pic32mz-internal.h"
+#include "pic32mz-ioport.h"
+#include "pic32mz-starterkit.h"
+
+#ifdef CONFIG_ARCH_LEDS
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+/* LED Configuration ********************************************************/
+/* The PIC32MZ Ethernet Starter kit has 3 user LEDs labelled LED1-3 on the
+ * board:
+ *
+ * PIN LED Notes
+ * --- ----- -------------------------
+ * RH0 LED1 High illuminates (RED)
+ * RH1 LED3 High illuminates (YELLOW)
+ * RH2 LED2 High illuminates (GREEN)
+ *
+ * If CONFIG_ARCH_LEDs is defined, then NuttX will control the 3 LEDs
+ * on board the Ethernet Starter Kit. The following definitions
+ * describe how NuttX controls the LEDs:
+ *
+ * ON OFF
+ * ------------------------- ---- ---- ---- ---- ---- ----
+ * LED1 LED2 LED3 LED1 LED2 LED3
+ * ------------------------- ---- ---- ---- ---- ---- ----
+ * LED_STARTED 0 OFF OFF OFF --- --- ---
+ * LED_HEAPALLOCATE 1 ON OFF N/C --- --- ---
+ * LED_IRQSENABLED 2 OFF ON N/C --- --- ---
+ * LED_STACKCREATED 3 ON ON N/C --- --- ---
+ * LED_INIRQ 4 N/C N/C ON N/C N/C OFF
+ * LED_SIGNAL 4 N/C N/C ON N/C N/C OFF
+ * LED_ASSERTION 4 N/C N/C ON N/C N/C OFF
+ * LED_PANIC 5 ON N/C N/C OFF N/C N/C
+ */
+
+/* LED Management Definitions ***********************************************/
+
+#define LED_OFF 0
+#define LED_ON 1
+#define LED_NC 2
+
+/* Debug ********************************************************************/
+
+#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_LEDS)
+# define leddbg lldbg
+# ifdef CONFIG_DEBUG_VERBOSE
+# define ledvdbg lldbg
+# else
+# define ledvdbg(x...)
+# endif
+#else
+# undef CONFIG_DEBUG_LEDS
+# undef CONFIG_DEBUG_VERBOSE
+# define leddbg(x...)
+# define ledvdbg(x...)
+#endif
+
+/****************************************************************************
+ * Private types
+ ****************************************************************************/
+
+struct led_setting_s
+{
+ uint8_t led1 : 2;
+ uint8_t led2 : 2;
+ uint8_t led3 : 2;
+ uint8_t unused : 2;
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+/* If CONFIG_ARCH_LEDS is defined then NuttX will control the LEDs. The
+ * following structures identified the LED settings for each NuttX LED state.
+ */
+
+static const struct led_setting_s g_ledonvalues[LED_NVALUES] =
+{
+ {LED_OFF, LED_OFF, LED_OFF, LED_OFF},
+ {LED_ON, LED_OFF, LED_NC, LED_OFF},
+ {LED_OFF, LED_ON, LED_NC, LED_OFF},
+ {LED_ON, LED_ON, LED_NC, LED_OFF},
+ {LED_NC, LED_NC, LED_ON, LED_OFF},
+ {LED_ON, LED_NC, LED_NC, LED_OFF},
+};
+
+static const struct led_setting_s g_ledoffvalues[LED_NVALUES] =
+{
+ {LED_NC, LED_NC, LED_NC, LED_OFF},
+ {LED_NC, LED_NC, LED_NC, LED_OFF},
+ {LED_NC, LED_NC, LED_NC, LED_OFF},
+ {LED_NC, LED_NC, LED_NC, LED_OFF},
+ {LED_NC, LED_NC, LED_OFF, LED_OFF},
+ {LED_OFF, LED_NC, LED_NC, LED_OFF},
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: pic32mz_setleds
+ ****************************************************************************/
+
+static void pic32mz_setleds(FAR const struct led_setting_s *setting)
+{
+ if (setting->led1 != LED_NC)
+ {
+ pic32mz_gpiowrite(GPIO_LED_1, setting->led1 == LED_ON);
+ }
+
+ if (setting->led2 != LED_NC)
+ {
+ pic32mz_gpiowrite(GPIO_LED_2, setting->led2 == LED_ON);
+ }
+
+ if (setting->led3 != LED_NC)
+ {
+ pic32mz_gpiowrite(GPIO_LED_3, setting->led3 == LED_ON);
+ }
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: pic32mz_ledinit
+ ****************************************************************************/
+
+void pic32mz_ledinit(void)
+{
+ /* Configure output pins */
+
+ pic32mz_configgpio(GPIO_LED_1);
+ pic32mz_configgpio(GPIO_LED_2);
+ pic32mz_configgpio(GPIO_LED_3);
+}
+
+/****************************************************************************
+ * Name: board_led_on
+ ****************************************************************************/
+
+void board_led_on(int led)
+{
+ if ((unsigned)led < LED_NVALUES)
+ {
+ pic32mz_setleds(&g_ledonvalues[led]);
+ }
+}
+
+/****************************************************************************
+ * Name: board_led_off
+ ****************************************************************************/
+
+void board_led_off(int led)
+{
+ if ((unsigned)led < LED_NVALUES)
+ {
+ pic32mz_setleds(&g_ledoffvalues[led]);
+ }
+}
+
+#endif /* CONFIG_ARCH_LEDS */
diff --git a/nuttx/configs/pic32mz-starterkit/src/pic32mz_boot.c b/nuttx/configs/pic32mz-starterkit/src/pic32mz_boot.c
new file mode 100644
index 000000000..8d0b87271
--- /dev/null
+++ b/nuttx/configs/pic32mz-starterkit/src/pic32mz_boot.c
@@ -0,0 +1,115 @@
+/************************************************************************************
+ * configs/pic32mz-starterkit/src/pic32mz_boot.c
+ *
+ * Copyright (C) 2015 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
+ *
+ * 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 <debug.h>
+
+#include <arch/board/board.h>
+
+#include "up_arch.h"
+#include "up_internal.h"
+
+#include "pic32mz-internal.h"
+#include "pic32mz-starterkit.h"
+
+/************************************************************************************
+ * Pre-processor Definitions
+ ************************************************************************************/
+
+/************************************************************************************
+ * Private Functions
+ ************************************************************************************/
+
+/************************************************************************************
+ * Public Functions
+ ************************************************************************************/
+
+/************************************************************************************
+ * Name: pic32mz_boardinitialize
+ *
+ * Description:
+ * All PIC32MZ architectures must provide the following entry point. This entry
+ * point is called early in the initialization -- after all memory has been
+ * configured and mapped but before any devices have been initialized.
+ *
+ ************************************************************************************/
+
+void pic32mz_boardinitialize(void)
+{
+ /* Configure SPI chip selects if 1) at least one SPI is enabled, and 2) the weak
+ * function pic32mz_spiinitialize() has been brought into the link.
+ */
+
+#if defined(CONFIG_PIC32MZ_SPI1) || defined(CONFIG_PIC32MZ_SPI2) || \
+ defined(CONFIG_PIC32MZ_SPI3) || defined(CONFIG_PIC32MZ_SPI4)
+ if (pic32mz_spiinitialize)
+ {
+ pic32mz_spiinitialize();
+ }
+#endif
+
+ /* Configure on-board LEDs if LED support has been selected. */
+
+#ifdef CONFIG_ARCH_LEDS
+ pic32mz_ledinit();
+#endif
+}
+
+/****************************************************************************
+ * Name: board_initialize
+ *
+ * Description:
+ * If CONFIG_BOARD_INITIALIZE is selected, then an additional
+ * initialization call will be performed in the boot-up sequence to a
+ * function called board_initialize(). board_initialize() will be
+ * called immediately after up_intiialize() is called and just before the
+ * initial application is started. This additional initialization phase
+ * may be used, for example, to initialize board-specific device drivers.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_BOARD_INITIALIZE
+void board_initialize(void)
+{
+ /* Perform board initialization */
+
+ (void)pic32mz_bringup();
+}
+#endif /* CONFIG_BOARD_INITIALIZE */
diff --git a/nuttx/configs/pic32mz-starterkit/src/pic32mz_bringup.c b/nuttx/configs/pic32mz-starterkit/src/pic32mz_bringup.c
new file mode 100644
index 000000000..ef899d016
--- /dev/null
+++ b/nuttx/configs/pic32mz-starterkit/src/pic32mz_bringup.c
@@ -0,0 +1,132 @@
+/****************************************************************************
+ * config/pic32mz-starterkit/src/pic32mz_bringup.c
+ *
+ * Copyright (C) 2015 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
+ *
+ * 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 <unistd.h>
+#include <syslog.h>
+#include <errno.h>
+
+#include <nuttx/spi/spi.h>
+#include <nuttx/mmcsd.h>
+
+#include "pic32mz-internal.h"
+#include "pic32mz-starterkit.h"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nsh_sdinitialize
+ *
+ * Description:
+ * Initialize SPI-based microSD.
+ *
+ ****************************************************************************/
+
+#ifdef PIC32MZ_HAVE_MMCSD
+static int nsh_sdinitialize(void)
+{
+ FAR struct spi_dev_s *spi;
+ int ret;
+
+ /* Get the SPI port */
+
+ spi = up_spiinitialize(PIC32MZ_MMCSDSPIPORTNO);
+ if (!spi)
+ {
+ syslog(LOG_ERR, "ERROR: Failed to initialize SPI port %d\n",
+ PIC32MZ_MMCSDSPIPORTNO);
+ ret = -ENODEV;
+ goto errout;
+ }
+
+ syslog(LOG_INFO, "Successfully initialized SPI port %d\n",
+ PIC32MZ_MMCSDSPIPORTNO);
+
+ /* Bind the SPI port to the slot */
+
+ ret = mmcsd_spislotinitialize(PIC32MZ_MMCSDMINOR, PIC32MZ_MMCSLOTNO, spi);
+ if (ret < 0)
+ {
+ syslog(LOG_ERR,
+ "ERROR: Failed to bind SPI port %d to MMC/SD slot %d: %d\n",
+ PIC32MZ_MMCSDSPIPORTNO, PIC32MZ_MMCSLOTNO, ret);
+ goto errout;
+ }
+
+ syslog(LOG_INFO, "Successfully bound SPI port %d to MMC/SD slot %d\n",
+ PIC32MZ_MMCSDSPIPORTNO, PIC32MZ_MMCSLOTNO);
+ return OK;
+
+errout:
+ return ret;
+}
+#else
+# define nsh_sdinitialize() (OK)
+#endif
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: pic32mz_bringup
+ *
+ * Description:
+ * Bring up board features
+ *
+ ****************************************************************************/
+
+int pic32mz_bringup(void)
+{
+ int ret;
+
+ /* Initialize SPI-based microSD */
+
+ ret = nsh_sdinitialize();
+
+ return ret;
+}
diff --git a/nuttx/configs/pic32mz-starterkit/src/pic32mz_nsh.c b/nuttx/configs/pic32mz-starterkit/src/pic32mz_nsh.c
new file mode 100644
index 000000000..9b235d43a
--- /dev/null
+++ b/nuttx/configs/pic32mz-starterkit/src/pic32mz_nsh.c
@@ -0,0 +1,71 @@
+/****************************************************************************
+ * config/pic32mz-starterkit/src/pic32mz_nsh.c
+ *
+ * Copyright (C) 2015 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
+ *
+ * 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 "pic32mz-starterkit.h"
+
+#ifdef CONFIG_NSH_ARCHINIT
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nsh_archinitialize
+ *
+ * Description:
+ * Perform architecture specific initialization
+ *
+ ****************************************************************************/
+
+int nsh_archinitialize(void)
+{
+ /* If CONFIG_BOARD_INITIALIZE is selected then board initialization was
+ * already performed in board_initialize.
+ */
+
+#ifndef CONFIG_BOARD_INITIALIZE
+ return pic32mz_bringup();
+#else
+ return OK;
+#endif
+}
+
+#endif /* CONFIG_NSH_ARCHINIT */
diff --git a/nuttx/configs/pic32mz-starterkit/src/pic32mz_spi.c b/nuttx/configs/pic32mz-starterkit/src/pic32mz_spi.c
new file mode 100644
index 000000000..3e5e7365e
--- /dev/null
+++ b/nuttx/configs/pic32mz-starterkit/src/pic32mz_spi.c
@@ -0,0 +1,222 @@
+/************************************************************************************
+ * configs/pic32mz-starterkit/src/pic32mz_spi.c
+ *
+ * Copyright (C) 2015 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
+ *
+ * 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 <stdint.h>
+#include <stdbool.h>
+#include <debug.h>
+
+#include <nuttx/spi/spi.h>
+#include <arch/board/board.h>
+
+#include "up_arch.h"
+#include "chip.h"
+#include "pic32mz-internal.h"
+#include "pic32mz-starterkit.h"
+
+#if defined(CONFIG_PIC32MZ_SPI1) || defined(CONFIG_PIC32MZ_SPI2) || \
+ defined(CONFIG_PIC32MZ_SPI3) || defined(CONFIG_PIC32MZ_SPI4)
+
+/************************************************************************************
+ * Pre-processor Definitions
+ ************************************************************************************/
+
+/* The following enable debug output from this file (needs CONFIG_DEBUG too).
+ *
+ * CONFIG_SPI_DEBUG - Define to enable basic SPI debug
+ * CONFIG_SPI_VERBOSE - Define to enable verbose SPI debug
+ */
+
+#ifdef CONFIG_SPI_DEBUG
+# define sspdbg lldbg
+# ifdef CONFIG_SPI_VERBOSE
+# define sspvdbg lldbg
+# else
+# define sspvdbg(x...)
+# endif
+#else
+# undef CONFIG_SPI_VERBOSE
+# define sspdbg(x...)
+# define sspvdbg(x...)
+#endif
+
+/************************************************************************************
+ * Private Functions
+ ************************************************************************************/
+
+/************************************************************************************
+ * Public Functions
+ ************************************************************************************/
+
+/************************************************************************************
+ * Name: pic32mz_sspinitialize
+ *
+ * Description:
+ * Called to configure SPI chip select GPIO pins for the Sure PIC32MZ board.
+ *
+ ************************************************************************************/
+
+void weak_function pic32mz_sspinitialize(void)
+{
+ /* Configure the SPI chip select GPIOs */
+
+#warning "Missing logic"
+}
+
+/************************************************************************************
+ * Name: pic32mz_spiNselect, pic32mz_spiNstatus, and pic32mz_spiNcmddata
+ *
+ * Description:
+ * These external functions must be provided by board-specific logic. They are
+ * implementations of the select, status, and cmddata methods of the SPI interface
+ * defined by struct spi_ops_s (see include/nuttx/spi/spi.h). All other methods
+ * including up_spiinitialize()) are provided by common PIC32MZ logic. To use
+ * this common SPI logic on your board:
+ *
+ * 1. Provide logic in pic32mz_boardinitialize() to configure SPI/SSP chip select
+ * pins.
+ * 2. Provide pic32mz_spiNselect() and pic32mz_spiNstatus() functions
+ * in your board-specific logic. These functions will perform chip selection
+ * and status operations using GPIOs in the way your board is configured.
+ * 2. If CONFIG_SPI_CMDDATA is defined in the NuttX configuration, provide
+ * pic32mz_spiNcmddata() functions in your board-specific logic. These
+ * functions will perform cmd/data selection operations using GPIOs in the way
+ * your board is configured.
+ * 3. Add a call to up_spiinitialize() in your low level application
+ * initialization logic
+ * 4. The handle returned by up_spiinitialize() may then be used to bind the
+ * SPI driver to higher level logic (e.g., calling
+ * mmcsd_spislotinitialize(), for example, will bind the SPI driver to
+ * the SPI MMC/SD driver).
+ *
+ ************************************************************************************/
+
+struct spi_dev_s;
+enum spi_dev_e;
+
+#ifdef CONFIG_PIC32MZ_SPI1
+void pic32mz_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
+{
+ sspdbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
+#warning "Missing logic"
+}
+
+uint8_t pic32mz_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
+{
+ sspdbg("Returning nothing\n");
+#warning "Missing logic"
+ return 0;
+}
+#ifdef CONFIG_SPI_CMDDATA
+int pic32mz_spi1cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
+{
+#warning "Missing logic"
+ return 0;
+}
+#endif
+#endif
+
+#ifdef CONFIG_PIC32MZ_SPI1
+void pic32mz_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
+{
+ sspdbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
+#warning "Missing logic"
+}
+
+uint8_t pic32mz_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
+{
+ sspdbg("Returning nothing\n");
+#warning "Missing logic"
+ return 0;
+}
+#ifdef CONFIG_SPI_CMDDATA
+int pic32mz_spi1cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
+{
+#warning "Missing logic"
+ return 0;
+}
+#endif
+#endif
+
+#ifdef CONFIG_PIC32MZ_SPI3
+void pic32mz_spi3select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
+{
+ sspdbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
+#warning "Missing logic"
+}
+
+uint8_t pic32mz_spi3status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
+{
+ sspdbg("Returning nothing\n");
+#warning "Missing logic"
+ return 0;
+}
+#ifdef CONFIG_SPI_CMDDATA
+int pic32mz_spi3cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
+{
+#warning "Missing logic"
+ return 0;
+}
+#endif
+#endif
+
+#ifdef CONFIG_PIC32MZ_SPI4
+void pic32mz_spi4select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
+{
+ sspdbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
+#warning "Missing logic"
+}
+
+uint8_t pic32mz_spi4status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
+{
+ sspdbg("Returning nothing\n");
+#warning "Missing logic"
+ return 0;
+}
+#ifdef CONFIG_SPI_CMDDATA
+int pic32mz_spi4cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
+{
+#warning "Missing logic"
+ return 0;
+}
+#endif
+#endif
+
+#endif /* CONFIG_PIC32MZ_SPI1..4 */
diff --git a/nuttx/configs/pic32mz-starterkit/src/pic32mz_userleds.c b/nuttx/configs/pic32mz-starterkit/src/pic32mz_userleds.c
new file mode 100644
index 000000000..b57e20166
--- /dev/null
+++ b/nuttx/configs/pic32mz-starterkit/src/pic32mz_userleds.c
@@ -0,0 +1,147 @@
+/****************************************************************************
+ * configs/pic32mz-starterkit/src/pic32mz_userleds.c
+ *
+ * Copyright (C) 2015 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
+ *
+ * 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 <stdint.h>
+#include <stdbool.h>
+#include <debug.h>
+
+#include <arch/board/board.h>
+
+#include "chip.h"
+#include "up_arch.h"
+#include "up_internal.h"
+
+#include "pic32mz-internal.h"
+#include "pic32mz-ioport.h"
+#include "pic32mz-starterkit.h"
+
+#ifndef CONFIG_ARCH_LEDS
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+/* LED Configuration ********************************************************/
+/* The PIC32MZ Ethernet Starter kit has 3 user LEDs labelled LED1-3 on the
+ * board:
+ *
+ * PIN LED Notes
+ * --- ----- -------------------------
+ * RH0 LED1 High illuminates (RED)
+ * RH1 LED3 High illuminates (YELLOW)
+ * RH2 LED2 High illuminates (GREEN)
+ *
+ * If CONFIG_ARCH_LEDS is not defined, then the user is free to control the
+ * LEDs through the functions provided in this file
+ */
+
+/* Debug ********************************************************************/
+
+#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_LEDS)
+# define leddbg lldbg
+# ifdef CONFIG_DEBUG_VERBOSE
+# define ledvdbg lldbg
+# else
+# define ledvdbg(x...)
+# endif
+#else
+# undef CONFIG_DEBUG_LEDS
+# undef CONFIG_DEBUG_VERBOSE
+# define leddbg(x...)
+# define ledvdbg(x...)
+#endif
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/* The following array simply maps the PIC32MZ_STARTERKIT_LEDn index values
+ * to the correct LED pin configuration.
+ */
+
+static const uint16_t g_ledpincfg[PIC32MZ_STARTERKIT_NLEDS] =
+{
+ GPIO_LED_1, GPIO_LED_2, GPIO_LED_3
+};
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: pic32mz_ledinit
+ ****************************************************************************/
+
+void pic32mz_ledinit(void)
+{
+ /* Configure output pins */
+
+ pic32mz_configgpio(GPIO_LED_1);
+ pic32mz_configgpio(GPIO_LED_2);
+ pic32mz_configgpio(GPIO_LED_3);
+}
+
+/****************************************************************************
+ * Name: pic32mz_setled
+ ****************************************************************************/
+
+void pic32mz_setled(int led, bool ledon)
+{
+ if ((unsigned)led < PIC32MZ_STARTERKIT_NLEDS)
+ {
+ pic32mz_gpiowrite(g_ledpincfg[led], ledon);
+ }
+}
+
+/****************************************************************************
+ * Name: pic32mz_setleds
+ ****************************************************************************/
+
+void pic32mz_setleds(uint8_t ledset)
+{
+ pic32mz_setled(PIC32MZ_STARTERKIT_LED1,
+ (ledset & PIC32MZ_STARTERKIT_LED1_BIT) != 0);
+ pic32mz_setled(PIC32MZ_STARTERKIT_LED2,
+ (ledset & PIC32MZ_STARTERKIT_LED2_BIT) != 0);
+ pic32mz_setled(PIC32MZ_STARTERKIT_LED3,
+ (ledset & PIC32MZ_STARTERKIT_LED3_BIT) != 0);
+}
+
+#endif /* !CONFIG_ARCH_LEDS */