diff --git a/configs/samv71-xult/src/sam_bringup.c b/configs/samv71-xult/src/sam_bringup.c index 6e7df1dbd1..7ff39ef12b 100644 --- a/configs/samv71-xult/src/sam_bringup.c +++ b/configs/samv71-xult/src/sam_bringup.c @@ -50,6 +50,7 @@ # include #endif +#include #include #include @@ -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 diff --git a/configs/samv71-xult/src/samv71-xult.h b/configs/samv71-xult/src/samv71-xult.h index 0ba190ce37..3a943af3dc 100644 --- a/configs/samv71-xult/src/samv71-xult.h +++ b/configs/samv71-xult/src/samv71-xult.h @@ -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 */