This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrf_fstorage_write len 6 bytes only write 4

I'm using nrf_fstorage_wrile() which work fine on most of the cases, except for len == 6 bytes. When I read back on the Flash, after successful write, I found that only 6 bytes are written.

As a workaround, I had to split in two writes:

nrf_fstorage_write(addr, p_buffer, 4, NULL);
nrf_fstorage_write(addr+4, p_buffer+4, 2, NULL);


Note a write of 4 bytes or 8 bytes is working fine in my case. 

Is there some constraints about the len ?

I'm using SDK15.2, nRF52840 and CrossWorks IDE.

Parents
  • Hi,

    It is expected that writing 6 bytes does not work, but I do not see how it could fail silently. You should get an error from this parameter check in the nrf_fstorage_write(), since you are trying to write a length which is not a multiple of 4 bytes:

        /* Length must be a multiple of the program unit. */
        NRF_FSTORAGE_PARAM_CHECK(!(len % p_fs->p_flash_info->program_unit), NRF_ERROR_INVALID_LENGTH);

Reply
  • Hi,

    It is expected that writing 6 bytes does not work, but I do not see how it could fail silently. You should get an error from this parameter check in the nrf_fstorage_write(), since you are trying to write a length which is not a multiple of 4 bytes:

        /* Length must be a multiple of the program unit. */
        NRF_FSTORAGE_PARAM_CHECK(!(len % p_fs->p_flash_info->program_unit), NRF_ERROR_INVALID_LENGTH);

Children
No Data
Related