Skip to content

assert block != LFS_BLOCK_NULL in lfs_bd_read failing in lfs_ctz_traverse #295

Open
@Ralim

Description

@Ralim

Hi,

Currently working on getting Littlefs running on a NAND flash.
The flash is 256MB, with erase pages of 128K and and read/write sizes of 2048 bytes.

Running into an issue, were after a long running series of reads and writes to the flash, something is becoming unhappy and the assert here is failing.

When this assert fails, this is the current call stack:

  • lfs_bd_read
  • lfs_ctz_traverse
  • lfs_alloc
  • lfs_dir_alloc
  • lfs_dir_split
  • lfs_dir_compact
  • lfs_dir_commit
  • lfs_file_opencfg

Looking in lfs_ctz_traverse, at the time of the read call before the one that fails the assert, the read is from block 1820 (head), and the result that is read into the buffer is all 0xFF (validated read is correct by manually reading this block as well).

Any ideas on what could have lead to this?
This appears to be showing up on all units after a decent number of file actions, (around 100 files created and then deleted). Files are mix of small (2k) and large (25MB).

I can look into dumping the entire flash memory out if that would be of use?

This is the config structure:


const struct lfs_config Filesystem::LittleFScfg = {
// block device operations
		context:0, //
		read : Filesystem::raw_read,  //
		prog : Filesystem::raw_prog,  //
		erase : Filesystem::raw_erase,  //
		sync : Filesystem::raw_sync,  //

		// block device configuration
		read_size : RawFlash::get_read_size(),  //minimum read size
		prog_size : RawFlash::get_program_size(),  // minimum programming size
		block_size : RawFlash::get_erase_size(),  //Erase block size
		block_count : RawFlash::size() / RawFlash::get_erase_size(),  // Number of eraseable blocks
		block_cycles:1000,  // Cycle blocks around every 1k writes
		cache_size :LFS_BUFFER_SIZE,  //Size of the cache buffer
		lookahead_size : LFS_LOOKAHEAD_SIZE,  // Size of the lookahead scratch buffer
		read_buffer : lfs_read_buffer,  // Static read buffer
		prog_buffer : lfs_prog_buffer,  // Static programming buffer
		lookahead_buffer:lfs_lookahead_buffer,  // Static lookahead buffer
		name_max: 65,  // Max length of file names
		file_max:LFS_FILE_MAX,  //Max fileSize
		attr_max:LFS_ATTR_MAX, };

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions