From 2f94570288b6bff18d3557df285498cec160845f Mon Sep 17 00:00:00 2001
From: patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>
Date: Wed, 13 Apr 2011 14:49:21 +0000
Subject: [PATCH] Fix some issues with LPC17xx UART2 and 3 configurations

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3498 42af7a65-404d-4744-a932-0658087f49c3
---
 arch/arm/src/lpc17xx/lpc17_lowputc.c        |  2 +-
 configs/lpcxpresso-lpc1768/include/board.h  |  2 +-
 configs/lpcxpresso-lpc1768/nsh/defconfig    | 72 +++++++++++++++++++-
 configs/lpcxpresso-lpc1768/nsh/setenv.sh    |  5 +-
 configs/lpcxpresso-lpc1768/ostest/defconfig | 73 ++++++++++++++++++++-
 configs/lpcxpresso-lpc1768/ostest/setenv.sh |  5 +-
 configs/lpcxpresso-lpc1768/tools/flash.sh   | 34 ++++++++--
 configs/olimex-lpc1766stk/ostest/defconfig  |  3 +-
 8 files changed, 178 insertions(+), 18 deletions(-)

diff --git a/arch/arm/src/lpc17xx/lpc17_lowputc.c b/arch/arm/src/lpc17xx/lpc17_lowputc.c
index 47746ef266..c2c52cbdc6 100755
--- a/arch/arm/src/lpc17xx/lpc17_lowputc.c
+++ b/arch/arm/src/lpc17xx/lpc17_lowputc.c
@@ -324,7 +324,7 @@ void lpc17_lowsetup(void)
   putreg32(regval, LPC17_SYSCON_PCLKSEL0);
 
   regval = getreg32(LPC17_SYSCON_PCLKSEL1);
-  regval &= ~(SYSCON_PCLKSEL1_UART2_MASK|SYSCON_PCLKSEL1_UART3_SHIFT);
+  regval &= ~(SYSCON_PCLKSEL1_UART2_MASK|SYSCON_PCLKSEL1_UART3_MASK);
 #if defined(CONFIG_UART2_SERIAL_CONSOLE)
   regval |= (CONSOLE_CCLKDIV << SYSCON_PCLKSEL1_UART2_SHIFT);
 #elif defined(CONFIG_UART3_SERIAL_CONSOLE)
diff --git a/configs/lpcxpresso-lpc1768/include/board.h b/configs/lpcxpresso-lpc1768/include/board.h
index b2b3dcaa64..2ebf941e2b 100755
--- a/configs/lpcxpresso-lpc1768/include/board.h
+++ b/configs/lpcxpresso-lpc1768/include/board.h
@@ -54,7 +54,7 @@
 
 #define BOARD_XTAL_FREQUENCY        (12000000)            /* XTAL oscillator frequency */
 #define BOARD_OSCCLK_FREQUENCY      BOARD_XTAL_FREQUENCY  /* Main oscillator frequency */
