Skip to content

Conversation

@ajuckler
Copy link
Contributor

Summary

The NuttX documentation states that it is possible to use an EEPROM character driver with a file system by converting it to a block device using the loop device (losetup). However, losetup() fails with message File is too small for blocksize because the st_size field is not populated by the stat() function when used on character drivers.

This MR fixes this error by:

  • Allowing to retrieve the geometry of an EEPROM character driver using ioctl;
  • Using this geometry to populate the st_size field on stat().

Impact

The eeprom_25xx_e enum contents have changed due to the addition of the sector size.

Testing

Tested on a custom target (STM32F7-based) with a Rhom BR25G256FVT EEPROM (equivalent to a Microchip 25xx256).

Following piece of code would fail before the changes in fs_stat:

ee25xx_initialize(spi_p, "/dev/ee25xx", EEPROM_25XX256, 0);
losetup("/dev/ee25blk", "/dev/ee25xx", 64, 0, 0);

@github-actions github-actions bot added Area: Drivers Drivers issues Area: File System File System issues Size: M The size of the change in this PR is medium labels Oct 30, 2025
acassis
acassis previously approved these changes Oct 30, 2025
@acassis
Copy link
Contributor

acassis commented Oct 30, 2025

@ajuckler I approved assuming you will submit the requested Documentation/

@ajuckler ajuckler requested a review from raiden00pl as a code owner November 2, 2025 09:15
@github-actions github-actions bot added Area: Documentation Improvements or additions to documentation Size: L The size of the change in this PR is large labels Nov 2, 2025
acassis
acassis previously approved these changes Nov 11, 2025
Copy link
Contributor

@acassis acassis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty good Documentation! Thank you!

Add EEPIOC_GEOMETRY IOCTL command to retrieve the
EEPROM geometry.

Signed-off-by: Antoine Juckler <6445757+ajuckler@users.noreply.github.com>
It acts as register_driver but also populates the inode size.
This allows to return a non-zero size when calling stat() on an eeprom
driver.

The conditions (CONFIG_PSEUDOFS_FILE or CONFIG_FS_SHMFS) for the
declaration of the inode size field have also been removed so that other
drivers can populate this field in the future.

Signed-off-by: Antoine Juckler <6445757+ajuckler@users.noreply.github.com>
Fix writing till the very last byte of the memory

Signed-off-by: Antoine Juckler <6445757+ajuckler@users.noreply.github.com>
@ajuckler
Copy link
Contributor Author

@acassis @xiaoxiang781216
I've just pushed a fix to the g_ee25xx_devices definition.
The location of the newly added sector size was wrong, I didn't notice it until now because I was not checking if a read call was returning what has been previously written.

The following has been tested on spi_xx25xx (in addition to the losetup):

  • Retrieving the geometry using IOCTL
  • Writing data at a fixed non-zero offset
  • Reading back the written data

@acassis acassis merged commit d996c2e into apache:master Nov 13, 2025
41 checks passed
@ajuckler ajuckler deleted the stat_eeprom branch November 25, 2025 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Documentation Improvements or additions to documentation Area: Drivers Drivers issues Area: File System File System issues Size: L The size of the change in this PR is large Size: M The size of the change in this PR is medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants