Hi Daniel,

No problem, happy to help. I looked back at the project where I used the larger flash ... it was a Cypress S25FL256 part. For that setup, I used the part's 64K sector erase size (vs. the 4K sub-sector erase) and CONIG_MTD_SMART_SECTOR_SIZE=4096.

Looks like the w25.c MTD driver only supports Sector Erase (4K) W25_SE erase sizes, though the part also supports 64K Block erase sizes. You may need to add an option to the w25.c driver for CONFIG_W25_BLOCK_ERASE instead of the normal 4K sector erase. And if CONFIG_W25_BLOCK_ERASE is selected, report the larger 64K erase size (and fewer "sectors", though actually blocks) in the ioctl call MTDIOC_GEOMETRY / BIOC_PARTINFO, plus use the larger W25_SECTOR_SIZE / W25_SECTOR_SHIFT for address calculation and W25_BE erase command instead of W25_SE command in w25_sectorerase function.

Ken

On 10/20/22 5:15 AM, Daniel Pereira Carvalho wrote:
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 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



Reply via email to