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 Children
Related