diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2013-11-25 12:10:24 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2013-11-25 12:10:24 -0600 |
commit | d0ae57d1bdbaa17cb2731778d5a63bb816eb222c (patch) | |
tree | 68f15f5b42f6e51ac75343756fcc017823030b8d /nuttx/configs | |
parent | 12da6f5a776216d833fdd51b17b9a89f52de1267 (diff) | |
download | px4-nuttx-d0ae57d1bdbaa17cb2731778d5a63bb816eb222c.tar.gz px4-nuttx-d0ae57d1bdbaa17cb2731778d5a63bb816eb222c.tar.bz2 px4-nuttx-d0ae57d1bdbaa17cb2731778d5a63bb816eb222c.zip |
SAMA5D3x-EK NAND: Integrate SAMA5 NAND support into SAMA5D3x-EK board support
Diffstat (limited to 'nuttx/configs')
-rw-r--r-- | nuttx/configs/sama5d3x-ek/Kconfig | 62 | ||||
-rw-r--r-- | nuttx/configs/sama5d3x-ek/README.txt | 48 | ||||
-rw-r--r-- | nuttx/configs/sama5d3x-ek/src/sam_at24.c | 8 | ||||
-rw-r--r-- | nuttx/configs/sama5d3x-ek/src/sam_at25.c | 8 | ||||
-rw-r--r-- | nuttx/configs/sama5d3x-ek/src/sam_nandflash.c | 79 | ||||
-rw-r--r-- | nuttx/configs/sama5d3x-ek/src/sam_nsh.c | 23 | ||||
-rw-r--r-- | nuttx/configs/sama5d3x-ek/src/sam_usbmsc.c | 4 | ||||
-rw-r--r-- | nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h | 77 |
8 files changed, 264 insertions, 45 deletions
diff --git a/nuttx/configs/sama5d3x-ek/Kconfig b/nuttx/configs/sama5d3x-ek/Kconfig index 8a110979d..ca8e9042b 100644 --- a/nuttx/configs/sama5d3x-ek/Kconfig +++ b/nuttx/configs/sama5d3x-ek/Kconfig @@ -42,13 +42,43 @@ config SAMA5_NOR_START option: If SAMA5_NOR_START is defined, then it will not wait but will, instead, immediately start the program in NOR FLASH. -config SAMA5_TSD_DEVMINOR - int "Touchscreen device minor" - default 0 - depends on SAMA5_TSD +config SAMA5_NAND_AUTOMOUNT + bool "NAND FLASH auto-mount" + default n + depends on NSH_ARCHINIT && SAMA5_EBICS3_NAND ---help--- - This touchscreen will be register as /dev/inputN where the value of - N is provided by this configuration setting. + Automatically initialize the NAND FLASH driver when NSH starts. + +choice + prompt "NAND FLASH configuration" + default SAMA5_NAND_NXFFS + depends on SAMA5_NAND_AUTOMOUNT + +config SAMA5_NAND_FTL + bool "Create NAND FLASH block driver" + ---help--- + Create the MTD driver for the NAND and "wrap" the NAND as a standard + block driver that could then, for example, be mounted using FAT or + any other file system. Any file system may be used, but there will + be no wear-leveling. + + NOTE: This options is not currently recommended. There is not now + NuttX file system that can handle the NAND back blocks or performs + wear-leveling other than NXFFS and NXFFS does not use a block driver + but, rather, operates directly upon the NAND MTD device. + +config SAMA5_NAND_NXFFS + bool "Create NAND FLASH NXFFS file system" + depends on FS_NXFFS + ---help--- + Create the MTD driver for the NAND and mount the NAND device as + a wear-leveling, NuttX FLASH file system (NXFFS). The downside of + NXFFS is that it can be very slow. + + NOTE: NXFFS is recommended because (1) it can handle the NAND back + blocks and (1) performs wear-leveling. + +endchoice # NAND FLASH configuration config SAMA5_AT25_AUTOMOUNT bool "AT25 serial FLASH auto-mount" @@ -65,7 +95,7 @@ choice config SAMA5_AT25_FTL bool "Create AT25 Serial FLASH block driver" ---help--- - Create the MTD driver for the AT25 and "wrap" the AT25 is a standard + Create the MTD driver for the AT25 and "wrap" the AT25 as a standard block driver that could then, for example, be mounted using FAT or any other file system. Any file system may be used, but there will be no wear-leveling. @@ -74,7 +104,7 @@ config SAMA5_AT25_NXFFS bool "Create AT25 serial FLASH NXFFS file system" depends on FS_NXFFS ---help--- - Create the MTD driver for the AT25 and and mount the AT25 device as + Create the MTD driver for the AT25 and mount the AT25 device as a wear-leveling, NuttX FLASH file system (NXFFS). The downside of NXFFS is that it can be very slow. @@ -106,7 +136,7 @@ choice config SAMA5_AT24_FTL bool "Create AT24 block driver" ---help--- - Create the MTD driver for the AT24 and "wrap" the AT24 is a standard + Create the MTD driver for the AT24 and "wrap" the AT24 as a standard block driver that could then, for example, be mounted using FAT or any other file system. Any file system may be used, but there will be no wear-leveling. @@ -115,12 +145,20 @@ config SAMA5_AT24_NXFFS bool "Create AT24 NXFFS file system" depends on FS_NXFFS ---help--- - Create the MTD driver for the AT24 and and mount the AT24 device as + Create the MTD driver for the AT24 and mount the AT24 device as a wear-leveling, NuttX FLASH file system (NXFFS). The downside of NXFFS is that it can be very slow. endchoice # AT24 serial EPPROM configuration +config SAMA5_TSD_DEVMINOR + int "Touchscreen device minor" + default 0 + depends on SAMA5_TSD + ---help--- + This touchscreen will be register as /dev/inputN where the value of + N is provided by this configuration setting. + config SAMA5D3X_EK_CHANNEL int "PWM channel number" default 0 if SAMA5_PWM_CHAN0 @@ -133,8 +171,6 @@ config SAMA5D3X_EK_CHANNEL Selects the PWM channel number that will be used to perform the PWM test. See apps/examples/pwm. -endif - if AUDIO_I2SCHAR && (SAMA5_SSC0 || SAMA5_SSC1) if SAMA5_SSC0 && SAMA5_SSC1 @@ -172,4 +208,6 @@ config SAMA5D3X_EK_I2SCHAR_MINOR device. The driver will be registered at /dev/is2charN where N is the value provided by this setting. +endif # AUDIO_I2SCHAR && (SAMA5_SSC0 || SAMA5_SSC1) + endif # ARCH_BOARD_SAMA5D3X_EK diff --git a/nuttx/configs/sama5d3x-ek/README.txt b/nuttx/configs/sama5d3x-ek/README.txt index 8596fb370..8c5516cb1 100644 --- a/nuttx/configs/sama5d3x-ek/README.txt +++ b/nuttx/configs/sama5d3x-ek/README.txt @@ -640,6 +640,48 @@ USB Ports ---- ----------- ------------------------------------------------------- PD28 OVCUR_USB Combined overrcurrent indication from port A and B +NAND Support +============ + NAND Support can be added to the the NSH configuration by modifying the + NuttX configuration file as follows: + + System Type -> SAMA5 Peripheal support + CONFIG_SAMA5_DMAC1=y : Use DMA1 for memory-to-memory DMA + CONFIG_SAMA5_HSMC=y : Make sure that the SMC is enabled + + Drivers -> Memory Technology Device (MTD) Support + CONFIG_MTD=y : Enable MTD support + CONFIG_MTD_NAND=y : Enable NAND support + CONFIG_MTD_NAND_BLOCKCHECK=y : Enable bad block checking support + CONFIG_MTD_NAND_HWECC=y : Use H/W ECC calculation + + Defaults for all other NAND settings should be okay + + System Type -> External Memory Configuration + CONFIG_SAMA5_EBICS3=y : Enable External CS3 memory + CONFIG_SAMA5_EBICS3_NAND=y : Select NAND memory type + CONFIG_SAMA5_EBICS3_SIZE=8388608 : Use this size + CONFIG_SAMA5_EBICS3_PMECC=y : Use H/W ECC calculation + CONFIG_SAMA5_PMECC_EMBEDDEDALGO=n : Use the software PMECC algorithm + CONFIG_SAMA5_PMECC_GALOIS_ROMTABLES=y : use the ROM Galois tables + + Defaults for ROM page table addresses should be okay + + File Systems: + CONFIG_FS_NXFFS=y : Enable the NXFFS file system + + Defaults for all other NXFFS settings should be okay + + Board Selection + CONFIG_SAMA5_NAND_AUTOMOUNT=y : Enable FS support on NAND + CONFIG_SAMA5_NAND_NXFFS=y : Use the NXFFS file system + + Other file systems are not recommended because only NXFFS can handle + bad blocks and only NXFFS performs wear-leveling. + + Application Configuration -> NSH Library + CONFIG_NSH_ARCHINIT=y : Use architecture-specific initialization + AT24 Serial EEPROM ================== @@ -2881,9 +2923,5 @@ To-Do List do with the camera. NuttX needs something liek V4L to provide the definition for what a camera driver is supposed to do. -11) NAND. There is no NAND support. A NAND driver is a complex thing - because it must support not only basic NAND access but also bad block - detection, sparing and ECC. Lots of work! - -12) GMAC has only been tested on a 10/100Base-T network. I don't have a +11) GMAC has only been tested on a 10/100Base-T network. I don't have a 1000Base-T network to support additional testing. diff --git a/nuttx/configs/sama5d3x-ek/src/sam_at24.c b/nuttx/configs/sama5d3x-ek/src/sam_at24.c index e935672ca..7efe93f6a 100644 --- a/nuttx/configs/sama5d3x-ek/src/sam_at24.c +++ b/nuttx/configs/sama5d3x-ek/src/sam_at24.c @@ -81,14 +81,14 @@ ****************************************************************************/ /**************************************************************************** - * Name: sam_at24_initialize + * Name: sam_at24_automount * * Description: * Initialize and configure the AT24 serial EEPROM * ****************************************************************************/ -int sam_at24_initialize(int minor) +int sam_at24_automount(int minor) { FAR struct i2c_dev_s *i2c; FAR struct mtd_dev_s *mtd; @@ -127,7 +127,7 @@ int sam_at24_initialize(int minor) ret = ftl_initialize(AT24_MINOR, mtd); if (ret < 0) { - fdbg("ERROR: Initialize the FTL layer\n"); + fdbg("ERROR: Failed to initialize the FTL layer: %d\n", ret); return ret; } @@ -138,7 +138,7 @@ int sam_at24_initialize(int minor) ret = nxffs_initialize(mtd); if (ret < 0) { - fdbg("ERROR: NXFFS initialization failed: %d\n", -ret); + fdbg("ERROR: NXFFS initialization failed: %d\n", ret); return ret; } diff --git a/nuttx/configs/sama5d3x-ek/src/sam_at25.c b/nuttx/configs/sama5d3x-ek/src/sam_at25.c index 4ecef3cf1..2be9a3bb1 100644 --- a/nuttx/configs/sama5d3x-ek/src/sam_at25.c +++ b/nuttx/configs/sama5d3x-ek/src/sam_at25.c @@ -64,14 +64,14 @@ ****************************************************************************/ /**************************************************************************** - * Name: sam_at25_initialize + * Name: sam_at25_automount * * Description: * Initialize and configure the AT25 serial FLASH * ****************************************************************************/ -int sam_at25_initialize(int minor) +int sam_at25_automount(int minor) { FAR struct spi_dev_s *spi; FAR struct mtd_dev_s *mtd; @@ -106,7 +106,7 @@ int sam_at25_initialize(int minor) ret = ftl_initialize(AT25_MINOR, mtd); if (ret < 0) { - fdbg("ERROR: Initialize the FTL layer\n"); + fdbg("ERROR: Failed to initialize the FTL layer: %d\n", ret); return ret; } @@ -116,7 +116,7 @@ int sam_at25_initialize(int minor) ret = nxffs_initialize(mtd); if (ret < 0) { - fdbg("ERROR: NXFFS initialization failed: %d\n", -ret); + fdbg("ERROR: NXFFS initialization failed: %d\n", ret); return ret; } diff --git a/nuttx/configs/sama5d3x-ek/src/sam_nandflash.c b/nuttx/configs/sama5d3x-ek/src/sam_nandflash.c index 8ad48ccc5..7c3680e21 100644 --- a/nuttx/configs/sama5d3x-ek/src/sam_nandflash.c +++ b/nuttx/configs/sama5d3x-ek/src/sam_nandflash.c @@ -46,8 +46,15 @@ #include <nuttx/config.h> +#include <sys/mount.h> +#include <stdbool.h> +#include <stdint.h> +#include <errno.h> #include <debug.h> +#include <nuttx/mtd/mtd.h> +#include <nuttx/fs/nxffs.h> + #include "up_arch.h" #include "sam_periphclks.h" #include "sam_nand.h" @@ -55,7 +62,7 @@ #include "sama5d3x-ek.h" -#ifdef CONFIG_SAMA5_BOOT_CS3FLASH +#ifdef CONFIG_SAMA5_EBICS3_NAND /**************************************************************************** * Pre-processor Definitions @@ -73,7 +80,7 @@ * Name: board_nandflash_config * * Description: - * If CONFIG_SAMA5_BOOT_CS3FLASH is defined, then NAND FLASH support is + * If CONFIG_SAMA5_EBICS3_NAND is defined, then NAND FLASH support is * enabled. This function provides the board-specific implementation of * the logic to reprogram the SMC to support NAND FLASH on the specified * CS. @@ -137,4 +144,70 @@ int board_nandflash_config(int cs) return -ENODEV; } -#endif /* CONFIG_SAMA5_BOOT_CS3FLASH */ +/**************************************************************************** + * Name: sam_nand_automount + * + * Description: + * Initialize and configure the NAND on CS3 + * + ****************************************************************************/ + +#ifdef HAVE_NAND +int sam_nand_automount(int minor) +{ + FAR struct mtd_dev_s *mtd; + static bool initialized = false; + int ret; + + /* Have we already initialized? */ + + if (!initialized) + { + /* Create and initialize an NAND MATD device */ + + mtd = sam_nand_initialize(HSMC_CS3); + if (!mtd) + { + fdbg("ERROR: Failed to create the NAND driver on CS%d\n", HSMC_CS3); + return -ENODEV; + } + +#if defined(CONFIG_SAMA5_NAND_FTL) + /* Use the FTL layer to wrap the MTD driver as a block driver */ + + ret = ftl_initialize(NAND_MINOR, mtd); + if (ret < 0) + { + fdbg("ERROR: Failed to initialize the FTL layer: %d\n", ret); + return ret; + } + +#elif defined(CONFIG_SAMA5_NAND_NXFFS) + /* Initialize to provide NXFFS on the MTD interface */ + + ret = nxffs_initialize(mtd); + if (ret < 0) + { + fdbg("ERROR: NXFFS initialization failed: %d\n", ret); + return ret; + } + + /* Mount the file system at /mnt/nand */ + + ret = mount(NULL, "/mnt/nand", "nxffs", 0, NULL); + if (ret < 0) + { + fdbg("ERROR: Failed to mount the NXFFS volume: %d\n", errno); + return ret; + } +#endif + /* Now we are intialized */ + + initialized = true; + } + + return OK; +} +#endif + +#endif /* CONFIG_SAMA5_EBICS3_NAND */ diff --git a/nuttx/configs/sama5d3x-ek/src/sam_nsh.c b/nuttx/configs/sama5d3x-ek/src/sam_nsh.c index 27c72158a..dc62c193e 100644 --- a/nuttx/configs/sama5d3x-ek/src/sam_nsh.c +++ b/nuttx/configs/sama5d3x-ek/src/sam_nsh.c @@ -86,18 +86,29 @@ int nsh_archinitialize(void) { -#if defined(HAVE_AT25) || defined(HAVE_AT24) || defined(HAVE_HSMCI) || \ - defined(HAVE_USBHOST) || defined(HAVE_USBMONITOR) +#if defined(HAVE_NAND) || defined(HAVE_AT25) || defined(HAVE_AT24) || \ + defined(HAVE_HSMCI) || defined(HAVE_USBHOST) || defined(HAVE_USBMONITOR) int ret; #endif +#ifdef HAVE_NAND + /* Initialize the NAND driver */ + + ret = sam_nand_automount(NAND_MINOR); + if (ret < 0) + { + message("ERROR: sam_nand_automount failed: %d\n", ret); + return ret; + } +#endif + #ifdef HAVE_AT25 /* Initialize the AT25 driver */ - ret = sam_at25_initialize(AT25_MINOR); + ret = sam_at25_automount(AT25_MINOR); if (ret < 0) { - message("ERROR: sam_at25_initialize failed: %d\n", ret); + message("ERROR: sam_at25_automount failed: %d\n", ret); return ret; } #endif @@ -105,10 +116,10 @@ int nsh_archinitialize(void) #ifdef HAVE_AT24 /* Initialize the AT24 driver */ - ret = sam_at24_initialize(AT24_MINOR); + ret = sam_at24_automount(AT24_MINOR); if (ret < 0) { - message("ERROR: sam_at24_initialize failed: %d\n", ret); + message("ERROR: sam_at24_automount failed: %d\n", ret); return ret; } #endif diff --git a/nuttx/configs/sama5d3x-ek/src/sam_usbmsc.c b/nuttx/configs/sama5d3x-ek/src/sam_usbmsc.c index b303e6d87..a386bda49 100644 --- a/nuttx/configs/sama5d3x-ek/src/sam_usbmsc.c +++ b/nuttx/configs/sama5d3x-ek/src/sam_usbmsc.c @@ -110,10 +110,10 @@ int usbmsc_archinitialize(void) /* Initialize the AT25 MTD driver */ #ifdef HAVE_AT25 - int ret = sam_at25_initialize(AT25_MINOR); + int ret = sam_at25_automount(AT25_MINOR); if (ret < 0) { - message("ERROR: sam_at25_initialize failed: %d\n", ret); + message("ERROR: sam_at25_automount failed: %d\n", ret); } return ret; diff --git a/nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h b/nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h index 99b097aa6..f0cff264e 100644 --- a/nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h +++ b/nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h @@ -58,6 +58,7 @@ #define HAVE_HSMCI 1 #define HAVE_AT24 1 #define HAVE_AT25 1 +#define HAVE_NAND 1 #define HAVE_USBHOST 1 #define HAVE_USBDEV 1 #define HAVE_USBMONITOR 1 @@ -84,6 +85,39 @@ # undef HAVE_HSMCI #endif +/* NAND FLASH */ +/* Can't support the NAND device if NAND flash is not configured on EBI CS3 */ + +#ifndef CONFIG_SAMA5_EBICS3_NAND +# undef HAVE_NAND +#endif + +/* Can't support NAND features if mountpoints are disabled or if we were not + * asked to mount the NAND part + */ + +#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_SAMA5_NAND_AUTOMOUNT) +# undef HAVE_NAND +#endif + +/* If we are going to mount the NAND, then they user must also have told + * us what to do with it by setting one of these. + */ + +#ifndef CONFIG_FS_NXFFS +# undef CONFIG_SAMA5_NAND_NXFFS +#endif + +#if !defined(CONFIG_SAMA5_NAND_FTL) && !defined(CONFIG_SAMA5_NAND_NXFFS) +# undef HAVE_NAND +#endif + +#if defined(CONFIG_SAMA5_NAND_FTL) && defined(CONFIG_SAMA5_NAND_NXFFS) +# warning Both CONFIG_SAMA5_NAND_FTL and CONFIG_SAMA5_NAND_NXFFS are set +# warning Ignoring CONFIG_SAMA5_NAND_NXFFS +# undef CONFIG_SAMA5_NAND_NXFFS +#endif + /* AT25 Serial FLASH */ /* Can't support the AT25 device if it SPI0 or AT25 support are not enabled */ @@ -167,15 +201,28 @@ # undef CONFIG_SAMA5_AT24_NXFFS #endif -/* Assign minor device numbers. We will also use MINOR number 0 for the AT25. - * It should appear as /dev/mtdblock0 +/* Assign minor device numbers. For example, if we also use MINOR number 0 + * for the AT25, it should appear as /dev/mtdblock0 */ +#define _NAND_MINOR 0 + +#ifdef HAVE_NAND +# define NAND_MINOR _NAND_MINOR +# define _AT25_MINOR (_NAND_MINOR+1) +#else +# define _AT25_MINOR _NAND_MINOR +#endif + #ifdef HAVE_AT25 -# define AT25_MINOR 0 -# define AT24_MINOR 1 +# define AT25_MINOR _AT25_MINOR +# define _AT24_MINOR (_AT25_MINOR+1) #else -# define AT24_MINOR 0 +# define _AT24_MINOR _AT25_MINOR +#endif + +#ifdef HAVE_AT24 +# define AT24_MINOR _AT24_MINOR #endif /* MMC/SD minor numbers: The NSH device minor extended is extened to support @@ -549,7 +596,19 @@ void sam_sdram_config(void); #endif /**************************************************************************** - * Name: sam_at25_initialize + * Name: sam_nand_automount + * + * Description: + * Initialize and configure the NAND on CS3 + * + ****************************************************************************/ + +#ifdef HAVE_NAND +int sam_nand_automount(int minor); +#endif + +/**************************************************************************** + * Name: sam_at25_automount * * Description: * Initialize and configure the AT25 serial FLASH @@ -557,11 +616,11 @@ void sam_sdram_config(void); ****************************************************************************/ #ifdef HAVE_AT25 -int sam_at25_initialize(int minor); +int sam_at25_automount(int minor); #endif /**************************************************************************** - * Name: sam_at24_initialize + * Name: sam_at24_automount * * Description: * Initialize and configure the AT24 serial EEPROM @@ -569,7 +628,7 @@ int sam_at25_initialize(int minor); ****************************************************************************/ #ifdef HAVE_AT24 -int sam_at24_initialize(int minor); +int sam_at24_automount(int minor); #endif /**************************************************************************** |