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

Fixing FileSystem for ESP32 #2985

Merged
merged 5 commits into from
Jul 24, 2024
Merged

Fixing FileSystem for ESP32 #2985

merged 5 commits into from
Jul 24, 2024

Conversation

josesimoes
Copy link
Member

@josesimoes josesimoes commented Jul 24, 2024

Description

  • Add missing configs for ESP32 series other than ESP32.
  • Improvements in FS add volumes configs.
  • Ignoring code for MMC cards interfaces for devices that don't support it.
  • Increase factory partition for ESP32-C6 series.

(thank you @AdrianSoundy for taking care of this)

Motivation and Context

How Has This Been Tested?

Screenshots

Types of changes

  • Improvement (non-breaking change that improves a feature, code or algorithm)
  • Bug fix (non-breaking change which fixes an issue with code or algorithm)
  • New feature (non-breaking change which adds functionality to code)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Config and build (change in the configuration and build system, has no impact on code or features)
  • Dev Containers (changes related with Dev Containers, has no impact on code or features)
  • Dependencies/declarations (update dependencies or assembly declarations and changes associated, has no impact on code or features)
  • Documentation (changes or updates in the documentation, has no impact on code or features)

Checklist

  • My code follows the code style of this project (only if there are changes in source code).
  • My changes require an update to the documentation (there are changes that require the docs website to be updated).
  • I have updated the documentation accordingly (the changes require an update on the docs in this repo).
  • I have read the CONTRIBUTING document.
  • I have tested everything locally and all new and existing tests passed (only if there are changes in source code).

Summary by CodeRabbit

  • New Features

    • Enabled support for SD card functionalities across multiple ESP32 targets.
    • Added conditional support for MMC storage management in file system operations.
  • Bug Fixes

    • Improved error handling for unsupported SD card configurations.
    • Streamlined file system volume management logic.
  • Documentation

    • Updated documentation to reflect changes in file system interface management and driver support.

@josesimoes josesimoes added the Platform: ESP32 Everything related specifically with ESP32 platform label Jul 24, 2024
Copy link

coderabbitai bot commented Jul 24, 2024

Walkthrough

The changes primarily enhance the ESP32 file system functionalities by enabling support for SD cards and file system drivers (LittleFS and FATFS) across various target configurations. This includes activating previously commented-out code and streamlining volume management logic, significantly improving flexibility and performance in handling storage devices.

Changes

File(s) Change Summary
targets/ESP32/CMakePresets.json Enabled SD card support by changing NF_FEATURE_HAS_SDCARD from "OFF" to "ON".
targets/ESP32/ESP32/target_FileSystem.cpp Renamed g_FATFS_STREAM_DriverInterface to g_FATFS_FILE_SYSTEM_DriverInterface; improved modularity by conditionally including the FATFS driver based on HAL_USE_SDC.
targets/ESP32/ESP32_C3/target_FileSystem.cpp, targets/ESP32/ESP32_C6/target_FileSystem.cpp, targets/ESP32/ESP32_H2/target_FileSystem.cpp, targets/ESP32/ESP32_S2/target_FileSystem.cpp, targets/ESP32/ESP32_S3/target_FileSystem.cpp Reactivated LittleFS and FATFS drivers, updated g_AvailableFSInterfaces to include active drivers, and simplified volume management focusing on a single internal storage option.
targets/ESP32/_IDF/esp32/app_main.c Changed logging level from ESP_LOG_VERBOSE to ESP_LOG_NONE to prevent interference with WireProtocol over Uart0.
targets/ESP32/_common/Target_System_IO_FileSystem.c Added conditional compilation for SD card mounting based on SOC_SDMMC_HOST_SUPPORTED.
targets/ESP32/_include/Target_System_IO_FileSystem.h Added conditional function declaration for Storage_MountMMC based on SOC_SDMMC_HOST_SUPPORTED.
targets/ESP32/_littlefs/littlefs_FS_Driver.cpp Commented out volume retrieval and drive setting lines in GetSizeInfo to improve performance and reliability.
targets/ESP32/_nanoCLR/System.IO.FileSystem/nf_sys_io_filesystem_nanoFramework_System_IO_FileSystem_SDCard.cpp Introduced conditional compilation for MMC support, improving error handling by returning CLR_E_NOT_SUPPORTED if unsupported.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App
    participant FileSystem
    participant Storage

    User->>App: Start Application
    App->>FileSystem: Initialize File Systems
    FileSystem->>Storage: Check SD Card Support
    Storage-->>FileSystem: Supported
    FileSystem->>Storage: Mount SD Card
    Storage-->>FileSystem: Mounted Successfully
    FileSystem->>App: File System Ready
    App-->>User: Ready to Use
