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

flash update just 1 byte

Hi, I'm using nrf51 without ble.

I want to update flash but not want to delete PAGE every time.

	NRF_NVMC->ERASEPAGE = (uint32_t) page_address;

How can i do?

Parents
  • If the specific address you're writing to is already erased (i.e. its value is 0xFFFFFFFF) you don't need to erase the whole page before the write.

    If the address is not erased, you may be able to write to it a second time. The absolute maximum ratings of the nRF51 state that an address can be written to 2 times without an erase. However, I believe you would be you could only change '1's to '0's on the second write.

  • Then you'll have to write your own or modify fstorage or pstorage. Designing your own memory management can be very simple or very complicated depending on your requirements (e.g. how often are you writing data, how big is the data you need to store, whether you can tolerate pulling old data accidentally, ect).

    For example, I had a uint32_t variable that I knew would never be 0xFFFFFFFF (if it ever did, the system would break). I reserved a page of flash for this variable.

    After boot, I would find the value by searching for the last non-empty value (non 0xFFFFFFFF).

    When I wrote a new value, I would write to the first empty address in the page. When I reached the end of the page, I erased the page and started from the beginning again.

    My erases were infrequent enough that I would never exceed the 10,000 write/erase cycle limit.

Reply
  • Then you'll have to write your own or modify fstorage or pstorage. Designing your own memory management can be very simple or very complicated depending on your requirements (e.g. how often are you writing data, how big is the data you need to store, whether you can tolerate pulling old data accidentally, ect).

    For example, I had a uint32_t variable that I knew would never be 0xFFFFFFFF (if it ever did, the system would break). I reserved a page of flash for this variable.

    After boot, I would find the value by searching for the last non-empty value (non 0xFFFFFFFF).

    When I wrote a new value, I would write to the first empty address in the page. When I reached the end of the page, I erased the page and started from the beginning again.

    My erases were infrequent enough that I would never exceed the 10,000 write/erase cycle limit.

Children
No Data
Related