mirror of
https://github.com/apache/nuttx.git
synced 2026-05-22 05:42:05 +08:00
Configuration for Sparkfun UBW32 board
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4660 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -2688,4 +2688,5 @@
|
||||
device is unregistered.
|
||||
* include/sys/prctl.h, sched/prctl.c, include/pthread.h: Add interfaces to
|
||||
support getting and setting of the thread or task name.
|
||||
* configs/ubw32: Add a configuration to support the Sparkfun UBW32 PIC32 board.
|
||||
|
||||
|
||||
@@ -2176,18 +2176,28 @@
|
||||
<tr>
|
||||
<td><br></td>
|
||||
<td>
|
||||
<p>
|
||||
<b>PIC32MX460F512L</b>.
|
||||
<p><b>PIC32MX460F512L</b>. There one two board ports using this chip:</p>
|
||||
<ul>
|
||||
<li><b>PIC32MX Board from PCB Logic Design Co</b>.
|
||||
This port is for the PIC32MX board from PCB Logic Design Co. and used the PIC32MX460F512L.
|
||||
The board is a very simple -- little more than a carrier for the PIC32 MCU plus voltage regulation, debug interface, and an OTG connector.
|
||||
</li>
|
||||
<p>
|
||||
<b>STATUS:</b>
|
||||
The basic port is code complete and fully verified in NuttX 6.13.
|
||||
Available configurations include the OS test and the NuttShell (NSH - see the <a href="http://www.nuttx.org/NuttShell.html">NSH User Guide</a>).
|
||||
</p>
|
||||
<ul>
|
||||
<p>
|
||||
<b>STATUS:</b>
|
||||
The basic port is code complete and fully verified in NuttX 6.13.
|
||||
Available configurations include the OS test and the NuttShell (NSH - see the <a href="http://www.nuttx.org/NuttShell.html">NSH User Guide</a>).
|
||||
</p>
|
||||
</ul>
|
||||
<li><b>UBW32 Board from Sparkfun</b>
|
||||
This is the port to the Sparkfun UBW32 board.
|
||||
This port uses the <a href="http://www.sparkfun.com/products/8971">original v2.4</a> board which is based on the MicroChip PIC32MX460F512L.
|
||||
This older version has been replaced with this <a href="http://www.sparkfun.com/products/9713">newer board</a>.
|
||||
See also the <a href="http://www.schmalzhaus.com/UBW32/">UBW32</a> web site.
|
||||
</li>
|
||||
<p>
|
||||
<b>STATUS:</b>
|
||||
This is a work in progress.
|
||||
</p>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -372,6 +372,16 @@ config ARCH_BOARD_TWR_K60N512
|
||||
Kinetis K60 Cortex-M4 MCU. This port uses the FreeScale TWR-K60N512
|
||||
development board.
|
||||
|
||||
config ARCH_BOARD_UBW32
|
||||
bool "UBW32 v2.4 board from Sparkfun"
|
||||
depends on ARCH_CHIP_PIC32MX460F512L
|
||||
---help---
|
||||
This is the port to the Sparkfun UBW32 board. This port uses the original v2.4
|
||||
board which is based on the MicroChip PIC32MX460F512L. See
|
||||
http://www.sparkfun.com/products/8971. This older version has been replaced
|
||||
with this board http://www.sparkfun.com/products/9713. See also
|
||||
http://www.schmalzhaus.com/UBW32/.
|
||||
|
||||
config ARCH_BOARD_US7032EVB1
|
||||
bool "Hitachi SH-1/US7032EVB1 board"
|
||||
depends on ARCH_CHIP_SH7032
|
||||
@@ -491,6 +501,7 @@ config ARCH_BOARD
|
||||
default "sure-pic32mx" if ARCH_BOARD_SUREPIC32MX
|
||||
default "teensy" if ARCH_BOARD_TEENSY
|
||||
default "twr-k60n512" if ARCH_BOARD_TWR_K60N512
|
||||
default "ubw32" if ARCH_BOARD_UBW32
|
||||
default "us7032evb1" if ARCH_BOARD_US7032EVB1
|
||||
default "vsn" if ARCH_BOARD_VSN
|
||||
default "xtrs" if ARCH_BOARD_XTRS
|
||||
|
||||
@@ -1566,6 +1566,14 @@ configs/twr-k60n512
|
||||
Kinetis K60 Cortex-M4 MCU. This port uses the FreeScale TWR-K60N512
|
||||
development board.
|
||||
|
||||
configs/ubw32
|
||||
|
||||
This is the port to the Sparkfun UBW32 board. This port uses the original v2.4
|
||||
board which is based on the MicroChip PIC32MX460F512L. See
|
||||
http://www.sparkfun.com/products/8971. This older version has been replaced
|
||||
with this board http://www.sparkfun.com/products/9713. See also
|
||||
http://www.schmalzhaus.com/UBW32/.
|
||||
|
||||
configs/us7032evb1
|
||||
This is a port of the Hitachi SH-1 on the Hitachi SH-1/US7032EVB1 board.
|
||||
STATUS: Work has just began on this port.
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see misc/tools/kconfig-language.txt.
|
||||
#
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,188 @@
|
||||
/****************************************************************************
|
||||
* configs/ubw32/include/board.h
|
||||
* include/arch/board/board.h
|
||||
*
|
||||
* Copyright (C) 2012 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_UBW32_INCLUDE_BOARD_H
|
||||
#define __CONFIGS_UBW32_INCLUDE_BOARD_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
/****************************************************************************
|
||||
* 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)
|
||||
* (Not present on my board) */
|
||||
|
||||
/* PLL configuration and resulting CPU clock.
|
||||
* CPU_CLOCK = ((POSC_FREQ / IDIV) * MULT) / ODIV
|
||||
*/
|
||||
|
||||
#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 */
|
||||
|
||||
/* LED definitions **********************************************************/
|
||||
/* ----- ----- -------------------------------------------------------------
|
||||
* LABEL COLOR CONTROL
|
||||
* ----- ----- -------------------------------------------------------------
|
||||
* USB Green RF3. This could be used by software if USB is not used.
|
||||
* Otherwise, RF3 is used as the USBID signal.
|
||||
* LED1 While RE2, Pulled up. Low value illuminates
|
||||
* LED2 Red RE1, Pulled up. Low value illuminates
|
||||
* LED3 Yellow RE0, Pulled up. Low value illuminates
|
||||
* PWR Blue Illuminated when 5V is present, not controlled by software
|
||||
*/
|
||||
|
||||
/* LED index values for use with pic32mx_setled() */
|
||||
|
||||
#define PIC32MX_UBW32_LED1 0
|
||||
#define PIC32MX_UBW32_LED2 1
|
||||
#define PIC32MX_UBW32_LED3 2
|
||||
#define PIC32MX_UBW32_NLEDS 3
|
||||
|
||||
/* LED bits for use with pic32mx_setleds() */
|
||||
|
||||
#define PIC32MX_UBW32_LED1_BIT (1 << PIC32MX_UBW32_LED1)
|
||||
#define PIC32MX_UBW32_LED2_BIT (1 << PIC32MX_UBW32_LED2)
|
||||
#define PIC32MX_UBW32_LED3_BIT (1 << PIC32MX_UBW32_LED3)
|
||||
|
||||
/* 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
|
||||
*/
|
||||
|
||||
#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
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/****************************************************************************
|
||||
* Inline Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C" {
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: pic32mx_ledinit and pic32mx_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 applicaitons.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_ARCH_LEDS
|
||||
EXTERN void pic32mx_ledinit(void);
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_ARCH_LEDS
|
||||
EXTERN void pic32mx_setled(int led, bool ledon);
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_ARCH_LEDS
|
||||
EXTERN void pic32mx_setleds(uint8_t ledset);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __CONFIGS_UBW32_INCLUDE_BOARD_H */
|
||||
@@ -0,0 +1,160 @@
|
||||
############################################################################
|
||||
# configs/ubw32/ostest/Make.defs
|
||||
#
|
||||
# Copyright (C) 2012 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
|
||||
|
||||
# Setup for the selected toolchain
|
||||
|
||||
ifeq ($(CONFIG_PIC32MX_MICROCHIPW),y)
|
||||
# Microchip toolchain under Windows
|
||||
CROSSDEV = pic32-
|
||||
WINTOOL = y
|
||||
MAXOPTIMIZATION = -O2
|
||||
ARCHCPUFLAGS = -mprocessor=elf32pic32mx -mno-float -mlong32 -membedded-data
|
||||
ARCHPICFLAGS = -fpic -membedded-pic
|
||||
LDFLAGS += -nostartfiles -nodefaultlibs
|
||||
endif
|
||||
ifeq ($(CONFIG_PIC32MX_MICROCHIPW_LITE),y)
|
||||
# Microchip toolchain under Windows
|
||||
CROSSDEV = pic32-
|
||||
WINTOOL = y
|
||||
# MAXOPTIMIZATION = -O2
|
||||
ARCHCPUFLAGS = -mprocessor=elf32pic32mx -mno-float -mlong32 -membedded-data
|
||||
ARCHPICFLAGS = -fpic -membedded-pic
|
||||
LDFLAGS += -nostartfiles -nodefaultlibs
|
||||
endif
|
||||
ifeq ($(CONFIG_PIC32MX_MICROCHIPL),y)
|
||||
# Microchip toolchain under Linux
|
||||
CROSSDEV = pic32-
|
||||
MAXOPTIMIZATION = -O2
|
||||
ARCHCPUFLAGS = -mprocessor=elf32pic32mx -mno-float -mlong32 -membedded-data
|
||||
ARCHPICFLAGS = -fpic -membedded-pic
|
||||
LDFLAGS += -nostartfiles -nodefaultlibs
|
||||
endif
|
||||
ifeq ($(CONFIG_PIC32MX_MICROCHIPL_LITE),y)
|
||||
# Microchip toolchain under Linux
|
||||
CROSSDEV = pic32-
|
||||
# MAXOPTIMIZATION = -O2
|
||||
ARCHCPUFLAGS = -mprocessor=elf32pic32mx -mno-float -mlong32 -membedded-data
|
||||
ARCHPICFLAGS = -fpic -membedded-pic
|
||||
LDFLAGS += -nostartfiles -nodefaultlibs
|
||||
endif
|
||||
|
||||
ifeq ($(WINTOOL),y)
|
||||
# Windows-native toolchains
|
||||
DIRLINK = $(TOPDIR)/tools/winlink.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)/ostest/ld.script}"
|
||||
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)/ostest/ld.script
|
||||
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
|
||||
else
|
||||
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.ld -no-check-sections
|
||||
LDNXFLATFLAGS = -e main -s 2048
|
||||
|
||||
OBJEXT = .o
|
||||
LIBEXT = .a
|
||||
EXEEXT =
|
||||
|
||||
define PREPROCESS
|
||||
@echo "CPP: $1->$2"
|
||||
@$(CPP) $(CPPFLAGS) $1 -o $2
|
||||
endef
|
||||
|
||||
define COMPILE
|
||||
@echo "CC: $1"
|
||||
@$(CC) -c $(CFLAGS) $1 -o $2
|
||||
endef
|
||||
|
||||
define COMPILEXX
|
||||
@echo "CXX: $1"
|
||||
@$(CXX) -c $(CXXFLAGS) $1 -o $2
|
||||
endef
|
||||
|
||||
define ASSEMBLE
|
||||
@echo "AS: $1"
|
||||
@$(CC) -c $(AFLAGS) $1 -o $2
|
||||
endef
|
||||
|
||||
define ARCHIVE
|
||||
echo "AR: $2"; \
|
||||
$(AR) $1 $2 || { echo "$(AR) $1 $2 FAILED!" ; exit 1 ; }
|
||||
endef
|
||||
|
||||
define CLEAN
|
||||
@rm -f *.o *.a
|
||||
endef
|
||||
|
||||
HOSTCC = gcc
|
||||
HOSTINCLUDES = -I.
|
||||
HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -g -pipe
|
||||
HOSTLDFLAGS =
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
############################################################################
|
||||
# configs/ubw32/ostest/appconfig
|
||||
#
|
||||
# Copyright (C) 2012 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
# Path to example in apps/examples containing the user_start entry point
|
||||
|
||||
CONFIGURED_APPS += examples/ostest
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,317 @@
|
||||
/****************************************************************************
|
||||
* configs/ubw32/ostest/ld.script
|
||||
*
|
||||
* Copyright (C) 2012 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 PIC32MX460F512L has 512Kb of program FLASH at physical address
|
||||
* 0x1d000000 but is always accessed at KSEG0 address 0x9d00:0000
|
||||
*/
|
||||
|
||||
kseg0_progmem (rx) : ORIGIN = 0x9d000000, LENGTH = 512K
|
||||
|
||||
/* The PIC32MX460F512L has 12Kb 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 0x1fc02ff0 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 = 0xbfc02ff0, LENGTH = 16
|
||||
|
||||
/* The PIC32MX460F512L has 32Kb of data memory at physical address
|
||||
* 0x00000000. Since the PIC32MX 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 = 32K - 512
|
||||
}
|
||||
|
||||
OUTPUT_FORMAT("elf32-tradlittlemips")
|
||||
OUTPUT_ARCH(pic32mx)
|
||||
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) }
|
||||
}
|
||||
Executable
+61
@@ -0,0 +1,61 @@
|
||||
#!/bin/bash
|
||||
# configs/ubw32/ostest/setenv.sh
|
||||
#
|
||||
# Copyright (C) 2012 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 the Cygwin path to the location where I installed the MicroChip
|
||||
# PIC32MX 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 PIC32MX toolchain as well
|
||||
export TOOLCHAIN_BIN="/cygdrive/c/MicroChip/mplabc32/v1.12/bin"
|
||||
|
||||
# This is the path to the toosl subdirectory
|
||||
export PIC32TOOL_DIR="${WD}/configs/ubw32/tools"
|
||||
|
||||
# Add the path to the toolchain to the PATH varialble
|
||||
export PATH="${TOOLCHAIN_BIN}:${PIC32TOOL_DIR}:/sbin:/usr/sbin:${PATH_ORIG}"
|
||||
|
||||
echo "PATH : ${PATH}"
|
||||
@@ -0,0 +1,95 @@
|
||||
############################################################################
|
||||
# configs/ubw32/src/Makefile
|
||||
#
|
||||
# Copyright (C) 2012 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 = up_boot.c up_leds.c
|
||||
|
||||
ifeq ($(CONFIG_NSH_ARCHINIT),y)
|
||||
CSRCS += up_nsh.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_PIC32MX_USBDEV),y)
|
||||
CSRCS += up_usbdev.c
|
||||
ifeq ($(CONFIG_EXAMPLES_USBTERM_DEVINIT),y)
|
||||
CSRCS += up_usbterm.c
|
||||
endif
|
||||
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)
|
||||
@( for obj in $(OBJS) ; do \
|
||||
$(call ARCHIVE, $@, $${obj}); \
|
||||
done ; )
|
||||
|
||||
.depend: Makefile $(SRCS)
|
||||
@$(MKDEP) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
|
||||
@touch $@
|
||||
|
||||
depend: .depend
|
||||
|
||||
clean:
|
||||
@rm -f libboard$(LIBEXT) *~ .*.swp
|
||||
$(call CLEAN)
|
||||
|
||||
distclean: clean
|
||||
@rm -f Make.dep .depend
|
||||
|
||||
-include Make.dep
|
||||
@@ -0,0 +1,101 @@
|
||||
/****************************************************************************
|
||||
* configs/ubw32/src/ubw32-internal.h
|
||||
*
|
||||
* Copyright (C) 2012 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_UBW32_SRC_UBW32_INTERNAL_H
|
||||
#define __CONFIGS_UBW32_SRC_UBW32_INTERNAL_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/****************************************************************************
|
||||
* Inline Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C" {
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Name: pic32mx_spiinitialize
|
||||
*
|
||||
* Description:
|
||||
* Called to configure SPI chip select GPIO pins for the UBW32 board.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#if defined(CONFIG_PIC32MX_SPI1) || defined(CONFIG_PIC32MX_SPI2)
|
||||
EXTERN void weak_function pic32mx_spiinitialize(void);
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Name: pic32mx_ledinit
|
||||
*
|
||||
* Description:
|
||||
* Configure on-board LEDs if LED support has been selected.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
EXTERN void pic32mx_ledinit(void);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __CONFIGS_UBW32_SRC_UBW32_INTERNAL_H */
|
||||
@@ -0,0 +1,93 @@
|
||||
/************************************************************************************
|
||||
* configs/ubw32/src/up_boot.c
|
||||
* arch/mips/src/board/up_boot.c
|
||||
*
|
||||
* Copyright (C) 2012 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 "pic32mx-internal.h"
|
||||
#include "ubw32-internal.h"
|
||||
|
||||
/************************************************************************************
|
||||
* Definitions
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Private Functions
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Public Functions
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Name: pic32mx_boardinitialize
|
||||
*
|
||||
* Description:
|
||||
* All PIC32MX architectures must provide the following entry point. This entry
|
||||
* point is called early in the intitialization -- after all memory has been
|
||||
* configured and mapped but before any devices have been initialized.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
void pic32mx_boardinitialize(void)
|
||||
{
|
||||
/* Configure SPI chip selects if 1) at least one SPI is enabled, and 2) the weak
|
||||
* function pic32mx_spiinitialize() has been brought into the link.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_PIC32MX_SPI1) || defined(CONFIG_PIC32MX_SPI2)
|
||||
if (pic32mx_spiinitialize)
|
||||
{
|
||||
pic32mx_spiinitialize();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Configure on-board LEDs if LED support has been selected. */
|
||||
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
pic32mx_ledinit();
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,266 @@
|
||||
/****************************************************************************
|
||||
* configs/ubw32/src/up_leds.c
|
||||
* arch/arm/src/board/up_leds.c
|
||||
*
|
||||
* Copyright (C) 2012 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 "pic32mx-internal.h"
|
||||
#include "ubw32-internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
/* LED Configuration ********************************************************/
|
||||
/* ----- ----- -------------------------------------------------------------
|
||||
* LABEL COLOR CONTROL
|
||||
* ----- ----- -------------------------------------------------------------
|
||||
* USB Green RF3. This could be used by software if USB is not used.
|
||||
* Otherwise, RF3 is used as the USBID signal.
|
||||
* LED1 While RE2, Pulled up. Low value illuminates
|
||||
* LED2 Red RE1, Pulled up. Low value illuminates
|
||||
* LED3 Yellow RE0, Pulled up. Low value illuminates
|
||||
* PWR Blue Illuminated when 5V is present, not controlled by software
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#define GPIO_LED_1 (GPIO_OUTPUT|GPIO_VALUE_ZERO|GPIO_PORTE|GPIO_PIN2)
|
||||
#define GPIO_LED_2 (GPIO_OUTPUT|GPIO_VALUE_ZERO|GPIO_PORTE|GPIO_PIN1)
|
||||
#define GPIO_LED_3 (GPIO_OUTPUT|GPIO_VALUE_ZERO|GPIO_PORTE|GPIO_PIN0)
|
||||
|
||||
/* LED Management Definitions ***********************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
# define LED_OFF 0
|
||||
# define LED_ON 1
|
||||
# define LED_NC 2
|
||||
#endif
|
||||
|
||||
/* 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
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
struct led_setting_s
|
||||
{
|
||||
uint8_t led1 : 2;
|
||||
uint8_t led2 : 2;
|
||||
uint8_t led3 : 2;
|
||||
uint8_t unused : 2;
|
||||
};
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
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},
|
||||
};
|
||||
|
||||
/* If CONFIG_ARCH_LEDS is not defined, the the user can control the LEDs in
|
||||
* any way. The following array simply maps the PIC32MX_UBW32_LEDn
|
||||
* index values to the correct LED pin configuration.
|
||||
*/
|
||||
|
||||
#else
|
||||
static const uint16_t g_ledpincfg[PIC32MX_UBW32_NLEDS] =
|
||||
{
|
||||
GPIO_LED_1, GPIO_LED_2, GPIO_LED_3
|
||||
};
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_setleds
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
void up_setleds(FAR const struct led_setting_s *setting)
|
||||
{
|
||||
if (setting->led1 != LED_NC)
|
||||
{
|
||||
pic32mx_gpiowrite(GPIO_LED_1, setting->led1 == LED_ON);
|
||||
}
|
||||
|
||||
if (setting->led2 != LED_NC)
|
||||
{
|
||||
pic32mx_gpiowrite(GPIO_LED_2, setting->led2 == LED_ON);
|
||||
}
|
||||
|
||||
if (setting->led3 != LED_NC)
|
||||
{
|
||||
pic32mx_gpiowrite(GPIO_LED_3, setting->led3 == LED_ON);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: pic32mx_ledinit
|
||||
****************************************************************************/
|
||||
|
||||
void pic32mx_ledinit(void)
|
||||
{
|
||||
/* Configure output pins */
|
||||
|
||||
pic32mx_configgpio(GPIO_LED_1);
|
||||
pic32mx_configgpio(GPIO_LED_2);
|
||||
pic32mx_configgpio(GPIO_LED_3);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: pic32mx_setled
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_ARCH_LEDS
|
||||
void pic32mx_setled(int led, bool ledon)
|
||||
{
|
||||
if ((unsigned)led < PIC32MX_UBW32_NLEDS)
|
||||
{
|
||||
pic32mx_gpiowrite(g_ledpincfg[led], ledon);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: pic32mx_setleds
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_ARCH_LEDS
|
||||
void pic32mx_setleds(uint8_t ledset)
|
||||
{
|
||||
pic32mx_setled(PIC32MX_UBW32_LED1, (ledset & PIC32MX_UBW32_LED1_BIT) != 0);
|
||||
pic32mx_setled(PIC32MX_UBW32_LED2, (ledset & PIC32MX_UBW32_LED2_BIT) != 0);
|
||||
pic32mx_setled(PIC32MX_UBW32_LED3, (ledset & PIC32MX_UBW32_LED3_BIT) != 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_ledon
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
void up_ledon(int led)
|
||||
{
|
||||
if ((unsigned)led < LED_NVALUES)
|
||||
{
|
||||
up_setleds(&g_ledonvalues[led]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_ledoff
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
void up_ledoff(int led)
|
||||
{
|
||||
if ((unsigned)led < LED_NVALUES)
|
||||
{
|
||||
up_setleds(&g_ledoffvalues[led]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,119 @@
|
||||
/****************************************************************************
|
||||
* config/ubw32/src/up_nsh.c
|
||||
* arch/arm/src/board/up_nsh.c
|
||||
*
|
||||
* Copyright (C) 2012 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 <debug.h>
|
||||
|
||||
#include "pic32mx-internal.h"
|
||||
#include "ubw32-internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Debug ********************************************************************/
|
||||
|
||||
#ifdef CONFIG_CPP_HAVE_VARARGS
|
||||
# ifdef CONFIG_DEBUG
|
||||
# define message(...) lib_lowprintf(__VA_ARGS__)
|
||||
# else
|
||||
# define message(...) printf(__VA_ARGS__)
|
||||
# endif
|
||||
#else
|
||||
# ifdef CONFIG_DEBUG
|
||||
# define message lib_lowprintf
|
||||
# else
|
||||
# define message printf
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_usbdevinitialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize SPI-based microSD.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_USBDEV
|
||||
static int nsh_usbdevinitialize(void)
|
||||
{
|
||||
/* The UBW32 has no way to know when the USB is connected. So we will fake
|
||||
* it and tell the USB driver that the USB is connected now.
|
||||
*/
|
||||
|
||||
pic32mx_usbattach();
|
||||
return OK;
|
||||
}
|
||||
#else
|
||||
# define nsh_usbdevinitialize() (OK)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_archinitialize
|
||||
*
|
||||
* Description:
|
||||
* Perform architecture specific initialization
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nsh_archinitialize(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* Initialize USB device */
|
||||
|
||||
ret = nsh_usbdevinitialize();
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
/************************************************************************************
|
||||
* configs/ubw32/src/up_usbdev.c
|
||||
* arch/arm/src/board/up_usbdev.c
|
||||
*
|
||||
* Copyright (C) 2012 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 <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/usb/usbdev.h>
|
||||
|
||||
#include "pic32mx-internal.h"
|
||||
#include "ubw32-internal.h"
|
||||
|
||||
#if defined(CONFIG_PIC32MX_USBDEV)
|
||||
|
||||
/************************************************************************************
|
||||
* Definitions
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Private Functions
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Public Functions
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Name: pic32mx_usbdevinitialize
|
||||
*
|
||||
* Description:
|
||||
* Called to configure the mini-A/B J5 on the UBW32 for the
|
||||
* USB device
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
void weak_function pic32mx_usbdevinitialize(void)
|
||||
{
|
||||
/* Connect the PHY to the USB mini-B port. Order and timing matter! */
|
||||
|
||||
pic32mx_configgpio(GPIO_USB_PGOOD);
|
||||
|
||||
/* Notes from the Sure Electronics sample code:
|
||||
*
|
||||
* "The USB specifications require that USB peripheral devices must never source
|
||||
* current onto the Vbus pin. Additionally, USB peripherals should not source
|
||||
* current on D+ or D- when the host/hub is not actively powering the Vbus line.
|
||||
* When designing a self powered (as opposed to bus powered) USB peripheral
|
||||
* device, the firmware should make sure not to turn on the USB module and D+
|
||||
* or D- pull up resistor unless Vbus is actively powered. Therefore, the
|
||||
* firmware needs some means to detect when Vbus is being powered by the host.
|
||||
* A 5V tolerant I/O pin can be connected to Vbus (through a resistor), and
|
||||
* can be used to detect when Vbus is high (host actively powering), or low
|
||||
* (host is shut down or otherwise not supplying power). The USB firmware
|
||||
* can then periodically poll this I/O pin to know when it is okay to turn on
|
||||
* the USB module/D+/D- pull up resistor. When designing a purely bus powered
|
||||
* peripheral device, it is not possible to source current on D+ or D- when the
|
||||
* host is not actively providing power on Vbus. Therefore, implementing this
|
||||
* bus sense feature is optional. ..."
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_USBHOST
|
||||
#endif
|
||||
|
||||
/* "If the host PC sends a GetStatus (device) request, the firmware must respond
|
||||
* and let the host know if the USB peripheral device is currently bus powered
|
||||
* or self powered. See chapter 9 in the official USB specifications for details
|
||||
* regarding this request. If the peripheral device is capable of being both
|
||||
* self and bus powered, it should not return a hard coded value for this request.
|
||||
* Instead, firmware should check if it is currently self or bus powered, and
|
||||
* respond accordingly. If the hardware has been configured like demonstrated
|
||||
* on the PICDEM FS USB Demo Board, an I/O pin can be polled to determine the
|
||||
* currently selected power source. ..."
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_USB_PWRSENSE
|
||||
#endif
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
* Name: pic32mx_usbpullup
|
||||
*
|
||||
* Description:
|
||||
* If USB is supported and the board supports a pullup via GPIO (for USB
|
||||
* software connect and disconnect), then the board software must provide
|
||||
* stm32_pullup. See include/nuttx/usb/usbdev.h for additional description
|
||||
* of this method. Alternatively, if no pull-up GPIO the following EXTERN
|
||||
* can be redefined to be NULL.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
int pic32mx_usbpullup(FAR struct usbdev_s *dev, bool enable)
|
||||
{
|
||||
/* The UBW32 does not have a USB pull-up */
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
* Name: pic32mx_usbsuspend
|
||||
*
|
||||
* Description:
|
||||
* Board logic must provide the stm32_usbsuspend logic if the USBDEV driver
|
||||
* is used. This function is called whenever the USB enters or leaves
|
||||
* suspend mode. This is an opportunity for the board logic to shutdown
|
||||
* clocks, power, etc. while the USB is suspended.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
void pic32mx_usbsuspend(FAR struct usbdev_s *dev, bool resume)
|
||||
{
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
#endif /* CONFIG_PIC32MX_USBDEV */
|
||||
@@ -0,0 +1,105 @@
|
||||
/****************************************************************************
|
||||
* configs/ubw32/src/up_usbterm.c
|
||||
* arch/arm/src/board/up_usbterm.c
|
||||
*
|
||||
* Copyright (C) 2012 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 <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/usb/usbdev.h>
|
||||
|
||||
#include "pic32mx-internal.h"
|
||||
#include "ubw32-internal.h"
|
||||
|
||||
#if defined(CONFIG_PIC32MX_USBDEV) && defined(CONFIG_EXAMPLES_USBTERM_DEVINIT)
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name:
|
||||
*
|
||||
* Description:
|
||||
* If CONFIG_EXAMPLES_USBTERM_DEVINIT is defined, then the example will
|
||||
* call this user provided function as part of its initialization.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int usbterm_devinit(void)
|
||||
{
|
||||
/* The UBW32 has no way to know when the USB is connected. So we will fake
|
||||
* it and tell the USB driver that the USB is connected now.
|
||||
*
|
||||
* If examples/usbterm is built as an NSH built-in application, then
|
||||
* pic32mx_usbattach() will be called in nsh_archinitialize().
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_USBTERM_BUILTIN
|
||||
pic32mx_usbattach();
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name:
|
||||
*
|
||||
* Description:
|
||||
* If CONFIG_EXAMPLES_USBTERM_DEVINIT is defined, then the example will
|
||||
* call this user provided function as part of its termination sequence.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void usbterm_devuninit(void)
|
||||
{
|
||||
/* Tell the USB driver that the USB is no longer connected */
|
||||
|
||||
pic32mx_usbdetach();
|
||||
}
|
||||
|
||||
#endif /* CONFIG_PIC32MX_USBDEV && CONFIG_EXAMPLES_USBTERM_DEVINIT */
|
||||
@@ -0,0 +1,51 @@
|
||||
############################################################################
|
||||
# configs/ubw32/tools/Makefile
|
||||
#
|
||||
# Copyright (C) 2012 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
all: mkpichex
|
||||
default: mkpichex
|
||||
.PHONY: clean
|
||||
|
||||
# Add CFLAGS=-g on the make command line to build debug versions
|
||||
|
||||
CFLAGS = -O2 -Wall -I.
|
||||
|
||||
# mkpichex - Convert virtual addresses in nuttx.hex to physical addresses
|
||||
|
||||
mkconfig: mkpichex.c mkpichex.c
|
||||
@gcc $(CFLAGS) -o mkpichex mkpichex.c
|
||||
|
||||
clean:
|
||||
@rm -f *.o *.a *~ .*.swp
|
||||
@rm -f mkpichex mkpichex.exe
|
||||
@@ -0,0 +1,315 @@
|
||||
/****************************************************************************
|
||||
* configs/ubw32/tools/mkpichex.c
|
||||
*
|
||||
* Copyright (C) 2012 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 <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define MAX_LINE 1024
|
||||
|
||||
/* Line offsets */
|
||||
|
||||
#define START_OFFSET 0
|
||||
#define LEN_OFFSET 1
|
||||
#define ADDR_OFFSET (LEN_OFFSET + 2)
|
||||
#define TYPE_OFFSET (ADDR_OFFSET + 4)
|
||||
#define PAYLOAD_OFFSET (TYPE_OFFSET + 2)
|
||||
#define CHKSUM_OFFSET(n) (PAYLOAD_OFFSET+2*(n))
|
||||
|
||||
/* Record types:
|
||||
*
|
||||
* 00, data record, contains data and 16-bit address. The format described
|
||||
* above.
|
||||
* 01, End Of File record, a file termination record. No data. Has to be
|
||||
* the last line of the file, only one per file permitted. Usually
|
||||
* ':00000001FF'. Originally the End Of File record could contain a
|
||||
* start address for the program being loaded, e.g. :00AB2F0125
|
||||
* would make a jump to address AB2F. This was convenient when programs
|
||||
* were loaded from punched paper tape.
|
||||
* 02, Extended Segment Address Record, segment-base address. Used when 16
|
||||
* bits are not enough, identical to 80x86 real mode addressing. The
|
||||
* address specified by the 02 record is multiplied by 16 (shifted 4
|
||||
* bits left) and added to the subsequent 00 record addresses. This
|
||||
* allows addressing of up to a megabyte of address space. The address
|
||||
* field of this record has to be 0000, the byte count is 02 (the segment
|
||||
* is 16-bit). The least significant hex digit of the segment address is
|
||||
* always 0.
|
||||
* 03, Start Segment Address Record. For 80x86 processors, it specifies the
|
||||
* initial content of the CS:IP registers. The address field is 0000, the
|
||||
* byte count is 04, the first two bytes are the CS value, the latter two
|
||||
* are the IP value.
|
||||
* 04, Extended Linear Address Record, allowing for fully 32 bit addressing.
|
||||
* The address field is 0000, the byte count is 02. The two data bytes
|
||||
* represent the upper 16 bits of the 32 bit address, when combined with
|
||||
* the address of the 00 type record.
|
||||
* 05, Start Linear Address Record. The address field is 0000, the byte
|
||||
* count is 04. The 4 data bytes represent the 32-bit value loaded into
|
||||
* the EIP register of the 80386 and higher CPU.
|
||||
*/
|
||||
|
||||
#define TYPE_DATA 0
|
||||
#define TYPE_EOF 1
|
||||
#define TYPE_EXTSEG 2
|
||||
#define TYPE_STARTSEG 3
|
||||
#define TYPE_EXTLIN 4
|
||||
#define TYPE_STARTLIN 5
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
struct hex_s
|
||||
{
|
||||
unsigned char len; /* Length of the data payload */
|
||||
unsigned char type; /* Record type */
|
||||
unsigned short addr; /* Lower 16-bit address */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static char line[MAX_LINE+1];
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
static inline char *getfilepath(const char *path, const char *name, const char *extension)
|
||||
{
|
||||
snprintf(line, MAX_LINE, "%s/%s.%s", path, name, extension);
|
||||
line[MAX_LINE] = '\0';
|
||||
return strdup(line);
|
||||
}
|
||||
|
||||
static void show_usage(const char *progname)
|
||||
{
|
||||
fprintf(stderr, "USAGE: %s <abs path to nuttx.hex>\n", progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static unsigned char get4(char hex)
|
||||
{
|
||||
if (hex >= '0' && hex <= '9')
|
||||
{
|
||||
return hex - '0';
|
||||
}
|
||||
else if (hex >= 'a' && hex <= 'f')
|
||||
{
|
||||
return hex - 'a' + 10;
|
||||
}
|
||||
else if (hex >= 'A' && hex <= 'F')
|
||||
{
|
||||
return hex - 'A' + 10;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Bad hex character code: %s\n", line);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
static unsigned char get8(const char *ptr)
|
||||
{
|
||||
return get4(ptr[0]) << 4 | get4(ptr[1]);
|
||||
}
|
||||
|
||||
static unsigned short get16(const char *ptr)
|
||||
{
|
||||
return (unsigned short)get8(&ptr[0]) << 8 | (unsigned short)get8(&ptr[2]);
|
||||
}
|
||||
|
||||
static int parse_line(struct hex_s *hexline)
|
||||
{
|
||||
/* :LLAAAATT... */
|
||||
|
||||
if (line[START_OFFSET] != ':')
|
||||
{
|
||||
fprintf(stderr, "Bad start code: %s\n", line);
|
||||
return 1;
|
||||
}
|
||||
|
||||
hexline->len = get8(&line[LEN_OFFSET]);
|
||||
hexline->addr = get16(&line[ADDR_OFFSET]);
|
||||
hexline->type = get8(&line[TYPE_OFFSET]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static unsigned char checksum(chksum_ndx)
|
||||
{
|
||||
int chksum = 0;
|
||||
int ndx;
|
||||
|
||||
for (ndx = 1; ndx < chksum_ndx; ndx += 2)
|
||||
{
|
||||
chksum += (int)get8(&line[ndx]);
|
||||
}
|
||||
return (unsigned char)((-chksum) & 0xff);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void adjust_extlin(struct hex_s *hexline)
|
||||
{
|
||||
unsigned short segment;
|
||||
int chksum;
|
||||
|
||||
/* Make sure that the payload is exactly 2 bytes */
|
||||
|
||||
if (hexline->len != 2)
|
||||
{
|
||||
fprintf(stderr, "Bad length on extended segment address record\n");
|
||||
fprintf(stderr, " %s", line);
|
||||
}
|
||||
|
||||
/* And the address field is supposed to be zero */
|
||||
|
||||
if (hexline->addr != 0)
|
||||
{
|
||||
fprintf(stderr, "Bad address on extended segment address record\n");
|
||||
fprintf(stderr, " %s", line);
|
||||
}
|
||||
|
||||
/* Decode the 2 byte payload */
|
||||
|
||||
segment = get16(&line[PAYLOAD_OFFSET]);
|
||||
|
||||
/* Convert the address to a 29-bit physical address */
|
||||
|
||||
segment &= 0x1fff;
|
||||
|
||||
/* Recalculate the checksum and make sure that there is a null terminator
|
||||
* Since len=2, addr=0, type=4, the is a trivial calculation.
|
||||
*/
|
||||
|
||||
chksum = (-(segment + (segment >> 8) + 6)) & 0xff;
|
||||
|
||||
/* Then create the new output record */
|
||||
|
||||
snprintf(line, MAX_LINE-PAYLOAD_OFFSET, ":02000004%04X%02X\n", segment, chksum);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int main(int argc, char **argv, char **envp)
|
||||
{
|
||||
struct hex_s hexline;
|
||||
char *srcfile;
|
||||
char *destfile;
|
||||
FILE *src;
|
||||
FILE *dest;
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
fprintf(stderr, "Unexpected number of arguments\n");
|
||||
show_usage(argv[0]);
|
||||
}
|
||||
|
||||
srcfile = getfilepath(argv[1], "nuttx", "hex");
|
||||
if (!srcfile)
|
||||
{
|
||||
fprintf(stderr, "getfilepath failed\n");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
destfile = getfilepath(argv[1], "nuttx", "tmp");
|
||||
if (!destfile)
|
||||
{
|
||||
fprintf(stderr, "getfilepath failed\n");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
src = fopen(srcfile, "r");
|
||||
if (!src)
|
||||
{
|
||||
fprintf(stderr, "open %s failed: %s\n", srcfile, strerror(errno));
|
||||
exit(3);
|
||||
}
|
||||
|
||||
dest = fopen(destfile, "w");
|
||||
if (!dest)
|
||||
{
|
||||
fprintf(stderr, "open %s failed: %s\n", destfile, strerror(errno));
|
||||
exit(3);
|
||||
}
|
||||
|
||||
/* Read each line from the source file */
|
||||
|
||||
while (fgets(line, MAX_LINE, src) != NULL)
|
||||
{
|
||||
if (parse_line(&hexline))
|
||||
{
|
||||
fprintf(stderr, "Failed to parse line\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Adjust 'Extended Segment Address Records'. */
|
||||
|
||||
if (hexline.type == TYPE_EXTLIN)
|
||||
{
|
||||
adjust_extlin(&hexline);
|
||||
}
|
||||
fputs(line, dest);
|
||||
}
|
||||
|
||||
fclose(src);
|
||||
fclose(dest);
|
||||
|
||||
/* Remove the original nuttx.hex file */
|
||||
|
||||
if (remove(srcfile) != 0)
|
||||
{
|
||||
fprintf(stderr, "Failed to remove the old '%s'\n", srcfile);
|
||||
|
||||
}
|
||||
|
||||
/* Rename the new nuttx.tmp file to nuttx.hex */
|
||||
|
||||
if (rename(destfile, srcfile) != 0)
|
||||
{
|
||||
fprintf(stderr, "Failed to rename '%s' to '%s'\n", destfile, srcfile);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
+5
-3
@@ -95,7 +95,7 @@ int prctl(int option, ...)
|
||||
FAR _TCB *tcb;
|
||||
|
||||
/* Get the TCB associated with the PID (handling the special case of
|
||||
* pid==0 meaning "this thread"
|
||||
* pid==0 meaning "this thread")
|
||||
*/
|
||||
|
||||
if (!pid)
|
||||
@@ -107,7 +107,7 @@ int prctl(int option, ...)
|
||||
tcb = sched_gettcb(pid);
|
||||
}
|
||||
|
||||
/* An invalid pid be indicated by a NULL TCB returned from
|
||||
/* An invalid pid will be indicated by a NULL TCB returned from
|
||||
* sched_gettcb()
|
||||
*/
|
||||
|
||||
@@ -118,6 +118,8 @@ int prctl(int option, ...)
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* A pointer to the task name storage must also be provided */
|
||||
|
||||
if (!name)
|
||||
{
|
||||
sdbg("No name provide\n");
|
||||
@@ -125,7 +127,7 @@ int prctl(int option, ...)
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Now get or set the name */
|
||||
/* Now get or set the task name */
|
||||
|
||||
if (option == PR_SET_NAME)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user