Loading

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (2)
targets/ESP32/ESP32_H2/target_FileSystem.cpp (1)

60-60: Document the lack of implementation in FS_MountRemovableVolumes.

The FS_MountRemovableVolumes function has no implementation. Ensure that this is intentional and document the reason for clarity.

targets/ESP32/ESP32_S2/target_FileSystem.cpp (1)

60-60: Document the lack of implementation in FS_MountRemovableVolumes.

The FS_MountRemovableVolumes function has no implementation. Ensure that this is intentional and document the reason for clarity.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f429bf6 and 8a67a69.

Files ignored due to path filters (3)
  • targets/ESP32/_IDF/esp32c6/partitions_nanoclr_16mb.csv is excluded by !**/*.csv
  • targets/ESP32/_IDF/esp32c6/partitions_nanoclr_4mb.csv is excluded by !**/*.csv
  • targets/ESP32/_IDF/esp32c6/partitions_nanoclr_8mb.csv is excluded by !**/*.csv
Files selected for processing (12)
  • targets/ESP32/CMakePresets.json (1 hunks)
  • targets/ESP32/ESP32/target_FileSystem.cpp (2 hunks)
  • targets/ESP32/ESP32_C3/target_FileSystem.cpp (2 hunks)
  • targets/ESP32/ESP32_C6/target_FileSystem.cpp (2 hunks)
  • targets/ESP32/ESP32_H2/target_FileSystem.cpp (2 hunks)
  • targets/ESP32/ESP32_S2/target_FileSystem.cpp (2 hunks)
  • targets/ESP32/ESP32_S3/target_FileSystem.cpp (2 hunks)
  • targets/ESP32/_IDF/esp32/app_main.c (1 hunks)
  • targets/ESP32/_common/Target_System_IO_FileSystem.c (2 hunks)
  • targets/ESP32/_include/Target_System_IO_FileSystem.h (1 hunks)
  • targets/ESP32/_littlefs/littlefs_FS_Driver.cpp (1 hunks)
  • targets/ESP32/_nanoCLR/System.IO.FileSystem/nf_sys_io_filesystem_nanoFramework_System_IO_FileSystem_SDCard.cpp (7 hunks)
Additional comments not posted (50)
targets/ESP32/_include/Target_System_IO_FileSystem.h (1)

16-18: LGTM! Conditional function declaration is correctly added.

The conditional compilation directive and the new function declaration are correctly implemented.

targets/ESP32/ESP32/target_FileSystem.cpp (4)

12-14: LGTM! Conditional inclusion of the FATFS driver is correctly implemented.

The inclusion of the FATFS driver is conditionally defined based on HAL_USE_SDC.


19-19: LGTM! Variable renaming is correctly implemented.

The variable g_FATFS_STREAM_DriverInterface is correctly renamed to g_FATFS_FILE_SYSTEM_DriverInterface.


21-24: LGTM! Conditional inclusion of the FATFS stream driver is correctly implemented.

The inclusion of the FATFS stream driver is conditionally defined based on HAL_USE_SDC.


28-30: LGTM! Initialization of the g_AvailableFSInterfaces array is correctly updated.

The initialization of the array correctly reflects the conditional inclusion of the FATFS driver interface.

targets/ESP32/_IDF/esp32/app_main.c (1)

55-55: LGTM! Logging configuration is correctly modified.

The log level for all components is correctly changed from ESP_LOG_VERBOSE to ESP_LOG_NONE.

targets/ESP32/ESP32_S3/target_FileSystem.cpp (8)

10-10: Inclusion of LittleFS driver enabled.

The inclusion of littlefs_FS_Driver.h has been uncommented, allowing the use of the LittleFS file system driver.


12-14: Conditional inclusion of FATFS driver.

The inclusion of fatfs_FS_Driver.h is within a conditional compilation block, ensuring it is only included when SDC support is enabled.


18-18: External declaration of LittleFS driver interface.

The external declaration for g_LITTLEFS_FILE_SYSTEM_DriverInterface has been uncommented, allowing its use.


19-19: External declaration of FATFS driver interface.

The external declaration for g_FATFS_FILE_SYSTEM_DriverInterface has been uncommented, allowing its use.


21-24: Conditional external declarations of stream driver interfaces.

The external declarations for g_FATFS_STREAM_DriverInterface and g_LITTLEFS_STREAM_DriverInterface are within a conditional compilation block, ensuring they are only included when SDC support is enabled.


26-30: Initialization of available file system interfaces.

The g_AvailableFSInterfaces array has been updated to include LittleFS interfaces, enhancing the file system interface options available in the system.


41-55: Simplified volume management logic.

The logic for adding file system volumes has been simplified to initialize g_FS_NumVolumes to 1, reflecting a single internal storage volume in the LittleFS partition.


60-60: No operations for removable volumes.

The function FS_MountRemovableVolumes indicates that no operations are necessary for removable volumes, reflecting a design choice.

targets/ESP32/ESP32_C3/target_FileSystem.cpp (8)

10-10: Inclusion of LittleFS driver enabled.

The inclusion of littlefs_FS_Driver.h has been uncommented, allowing the use of the LittleFS file system driver.


12-14: Conditional inclusion of FATFS driver.

The inclusion of fatfs_FS_Driver.h is within a conditional compilation block, ensuring it is only included when SDC support is enabled.


18-18: External declaration of LittleFS driver interface.

The external declaration for g_LITTLEFS_FILE_SYSTEM_DriverInterface has been uncommented, allowing its use.


19-19: External declaration of FATFS driver interface.

The external declaration for g_FATFS_FILE_SYSTEM_DriverInterface has been uncommented, allowing its use.


21-24: Conditional external declarations of stream driver interfaces.

The external declarations for g_FATFS_STREAM_DriverInterface and g_LITTLEFS_STREAM_DriverInterface are within a conditional compilation block, ensuring they are only included when SDC support is enabled.


26-31: Initialization of available file system interfaces.

The g_AvailableFSInterfaces array has been updated to include LittleFS interfaces, enhancing the file system interface options available in the system.


41-55: Simplified volume management logic.

The logic for adding file system volumes has been simplified to initialize g_FS_NumVolumes to 1, reflecting a single internal storage volume in the LittleFS partition.


60-60: No operations for removable volumes.

The function FS_MountRemovableVolumes indicates that no operations are necessary for removable volumes, reflecting a design choice.

targets/ESP32/ESP32_C6/target_FileSystem.cpp (8)

10-10: Inclusion of LittleFS driver enabled.

The inclusion of littlefs_FS_Driver.h has been uncommented, allowing the use of the LittleFS file system driver.


12-14: Conditional inclusion of FATFS driver.

The inclusion of fatfs_FS_Driver.h is within a conditional compilation block, ensuring it is only included when SDC support is enabled.


18-18: External declaration of LittleFS driver interface.

The external declaration for g_LITTLEFS_FILE_SYSTEM_DriverInterface has been uncommented, allowing its use.


19-19: External declaration of FATFS driver interface.

The external declaration for g_FATFS_FILE_SYSTEM_DriverInterface has been uncommented, allowing its use.


21-24: Conditional external declarations of stream driver interfaces.

The external declarations for g_FATFS_STREAM_DriverInterface and g_LITTLEFS_STREAM_DriverInterface are within a conditional compilation block, ensuring they are only included when SDC support is enabled.


26-31: Initialization of available file system interfaces.

The g_AvailableFSInterfaces array has been updated to include LittleFS interfaces, enhancing the file system interface options available in the system.


41-55: Simplified volume management logic.

The logic for adding file system volumes has been simplified to initialize g_FS_NumVolumes to 1, reflecting a single internal storage volume in the LittleFS partition.


60-60: No operations for removable volumes.

The function FS_MountRemovableVolumes indicates that no operations are necessary for removable volumes, reflecting a design choice.

targets/ESP32/ESP32_H2/target_FileSystem.cpp (6)

10-10: Inclusion of LittleFS driver approved.

The inclusion of littlefs_FS_Driver.h is necessary for integrating the LittleFS driver.


12-14: Conditional inclusion of FATFS driver approved.

The conditional inclusion of fatfs_FS_Driver.h based on HAL_USE_SDC is correctly implemented and necessary for integrating the FATFS driver when SD card support is enabled.


18-19: External declarations of file system driver interfaces approved.

The external declarations for g_LITTLEFS_FILE_SYSTEM_DriverInterface and g_FATFS_FILE_SYSTEM_DriverInterface are necessary for integrating these drivers.


21-24: Conditional external declarations of stream driver interfaces approved.

The conditional external declarations for g_FATFS_STREAM_DriverInterface and g_LITTLEFS_STREAM_DriverInterface based on HAL_USE_SDC are correctly implemented and necessary for integrating these stream drivers when SD card support is enabled.


26-31: Initialization of g_AvailableFSInterfaces approved.

The initialization of the g_AvailableFSInterfaces array with LittleFS and FATFS interfaces based on HAL_USE_SDC is correctly implemented and necessary for integrating these file systems.


41-55: Implementation of FS_AddVolumes function approved.

The FS_AddVolumes function correctly initializes one volume for the LittleFS partition, ensuring proper volume management.

targets/ESP32/ESP32_S2/target_FileSystem.cpp (6)

10-10: Inclusion of LittleFS driver approved.

The inclusion of littlefs_FS_Driver.h is necessary for integrating the LittleFS driver.


12-14: Conditional inclusion of FATFS driver approved.

The conditional inclusion of fatfs_FS_Driver.h based on HAL_USE_SDC is correctly implemented and necessary for integrating the FATFS driver when SD card support is enabled.


18-19: External declarations of file system driver interfaces approved.

The external declarations for g_LITTLEFS_FILE_SYSTEM_DriverInterface and g_FATFS_FILE_SYSTEM_DriverInterface are necessary for integrating these drivers.


21-24: Conditional external declarations of stream driver interfaces approved.

The conditional external declarations for g_FATFS_STREAM_DriverInterface and g_LITTLEFS_STREAM_DriverInterface based on HAL_USE_SDC are correctly implemented and necessary for integrating these stream drivers when SD card support is enabled.


26-31: Initialization of g_AvailableFSInterfaces approved.

The initialization of the g_AvailableFSInterfaces array with LittleFS and FATFS interfaces based on HAL_USE_SDC is correctly implemented and necessary for integrating these file systems.


41-55: Implementation of FS_AddVolumes function approved.

The FS_AddVolumes function correctly initializes one volume for the LittleFS partition, ensuring proper volume management.

targets/ESP32/_common/Target_System_IO_FileSystem.c (2)

Line range hint 86-188:
Conditional compilation directive for SDMMC host support approved.

The #if SOC_SDMMC_HOST_SUPPORTED directive is correctly implemented and necessary for conditionally including the SDMMC host support code.


188-188: Implementation of Storage_MountSpi function approved.

The Storage_MountSpi function correctly handles the mounting of an SPI SD card, ensuring proper volume management.

targets/ESP32/_nanoCLR/System.IO.FileSystem/nf_sys_io_filesystem_nanoFramework_System_IO_FileSystem_SDCard.cpp (4)

26-27: Conditional Compilation for MMC Pin Reservation

The introduction of conditional compilation for MMC pin reservation is well-implemented.


48-49: End of Conditional Compilation Block

The end of the conditional compilation block for MMC pin reservation is correctly placed.


Line range hint 104-119:
Conditional Compilation for MMC Initialization

The conditional compilation for MMC initialization within the InitNative method is well-implemented.


Line range hint 191-203:
Conditional Compilation for MMC Pin Unreservation

The conditional compilation for MMC pin unreservation within the NativeDispose method is well-implemented.

targets/ESP32/_littlefs/littlefs_FS_Driver.cpp (1)

92-94: Verify Impact of Commented-Out Volume Retrieval and Drive Setting

The commented-out lines in the GetSizeInfo method indicate a change in how the function interacts with the file system. Verify that this change does not negatively impact the functionality.

targets/ESP32/CMakePresets.json (1)

290-290: Verify Impact of Enabling SD Card Support

The change in the configuration setting for NF_FEATURE_HAS_SDCARD from "OFF" to "ON" enables SD card support. Verify that this change does not introduce any issues and that the system interacts correctly with SD card hardware and software components.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8a67a69 and fa1dc87.

Files ignored due to path filters (3)
  • targets/ESP32/_IDF/esp32c6/partitions_nanoclr_16mb.csv is excluded by !**/*.csv
  • targets/ESP32/_IDF/esp32c6/partitions_nanoclr_4mb.csv is excluded by !**/*.csv
  • targets/ESP32/_IDF/esp32c6/partitions_nanoclr_8mb.csv is excluded by !**/*.csv
