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

How to handle flashwrit in an safe way.

Hi,

i need to store data in my Flash, for that i use the flashwrite example. Am i right taht i can use the remain of my application flash? So all flash = 256 kB - App = 20 kB = Flash i can use to write my Data to ?

I read that if i use flashwrite and the Softdevie, that i have to halt the Softdevie becauose of the latncy of flahswriting is that right? How can i handle this in a safe way?

Best reagrds Nils

Parents
  • Flash is normally divided into parts, called pages. On the nRF51822, a page is a 1024 byte area of the flash, so a 256 kB version of the chip will have NRF_FICR->CODESIZE = 0x100 = 256.

    The example snippet you show takes this number, subtracts 1, and multiplies it with the page size in bytes. This will give you the start address of the last page, which is then written to.

    There isn't any magic way to know if a page is used by the application, you simply have to use your application size to calculate which pages are used. In addition, the bond manager and possibly the error handler also writes to flash, so you should avoid those pages as well. If a flash address contains only 0xFFs, this normally indicates that it is not written. You can inspect any address using either J-Link Commander, nrfjprog or Keil's debugger.

Reply
  • Flash is normally divided into parts, called pages. On the nRF51822, a page is a 1024 byte area of the flash, so a 256 kB version of the chip will have NRF_FICR->CODESIZE = 0x100 = 256.

    The example snippet you show takes this number, subtracts 1, and multiplies it with the page size in bytes. This will give you the start address of the last page, which is then written to.

    There isn't any magic way to know if a page is used by the application, you simply have to use your application size to calculate which pages are used. In addition, the bond manager and possibly the error handler also writes to flash, so you should avoid those pages as well. If a flash address contains only 0xFFs, this normally indicates that it is not written. You can inspect any address using either J-Link Commander, nrfjprog or Keil's debugger.

Children
No Data
Related