I had similar problems trying smart FS with a large device. It was over a year ago, and I put it on the back burner at the time, but I am sure there was something that exceeded the max value of a 16 bit integer somewhere and it went wrong. To me it seemed like it wasn't suited to large devices "out of the box" and needed some work.
I would be delighted if this is sorted; otherwise I'll be looking at again sometime in the next few months. >-----Original Message----- >From: Daniel Pereira Carvalho <daniel...@gmail.com> >Sent: 20 October 2022 13:16 >To: dev@nuttx.apache.org >Subject: Re: Is SmartFS limited to 16M memories > >Hi Ken, > >First of all, thanks for your quick response. > >One of the first things I tried was to change the values of >MTD_SMART_SECTOR_SIZE [=2048] and MTD_SMART_SECTOR_CACHE_SIZE >[=2048] but the smartfs_mount() is still failing to validate the low-level >format. >For reference the struct fs->fs_llformat has the following values just before >the error > >fs->fs_llformat.sectorsize:2048 >fs->fs_llformat.availbytes:2043 >fs->fs_llformat.nsectors:16384 >fs->fs_llformat.nfreesectors:16378 >fs->fs_llformat.flags:0 '\000' >fs->fs_llformat.namesize:16 '\020' > >Changing the capacity to W25_JEDEC_CAPACITY_128MBIT and keeping >MTD_SMART_SECTOR_SIZE and MTD_SMART_SECTOR_CACHE_SIZE the same >[2048] the file system works as expected. For reference the struct fs- >>fs_llformat has the following values just before the function validates the >low level format. > >fs->fs_llformat.sectorsize:2048 >fs->fs_llformat.availbytes:2043 >fs->fs_llformat.nsectors:8192 >fs->fs_llformat.nfreesectors:8183 >fs->fs_llformat.flags:1 '\001' >fs->fs_llformat.namesize:16 '\020' > >Thanks > >Daniel Pereira de Carvalho > >Em qua., 19 de out. de 2022 às 21:26, Ken Pettit <petti...@gmail.com> >escreveu: > >> Hi Daniel, >> >> The SmartFS FS *can* work with devices greater than 16M Bytes. I have >> used it with a 256MBit / 32M Byte SPI flash before quite successfully. >> >> But you have to ensure the logical sector size is large enough. One >> limitation of the SMART MTD (and therefore SMART FS) implementation is >> that it uses unsigned 16-bit integers for logical sector numbers. >> This means you can only have 65536 maximum logical sectors (actually a >> few less than that, but the code knows how to deal with 65536 values >> and simply "waste" a few reserved values like zero and 0xFFFF). >> >> This means that for a 32M byte flash, you would need to ensure the >> logical sector size is at least 32M / 65536 = 512 bytes. Typically >> for the SMART MTD layer, a logical sector size of 1024 or 2048 (or >> larger) is preferred because the code can manage erase blocks / free >> sector collection management better. >> >> In your 'make menuconfig', check your SMART logical sector size and try >> setting it to 2048. For the W25256JEVIEQ part with 256-byte pages, >> this will be 8 pages per logical sector, which is a good setting. Of >> course this also means that the smallest file size is 2K bytes, even >> if the file only has 1 byte stored in it. That's the price you pay >> for a structured file system though. >> >> Ken >> >> >> On 10/19/22 4:39 PM, Daniel Pereira Carvalho wrote: >> > Hi guys, >> > >> > I am trying to use the memory W25Q256JVEIQ, with SMARTS FS. To do it >> > I added the support for this memory in "drivers/mtd/w25.c". I just >> > added >> the >> > code below >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > *..#define W25_JEDEC_CAPACITY_256MBIT 0x19 /* 8192x4096 = 256Mbit >> > memory capacity */../* 256M-bit / 32M-byte (33,554,432) * * >> > W25Q256JV (Standard >> > SPI) */else if (capacity == W25_JEDEC_CAPACITY_256MBIT) { >> > priv->nsectors = NSECTORS_256MBIT; }..* >> > >> > The memory initialization seems to go well. I can run the mksmartfs >> > utility, mount and write to the filesystem. However when I reboot >> > the >> board >> > I can't mount the filesystem again. The function smartfs_mount() >> > returns the error "ERROR: No low-level format found". >> > >> > The documentation says that SMARTS FS is designed to work with 1M >> > byte to 16M byte in size (though this is not a limitation). So I >> > changed the >> > priv->nsectors from NSECTORS_256MBIT to NSECTORS_128MBIT to see if >> > priv->the >> > problem was with the size of the memory. After this change the file >> system >> > started to work as expected. >> > >> > Should SMARTS FS work with memories larger than 16M, since in the >> > docs it is said that this is not a limitation? If SMART FS is >> > limited to memories smaller than 16M do you recommend another >filesystem? >> > >> > Thanks >> > >> > Daniel Pereira de Carvalho >> > >> >>