Possible bug: SES copies buffer from named ProgramSection when present in module header

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Possible bug: SES copies buffer from named ProgramSection when present in module header

      Working with a Nordic nRF52840, which has RAM divided into nine AHB secondaries. If I add a ProgramSection for one of these in the RAM MemorySegment in flash_placement.xml, then I declare a buffer in that named RAM region in the header file of a module, the buffer is copied when I use it in the code file. This does not happen if I declare a buffer in that named RAM region in the code file of a module. This behavior occurs with all optimization levels.

      Minimal example:

      flash_placement.xml:

      XML Source Code

      1. ...
      2. <MemorySegment name="RAM1" start="$(RAM_PH_START)" size="$(RAM_PH_SIZE)">
      3. ...
      4. <ProgramSection alignment="4" keep="Yes" load="No" name=".buffer1" start="0x2000A000" size="0x2000" />
      5. <ProgramSection alignment="4" keep="Yes" load="No" name=".buffer2" start="0x2000C000" size="0x2000" />
      6. ...


      some_module.h:

      C Source Code

      1. ...
      2. static uint8_t buffer1[0x2000];
      3. static uint8_t buffer2[0x2000];
      4. ...


      some_module.c:

      C Source Code

      1. ...
      2. buffer1[0] = (uint8_t)0x01;
      3. ...


      Results in this error:

      Shell-Script

      1. 1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.42b/gcc/arm-none-eabi/bin/ld: error: section .buffer1 overlaps absolute placed section .buffer2
      2. 1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.42b/gcc/arm-none-eabi/bin/ld: section .buffer1 VMA [000000002000c000,0000000020013fff] overlaps section .buffer2 VMA [000000002000a000,0000000020013fff]
      where the greater memory boundary grows with the number of references to the buffer in the code file.

      The post was edited 1 time, last by jacobw56 ().

    • Hello,

      Thank you for your inquiry.
      The overlap most likely happens as you have static defined buffers in your header. Now every C file you include this header will initialize its own copy of this buffer. Thus it does not fit into the section if used more than once.
      What you are probably looking to do is to have a global buffer which is reference in multiple modules. For this you use the extern declaration in the other modules.

      Please understand that we can't provide further assistance as this is not an Embedded Studio specific inquiry but rather a general C coding question.

      Best regards,
      Nino
      Please read the forum rules before posting.

      Keep in mind, this is *not* a support forum.
      Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
      Should you be entitled to support you can contact us via our support system: segger.com/ticket/

      Or you can contact us via e-mail.