SAMV7-XULT: If no file system is specified for the S25FL1, wrap it as a character device

This commit is contained in:
Gregory Nutt 2015-11-09 09:33:41 -06:00
parent aae9b2b40c
commit e85baa6dde
2 changed files with 40 additions and 3 deletions

View File

@ -50,6 +50,7 @@
# include <apps/usbmonitor.h>
#endif
#include <nuttx/fs/fs.h>
#include <nuttx/fs/ramdisk.h>
#include <nuttx/binfmt/elf.h>
@ -98,6 +99,10 @@ int sam_bringup(void)
#ifdef HAVE_S25FL1
FAR struct qspi_dev_s *qspi;
FAR struct mtd_dev_s *mtd;
#ifndef HAVE_SMARTFS
char blockdev[18];
char chardev[12];
#endif
#endif
int ret;
@ -211,16 +216,35 @@ int sam_bringup(void)
#ifdef HAVE_SMARTFS
/* Configure the device with no partition support */
ret = smart_initialize(0, mtd, NULL);
ret = smart_initialize(S25FL1_SMART_MINOR, mtd, NULL);
if (ret != OK)
{
SYSLOG("ERROR: Failed to initialize SmartFS: %d\n", ret);
}
#else
/* And now do what with the S25FL1 MTD device? */
# warning Missing Logic
/* Use the FTL layer to wrap the MTD driver as a block driver */
ret = ftl_initialize(S25FL1_MTD_MINOR, mtd);
if (ret < 0)
{
SYSLOG("ERROR: Failed to initialize the FTL layer: %d\n", ret);
return ret;
}
/* Use the minor number to create device paths */
snprintf(blockdev, 18, "/dev/mtdblock%d", S25FL1_MTD_MINOR);
snprintf(chardev, 12, "/dev/mtd%d", S25FL1_MTD_MINOR);
/* Now create a character device on the block device */
ret = bchdev_register(blockdev, chardev, false);
if (ret < 0)
{
SYSLOG("ERROR: bchdev_register %s failed: %d\n", chardev, ret);
return ret;
}
#endif
}
#endif

View File

@ -199,6 +199,19 @@
# undef HAVE_SMARTFS
#endif
/* If both the S25FL1 FLASH and SmartFS, then this is the minor device
* number of the Smart block driver (/dev/smartN)
*/
#define S25FL1_SMART_MINOR 0
/* If the S25FL1 FLASH is enabled but not SmartFS, then the S25FL will be
* wrapped as a character device. This is the minor number of both the
* block device (/dev/mtdblockN) and the character device (/dev/mtdN).
*/
#define S25FL1_MTD_MINOR 0
/* Audio */
/* PCM/WM8904 driver */