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

Update sdcard etc #110

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

AdrianSoundy
Copy link
Member

@AdrianSoundy AdrianSoundy commented Aug 12, 2024

Description

This PR fixes a number of issues related to the SDCARD class in System.IO.Filesystem

  • The mapping of gpio pins for S3 and P4 targets.
  • Allowing the card detect to be active high or low
  • Adds some missing unit tests for a previous fix for list files with directories in same folder.
  • Card detct has been broken for a while. Fixes a problem where interrupts for card detect was not working due the same event names being used for card detect and when drives are mounted.
  • Added an Auto mount on card detect (optional)
  • Added feature to allow multiple cards (which was already existing in firmware). There is now a slotIndex parameter which denotes which card slot is being worked with. ESP32 allow 2 x slots for SDIO pins and we can have additional slots on SPI bus.
  • Separate the Card detect parameter in to separate parameter class.
  • Due to all these changes the API has been changed and not backward compatible.

This assembly requires updated NanoClr

  • Includes native code fix for unreliable GPIO event when debounce was enabled.
  • SDcard pins mapping
  • Update events

Also updated Hardware.ESP32

  • New pin mapping option for SDMMC1 and SDMMC2 devices.

Motivation and Context

How Has This Been Tested?

Tested locally with updated mount sample

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)
  • Dependencies (update dependencies and changes associated, has no impact on code or features)
  • Unit Tests (add new Unit Test(s) or improved existing one(s), 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).
  • I have added new tests to cover my changes.

Summary by CodeRabbit

  • New Features

    • Updated the Nerdbank.GitVersioning package to a newer version, which may include improved performance, bug fixes, or new functionalities for users.
  • Bug Fixes

    • This update is expected to address previously known issues related to the earlier version of the package.

@nfbot
Copy link
Member

nfbot commented Aug 12, 2024

@AdrianSoundy I've fixed the checklist for you.
FYI, the correct format is [x], no spaces inside brackets, no other chars.

@nfbot nfbot added Type: Bug Something isn't working Type: Unit Tests labels Aug 12, 2024
Copy link

coderabbitai bot commented Aug 12, 2024

Important

Review skipped

Review was skipped due to path filters

Files ignored due to path filters (5)
  • System.IO.FileSystem.UnitTests/FileSystemUnitTestsBase.cs is excluded by none and included by none
  • System.IO.FileSystem/System.IO.FileSystem.nfproj is excluded by none and included by none
  • System.IO.FileSystem/nanoFramework/CardDetectParameters.cs is excluded by none and included by none
  • System.IO.FileSystem/nanoFramework/SDCard.cs is excluded by none and included by none
  • System.IO.FileSystem/nanoFramework/StorageEventManager.cs is excluded by none and included by none

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The recent changes involve updating the dependency for the Nerdbank.GitVersioning package in the System.IO.FileSystem/packages.lock.json file. This adjustment reflects a move to a newer version (3.6.141) that may include important updates such as bug fixes or enhancements. Additionally, two linked issues highlight the need for improvements in SD card handling on the ESP32 platform, focusing on GPIO configuration and card detection logic.

Changes

Files Change Summary
System.IO.FileSystem/packages.lock.json Updated Nerdbank.GitVersioning from 3.6.139 to 3.6.141, altering the requested and resolved versions, and updated the content hash.

Assessment against linked issues

Objective Addressed Explanation
Support configuring GPIO numbers for SDCARD on ESP32-S3 (1447) The code does not implement GPIO configuration for data lines and clock.
Card detect pin logic for SD card detection (1475) The existing logic is unchanged and does not accommodate different pin states.

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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 507a952 and d891a97.

Files ignored due to path filters (11)
  • System.IO.FileSystem.UnitTests/DirectoryUnitTests.cs is excluded by none and included by none
  • System.IO.FileSystem.UnitTests/FileSystemUnitTestsBase.cs is excluded by none and included by none
  • System.IO.FileSystem/Properties/AssemblyInfo.cs is excluded by none and included by none
  • System.IO.FileSystem/System.IO.FileSystem.nfproj is excluded by none and included by none
  • System.IO.FileSystem/nanoFramework/CardDetectChangedEventArgs.cs is excluded by none and included by none
  • System.IO.FileSystem/nanoFramework/SDCard.cs is excluded by none and included by none
  • System.IO.FileSystem/nanoFramework/SDCardCDParameters.cs is excluded by none and included by none
  • System.IO.FileSystem/nanoFramework/SDCardMmcParameters.cs is excluded by none and included by none
  • System.IO.FileSystem/nanoFramework/SDCardSpiParameters.cs is excluded by none and included by none
  • System.IO.FileSystem/nanoFramework/StorageEventManager.cs is excluded by none and included by none
  • System.IO.FileSystem/packages.config is excluded by none and included by none
