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

Correct calculation of the erase sector size #49

Merged
merged 1 commit into from
Aug 17, 2017

Conversation

LemonBoy
Copy link
Contributor

According to the documentation (page 95) you should add one to the value extracted from the CSD to obtain the real erase sector size.

@LemonBoy LemonBoy mentioned this pull request Aug 14, 2017
@deepikabhavnani
Copy link

deepikabhavnani commented Aug 16, 2017

@LemonBoy - Thanks for the PR. Sector size should be incremented by 1. But seems erase size is still incorrect for the CSD Version 1 cards.

Erase size should be _erase_size =(BLOCK_SIZE_HC * (ext_bits(csd, 45, 39) + 1)). For explanation please refer to SD card specification Pg 94/95
SECTOR_SIZE - Value of 127 means 128 write blocks.

We do not have CSD version 1 card, Can you please update and verify.

@LemonBoy
Copy link
Contributor Author

LemonBoy commented Aug 17, 2017

Alright, I've been fooled by the use of the byte offsets.
I think that's why the erase+program sequence ends up trashing the whole filesystem, there should be a way to ask the FS driver not to do so when the single-block erase isn't supported.

I've updated the PR, the ball's back into the FATFilesystem court.

The specification states that the real value is obtained by increasing
by one the value extracted from the csd register.
Copy link

@deepikabhavnani deepikabhavnani left a comment

Choose a reason for hiding this comment

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

LG 👍

@deepikabhavnani deepikabhavnani merged commit 0ac12a0 into PelionIoT:master Aug 17, 2017
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.

3 participants