-
Notifications
You must be signed in to change notification settings - Fork 14
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
Async support #17
Async support #17
Conversation
Nice! I have just merged something big, so you're now getting conflicts :P |
Map is going to be annoying though because it uses a bit of recursion for its store operation. This can't be done with futures without alloc. So that has to be changed to a loop... |
ee25feb
to
642aa2a
Compare
Map support is done now. Tested queue on nRF with nrf-softdevice and qspi flash. |
@lulf Thanks! Took a quick look and looks good at first glance. I'm not really feeling the required input buffer alignment for the mock flash, though. Or are there more flash implementations that require the write buffer to be aligned? |
No rush on my part, thanks for taking the time.
We can remove the alignment requirement from the mock flash, it was merely added to trigger this condition in tests and in the fuzzer, otherwise it might sneak in a bug in the future and break nrf flash in the process, so I figured it would be useful for preventing a regression in the future. The write_aligned was added so that the unit test in lib.rs didn't have to do the alignment dance, I'm happy to move that into the test instead. The important part is that the internal buffers in sequential-storage used to write things like item headers are aligned, otherwise it simply won't work with that nrf flash alignment.
No that I'm aware of, it's an nRF quirk, might even be specific to softdevice. It's not a lot to go by, but the closest source of information on this that I found is the description of the flash write error values: "NRF_ERROR_INVALID_ADDR Tried to write to a non existing flash address, or p_dst or p_src was unaligned." (From https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v7.3.0/group___n_r_f___s_o_c___f_u_n_c_t_i_o_n_s.html#gae5361e65cbb5e7f6e258947a394c9b55) |
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.
Thorough review done. Couple of things that I'd like to see different
@diondokter Thanks for the review! All comments should be addressed, except the bool one... I can change it to bool if you insist, but I really do think it hurts readability. |
Changes the sequential-storage APIs for queues and maps to be async first. Non-async behavior is achieved using a block_on, optionally combined with an adapter for the flash supporting embedded-storage-async.
* wrap entire doc comment in block_on * use futures_test in unit tests * use aligned buf for failing tests
Awesome, thanks for the work! |
@diondokter Just a headsup that I started looking at this... I've gotten the queue implementation to work nicely with async, and was able to use it with the Flash on nrf-softdevice. This revealed an issue which might be only specific to the softdevice, where the buffer to write into flash must be word-aligned, so the AlignedBuf is introduced for that. I set the alignment to 32 bytes, but I'm not sure if there are anyone besides the nRF flash which has this requirement (could be set to 4 bytes in that case).
I need to finish the map support, but just thought to give an early notice!