aboutsummaryrefslogtreecommitdiff
path: root/nuttx/configs
diff options
context:
space:
mode:
authorpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2012-07-13 16:03:13 +0000
committerpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2012-07-13 16:03:13 +0000
commit397386eb8aaaa4c9badd233ce2ec304fc6af7901 (patch)
tree26d3878d2b971cb3523134d71701d12867ad23d7 /nuttx/configs
parent91e5d3ac52668eff19e4994b85411a73170c01ab (diff)
downloadpx4-firmware-397386eb8aaaa4c9badd233ce2ec304fc6af7901.tar.gz
px4-firmware-397386eb8aaaa4c9badd233ce2ec304fc6af7901.tar.bz2
px4-firmware-397386eb8aaaa4c9badd233ce2ec304fc6af7901.zip
Implement basic SPIFI block driver for the LPC43xx (doesn't work)
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4938 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'nuttx/configs')
-rw-r--r--nuttx/configs/lpc4330-xplorer/README.txt22
-rw-r--r--nuttx/configs/lpc4330-xplorer/nsh/defconfig31
-rw-r--r--nuttx/configs/lpc4330-xplorer/src/up_nsh.c111
3 files changed, 159 insertions, 5 deletions
diff --git a/nuttx/configs/lpc4330-xplorer/README.txt b/nuttx/configs/lpc4330-xplorer/README.txt
index b0385592d..e3697f6e7 100644
--- a/nuttx/configs/lpc4330-xplorer/README.txt
+++ b/nuttx/configs/lpc4330-xplorer/README.txt
@@ -867,3 +867,25 @@ Where <subdir> is one of the following:
CONFIG_BOOT_SRAM=y : Executing in SRAM
CONFIG_LPC32_CODEREDW=y : Code Red under Windows
+
+ This configuration has some special options that can be used to
+ create a block device on the SPIFI FLASH:
+
+ CONFIG_SPIFI_BLKDRVR - Enable to create a block driver on the SPFI
+ device.
+ CONFIG_SPIFI_DEVNO - SPIFI minor device number. The SPFI device will
+ be at /dev/ramN, where N is the value of CONFIG_SPIFI_DEVNO.
+ Default: 0.
+ CONFIG_SPIFI_RDONLY - Create a read only device on SPIFI.
+ CONFIG_SPIFI_OFFSET - Offset the beginning of the block driver this
+ many bytes into the device address space. Default 0.
+ CONFIG_SPIFI_BLKSIZE - The size of one block. SPIFI is not block
+ oriented, so most any size of the block used in the SPIFI block
+ device can be used. NOTE: FAT will support only sector sizes of
+ 512, 1024, 2048, or 4096. Default: 512
+ CONFIG_SPIFI_NBLOCKS - The number of blocks in the file system,
+ each of size CONFIG_SPIFI_BLKSIZE. The end of the file system
+ will be at device offset:
+ CONFIG_SPIFI_OFFSET + CONFIG_SPIFI_BLKSIZE*CONFIG_SPIFI_NBLOCKS
+ The must assure that this does offset does not go beyond the end
+ of the FLASH memory.
diff --git a/nuttx/configs/lpc4330-xplorer/nsh/defconfig b/nuttx/configs/lpc4330-xplorer/nsh/defconfig
index a14013152..4bb270bb8 100644
--- a/nuttx/configs/lpc4330-xplorer/nsh/defconfig
+++ b/nuttx/configs/lpc4330-xplorer/nsh/defconfig
@@ -381,6 +381,7 @@ CONFIG_DEBUG=n
CONFIG_DEBUG_VERBOSE=n
CONFIG_DEBUG_SYMBOLS=n
CONFIG_DEBUG_SCHED=n
+CONFIG_DEBUG_FS=n
CONFIG_HAVE_CXX=n
CONFIG_HAVE_CXXINITIALIZE=n
@@ -657,6 +658,35 @@ CONFIG_MMCSD_MMCSUPPORT=n
CONFIG_MMCSD_HAVECARDDETECT=n
#
+# This configuration has some special options that can be used to
+# create a block device on the SPIFI FLASH:
+#
+# CONFIG_SPIFI_BLKDRVR - Enable to create a block driver on the SPFI
+# device.
+# CONFIG_SPIFI_DEVNO - SPIFI minor device number. The SPFI device will
+# be at /dev/rdN, where N is the value of CONFIG_SPIFI_DEVNO.
+# Default: 0.
+# CONFIG_SPIFI_RDONLY - Create a read only device on SPIFI.
+# CONFIG_SPIFI_OFFSET - Offset the beginning of the block driver this
+# many bytes into the device address space. Default 0.
+# CONFIG_SPIFI_BLKSIZE - The size of one block. SPIFI is not block
+# oriented, so most any size of the block used in the SPIFI block
+# device can be used. NOTE: FAT will support only sector sizes of 512,
+# 1024, 2048, or 4096. Default: 512
+# CONFIG_SPIFI_NBLOCKS - The number of blocks in the file system,
+# each of size CONFIG_SPIFI_BLKSIZE. The end of the file system
+# will be at device offset:
+# CONFIG_SPIFI_OFFSET + CONFIG_SPIFI_BLKSIZE*CONFIG_SPIFI_NBLOCKS
+# The must assure that this does offset does not go beyond the end
+# of the FLASH memory.
+#
+CONFIG_SPIFI_BLKDRVR=n
+CONFIG_SPIFI_DEVNO=0
+CONFIG_SPIFI_RDONLY=n
+CONFIG_SPIFI_OFFSET=0
+CONFIG_SPIFI_BLKSIZE=512
+CONFIG_SPIFI_NBLOCKS=(1024*1024/512)
+
# TCP/IP and UDP support via uIP
# CONFIG_NET - Enable or disable all network features
# CONFIG_NET_IPv6 - Build in support for IPv6
@@ -866,6 +896,7 @@ CONFIG_EXAMPLE_UIP_DHCPC=n
#
# Settings for examples/nettest
+#
CONFIG_EXAMPLE_NETTEST_SERVER=n
CONFIG_EXAMPLE_NETTEST_PERFORMANCE=n
CONFIG_EXAMPLE_NETTEST_NOMAC=n
diff --git a/nuttx/configs/lpc4330-xplorer/src/up_nsh.c b/nuttx/configs/lpc4330-xplorer/src/up_nsh.c
index 98387dfe1..c9284ab5b 100644
--- a/nuttx/configs/lpc4330-xplorer/src/up_nsh.c
+++ b/nuttx/configs/lpc4330-xplorer/src/up_nsh.c
@@ -44,14 +44,21 @@
#include <debug.h>
#include <errno.h>
-#include <nuttx/spi.h>
-#include <nuttx/mmcsd.h>
+/* This should be removed someday when we are confident in SPIFI */
+
+#ifdef CONFIG_DEBUG_FS
+# include "up_arch.h"
+# include "chip/lpc43_cgu.h"
+# include "chip/lpc43_ccu.h"
+#endif
+
+#include "chip.h"
+#include <nuttx/ramdisk.h>
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
-
-/* Configuration ************************************************************/
+/* USB Configuration ********************************************************/
/* PORT and SLOT number probably depend on the board configuration */
@@ -68,6 +75,43 @@
# undef CONFIG_NSH_HAVEUSBDEV
#endif
+/* SPIFI Configuration ******************************************************/
+/* CONFIG_SPIFI_BLKDRVR - Enable to create a block driver on the SPFI device.
+ * CONFIG_SPIFI_DEVNO - SPIFI minor device number. The SPFI device will be
+ * at /dev/ramN, where N is the value of CONFIG_SPIFI_DEVNO. Default: 0.
+ * CONFIG_SPIFI_RDONLY - Create a read only device on SPIFI.
+ * CONFIG_SPIFI_OFFSET - Offset the beginning of the block driver this many
+ * bytes into the device address space. Default 0.
+ * CONFIG_SPIFI_BLKSIZE - The size of one block. SPIFI is not block oriented,
+ * so most any size of the block used in the SPIFI block device can be
+ * used. NOTE: FAT will support only sector sizes of 512, 1024, 2048, or
+ * 4096. Default: 512
+ * CONFIG_SPIFI_NBLOCKS - The number of blocks in the file system, each of
+ * size CONFIG_SPIFI_BLKSIZE. The end of the file system will be at
+ * device offset:
+ * CONFIG_SPIFI_OFFSET + CONFIG_SPIFI_BLKSIZE*CONFIG_SPIFI_NBLOCKS
+ * The must assure that this does offset does not go beyond the end of
+ * the FLASH memory.
+ */
+
+#ifdef CONFIG_SPIFI_BLKDRVR
+# ifndef CONFIG_SPIFI_DEVNO
+# define CONFIG_SPIFI_DEVNO 0
+# endif
+# ifndef CONFIG_SPIFI_OFFSET
+# define CONFIG_SPIFI_OFFSET 0
+# endif
+# ifndef CONFIG_SPIFI_BLKSIZE
+# define CONFIG_SPIFI_BLKSIZE 512
+# endif
+# ifndef CONFIG_SPIFI_NBLOCKS
+# error "Need number of SPIFI blocks (CONFIG_SPIFI_NBLOCKS)"
+# endif
+#endif
+
+#define SPIFI_BUFFER \
+ (FAR uint8_t *)(LPC43_LOCSRAM_SPIFI_BASE + CONFIG_SPIFI_OFFSET)
+
/* Debug ********************************************************************/
#ifdef CONFIG_CPP_HAVE_VARARGS
@@ -85,6 +129,61 @@
#endif
/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nsh_spifi_initialize
+ *
+ * Description:
+ * Make the SPIFI (or part of it) into a block driver that can hold a
+ * file system.
+ *
+ * SPIFI AHB register clock:
+ * Base clock = BASE_M4_CLK
+ * Branch clock = CLK_M4_SPIFI
+ * SPIFI serial clock input:
+ * Base clock = BASE_SPIFI_CLK
+ * Branch clock = SPIFI_CLK
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_SPIFI_BLKDRVR
+static int nsh_spifi_initialize(void)
+{
+ /* This should be removed someday when we are confident in SPIFI */
+
+#ifdef CONFIG_DEBUG_FS
+ fdbg("BASE_SPIFI_CLK=%08x\n",
+ getreg32(LPC43_BASE_SPIFI_CLK));
+ fdbg("SPFI CFG=%08x STAT=%08x\n",
+ getreg32(LPC43_CCU1_SPIFI_CFG), getreg32(LPC43_CCU1_SPIFI_STAT));
+ fdbg("M4 SPFI CFG=%08x STAT=%08x\n",
+ getreg32(LPC43_CCU1_M4_SPIFI_CFG), getreg32(LPC43_CCU1_M4_SPIFI_STAT));
+#endif
+
+#ifdef CONFIG_SPIFI_RDONLY
+ /* Register a read-only SPIFI RAM disk at /dev/ramN, where N is the
+ * value of CONFIG_SPIFI_DEVNO.
+ */
+
+ return romdisk_register(CONFIG_SPIFI_DEVNO, SPIFI_BUFFER,
+ CONFIG_SPIFI_NBLOCKS, CONFIG_SPIFI_BLKSIZE);
+#else
+ /* Register a write-able SPIFI RAM disk at /dev/ramN, where N is the
+ * value of CONFIG_SPIFI_DEVNO.
+ */
+
+ return ramdisk_register(CONFIG_SPIFI_DEVNO, SPIFI_BUFFER,
+ CONFIG_SPIFI_NBLOCKS, CONFIG_SPIFI_BLKSIZE,
+ true);
+#endif
+}
+#else
+# define nsh_spifi_initialize() (OK)
+#endif
+
+/****************************************************************************
* Public Functions
****************************************************************************/
@@ -98,5 +197,7 @@
int nsh_archinitialize(void)
{
- return OK;
+ /* Initialize the SPIFI block device */
+
+ return nsh_spifi_initialize();
}