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

Bugfix/zynq mount fix2 #48

Closed
wants to merge 14 commits into from
Closed

Conversation

phelter
Copy link
Contributor

@phelter phelter commented Jul 8, 2023

Description

Fixing Mounting issues - when mounting with zynq.

Test Steps

Won't mount unless the mountFailIgnore is set. Should this be an option/configuration?

Checklist:

  • I have tested my changes. No regression in existing tests.
  • I have modified and/or added unit-tests to cover the code changes in this Pull Request.

Note Unable to add unit tests as this needs to be tested with Zynq.

Related Issue

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@phelter phelter requested a review from a team as a code owner July 8, 2023 20:46
@htibosch
Copy link
Contributor

htibosch commented Jul 8, 2023

Hi @phelter, this is the code where xMountFailIgnore is checked:

if( FF_SDDiskMount( pxDisk ) == 0 )
{
    /* _HT_ Suppose that the partition is not yet
     * formatted, it might be desirable to have a valid
     * i/o manager. */
    if( xMountFailIgnore == 0 )
    {
        FF_SDDiskDelete( pxDisk );
        pxDisk = NULL;
    }
}

So when mounting the drive fails, it is possible to keep the i/o manager and use it for formatting.

In your case, can you tell why mounting fails? Is the drive already formatted?

xMountFailIgnore could indeed become a configurable property.

@sidmodi-mw
Copy link

Hello @htibosch. I am responding to your questions since @phelter had created this PR on my behalf.

The mounting fails exactly because of your comment in the code:

/* _HT_ Suppose that the partition is not yet
     * formatted, it might be desirable to have a valid
     * i/o manager. */

When the system boots up, it runs the FF_SDDiskInit function. But on a brand new setup which has never been formatted before, there are no partitions available to mount. And to run the FF_Partition function, a valid i/o manager is required. For a new device, this is the sequence of events for me:

FF_SDDiskInit -> fails but keeps i/o manager if xMountFailIgnore == 1
FF_Partition
FF_Format
FF_SDDiskMount
FF_FS_Add

None of this works if xMountFailIgnore == 0 on a system that has never been formatted before.

Thank you!

@htibosch
Copy link
Contributor

Hello @sidmodi-mw, thank you for explaining the situation.

on a system that has never been formatted before.

Ah yes, I recognise this problem, Let's make an option that controls xMountFailIgnore.

@phelter
Copy link
Contributor Author

phelter commented Jul 11, 2023

Thanks @htibosch ,

Would strongly lobby for: adding an init function that allows that in lieu of a precompiler defines which are very problematic for both testing and integration.

eg:
https://github.com/FreeRTOS/Lab-Project-FreeRTOS-FAT/blob/08d0cff40d9832f235442ab22e577ddf4204da52/portable/Zynq.2019.3/ff_sddisk.c#L435C1-L445

Change to:

FF_Disk_t * FF_SDDiskInit( const char * pcName )
{
  return FF_SDDiskInitWithSettings(pcName, pdFALSE, 0);
}

/** 
 * Initialize  the SD Disk with configurable settings
 * @param[in] xMountFailIgnore ignore fails on mount, set to true when have systems where may not have initialized mount
 * @param[in] xDiskPartition the disk partition number to use
 */ 
FF_Disk_t * FF_SDDiskInitWithSettings( const char * pcName, BaseType_t xMountFailIgnore, BaseType_t xDiskPartition )

And in the header support the new declaration of the InitWithSettings() API.

@AniruddhaKanhere
Copy link
Member

AniruddhaKanhere commented Jul 13, 2023

I like the approach @phelter suggested above.
Instead of making a macro/global variable, lets just create an API which can be used in lieu of the original API.

Would @sidmodi-mw or @phelter like to take a stab at modifying the current PR?

@htibosch
Copy link
Contributor

@AniruddhaKanhere wrote:

I like the approach @phelter suggested above

Me too 👍

@AniruddhaKanhere
Copy link
Member

@htibosch and @phelter I added a PR to do what we discussed here: #49.

I have not added the same API to other ports. Not sure whether we need that.
I do not have much experience with this library and will do what you folks suggest.

Let me know how would you like to proceed.

@AniruddhaKanhere
Copy link
Member

Since PR #51 has been merged which does the exact same thing as this PR, I shall close this.

Thank you for taking the time to notice, discuss and contribute to FreeRTOS+FAT @phelter and @sidmodi-mw.

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

Successfully merging this pull request may close these issues.

4 participants