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

Fixed the SPIFFS size calculation. #1653

Merged
merged 5 commits into from
Mar 28, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions Sming/Services/SpifFS/spiffs_sming.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ bool spiffs_format_internal(spiffs_config *cfg)
{
if (cfg->phys_addr == 0)
{
SYSTEM_ERROR("Can't format file system, wrong address");
SYSTEM_ERROR("Can't format file system, wrong address given.");
return false;
}

if (cfg->phys_size == 0)
{
SYSTEM_ERROR("Can't format file system, wrong size given.");
return false;
}

Expand All @@ -67,14 +73,14 @@ bool spiffs_format_internal(spiffs_config *cfg)
sect_last = flashmem_get_sector_of_address(sect_last);
debugf("sect_first: %x, sect_last: %x\n", sect_first, sect_last);
ETS_INTR_LOCK();
int total = sect_last - sect_first;
int total = sect_last - sect_first + 1;
Copy link

Choose a reason for hiding this comment

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

This is not correct (see PR 1313)

Copy link

Choose a reason for hiding this comment

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

As you can see (here) I also did the same change but in conjunction with the change in line 67 (which is the fix of the bug).

int cur = 0;
int last = -1;
while( sect_first <= sect_last )
{
if(flashmem_erase_sector( sect_first++ ))
{
int percent = cur++ * 100 / total;
int percent = ++cur * 100 / total;
if (percent > last)
debugf("%d%%", percent);
last = percent;
Expand All @@ -85,7 +91,7 @@ bool spiffs_format_internal(spiffs_config *cfg)
return false;
}
}
debugf("formated");
debugf("formatted");
ETS_INTR_UNLOCK();

return true;
Expand Down