Files selected for processing (12)
  • targets/ESP32/CMakePresets.json (1 hunks)
  • targets/ESP32/ESP32/target_FileSystem.cpp (2 hunks)
  • targets/ESP32/ESP32_C3/target_FileSystem.cpp (2 hunks)
  • targets/ESP32/ESP32_C6/target_FileSystem.cpp (2 hunks)
  • targets/ESP32/ESP32_H2/target_FileSystem.cpp (2 hunks)
  • targets/ESP32/ESP32_S2/target_FileSystem.cpp (2 hunks)
  • targets/ESP32/ESP32_S3/target_FileSystem.cpp (2 hunks)
  • targets/ESP32/_IDF/esp32/app_main.c (1 hunks)
  • targets/ESP32/_common/Target_System_IO_FileSystem.c (2 hunks)
  • targets/ESP32/_include/Target_System_IO_FileSystem.h (1 hunks)
  • targets/ESP32/_littlefs/littlefs_FS_Driver.cpp (1 hunks)
  • targets/ESP32/_nanoCLR/System.IO.FileSystem/nf_sys_io_filesystem_nanoFramework_System_IO_FileSystem_SDCard.cpp (7 hunks)
Files skipped from review due to trivial changes (1)
  • targets/ESP32/_include/Target_System_IO_FileSystem.h
