-
-
Notifications
You must be signed in to change notification settings - Fork 99
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
Add CFLAG to select SPIRAM heap caps malloc #159
Add CFLAG to select SPIRAM heap caps malloc #159
Conversation
Thanks for the PR! I think this is something appropritate to add to the |
I was pondering whether to do that or not. The reason I didn't add it to the Kconfig was because in the These could both also be Kconfig, and that's a change I'm happy to make - if it's in fitting with the rest of the code? |
The I'd say for now, just adding |
Although Particularly, Also this vfs wrapper is strictly not static anyway, even if LFS_NO_MALLOC or the new Kconfig is set - there are a number of callocs in esp_littlefs.c which I've also wrapped to reflect the selected allocation strategy. A question - a comment against
However, the previous code was not ensuring 64-bit alignment. I have changed this to use |
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.
git-blaming the 64-bit alignment comment in the littlefs repo yields the following commit message:
In v2, the lookahead_buffer was changed from requiring 4-byte alignment
to requiring 8-byte alignment. This was not documented as well as it
could be, and as FabianInostroza noted, this also implies that
lfs_malloc must provide 8-byte alignment.
To protect against this, I've also added an assert on the alignment of
both the lookahead_size and lookahead_buffer.
However, looking at the assert:
// setup lookahead, must be multiple of 64-bits, 32-bit aligned
LFS_ASSERT(lfs->cfg->lookahead_size > 0);
LFS_ASSERT(lfs->cfg->lookahead_size % 8 == 0 &&
(uintptr_t)lfs->cfg->lookahead_buffer % 4 == 0);
We see that the lookahead needs to be a multiple of 64-bits, but only required to be 32-bit aligned. I think this is a slight error in the documentation @geky.
Overall, I think this PR is pretty good now, just a few minor clarifying comments. I also need to give this a test on some hardware.
thanks for all the commits! I'm going to try and run this on hardware tonight, and then merge 👍 |
Awesome. If this goes well I'll have a go at some of the other things that could do with being in Kconfig (I'm looking at you, debug levels!) |
@tonyjackson-srt are you looking to make more PRs over the next few days? Or would you prefer me to cut a new minor release now? |
@BrianPugh definitely more to come, I see the version has been bumped - thanks for this as I will be able to use that in my project in the meantime :) |
Allows including project to select SPIRAM for mallocs with
add_compile_definitions(LFS_MALLOC_SPIRAM)