-
-
Notifications
You must be signed in to change notification settings - Fork 345
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
Conversation
@jonnykl Please, check this PR and tell me if it is working for you. |
@@ -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; |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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).
Except the change I commented a few minutes ago everything is correct but does not solve the problem. You prevent the developer from using illegal values which is good but anyways the function |
The fix works now if Pro (for this fix):
Con:
This fix is OK, but this behavior should be documented (bytes from Pro (my fix):
Con:
I think both versions of the fix are OK. They only differ if the developer specifies a offset/size that the FS does not fit exactly in physical blocks. |
… the size to include the end of the sector.
maxAllowedEndAddress = INTERNAL_FLASH_SIZE - 1; | ||
requestedEndAddress = cfg.phys_addr + SPIFF_SIZE - 1; | ||
if(requestedEndAddress > maxAllowedEndAddress) { | ||
cfg.phys_addr &= 0xFFFFF000; // get the start address of the sector |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the following code would be better:
cfg.phys_addr -= cfg.phys_addr % INTERNAL_FLASH_SECTOR_SIZE;
Closes #1313.