This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

flash write

hi everyone (1) everytime,the pstorage_init get the same block id, if we wrtie it more than 20,000 times , will this block become a bad one? if it will, can the program automatically get another good block id,and write it smoothly? thank you. (2)is the block id actually the physical address?

  • Hi

    (1) You are correct, the flash memory has specified endurance of 20.000 write cycles. This endurance is per bit, meaning that if you write or erase a single bit more than 20.000 times, it is not guaranteed to work any more (even though it might). So if you anticipate that you will need to write a certain data to flash more than 20.000 times for the lifetime of your product, you should implement a mechanism to write that data into different flash locations.

    (2) The block id is not exactly the physical address of the flash you write to. The physical address space for flash operations made by the application is specified in the pstorage_platform.h file. Typically, the application writes to the last page of the flash. If there is a bootloader already flashed to the chip, the application flash space is located at the last page before the bootloader.

    • Address space of the whole flash is from 0x00000 - 0x40000, i.e. 256kB
    • Size of each page is 0x400, i.e. 1kB

    Lets assume that there is no bootloader flashed to the chip and the application flash space is located at the last page in flash. If specifying 10 blocks, each with 16 bytes (like done in the example provided in this thread), the first block is located at 0x40000 - 0x400 = 0x3FC00, the address of the second block is 0x3FC00 + 0x10 = 0x3FC10, the address of the third block is 0x3FC00 + 0x20 = 0x3FC20, and so on

Related