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

How to find the start address for writing to flash

There are two central sd_* methods for writing to flash - write and erase. The problem is I need to know where I can put my data without trashing something else that is already there and without reading every memory location and looking for the 'magic value'.

The examples do not help a bit, as they simply use the address of the last page. What if I need more than 1024 bytes?

Yes I know how to get the end of the memory. But that is a pretty stupid place to begin writing unless one writes backwards.

Clearly what the application writer wants is to find the start of free flash, so there is a maximum amount of flash available. 

How does one do this???

Why isn't there a method sd_get_start_address_of_free_flash()?  I think that was first suggested some six years ago.

Parents
  • Hi,

    The softdevice is a standalone built hex-file, completely separate from the application. The softdevice does not have any prerequisites to know where your application ends (apart from parsing flash and looking for empty pages), or know if some parts of flash are reserved for other purposes in your application.

    I do not understand why you are facing issues with knowing where the application flash space ends, you set the start of flash in you application, and the compiler tells you the size of the compiled application. This should allow you to know the area that is safe for writing. Softdevice and bootloader regions are described in the softdevice specifications and SDK documentation.

    If you want to be totally safe from overwriting the application, you can reduce the size of the application flash area in your project settings, to set aside the desired area of pages required for application flash area. Then the compiler will give you an error if it grows out of the allocated area at a later point in time.

    Best regards,
    Jørgen

  • I set the start of flash in my application? I guess I don't know where this done - I haven't implemented any code that does that. Of course I have inherited an old project s110. I have looked at some settings in the Keil project but all of those appear to be the entire size.

    I see in the 'target' options a start of IROM of 0x14000 and a size of 0x2B000 but I have no idea what that is for. I assumed it was the total size I have for the application and data but I am not sure.

    Does it mean that my application will be placed at 0x14000 and then I use the NRF_FICR->CODESIZE to find the end of my code?

    That doesn't make sense either since the flash write examples say NRF_FICR->CODESIZE - 1 is the last page. Last page? It sounds to me like NRF_FICR->CODESIZE is the entire size of flash. I must be missing a critical piece of information as none of this is making sense. Is the flash write top down?

    I have seen some pretty maps in some of the later docs but that doesn't tell me how to get that information. Maybe the s110 is old enough that such info is not available, thus the cry for a  sd_get_start_address_of_free_flash() some 6 years ago?

Reply
  • I set the start of flash in my application? I guess I don't know where this done - I haven't implemented any code that does that. Of course I have inherited an old project s110. I have looked at some settings in the Keil project but all of those appear to be the entire size.

    I see in the 'target' options a start of IROM of 0x14000 and a size of 0x2B000 but I have no idea what that is for. I assumed it was the total size I have for the application and data but I am not sure.

    Does it mean that my application will be placed at 0x14000 and then I use the NRF_FICR->CODESIZE to find the end of my code?

    That doesn't make sense either since the flash write examples say NRF_FICR->CODESIZE - 1 is the last page. Last page? It sounds to me like NRF_FICR->CODESIZE is the entire size of flash. I must be missing a critical piece of information as none of this is making sense. Is the flash write top down?

    I have seen some pretty maps in some of the later docs but that doesn't tell me how to get that information. Maybe the s110 is old enough that such info is not available, thus the cry for a  sd_get_start_address_of_free_flash() some 6 years ago?

Children
No Data
Related