-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
[nrf_qspi_nor] LittleFS file system fails to mount if LFS rcache buffer is not word aligned #24122
Comments
I've opened #24128 to add the alignment check that was missing, but that doesn't really solve the problem. The flash_read API allows for alignment requirements on offset and size, but fails to specify whether the destination buffer must be aligned. For this driver, it apparently does, and I don't think we can change that. The bigger question is how you got an unaligned buffer. One way I can reproduce this is to assign a misaligned buffer in the
In current master that would cause a silent failure as you see; with #24128 it produces:
which is a better failure mode. Are you allocating your own buffers in the mount point configuration, and if so are you making sure they're aligned? The driver does support dynamically allocating buffers from a pool, and will do so with the correct size, so you don't have to do it yourself. Alignment should be automatically satisfied in that case as long as all the sizes involved are multiples of 4. |
I'm initialising the buffers as per the sample:
Looking at the macro definition, I don't think there's any requirement for the buffers to be word-aligned? Lines 71 to 72 in 093fec6
( It does seem odd to me that the compiler wouldn't choose to word-align a 64 byte array, but I really don't understand enough to work out why that might be.
That's interesting. How do I go about that? |
You'd have to initialize the structure yourself. (I misread the source and thought the default left them null.) There's no obligation on allocating a |
Ah - that makes sense. I've applied the patch in #24146 and that works nicely - thank you. |
Describe the bug
When using LittleFS on an nRF52840 PCA10056, I find that
fs_mount
hangs when using the following config:On investigation,
nrfx_qspi_read
requires that the destination buffer supplied is 32-bit word-aligned. As it stands, there is no guarantee that this is the case when using the flash API (as far as I can tell).To Reproduce
I've attempted to reproduce this using
samples/subsys/fs/littlefs
, but haven't been able to coerce the compiler into not word-aligning the rcache buffer.I am, unfortunately, hitting this bug in my own project.
Expected behavior
Calling
fs_mount
as documented insamples/subsys/fs/littlefs
should result in the file system being mounted, regardless of decisions the compiler has made about the location of the cache.Impact
Without an appropriate workaround, this is preventing us from reading qSPI flash storage.
Screenshots or console output
In my project, the call to
fs_mount
results in the following outputNote that the mount never completes or fails.
Environment (please complete the following information):
gnuarmemb
367eec2dd60d4e15ab6b9aff22d33686312997ed
Additional context
Initially reported as a proposed naive patch at nrfconnect/sdk-zephyr#291.
Applying the above patch does resolve the issue, which IMHO confirms this is an issue with word alignment of the buffer.
The text was updated successfully, but these errors were encountered: