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

Clarify flash storage start & end address for nRF52840

I am using flash_fstorage_s140_pca10056 example from SDK v17.0.2, I see that the start address is 0x0003 E000 and the end address is 0x0003 EFFF respectively.

I want to determine the max size to store device configuration. This will let us decide limits on the data structure for storing device configuration. I have followed some of the threads on this topic and need some help in understanding the start and end addresses.

I have made no other changes to the code in the example project, I have only done the following change to print the end address. The value I get on logging is 0x00100000. In the following line, I determine the start address which is commented, I think that's not right. Need help here.

I haven't programmed any bootloader, I have erased the device fully and reflashed the binary. With reference to this thread, the value I get for NRF_UICR->NRFFW[0] is 0xFFFF FFFF. So, what's the start address in this case? I am confused with the values 0x0003 E000 and 0xFFEF FFFF.

Parents
  • After reading this thread, I used the symbol CODE_END to identify the end address of the application. So I think, CODE_END + 1 (4 bytes) should be the start address for fstorage.

    For the end address, I used the nrf5_flash_end_addr_get API. With a little bit of digging, I was able to understand how the end address is determined. This Memory Layout under the bootloader section was really helpful to visualize and understand.

    With this information, I print the addresses and the amount of free space on flash. It tallies with the free space viewed in the Memory Usage window. I think I have understood now.

    Can somebody validate if I am on the right track?

  • Hi Jaimin, 

    Yes, you are correct on how to find the area between the end flash (can be the actual end of the chip's flash or it can be the last address before the bootloader start). 

    But be aware when you use the address right after the CODE_END, it's because the chip manage the flash by pages. So if you want to erase a word in a page you would need to erase the whole page. 
    So if you want to use the free space to store your application data, you should start from the next available page, not at CODE_END + 1

    Same applied for the last page. 

    Note that if your application use fds (which used in our BLE example) you need to avoid the area occupied by the fds module. 

Reply
  • Hi Jaimin, 

    Yes, you are correct on how to find the area between the end flash (can be the actual end of the chip's flash or it can be the last address before the bootloader start). 

    But be aware when you use the address right after the CODE_END, it's because the chip manage the flash by pages. So if you want to erase a word in a page you would need to erase the whole page. 
    So if you want to use the free space to store your application data, you should start from the next available page, not at CODE_END + 1

    Same applied for the last page. 

    Note that if your application use fds (which used in our BLE example) you need to avoid the area occupied by the fds module. 

Children
No Data
Related