SAMA5D3x-EK NAND: Integrate SAMA5 NAND support into SAMA5D3x-EK board support

This commit is contained in:
Gregory Nutt 2013-11-25 12:10:24 -06:00
parent 395b7bff67
commit b7a3597f87
8 changed files with 265 additions and 46 deletions

View File

@ -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

View File

@ -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.

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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 */

View File

@ -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

View File

@ -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;

View File

@ -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
*/
#ifdef HAVE_AT25
# define AT25_MINOR 0
# define AT24_MINOR 1
#define _NAND_MINOR 0
#ifdef HAVE_NAND
# define NAND_MINOR _NAND_MINOR
# define _AT25_MINOR (_NAND_MINOR+1)
#else
# define AT24_MINOR 0
# define _AT25_MINOR _NAND_MINOR
#endif
#ifdef HAVE_AT25
# define AT25_MINOR _AT25_MINOR
# define _AT24_MINOR (_AT25_MINOR+1)
#else
# 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
/****************************************************************************