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

52833 write flash error

    #define SIZE 10
    int i;
    int8_t ret;
    int main_addr_buff,backup_addr_buff;
    int write_buff[SIZE];
    for(i=0;i<SIZE;i++){
        write_buff[i] = 10+i;
    }
    if((ret = nrf_fstorage_erase(&fstorage, 0x74000, 1, NULL)) != NRF_SUCCESS)
        SLOG_E("nrf_fstorage_erase error,%d",ret);
    waitForFlashReady(&fstorage);

    if((ret = nrf_fstorage_write(&fstorage, 0x74000, write_buff, sizeof(int)*SIZE, NULL)) != NRF_SUCCESS)
        SLOG_E("nrf_fstorage_write error,%d",ret);
    waitForFlashReady(&fstorage);

    for(i = 0;i < 1024;i++){
        nrf_fstorage_read(&fstorage, 0x74000+i*4, &main_addr_buff, sizeof(int));
        DLOG_I("main_addr=0x%x,main_addr_buff=0x%x",0x74000+i*4,main_addr_buff);
    }

i write 40bytes to flash 0x74000 and read 0x74000。i find it actually use 160bytes. I try to write a different number of bytes, it actually use 4*(write bytes)

this is jflash image

Thank you for your reply!!

  • Hi, the units  of len in nrf_fstorage_write(&fstorage, TEST_ADDR, write_buff, len, NULL))  is 4 bytes? 

  • Hi,

    The documentation states "Length of the data (in bytes)", so I do not think that can be the issue. I also looked into the code, and it looks like it is correct that it is number of bytes.

    When testing the code from your flash_write_test() function, by copying it into the fstorage example from SDK 16, and removing the existing flash writes in that example, I do get the expected result of 10 words with hexadecimal values A, B, C, D, E, F, 10, 11, 12, 13 written to flash. The rest of the flash page is all 0xFF.

    Do you have any other code writing to the same flash area?

    Can you share the full project, including project files, so that I can test with the exact same as what you have?

    Regards,
    Terje

Related