Files selected for processing (1)
  • System.IO.FileSystem/packages.lock.json (1 hunks)
Additional comments not posted (1)
System.IO.FileSystem/packages.lock.json (1)

37-39: Update to Nerdbank.GitVersioning package version.

The package version has been updated from 3.6.139 to 3.6.141. Ensure that this new version is compatible with your project and does not introduce any breaking changes.

Verification successful

Update to Nerdbank.GitVersioning package version confirmed.

The package version has been updated from 3.6.139 to 3.6.141. The references in the project files have been updated accordingly. Ensure that the new version's .props and .targets files are present, and review the release notes for any breaking changes.

  • Files Updated:
    • System.IO.FileSystem.nfproj: Updated to reference version 3.6.141.
    • packages.config: Updated to version 3.6.141.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify compatibility of the updated `Nerdbank.GitVersioning` package version.

# Test: Check for any known issues with version 3.6.141.
# Note: This would typically involve checking release notes or known issues online.
echo "Please verify the release notes for Nerdbank.GitVersioning version 3.6.141 for any breaking changes."

Length of output: 210


Script:

#!/bin/bash
# Search for references to Nerdbank.GitVersioning in the codebase
rg "Nerdbank.GitVersioning" --context 5

Length of output: 5044

Copy link
Member

@josesimoes josesimoes left a comment

Choose a reason for hiding this comment

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

There is already RemovableDriveEventArgs why should it be replaced with CardDetectChangedEventArgs? I get it that there is this new slotIndex, but that can be added to the existing class.
Moreover, card implies that it's card only opposed to removable driver that works for cards and USB MSD (any removable media).

@@ -78,19 +82,19 @@
<Content Include="packages.lock.json" />
</ItemGroup>
<ItemGroup>
<Reference Include="mscorlib, Version=1.15.6.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
<Reference Include="mscorlib">
Copy link
Member

Choose a reason for hiding this comment

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

These versions and sing key tokens need to be here.

Copy link
Member Author

@AdrianSoundy AdrianSoundy Aug 13, 2024

Choose a reason for hiding this comment

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

I had problems updating to latest nugets so removed and added again and that's what i ended with. Seems to build ok. I can manually add token etc back in.

Copy link
Member Author

Choose a reason for hiding this comment

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

Had to manually update version for gitversion in project for it to update properly.

Copy link
Member

@josesimoes josesimoes left a comment

Choose a reason for hiding this comment

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

@AdrianSoundy I think that with these changes in StorageEventManager you are recreating the logic that already exists at the native end...
There is an API to mount and unmount that calls the appropriate driver handler.
There is already a volume list that takes care of storing pointers to the volumes, etc.
Let's discuss this please.

@AdrianSoundy
Copy link
Member Author

Sorry a meant to leave some notes for discussion for this PR before review. That why I hadn't requested review yet :-)

When started testing the SD card stuff I found the storagemanager RemovableDeviceInsertion event was being used to indicate when a removable device had been mounted in file system although I thought it was for the card detect. The event logic for card detect was no longer working but looked like it had been calling the same event which didn't make sense. I fixed event so card detect called RemovableDeviceInsertion event then found the args for event didn't make sense. It was passing a drive path for I: drive for a card which wasn't mounted yet. I hope this makes sense.

So that's why I decided to create a new event for card detect with new args and leave the mount & unmount events alone.

Probably the RemovableDeviceInsertion event is the wrong name as it is being used for when a device is mounted. Should we rename it ? And call the Card Detect event that name ?

The card detect event I routed to the relevant sdcard object which I thought made more sense.

Everything is working now but I do think maybe some renaming will be in order. What do you think.

@josesimoes

@AdrianSoundy
Copy link
Member Author

AdrianSoundy commented Aug 13, 2024

The storage list is for mounted drives. With the card detect it isn't mounted yet so could not use that for lookup.

@AdrianSoundy
Copy link
Member Author

Unit tests failing because references wrong firmware checksum for filesystem. Won't be fixed until interpreter updated.

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