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

nRF52832 FLASH write issue

I want to write a piece of big data to flash.
Every time I write 112 word length, I write it many times.
Every time I write, the address is shifted back 112.
Before I write, I need to erase the pages that need to be written.
However, I find that only the first time I write successfully, but later I write unsuccessfully.
The API I use is sd_flash_write, what's the reason? thank you!

Parents
  • #define START_ERASE_PAGE            86

    #define OTA_DATA_START_ADDRESS      0x56000

    uint8_t *tag_ota_write_addr = (uint8_t *)(OTA_DATA_START_ADDRESS);

    void tag_ota_erase(uint8 page)
    {
        NRF_LOG_INFO("tag_ota_erase \n");

        for(int i = 0; i < page; i++)
        {
            sd_flash_page_erase(START_ERASE_PAGE + i);
            NRF_LOG_INFO("tag_ota_erase page : %d\n",START_ERASE_PAGE+i);
            nrf_delay_ms(100);
        }
    }

    At the time of initialization, 10 pages have been erased.

    using

    tag_ota_erase(10);

Reply
  • #define START_ERASE_PAGE            86

    #define OTA_DATA_START_ADDRESS      0x56000

    uint8_t *tag_ota_write_addr = (uint8_t *)(OTA_DATA_START_ADDRESS);

    void tag_ota_erase(uint8 page)
    {
        NRF_LOG_INFO("tag_ota_erase \n");

        for(int i = 0; i < page; i++)
        {
            sd_flash_page_erase(START_ERASE_PAGE + i);
            NRF_LOG_INFO("tag_ota_erase page : %d\n",START_ERASE_PAGE+i);
            nrf_delay_ms(100);
        }
    }

    At the time of initialization, 10 pages have been erased.

    using

    tag_ota_erase(10);

Children
Related