Files skipped from review as they are similar to previous changes (10)
  • targets/ESP32/CMakePresets.json
  • targets/ESP32/ESP32/target_FileSystem.cpp
  • targets/ESP32/ESP32_C3/target_FileSystem.cpp
  • targets/ESP32/ESP32_C6/target_FileSystem.cpp
  • targets/ESP32/ESP32_H2/target_FileSystem.cpp
  • targets/ESP32/ESP32_S2/target_FileSystem.cpp
  • targets/ESP32/_IDF/esp32/app_main.c
  • targets/ESP32/_common/Target_System_IO_FileSystem.c
  • targets/ESP32/_littlefs/littlefs_FS_Driver.cpp
  • targets/ESP32/_nanoCLR/System.IO.FileSystem/nf_sys_io_filesystem_nanoFramework_System_IO_FileSystem_SDCard.cpp
Additional comments not posted (6)
targets/ESP32/ESP32_S3/target_FileSystem.cpp (6)

10-10: Inclusion of LittleFS driver approved.

Uncommenting the #include <littlefs_FS_Driver.h> directive enables the use of the LittleFS driver.


12-14: Conditional inclusion of FATFS driver approved.

Including the #include <fatfs_FS_Driver.h> directive within the #if (HAL_USE_SDC == TRUE) block ensures that the FATFS driver is included only when SDC support is enabled.


18-24: External declarations for file system interfaces approved.

The external declarations for g_LITTLEFS_FILE_SYSTEM_DriverInterface and g_LITTLEFS_STREAM_DriverInterface make these interfaces available for use. The conditional inclusion of g_FATFS_FILE_SYSTEM_DriverInterface and g_FATFS_STREAM_DriverInterface ensures they are available only when SDC support is enabled.


27-30: Updates to g_AvailableFSInterfaces array approved.

The g_AvailableFSInterfaces array now includes the LittleFS interfaces and conditionally includes the FATFS interfaces, expanding the available file system interface options.


41-55: Simplification of volume management logic approved.

The FS_AddVolumes function has been simplified to manage a single internal storage volume within the LittleFS partition, enhancing maintainability and focusing on a straightforward volume management approach.


60-60: Placeholder comment in FS_MountRemovableVolumes function approved.

The placeholder comment indicating no action is required is appropriate given the current scope and potential future use of the function.

@josesimoes josesimoes merged commit 23cb7d1 into main Jul 24, 2024
17 checks passed
@josesimoes josesimoes deleted the filesystem_fixes branch July 24, 2024 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: ESP32 Everything related specifically with ESP32 platform Type: bug Type: enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants