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

feat(fs): default drive letter + ESP FS docs #6367

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

becseya
Copy link
Contributor

@becseya becseya commented Jun 13, 2024

This PR introduces the following changes:

  • Introduces the LV_FS_DEFAULT_DRIVE_LETTER configuration, which allows skipping the drive letter form file paths
  • Add a detailed example on how to use the File Systems under ESP IDF (uses SPIFFS as suggested in ESP32 SPIFFS #6325)
  • Minor fixes in the documentation, and code

Copy link
Member

@kisvegabor kisvegabor left a comment

Choose a reason for hiding this comment

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

Very elegant! Special thanks for the minor fixes in the docs 🙂

Kconfig Outdated Show resolved Hide resolved
docs/libs/fs.rst Show resolved Hide resolved
src/misc/lv_fs.c Show resolved Hide resolved
@kisvegabor kisvegabor mentioned this pull request Jun 14, 2024
@@ -20,7 +20,7 @@
#define DIR FF_DIR /* ESP IDF typedefs `DIR` as `FF_DIR` in its version of ff.h. Use `FF_DIR` in LVGL too */
#endif

#if LV_FS_FATFS_LETTER == '\0'
#if (LV_FS_FATFS_LETTER < 'A') || (LV_FS_FATFS_LETTER > 'Z')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need to add this restriction?

Copy link
Collaborator

Choose a reason for hiding this comment

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

lv_fs also needs to support '/' as the drive letter, for example: lv_fs_open(&fa, "/test_files/readtest.txt", LV_FS_MODE_RD);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to make the code consistent with the error message and the documentation (which states the [A-Z]: format).

Using / as drive letter should not be encouraged as it can be confused with an absolute path. I also feel like pitfalls will occur if we want to make it work with LV_FS_DEFAULT_DRIVE_LETTER.

And I think the intention behind default drive letter was to elegantly handle situations like this, but correct me @kisvegabor

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is done to be compatible with absolute paths. It has been used on our platform for quite a long time, and I believe there is no problem with the current design.

Copy link
Collaborator

Choose a reason for hiding this comment

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

See this change: a708450

Copy link
Contributor Author

@becseya becseya Jun 18, 2024

Choose a reason for hiding this comment

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

The goal of "default driver letter" feature is to better support absolute and "desktop" paths.

I'm assuming a driver is registered for letter / on your platform at the moment. The same driver has to be registered for - let's say - A, then LV_FS_DEFAULT_DRIVE_LETTER set to be A, then all the paths in your code should work the same way as before.

This allows replacing the workaround of using / as a drive letter with a more clear and verbose solution.

Copy link
Member

Choose a reason for hiding this comment

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

If I understand correct this is what happens if you are using / as driver letter:

  • /path/to/files: is a relative path
  • //path/to/files: is an absolute path

If this is the case then it seems a little but hacky. Using / as driver letter might work, but according to the docs it should have been an upper case letter. How complicated would it be for you to migrate to this new approac?

Copy link
Collaborator

Choose a reason for hiding this comment

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

  • //path/to/files: is an absolute path

Aren't all LV FS paths absolute relative to the driver mount point?

To me it just looks like the : is optional for any drive letter or / and / does not get any special treatment.

IMO it's okay to lock down the drive letters to [A-Z] especially now that a default drive letter is being added.

@lvgl-bot
Copy link

lvgl-bot commented Jul 3, 2024

We need some feedback on this pull request.

Now we mark this as "stale" because there was no activity here for 14 days.

Remove the "stale" label or comment else this will be closed in 7 days.

@lvgl-bot lvgl-bot added the stale label Jul 3, 2024
Copy link
Collaborator

@liamHowatt liamHowatt left a comment

Choose a reason for hiding this comment

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

Nice.

Can we make lv_fs_dir_open work with LV_FS_DEFAULT_DRIVE_LETTER? So far it looks like lv_fs_dir_open will not work unless the drive letter is explicitly given.

@@ -20,7 +20,7 @@
#define DIR FF_DIR /* ESP IDF typedefs `DIR` as `FF_DIR` in its version of ff.h. Use `FF_DIR` in LVGL too */
#endif

#if LV_FS_FATFS_LETTER == '\0'
#if (LV_FS_FATFS_LETTER < 'A') || (LV_FS_FATFS_LETTER > 'Z')
Copy link
Collaborator

Choose a reason for hiding this comment

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

  • //path/to/files: is an absolute path

Aren't all LV FS paths absolute relative to the driver mount point?

To me it just looks like the : is optional for any drive letter or / and / does not get any special treatment.

IMO it's okay to lock down the drive letters to [A-Z] especially now that a default drive letter is being added.

Comment on lines -503 to +522
path++; /*Ignore the driver letter*/
if(*path == ':') path++;
if(lv_fs_path_has_drive(path))
path += 2;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like it will break file paths missing the :, like A/path/to/file. I think this is ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants