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

Programmatically accessing flash_placement.xml

Hi 

I am writing a bootloader and am trying to get the start locations of the different memory segments e.g. the FLASH start segment from the flash_placement file.

On a different manufacturer's micro on a Rowley IDE I used:

  int ramEnd = (int)(&__FLASH_segment_start__ );

But this returns 0x0 using Segger Embedded on a nrf52832

Please can you give me an example for Segger Embedded Studio

Thank you

  • Hi,

    The flash_placement files provided with the SDK examples are written so that FLASH segment covers the entire address range from 0x0 to 0x80000. This is defined by the FLASH_PH_*  placement macros under common linker configurations.  

    I should work if you change the FLASH_PH_ to only cover the bootloader's address range, but I think it might be better to define your own linker symbols in the xml file. That way you don't have to change the default configuration. 

    <!DOCTYPE Linker_Placement_File>
    <Root name="Flash Section Placement">
    <MemorySegment name="FLASH" start="$(FLASH_PH_START)" size="$(FLASH_PH_SIZE)">
    <ProgramSection load="no" name=".reserved_flash" start="$(FLASH_PH_START)" size="$(FLASH_START)-$(FLASH_PH_START)" />
    <ProgramSection alignment="0x100" load="Yes" name=".vectors" start="$(FLASH_START)" address_symbol="__app_flash_start__" />

     

     

  • Hi Vidar

    I have added into the flash placement file:

        <ProgramSection alignment="4" load="Yes" name=".textBootCall" start = "$(FLASH_CALL_START)" size = "$(FLASH_CALL_SIZE)" address_symbol="__app_flash_start__" />

    But still am unsure how to access it in code. The compiler gives:

    '__app_flash_start__' undeclared (first use in this function); did you mean 'app_timer_start'?

    Is there an include file I need to reference?

    Thank you 

    Nick

  • Hi Nick,

    Looks like you must use 'extern' to link in user defined symbols. Didn't think it was necessary since you were able to use the __FLASH_segment_start__ symbol. 

    E.g., 

        extern uint32_t  __app_flash_start__;
        uint32_t const * const m_flash_start = &__app_flash_start__;

  • well you always need a declaration of a variable just to tell the compiler 'this exists somewhere and this is what type it is' so it can compile, then it's the linker's job to actually find and resolve it. If you just put the thing in the linker file (which is what flash_placement.xml really is) then nothing at compile time has a clue it's even there. Hence the need for an external. 

    I think for the Rowley standard symbols they define them in some of the top level header files so that's why you can use them. If the original poster clicks on __FLASH_segment_start__ and asks the IDE to go to the definition he'll probably find where it was defined. 

Related