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

using flash memory

Hi everyone !
I am working at a project. I dont't know which mcu was used this project but it was written for pca10040 and used s132.
Many values are write to flash memory at the project. In some places it was deleted as a flash page. for example: sd_flash_page_erase(0x66) or sd_flash_page_erase(0x67) etc.. And I also want to write to flash memory more value but I don't know that which flash address are usable.

How much flash memory can I use to store my information?

Which address ranges can I use?

Also what does a flash page mean?

How many addresses are on a page?

Which document should I follow? 

  • PCA10040 is the nRF52832 Dev Kit 

    How much flash memory can I use to store my information?

    Which address ranges can I use?

    Whatever's left after the flash space used by your application & the SoftDevice

    Also what does a flash page mean?

    How many addresses are on a page?

    Which document should I follow? 

    See the Product Specification

  • Hi,

    I am working at a project. I dont't know which mcu was used this project but it was written for pca10040 and used s132.

    The pca10040 is the nRF52 DK, which has an nRF52832 on it. That also fits well with using the s132 SoftDevice.

    sd_flash_page_erase(0x66)

    See the SoftDevice API documentation for sd_flash_page_erase().

    How much flash memory can I use to store my information?

    Which address ranges can I use?

    In theory you can use any flash area, but here is the general layout used when using SoftDevice and nRF5 SDK: Memory layout.

    Also what does a flash page mean?

    How many addresses are on a page?

    The flash is organized in "pages", and the flash page size on the nRF52 series is 4096 bytes. The smallest addressable unit is the byte, but flash is written as words (4 bytes), and so the address need to be at a word boundary. One limitation of flash is that it can only be erased in full pages. When erased, all bits are set to 1, meaning all bytes are 0xFF in hexadecimal. When writing, bits are flipped from 1 to 0. The only way to flip bits back from 0 to 1 is to do erase. There is also a limitation that the processor is halted while doing writes and erases, so APIs for writing and erasing is typically asynchronous, with a callback or event triggered when the operation has succeeded.

    Which document should I follow?

    It depends on what level you work on, what the project looks like. In addition to the SoftDevice API, which is very direct, there are higher level abstractions for working with flash in the SDK: Flash Data Storage (FDS) is one, giving a high level abstraction of "records". FDS is in turn built on top of fstorage, which gives access to areas and addresses directly.

    Regards,
    Terje

  • One limitation of flash is that it can only be erased in full pages. When erased, all bits are set to 1, meaning all bytes are 0xFF in hexadecimal. When writing, bits are flipped from 1 to 0. The only way to flip bits back from 0 to 1 is to do erase.

    as far as I understand there is no command to delete the value in just one address. If I type 0xffffffff into an address, doesn't it mean deleting the value at that address? when I want to erase  only 1 address, is it true writing 0xffffffff the adres? is it going to be any problem?

  • Hi,

    Erasing can only be done by using the erase functionality, and it erases one full flash page at the time.

    Writing can be done four bytes at a time, but what happens then is that only the 0 bits are written. When a bit has been written to 0, it cannot be written back to 1 again. In order to get it back to 1, the only way is to do a flash page erase.

    Regards,
    Terje

  • note that these are general characteristics of all flash - not something specific or special to Nordic or nRF52.

    The key difference between "Flash" used for program storage, and "EEPROM" designed for non-volatile data storage is this.

    Also beware that erasing Flash causes "wear" - so you want to avoid it as much as possible.

    has already mentioned the Flash Data Storage (FDS)  module in the SDK - which takes care of all these details (and more) for you.

Related