Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrf_fsotrage_read, why does the source address need to be word-aligned?

SDK14.2
nRF52832
No SD present (using the nrf_fstorage_nvmc backend)

Question 1.

I was reading the source code for the nrf_fstorage library and saw this comment in the nrf_fstorage_read(..) function in nrf_fstorage.c

/* Source addres must be word-aligned. */


My question is why does it need to be word-aligned?

The nrf_fstorage_read(..) calls the memcpy function. If I ignore nrf_fstorage_read(..) and just call: 

memcpy(dest, (uint32_t*) 0x1000, 4);

(word-aligned address), I can read successfully and correctly.

But if I do 

memcpy(dest, (uint32_t*) 0x1001, 4);

(not a word-aligned address), I can STILL read successfully and correctly. So where/how would this (source address not being word-aligned) cause problems?

Question 2.

Also, second question, we can't use memcpy to read data above 0x80000 address. For example, we can't do: 

memcpy(dest, 0x80000, 4); 

This fails, but why?

Thank you for all of your help! (May I also suggest putting the preview post button in the toolbar as a button instead of having it under tools!)

Related