Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UFile::available() does not work correctly with QSPI flash and other issues #41

Open
ddmesh opened this issue Apr 15, 2024 · 0 comments
Labels
type: imperfection Perceived defect in any part of project

Comments

@ddmesh
Copy link

ddmesh commented Apr 15, 2024

The Finder Opta device contains a 2Mbyte QSPI flash.
When calling UFile::available() to get the file size (file position still at 0 after opening), I would expect the file size. But I get almost flash size.

  • Firstly I have seen that when you call ftell() you use integer type instead of the required
    type long. On different platforms, int can use from one to 4 bytes.
  • UFile::available() return type is uint32_t, but typically size_t should be used, as this
    is semantically the same as file position or number of bytes written/read.
  • In this function there are no check if the call to ftell() was successful. The returned data are just used. but those could be wrong if seeking failed.
  • Using ftell(,,SEEK_END) is not implemented on every platform.
    please see https://en.cppreference.com/w/c/io/fseek (right at the beginning).
    For this Finder Opta device (supported by Arduino) the current position returned after
    seeking to end and calling tell(), returns 1966048 bytes. Same file on USB returns the correct size (e.g. 128780)
  • Also UFile should support ftell and fflush as API (see end of page under section "Notes").

If you like you may create several issues for this one and separate it. I just wanted to tell you my findings.

@per1234 per1234 added the type: imperfection Perceived defect in any part of project label Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

2 participants