Using SmartFS on NuttX

After fixing many issues and thanks to help of Greg Nutt and Ken Petit (SmartFS author) finally I got SmartFS working on NuttX.

This is the NuttX initialization with FileSystem debug enabled:

ABCDF
smart_scan: SMART Scan
smart_scan:    Erase size:          512
smart_scan:    Erase count:        5120
smart_scan:    Sect/block:            1
smart_scan:    MTD Blk/Sect:          1
smart_scan: SMART Scan
smart_scan:    Erase size:          512
smart_scan:    Erase count:        5120
smart_scan:    Sect/block:            1
smart_scan:    MTD Blk/Sect:          1
smart_scan: SMART Scan
smart_scan:    Erase size:          512
smart_scan:    Erase count:        2048
smart_scan:    Sect/block:            1
smart_scan:    MTD Blk/Sect:          1
smart_scan: SMART Scan
smart_scan:    Erase size:          512
smart_scan:    Erase count:        2048
smart_scan:    Sect/block:            1
smart_scan:    MTD Blk/Sect:          1
smart_scan: SMART Scan
smart_scan:    Erase size:          512
smart_scan:    Erase count:        1016
smart_scan:    Sect/block:            1
smart_scan:    MTD Blk/Sect:          1
smart_scan: SMART Scan
smart_scan:    Erase size:          512
smart_scan:    Erase count:        1016
smart_scan:    Sect/block:            1
smart_scan:    MTD Blk/Sect:          1

NuttShell (NSH)
nsh>

Now let see the enabled commands:

nsh> ?
help usage:  help [-v] [<cmd>]

[           dd          hexdump     mkdir       ping        test
?           df          ifconfig    mkfifo      ps          true
break       echo        ifdown      mkrd        pwd         uname
cat         exec        ifup        mksmartfs   rm          umount
cd          exit        kill        mh          rmdir       unset
cp          false       losetup     mount       set         usleep
cmp         free        ls          mv          sh          xd
date        help        mb          mw          sleep

Builtin Apps:
flash_eraseall
pppd
tracker
nsh>

And the created devices:

nsh> ls /dev
/dev:
config
console
null
smart0p1
smart0p2
smart0p3
smart0p4
smart0p5
smart0p6
ttyS0
ttyS1
ttyS2
ttyS3
ttyS4
ttyS5
tun
nsh>

Time to format the smartfs partitions:

nsh> flash_eraseall /dev/smart0p1

Create the file system on it:

nsh> mksmartfs /dev/smart0p1
smart_scan: SMART Scan
smart_scan:    Erase size:          512
smart_scan:    Erase count:        5120
smart_scan:    Sect/block:            1
smart_scan:    MTD Blk/Sect:          1

nsh> mksmartfs /dev/smart0p2
smart_scan: SMART Scan
smart_scan:    Erase size:          512
smart_scan:    Erase count:        5120
smart_scan:    Sect/block:            1
smart_scan:    MTD Blk/Sect:          1

nsh> mksmartfs /dev/smart0p3
smart_scan: SMART Scan
smart_scan:    Erase size:          512
smart_scan:    Erase count:        2048
smart_scan:    Sect/block:            1
smart_scan:    MTD Blk/Sect:          1

nsh> mksmartfs /dev/smart0p4
smart_scan: SMART Scan
smart_scan:    Erase size:          512
smart_scan:    Erase count:        2048
smart_scan:    Sect/block:            1
smart_scan:    MTD Blk/Sect:          1

nsh> mksmartfs /dev/smart0p5
smart_scan: SMART Scan
smart_scan:    Erase size:          512
smart_scan:    Erase count:        1016
smart_scan:    Sect/block:            1
smart_scan:    MTD Blk/Sect:          1

nsh> mksmartfs /dev/smart0p6
smart_scan: SMART Scan
smart_scan:    Erase size:          512
smart_scan:    Erase count:        1016
smart_scan:    Sect/block:            1
smart_scan:    MTD Blk/Sect:          1
nsh>

Finally let to mount it:

nsh> mount -t smartfs /dev/smart0p1 /mnt/
smartfs_mount: SMARTFS:
smartfs_mount:      Sector size:     512
smartfs_mount:      Bytes/sector     507
smartfs_mount:      Num sectors:     5120
smartfs_mount:      Free sectors:    5113
smartfs_mount:      Max filename:    16
smartfs_mount:      RootDirSector:   3
nsh>

Your redemption is drawing near:

nsh> mkdir /mnt/teste

nsh> ls /mnt/
/mnt/:
 teste/

nsh> cd /mnt
nsh> ls -l
/mnt:
 drwxrwxrwx       0 teste/

nsh> df
  Block  Number
  Size   Blocks     Used Available Mounted on
   512     5120        8      5112 /mnt
nsh> 

Does anyone doubt that NuttX rock?!?

Just for your information this is my configuration:

CONFIG_MTD=y
CONFIG_MTD_PARTITION=y
CONFIG_MTD_SECT512=y
CONFIG_MTD_SECT512_ERASED_STATE=0xff
CONFIG_MTD_PARTITION_NAMES=y
CONFIG_MTD_BYTE_WRITE=y
CONFIG_MTD_CONFIG=y
CONFIG_MTD_CONFIG_RAM_CONSOLIDATE=y
CONFIG_MTD_CONFIG_ERASEDVALUE=0xff
# MTD Device Drivers
# CONFIG_MTD_NAND is not set

CONFIG_RAMMTD=y
CONFIG_RAMMTD_BLOCKSIZE=512
CONFIG_RAMMTD_ERASESIZE=4096
CONFIG_RAMMTD_ERASESTATE=0xff

CONFIG_MTD_SMART=y
CONFIG_MTD_SMART_SECTOR_SIZE=512
# CONFIG_MTD_SMART_WEAR_LEVEL is not set
# CONFIG_MTD_SMART_CONVERT_WEAR_FORMAT is not set
# CONFIG_MTD_SMART_ENABLE_CRC is not set
# CONFIG_MTD_SMART_MINIMIZE_RAM is not set
# CONFIG_MTD_SMART_SECTOR_ERASE_DEBUG is not set
# CONFIG_MTD_SMART_ALLOC_DEBUG is not set

CONFIG_MTD_W25=y


CONFIG_FS_SMARTFS=y
CONFIG_SMARTFS_ERASEDSTATE=0xff
CONFIG_SMARTFS_MAXNAMLEN=16
# CONFIG_SMARTFS_MULTI_ROOT_DIRS is not set
# CONFIG_SMARTFS_ALIGNED_ACCESS is not set
Advertisements

2 thoughts on “Using SmartFS on NuttX

  1. Hi Celem!
    Yes, SmartFS is a great contribution for NuttX, I think Ken did a great and huge work! I think it is proportional to JFFS2 for Linux (obviously comparing the scale of each system). My work was just to get it working on my board, everything were already in place and my help was just to rise some issues introduced recently that rendered it not working.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s