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

how erase flash memory only N bytes?

Hi, all

I'm trying to write/erase data to flash memory (nrf52833, pca10100)

I want to erase only 4 bytes.. Is it wrong to define like this? I guess '4' value's unit is not bytes.  

        ret_code_t rc = nrf_fstorage_erase(&fstorage, now_addr, 4, NULL);
        APP_ERROR_CHECK(rc);
        wait_for_flash_ready(&fstorage);
        NRF_LOG_INFO("Done.");

I write code like above, but didn't work what I expected,

so I changed 'erase unit' 4096 to 4.. (in nrf_fstorage_sd.c)

/* Flash device information. */
static nrf_fstorage_info_t m_flash_info =
{
#if   defined(NRF51)
    .erase_unit   = 1024,
#elif defined(NRF52_SERIES)
//    .erase_unit   = 4,
    .erase_unit   = 4096,
#endif
    .program_unit = 4,
    .rmap         = true,
    .wmap         = false,
};

but it returns 0x03 error in fstorage_evt_handler function.

I don't know which part to modify more.

I'd appreciate it if you could suggest other methods than the ones above.

BR,

lyrics

Parents Reply
  • Hi, thank you for reply..

    So change the erase unit 4096 to 4 does not work.. right?

    Have in mind that when calling nrf_fstorage_erase() you specify the flash page address you want to erase, not the memory address.

    and can you explain more about this? What is different between flash page address and memory address? 

    I though erasing flash page address is same as erasing memory.

    I mean.. I want to erase(or write) data in flash memory, and is it right to use 'nrf_fstorage_earse()' function?

Children
Related