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

How to prevent the application project to write to a defined memory segment

H,

I am using the SDK 15.0.0 and Segger Embedded Studio for ARM V3.40.

I have been successfully defining a flash memory section for data exchange between the bootloader project and the application project.

The flash memory section is the following
btldr_app_exchange R 0x0007D000 0x1000

Currently the bootloader project can write to this memory section. The problem I am facing is that the application project writes at run time to this very memory segment at the address 0x0007D000 to 0x0007D007(below)

When I define a different memory segment (btldr_app_exchange R 0x0007D08 0xFF8) the exact same behaviour is observed (the application project writes at run time at the address 0x0007D000 to 0x0007D007 and only at this address)

1/ How can I prevent the application project to write at as given memory segment?

2/ Is the address x0007D000 to 0x0007D007 specific and shall not be used to exchange data between the bootloader and the application?

For the moment, I have decided to exclude address x0007D000 to 0x0007D007 from my memory segment (btldr_app_exchange R 0x0007D08 0xFF8)

Thanks in advance for your support.

M Nayrolles

  • Hi Edvin,


    Thank again.

    It now works (I made the mistake that I merged an incorrect bootloader file using the merge command from the nrfutil sorry for that...). Below I try to summarise what I did, I I still have a problem at described at the end of this post. I can still close the case because it seems to be a different issue. 

    I have been using the flash area at address 0x77000 (size 0x1000) 

    in the .emProject file, I added btldr_app_exchange in both project files (application and bootloader)

    secure_bootloader.emProject:

    
    
    linker_section_placements_segments="FLASH RX 0x0 0x80000;RAM RWX 0x20000000 0x10000;uicr_mbr_params_page RX 0x10001018 0x4;mbr_params_page RX 0x0007E000 0x1000;btldr_app_exchange RWX 0x00077000 0x1000;bootloader_settings_page RX 0x0007F000 0x1000;uicr_bootloader_start_address RX 0x10001014 0x4"

    my_application.emProject:

    
    
    linker_section_placements_segments="FLASH RX 0x0 0x80000;RAM RWX 0x20000000 0x10000;btldr_app_exchange R 0x00077000 0x1000"

    I defined as below the page for the flash storage btldr_app_exchange_data both in the bootloader project and the application project: 

    
    
    NRF_FSTORAGE_DEF(nrf_fstorage_t m_btldr_app_exchange_data_fs) =
    {
        .evt_handler = NULL,
        .start_addr  = 0x00077000,
        .end_addr    = 0x00077FFF
    };
    
    #define BTLDR_APP_EXCHANGE_PAGE_SIZE 1000
    
    
    
    /**@brief   This variable reserves a page in flash for btldr_app_exchange_data (including the Bootloader version)
     *          to ensure the linker doesn't place any code or variables at this location.
     */
    #if defined (__CC_ARM )
    
        uint8_t m_btldr_app_exchange_data_buffer[BTLDR_APP_EXCHANGE_PAGE_SIZE]
            __attribute__((at(BOOTLOADER_SETTINGS_ADDRESS)))
            __attribute__((used));
    
    #elif defined ( __GNUC__ ) || defined ( __SES_ARM )
    
        uint8_t m_btldr_app_exchange_data_buffer[CBTLDR_APP_EXCHANGE_PAGE_SIZE]
            __attribute__((section(".btldr_app_exchange")))
            __attribute__((used));
    
    #elif defined ( __ICCARM__ )
    
        __no_init __root uint8_t m__btldr_app_exchange_data_buffer[BTLDR_APP_EXCHANGE_PAGE_SIZE]
            @ BOOTLOADER_SETTINGS_ADDRESS;
    
    #else
    
        #error Not a valid compiler/linker for m_dfu_settings placement.
    
    #endif // Compiler specific

    I then used "bare metal" fstorage in the bootloader project as I said in my last post and I was able to both to write to the defined flash area from the bootloader project and then read from it from the application project

    My only concern now is that the bootloader project will not compile in Debug configuration giving following error message

    error: section .tdata overlaps absolute placed section .reserved_flash_tail

    Best regards Marlene

  • I am not 100% certain, but I suggest you open the bootloader's flash_placement.xml file (right click the project name and select "Edit Section Placement"). Check if there are any hard coded flash addressess that needs to be updated there.

    Also, I am not sure whether you need to worry about the "Debug" build in your bootloader. I believe you would want to go with the "Release" version.

    BR,

    Edvin

Related