mirror of
https://github.com/apache/nuttx.git
synced 2026-05-18 08:54:05 +08:00
Add basic board support for the PIC32MZ (can't build yet of course because there is not yet any PIC32MZ support)
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
@@ -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 */
|
||||
@@ -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 =
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Executable
+66
@@ -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}"
|
||||
@@ -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) }
|
||||
}
|
||||
@@ -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) }
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
/.depend
|
||||
/Make.dep
|
||||
@@ -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
|
||||
@@ -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 */
|
||||
@@ -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 */
|
||||
@@ -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 */
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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 */
|
||||
@@ -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 */
|
||||
@@ -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 */
|
||||
Reference in New Issue
Block a user