segger studio seems to ignore the memory map file

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

    • segger studio seems to ignore the memory map file

      Hi.
      I have the following memory map file:

      Source Code

      1. <!DOCTYPE Board_Memory_Definition_File>
      2. <Root name="nrf52840">
      3. <MemorySegment name="FLASH" start="0x0" size="0x100000" access="ReadOnly" />
      4. <MemorySegment name="RAM" start="0x20000000" size="0x40000" access="Read/Write" />
      5. <MemorySegment name="uicr_bootloader_start_address" start="0x00000FF8" size="0x4" access="ReadOnly" />
      6. <MemorySegment name="bootloader_settings_page" start="0x000FF000" size="0x1000" access="ReadOnly" />
      7. <MemorySegment name="uicr_mbr_params_page" start="0x00000FFC" size="0x4" access="ReadOnly" />
      8. <MemorySegment name="mbr_params_page" start="0x000FE000" size="0x1000" access="ReadOnly" />
      9. </Root>

      when it's processed to generate an ld script for gcc this is the header of the ld script:

      Source Code

      1. MEMORY
      2. {
      3. UNPLACED_SECTIONS (wx) : ORIGIN = 0x100000000, LENGTH = 0
      4. uicr_mbr_params_page (wx) : ORIGIN = 0x00000ffc, LENGTH = 0x00000004
      5. uicr_bootloader_start_address (wx) : ORIGIN = 0x00000ff8, LENGTH = 0x00000004
      6. mbr_params_page (wx) : ORIGIN = 0x000fe000, LENGTH = 0x00001000
      7. bootloader_settings_page (wx) : ORIGIN = 0x000ff000, LENGTH = 0x00001000
      8. RAM (wx) : ORIGIN = 0x20000000, LENGTH = 0x00040000
      9. FLASH (wx) : ORIGIN = 0x00000000, LENGTH = 0x00100000
      10. }

      I verified using all kind of parameters and trying to use options->build->memory segment playing with various RWX permissions, i always get (RW) eventually in the ld script.
      i tried to look in the generated ld script to see if i see somewhere lese restrictions for read only sections but i cannot find any.

      i'm using segger studio for nordic nrf52840, the flash memory is not writable in any case, but memory map should also define peripherals and registers which are also read only, what's the point defining it right if eventually the ld script does not enforce it ?
      I have verified the same behavior with various nrf sdk 15.2 examples, changing the permissions in the memory map results in the same ld script permissions. is that a bug or done on purpose ?
    • Hello,

      Thank you for your inquiry.
      Such an issue is not known to us.
      Could you provide an example project for reference?
      Did you set the memory map in project options?
      The Nordic SDK samples use the memory segments option instead. To use your own memory map make sure to set it under Build->Memory Map File.

      Do other example projects from the SDK work?
      Which ES version are you using when running the samples? Are you using the recommended version by the SDK?

      Best regards,
      Nino
      Please read the forum rules before posting: Forum Rules

      Keep in mind, this is not a support forum. Its main purpose is user to user interaction.
      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.
    • Hi.
      i'm using version 4.18 of the segger arm studio.
      The Nordik SDK indeed uses segments, i also tried playing with them as well. it did not change the ld script. yes it's consistent with all samples i tried and i tried a few. indeed i am setting the memory map in the project options.

      For ref i'm using nordik SDK 15.2 example: nRF5_SDK_15.3.0_59ac345/examples/dfu/secure_bootloader/pca10056_ble/

      the memory file i used instead of the segment is already published here, but you can see the segments definitions as well of RX that results in ld (wx) as well.
    • Hi,

      Thank you for clarifying which project you use.
      Unfortunately Nordic chose a bit different approach here for setting section placement and memory segments.
      Instead of using memory maps or memory segments option the Nordic SDK samples are using "section placement macros" project option.
      The other memory map and memory segments are simply ignored.

      If you edit the section placement macros you should be able to move the placement around.

      Does that work for you?

      Best regards,
      Nino
      Please read the forum rules before posting: Forum Rules

      Keep in mind, this is not a support forum. Its main purpose is user to user interaction.
      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.
    • Thanks for the response.
      My problem is not with the placement itself in memory, at least not yet.
      My problem is the top part of the generated ld script and the fact that all sections are with permission '(wx)' is there a way to use the flasdh_placement.xml file or the section placement macro to change those permission to what they should be ? eventually, and correct me if i'm wrong, the executable is linked using gnu ld which means it uses the generated ld script, and so what matters is the generated def:



      Source Code

      1. FLASH (wx) : ORIGIN = 0x00000000, LENGTH = 0x00100000
      flash section should not be writable as you need hardware to write to it. and i prefer tha the ld will alert on such events which can be done if the linker script will be:

      FLASH (r) : ORIGIN = 0x00000000, LENGTH = 0x00100000

      same goes for registers in the MCU that are defined in those sections, they might be read only, it's always better that the compiler\linker will verify that then it will happen in run-time...
    • Hello,

      Please understand that this is not a support forum so quick answers/solutions are not guaranteed.
      More information can be found in my signature.

      Regarding Flash placement. If I understand you correctly you want to set FLASH to read only. Keep in mind that then you can't link any code from your project at that location.
      So to program your Flash you need to use some external tool instead of using Embedded Studio directly.
      Not sure why you would want to do this, could you elaborate?

      If you still want to do this you need to remove the placement macros used by Nordic and set your linker script xml and memory map xml instead. Make sure that they use the same memory names otherwise linking will fail.

      Best regards,
      Nino
      Please read the forum rules before posting: Forum Rules

      Keep in mind, this is not a support forum. Its main purpose is user to user interaction.
      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.
    • I'm not 100% we are talking about the same thing.
      in the ld script a memory region that is defined RO only means that this region if written to by the program should generate compile time\link time error.
      All flash regions should be defined RO according to best practice since write to flash is not done by copying from register to mem but using a controller + buffer.

      This is what i mean and this is why i want to make it read only, memory regions that are just memory mapped regions like bootloader start address or secure bootloader settings address should be readonly since it's not writable memory in reality (you just can't write to it as it's not ram...)

      If i'm missing something here do let me know.

      In any case if you compare an ld script we manually wrote to the one generated by segger studio you can clear see the difference. i have no problem burning the .hex files myself but i really don't see how it is a problem in my configurations :-\

      I use memory_map.xml and not the macros. You can see my memory map xml in the beginning of this thread. if i had the time i would defiantly try out the segger linker instead i'm sure it will behave properly , but i'm also sure it doesn't generate .ld script but actually linking on it's own, am i right ? so i can't compare and i can't currently do the conversion.

      Thanks,

      Eyal.
    • Hi Eyal,

      Could you provide an example Embedded Studio project for reproduction that shows this behaviour?

      Best regards,
      Nino
      Please read the forum rules before posting: Forum Rules

      Keep in mind, this is not a support forum. Its main purpose is user to user interaction.
      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.