diff --git a/configs/samv71-xult/src/sam_bringup.c b/configs/samv71-xult/src/sam_bringup.c index b8c93d733b1..0d801c8e1dc 100644 --- a/configs/samv71-xult/src/sam_bringup.c +++ b/configs/samv71-xult/src/sam_bringup.c @@ -57,10 +57,13 @@ #include "samv71-xult.h" +#if defined(HAVE_S25FL1) || defined(HAVE_PROGMEM_CHARDEV) +# include +#endif + #ifdef HAVE_S25FL1 -#include -#include -#include "sam_qspi.h" +# include +# include "sam_qspi.h" #endif #ifdef HAVE_ROMFS @@ -99,11 +102,13 @@ int sam_bringup(void) { #ifdef HAVE_S25FL1 FAR struct qspi_dev_s *qspi; +#endif +#if defined(HAVE_S25FL1) || defined(HAVE_PROGMEM_CHARDEV) FAR struct mtd_dev_s *mtd; -#ifndef HAVE_S25FL1_SMARTFS +#endif +#if defined(HAVE_S25FL1_CHARDEV) || defined(HAVE_PROGMEM_CHARDEV) char blockdev[18]; char chardev[12]; -#endif #endif int ret; @@ -241,7 +246,7 @@ int sam_bringup(void) return ret; } -#else +#else /* if defined(HAVE_S25FL1_CHARDEV) */ /* Use the FTL layer to wrap the MTD driver as a block driver */ ret = ftl_initialize(S25FL1_MTD_MINOR, mtd); @@ -268,6 +273,39 @@ int sam_bringup(void) } #endif +#ifdef HAVE_PROGMEM_CHARDEV + /* Create an instance of the SAMV71 FLASH program memory device driver */ + + mtd = progmem_initialize(); + if (!mtd) + { + SYSLOG("ERROR: progmem_initialize failed\n"); + } + + /* Use the FTL layer to wrap the MTD driver as a block driver */ + + ret = ftl_initialize(PROGMEM_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", PROGMEM_MTD_MINOR); + snprintf(chardev, 12, "/dev/mtd%d", PROGMEM_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 + #ifdef HAVE_USBHOST /* Initialize USB host operation. sam_usbhost_initialize() starts a thread * will monitor for USB connection and disconnection events. diff --git a/configs/samv71-xult/src/samv71-xult.h b/configs/samv71-xult/src/samv71-xult.h index 74cf5c99c6c..2f7a11c5ece 100644 --- a/configs/samv71-xult/src/samv71-xult.h +++ b/configs/samv71-xult/src/samv71-xult.h @@ -53,19 +53,21 @@ ************************************************************************************/ /* Configuration ********************************************************************/ -#define HAVE_HSMCI 1 -#define HAVE_AUTOMOUNTER 1 -#define HAVE_USB 1 -#define HAVE_USBDEV 1 -#define HAVE_USBMONITOR 1 -#define HAVE_NETWORK 1 -#define HAVE_MACADDR 1 -#define HAVE_MTDCONFIG 1 -#define HAVE_S25FL1 1 -#define HAVE_S25FL1_NXFFS 1 -#define HAVE_S25FL1_SMARTFS 1 -#define HAVE_WM8904 1 -#define HAVE_AUDIO_NULL 1 +#define HAVE_HSMCI 1 +#define HAVE_AUTOMOUNTER 1 +#define HAVE_USB 1 +#define HAVE_USBDEV 1 +#define HAVE_USBMONITOR 1 +#define HAVE_NETWORK 1 +#define HAVE_MACADDR 1 +#define HAVE_MTDCONFIG 1 +#define HAVE_S25FL1 1 +#define HAVE_S25FL1_NXFFS 1 +#define HAVE_S25FL1_SMARTFS 1 +#define HAVE_S25FL1_CHARDEV 1 +#define HAVE_PROGMEM_CHARDEV 1 +#define HAVE_WM8904 1 +#define HAVE_AUDIO_NULL 1 /* HSMCI */ /* Can't support MMC/SD if the card interface is not enabled */ @@ -190,12 +192,14 @@ # undef HAVE_S25FL1 # undef HAVE_S25FL1_NXFFS # undef HAVE_S25FL1_SMARTFS +# undef HAVE_S25FL1_CHARDEV #endif #ifndef CONFIG_SAMV7_QSPI # undef HAVE_S25FL1 # undef HAVE_S25FL1_NXFFS # undef HAVE_S25FL1_SMARTFS +# undef HAVE_S25FL1_CHARDEV #endif #ifndef CONFIG_FS_NXFFS @@ -206,6 +210,20 @@ # undef HAVE_S25FL1_SMARTFS #endif +#if defined(HAVE_S25FL1_NXFFS) && defined(HAVE_S25FL1_SMARTFS) +# undef HAVE_S25FL1_NXFFS +#endif + +#if defined(HAVE_S25FL1_NXFFS) || defined(HAVE_S25FL1_SMARTFS) +# undef HAVE_S25FL1_CHARDEV +#endif + +/* On-chip Programming Memory */ + +#if !defined(CONFIG_SAMV7_PROGMEM) || !defined(CONFIG_MTD_PROGMEM) +# undef HAVE_PROGMEM_CHARDEV +#endif + /* If both the S25FL1 FLASH and SmartFS, then this is the minor device * number of the Smart block driver (/dev/smartN) */ @@ -219,6 +237,10 @@ #define S25FL1_MTD_MINOR 0 +/* This is the on-chip progmem memroy driver minor number */ + +#define PROGMEM_MTD_MINOR 1 + /* Audio */ /* PCM/WM8904 driver */