-#define BOARD_RTCCLK_FREQUENCY      (32000)               /* RTC oscillator frequency */
+#define BOARD_RTCCLK_FREQUENCY      (32768)               /* RTC oscillator frequency */
 #define BOARD_INTRCOSC_FREQUENCY    (4000000)             /* Internal RC oscillator frequency */
 
 /* This is the clock setup we configure for:
diff --git a/configs/lpcxpresso-lpc1768/nsh/defconfig b/configs/lpcxpresso-lpc1768/nsh/defconfig
index fbcceabfe6..ff8124aeea 100755
--- a/configs/lpcxpresso-lpc1768/nsh/defconfig
+++ b/configs/lpcxpresso-lpc1768/nsh/defconfig
@@ -52,7 +52,7 @@
 # CONFIG_DRAM_SIZE - Describes the installed DRAM.
 # CONFIG_DRAM_START - The start address of DRAM (physical)
 # CONFIG_DRAM_END - Last address+1 of installed RAM
-# CONFIG_ARCH_IRQPRIO - The ST32F103Z supports interrupt prioritization
+# CONFIG_ARCH_IRQPRIO - The LPC17xx supports interrupt prioritization
 # CONFIG_ARCH_INTERRUPTSTACK - This architecture supports an interrupt
 #   stack. If defined, this symbol is the size of the interrupt
 #   stack in bytes.  If not defined, the user task stacks will be
@@ -64,7 +64,7 @@
 # CONFIG_ARCH_CALIBRATION - Enables some build in instrumentation that
 #   cause a 100 second delay during boot-up.  This 100 second delay
 #   serves no purpose other than it allows you to calibrate
-#   CONFIG_BOARD_LOOPSPERMSEC.  You simply use a stop watch to measure
+# CONFIG_BOARD_LOOPSPERMSEC.  You simply use a stop watch to measure
 #   the 100 second delay then adjust CONFIG_BOARD_LOOPSPERMSEC until
 #   the delay actually is 100 seconds.
 # CONFIG_ARCH_DMA - Support DMA initialization
@@ -104,6 +104,7 @@ CONFIG_LPC17_CODEREDL=y
 #
 # Individual subsystems can be enabled:
 # (MAINOSC, PLL0, PLL1 and FLASH are controlled in board.h)
+#
 CONFIG_LPC17_ETHERNET=y
 CONFIG_LPC17_USBHOST=n
 CONFIG_LPC17_USBOTG=n
@@ -462,6 +463,7 @@ CONFIG_PREALLOC_TIMERS=4
 # CONFIG_FS_FAT - Enable FAT filesystem support
 # CONFIG_FAT_SECTORSIZE - Max supported sector size
 # CONFIG_FS_ROMFS - Enable ROMFS filesystem support
+#
 CONFIG_FS_FAT=y
 CONFIG_FS_ROMFS=n
 
@@ -742,9 +744,23 @@ CONFIG_EXAMPLE_UIP_DHCPC=n
 
 #
 # Settings for examples/nettest
+#
+# CONFIG_EXAMPLE_NETTEST_SERVER - The target board can act
+#   as either the client side or server side of the test
+# CONFIG_EXAMPLE_NETTEST_PERFORMANCE - If set, then the
+#   client side simply receives messages forever, allowing
+#   measurement of throughput
+# CONFIG_EXAMPLE_NETTEST_NOMAC - Set if the hardware has
+#   no MAC address; one will be assigned
+# CONFIG_EXAMPLE_NETTEST_IPADDR - Target board IP address
+# CONFIG_EXAMPLE_NETTEST_DRIPADDR - Default router address
+# CONFIG_EXAMPLE_NETTEST_NETMASK - Network mask
+# CONFIG_EXAMPLE_NETTEST_CLIENTIP - IP address of the
+#   client side of the test (may be target or host)
+#
 CONFIG_EXAMPLE_NETTEST_SERVER=n
 CONFIG_EXAMPLE_NETTEST_PERFORMANCE=n
-CONFIG_EXAMPLE_NETTEST_NOMAC=n
+CONFIG_EXAMPLE_NETTEST_NOMAC=y
 CONFIG_EXAMPLE_NETTEST_IPADDR=(10<<24|0<<16|0<<8|2)
 CONFIG_EXAMPLE_NETTEST_DRIPADDR=(10<<24|0<<16|0<<8|1)
 CONFIG_EXAMPLE_NETTEST_NETMASK=(255<<24|255<<16|255<<8|0)
@@ -847,6 +863,56 @@ CONFIG_EXAMPLES_USBSERIAL_TRACETRANSFERS=n
 CONFIG_EXAMPLES_USBSERIAL_TRACECONTROLLER=n
 CONFIG_EXAMPLES_USBSERIAL_TRACEINTERRUPTS=n
 
+#
+# Settings for examples/usbstorage
+#
+# CONFIG_EXAMPLES_USBSTRG_NLUNS
+#    Defines the number of logical units (LUNs) exported by the USB storage
+#    driver.  Each LUN corresponds to one exported block driver (or partition
+#    of a block driver).  May be 1, 2, or 3.  Default is 1.
+# CONFIG_EXAMPLES_USBSTRG_DEVMINOR1
+#    The minor device number of the block driver for the first LUN. For
+#    example, N in /dev/mmcsdN.  Used for registering the block driver. Default
+#    is zero.
+# CONFIG_EXAMPLES_USBSTRG_DEVPATH1
+#    The full path to the registered block driver.  Default is "/dev/mmcsd0"
+#  CONFIG_EXAMPLES_USBSTRG_DEVMINOR2 and CONFIG_EXAMPLES_USBSTRG_DEVPATH2
+#    Similar parameters that would have to be provided if CONFIG_EXAMPLES_USBSTRG_NLUNS
+#    is 2 or 3.  No defaults.
+#  CONFIG_EXAMPLES_USBSTRG_DEVMINOR3 and CONFIG_EXAMPLES_USBSTRG_DEVPATH3
+#    Similar parameters that would have to be provided if CONFIG_EXAMPLES_USBSTRG_NLUNS
+#    is 3.  No defaults.
+#
+#  If CONFIG_USBDEV_TRACE is enabled (or CONFIG_DEBUG and CONFIG_DEBUG_USB), then
+#  the example code will also manage the USB trace output.  The amount of trace output
+#  can be controlled using:
+#
+#  CONFIG_EXAMPLES_USBSTRG_TRACEINIT
+#    Show initialization events
+#  CONFIG_EXAMPLES_USBSTRG_TRACECLASS
+#    Show class driver events
+#  CONFIG_EXAMPLES_USBSTRG_TRACETRANSFERS
+#    Show data transfer events
+#  CONFIG_EXAMPLES_USBSTRG_TRACECONTROLLER
+#    Show controller events
+#  CONFIG_EXAMPLES_USBSTRG_TRACEINTERRUPTS
+#    Show interrupt-related events.
+#
+CONFIG_EXAMPLES_USBSTRG_NLUNS=1
+CONFIG_EXAMPLES_USBSTRG_DEVMINOR1=0
+CONFIG_EXAMPLES_USBSTRG_DEVPATH1="/dev/mmcsd0"
+CONFIG_EXAMPLES_USBSTRG_TRACEINIT=n
+CONFIG_EXAMPLES_USBSTRG_TRACECLASS=n
+CONFIG_EXAMPLES_USBSTRG_TRACETRANSFERS=n
+CONFIG_EXAMPLES_USBSTRG_TRACECONTROLLER=n
+CONFIG_EXAMPLES_USBSTRG_TRACEINTERRUPTS=n
+
+CONFIG_EXAMPLES_USBSTRG_TRACEINIT=n
+CONFIG_EXAMPLES_USBSTRG_TRACECLASS=n
+CONFIG_EXAMPLES_USBSTRG_TRACETRANSFERS=n
+CONFIG_EXAMPLES_USBSTRG_TRACECONTROLLER=n
+CONFIG_EXAMPLES_USBSTRG_TRACEINTERRUPTS=n
+
 #
 # Stack and heap information
 #
diff --git a/configs/lpcxpresso-lpc1768/nsh/setenv.sh b/configs/lpcxpresso-lpc1768/nsh/setenv.sh
index fc14efd091..fea794e86d 100755
--- a/configs/lpcxpresso-lpc1768/nsh/setenv.sh
+++ b/configs/lpcxpresso-lpc1768/nsh/setenv.sh
@@ -50,7 +50,10 @@ export TOOLCHAIN_BIN="/usr/local/LPCXpresso/tools/bin"
 # This the Cygwin path to the LPCXpresso 3.6 install location under Windows
 #export TOOLCHAIN_BIN="/cygdrive/c/nxp/lpcxpresso_3.6/Tools/bin"
 
+# This is the path to the LPCXpression tool subdirectory
+export LPCTOOL_DIR="${WD}/configs/lpcxpresso-lpc1768/tools"
+
 # Add the path to the toolchain to the PATH varialble
-export PATH="${TOOLCHAIN_BIN}:/sbin:/usr/sbin:${PATH_ORIG}"
+export PATH="${TOOLCHAIN_BIN}:${LPCTOOL_DIR}:/sbin:/usr/sbin:${PATH_ORIG}"
 
 echo "PATH : ${PATH}"
diff --git a/configs/lpcxpresso-lpc1768/ostest/defconfig b/configs/lpcxpresso-lpc1768/ostest/defconfig
index d711f7eb12..57064af5d7 100755
--- a/configs/lpcxpresso-lpc1768/ostest/defconfig
+++ b/configs/lpcxpresso-lpc1768/ostest/defconfig
@@ -52,7 +52,7 @@
 # CONFIG_DRAM_SIZE - Describes the installed DRAM.
 # CONFIG_DRAM_START - The start address of DRAM (physical)
 # CONFIG_DRAM_END - Last address+1 of installed RAM
-# CONFIG_ARCH_IRQPRIO - The ST32F103Z supports interrupt prioritization
+# CONFIG_ARCH_IRQPRIO - The LPC17xx supports interrupt prioritization
 # CONFIG_ARCH_INTERRUPTSTACK - This architecture supports an interrupt
 #   stack. If defined, this symbol is the size of the interrupt
 #   stack in bytes.  If not defined, the user task stacks will be
@@ -64,7 +64,7 @@
 # CONFIG_ARCH_CALIBRATION - Enables some build in instrumentation that
 #   cause a 100 second delay during boot-up.  This 100 second delay
 #   serves no purpose other than it allows you to calibrate
-#   CONFIG_BOARD_LOOPSPERMSEC.  You simply use a stop watch to measure
+# CONFIG_BOARD_LOOPSPERMSEC.  You simply use a stop watch to measure
 #   the 100 second delay then adjust CONFIG_BOARD_LOOPSPERMSEC until
 #   the delay actually is 100 seconds.
 # CONFIG_ARCH_DMA - Support DMA initialization
@@ -104,6 +104,7 @@ CONFIG_LPC17_CODEREDL=y
 #
 # Individual subsystems can be enabled:
 # (MAINOSC, PLL0, PLL1 and FLASH are controlled in board.h)
+#
 CONFIG_LPC17_ETHERNET=n
 CONFIG_LPC17_USBHOST=n
 CONFIG_LPC17_USBOTG=n
@@ -455,6 +456,7 @@ CONFIG_PREALLOC_TIMERS=4
 # CONFIG_FS_FAT - Enable FAT filesystem support
 # CONFIG_FAT_SECTORSIZE - Max supported sector size
 # CONFIG_FS_ROMFS - Enable ROMFS filesystem support
+#
 CONFIG_FS_FAT=n
 CONFIG_FS_ROMFS=n
 
@@ -685,9 +687,24 @@ CONFIG_EXAMPLE_UIP_DHCPC=n
 
 #
 # Settings for examples/nettest
+#
+#
+# CONFIG_EXAMPLE_NETTEST_SERVER - The target board can act
+#   as either the client side or server side of the test
+# CONFIG_EXAMPLE_NETTEST_PERFORMANCE - If set, then the
+#   client side simply receives messages forever, allowing
+#   measurement of throughput
+# CONFIG_EXAMPLE_NETTEST_NOMAC - Set if the hardware has
+#   no MAC address; one will be assigned
+# CONFIG_EXAMPLE_NETTEST_IPADDR - Target board IP address
+# CONFIG_EXAMPLE_NETTEST_DRIPADDR - Default router address
+# CONFIG_EXAMPLE_NETTEST_NETMASK - Network mask
+# CONFIG_EXAMPLE_NETTEST_CLIENTIP - IP address of the
+#   client side of the test (may be target or host)
+#
 CONFIG_EXAMPLE_NETTEST_SERVER=n
 CONFIG_EXAMPLE_NETTEST_PERFORMANCE=n
-CONFIG_EXAMPLE_NETTEST_NOMAC=n
+CONFIG_EXAMPLE_NETTEST_NOMAC=y
 CONFIG_EXAMPLE_NETTEST_IPADDR=(10<<24|0<<16|0<<8|2)
 CONFIG_EXAMPLE_NETTEST_DRIPADDR=(10<<24|0<<16|0<<8|1)
 CONFIG_EXAMPLE_NETTEST_NETMASK=(255<<24|255<<16|255<<8|0)
@@ -790,6 +807,56 @@ CONFIG_EXAMPLES_USBSERIAL_TRACETRANSFERS=n
 CONFIG_EXAMPLES_USBSERIAL_TRACECONTROLLER=n
 CONFIG_EXAMPLES_USBSERIAL_TRACEINTERRUPTS=n
 
+#
+# Settings for examples/usbstorage
+#
+# CONFIG_EXAMPLES_USBSTRG_NLUNS
+#    Defines the number of logical units (LUNs) exported by the USB storage
+#    driver.  Each LUN corresponds to one exported block driver (or partition
+#    of a block driver).  May be 1, 2, or 3.  Default is 1.
+# CONFIG_EXAMPLES_USBSTRG_DEVMINOR1
+#    The minor device number of the block driver for the first LUN. For
+#    example, N in /dev/mmcsdN.  Used for registering the block driver. Default
+#    is zero.
+# CONFIG_EXAMPLES_USBSTRG_DEVPATH1
+#    The full path to the registered block driver.  Default is "/dev/mmcsd0"
+#  CONFIG_EXAMPLES_USBSTRG_DEVMINOR2 and CONFIG_EXAMPLES_USBSTRG_DEVPATH2
+#    Similar parameters that would have to be provided if CONFIG_EXAMPLES_USBSTRG_NLUNS
+#    is 2 or 3.  No defaults.
+#  CONFIG_EXAMPLES_USBSTRG_DEVMINOR3 and CONFIG_EXAMPLES_USBSTRG_DEVPATH3
+#    Similar parameters that would have to be provided if CONFIG_EXAMPLES_USBSTRG_NLUNS
+#    is 3.  No defaults.
+#
+#  If CONFIG_USBDEV_TRACE is enabled (or CONFIG_DEBUG and CONFIG_DEBUG_USB), then
+#  the example code will also manage the USB trace output.  The amount of trace output
+#  can be controlled using:
+#
+#  CONFIG_EXAMPLES_USBSTRG_TRACEINIT
+#    Show initialization events
+#  CONFIG_EXAMPLES_USBSTRG_TRACECLASS
+#    Show class driver events
+#  CONFIG_EXAMPLES_USBSTRG_TRACETRANSFERS
+#    Show data transfer events
+#  CONFIG_EXAMPLES_USBSTRG_TRACECONTROLLER
+#    Show controller events
+#  CONFIG_EXAMPLES_USBSTRG_TRACEINTERRUPTS
+#    Show interrupt-related events.
+#
+CONFIG_EXAMPLES_USBSTRG_NLUNS=1
+CONFIG_EXAMPLES_USBSTRG_DEVMINOR1=0
+CONFIG_EXAMPLES_USBSTRG_DEVPATH1="/dev/mmcsd0"
+CONFIG_EXAMPLES_USBSTRG_TRACEINIT=n
+CONFIG_EXAMPLES_USBSTRG_TRACECLASS=n
+CONFIG_EXAMPLES_USBSTRG_TRACETRANSFERS=n
+CONFIG_EXAMPLES_USBSTRG_TRACECONTROLLER=n
+CONFIG_EXAMPLES_USBSTRG_TRACEINTERRUPTS=n
+
+CONFIG_EXAMPLES_USBSTRG_TRACEINIT=n
+CONFIG_EXAMPLES_USBSTRG_TRACECLASS=n
+CONFIG_EXAMPLES_USBSTRG_TRACETRANSFERS=n
+CONFIG_EXAMPLES_USBSTRG_TRACECONTROLLER=n
+CONFIG_EXAMPLES_USBSTRG_TRACEINTERRUPTS=n
+
 #
 # Stack and heap information
 #
diff --git a/configs/lpcxpresso-lpc1768/ostest/setenv.sh b/configs/lpcxpresso-lpc1768/ostest/setenv.sh
index c31fa87d37..7f902d549b 100755
--- a/configs/lpcxpresso-lpc1768/ostest/setenv.sh
+++ b/configs/lpcxpresso-lpc1768/ostest/setenv.sh
@@ -50,7 +50,10 @@ export TOOLCHAIN_BIN="/usr/local/LPCXpresso/tools/bin"
 # This the Cygwin path to the LPCXpresso 3.6 install location under Windows
 #export TOOLCHAIN_BIN="/cygdrive/c/nxp/lpcxpresso_3.6/Tools/bin"
 
+# This is the path to the LPCXpression tool subdirectory
+export LPCTOOL_DIR="${WD}/configs/lpcxpresso-lpc1768/tools"
+
 # Add the path to the toolchain to the PATH varialble
-export PATH="${TOOLCHAIN_BIN}:/sbin:/usr/sbin:${PATH_ORIG}"
+export PATH="${TOOLCHAIN_BIN}:${LPCTOOL_DIR}:/sbin:/usr/sbin:${PATH_ORIG}"
 
 echo "PATH : ${PATH}"
diff --git a/configs/lpcxpresso-lpc1768/tools/flash.sh b/configs/lpcxpresso-lpc1768/tools/flash.sh
index 6d3f890a78..0dc2851327 100755
--- a/configs/lpcxpresso-lpc1768/tools/flash.sh
+++ b/configs/lpcxpresso-lpc1768/tools/flash.sh
@@ -35,14 +35,19 @@
 ####################################################################################
 
 USAGE="$0 <nuttx-path>"
-echo "Assumptions:"
-echo ""
-echo "  - Windows 7"
-echo "  - LPCXpresso 4.6 installed at /cygdrive/c/nxp/lpcxpresso_3.6"
-echo "  - AXF image built with Code Red"
-echo "  - LPC17xx"
+
+echo "############################################################################"
+echo "# Assumptions:"
+echo "#"
+echo "#   - Windows 7"
+echo "#   - LPCXpresso 3.6 installed at /cygdrive/c/nxp/lpcxpresso_3.6"
+echo "#   - AXF image built with Code Red"
+echo "#   - LPC1768"
+echo "#"
+echo "# You will need to edit this is any of the above are false"
+echo "#"
+echo "############################################################################"
 echo ""
-echo "You will need to edit this is any of the above are false"
 
 # This is the default install location for binaries on Windows (note that this
 # path could change with the Code Red version number)
@@ -121,6 +126,21 @@ cd ${BINDIR} || \
 ./${BOOTLPC} ${BOOTLPC_ARG} || \
 	{ echo "'${BOOTLPC} ${BOOTLPC_ARG}' Failed"; }
 
+echo ""
+echo "Wait a bit"
+echo "5..."
+sleep 1
+echo "4..."
+sleep 1
+echo "3..."
+sleep 1
+echo "2..."
+sleep 1
+echo "1..."
+sleep 1
+echo "0..."
+echo ""
+
 # Then program the FLASH
 
 ./${FLASHUTIL} ${WIRE} -p${TARGET} -flash-load-exec="${NUTTXPATH}"
diff --git a/configs/olimex-lpc1766stk/ostest/defconfig b/configs/olimex-lpc1766stk/ostest/defconfig
index 01f6e418bc..fd9b3b409c 100755
--- a/configs/olimex-lpc1766stk/ostest/defconfig
+++ b/configs/olimex-lpc1766stk/ostest/defconfig
@@ -64,7 +64,7 @@
 # CONFIG_ARCH_CALIBRATION - Enables some build in instrumentation that
 #   cause a 100 second delay during boot-up.  This 100 second delay
 #   serves no purpose other than it allows you to calibrate
-#   CONFIG_BOARD_LOOPSPERMSEC.  You simply use a stop watch to measure
+# CONFIG_BOARD_LOOPSPERMSEC.  You simply use a stop watch to measure
 #   the 100 second delay then adjust CONFIG_BOARD_LOOPSPERMSEC until
 #   the delay actually is 100 seconds.
 # CONFIG_ARCH_DMA - Support DMA initialization
@@ -685,6 +685,7 @@ CONFIG_EXAMPLE_UIP_DHCPC=n
 
 #
 # Settings for examples/nettest
+#
 # CONFIG_EXAMPLE_NETTEST_SERVER - The target board can act
 #   as either the client side or server side of the test
 # CONFIG_EXAMPLE_NETTEST_PERFORMANCE - If set, then the
-- 
GitLab