This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ARM-CGT: error: memory ranges "image_1" and "image_2" out of order

Part Number: ARM-CGT

I am combing two elf file using the armhex tool but I am now seeing this error:

armhex --load_image --load_image:format=elf --load_image:endian=big --load_image:combine_sections=true bootloader.elf application.elf -o app.elf
error: memory ranges "image_1" and "image_2" out of order
error: memory ranges "image_2" and "image_3" out of order

How do I solve this issue?

  • This typically occurs when there is overlap in the memory ranges used by the input files.  In your case, that is the files bootloader.elf and application.elf.  Is that accurate?

    What version of the TI ARM compiler tools do you use?

    Thanks and regards,

    -George

  • I am using TI ARM Hex Converter v20.2.5.LTS

    The linker scripts look like this:

    bootloader application
    --retain="*(.intvecs)"
    MEMORY {
        VECTORS (X)  : origin=0x00000000 length=0x00000020
        FLASH0  (RX) : origin=0x00008020 length=0x00007FE0
        STACKS  (RW) : origin=0x08000000 length=0x00000800
        RAM     (RW) : origin=0x08000800 length=0x0007f800
    }
    
    SECTIONS {
        .intvecs          : {} > VECTORS
        .text   align(32) : {} > FLASH0
        .const  align(32) : {} > FLASH0
        .cinit  align(32) : {} > FLASH0
        .pinit  align(32) : {} > FLASH0
        .bss              : {} > RAM
        .data             : {} > RAM
        .sysmem           : {} > RAM
    }
    --retain="*(.intvecs)"
    MEMORY {
        VECTORS (X)  : origin=0x00010020 length=0x00000020
        FLASH1  (RX) : origin=0x00200000 length=0x00200000
        STACKS  (RW) : origin=0x08000000 length=0x00001500
        RAM     (RW) : origin=0x08001500 length=0x0007EB00
    }
    
    SECTIONS {
        .intvecs          : {} > VECTORS
        .text   align(32) : {} > FLASH1
        .const  align(32) : {} > FLASH1
        .cinit  align(32) : {} > FLASH1
        .pinit  align(32) : {} > FLASH1
        .bss              : {} > RAM
        .data             : {} > RAM
        .sysmem           : {} > RAM
    }
  • There is overlap in the memory ranges STACKS and RAM.  The memory range STACKS is never used, so that can be ignored.  I cannot immediately tell which of the sections allocated to RAM overlap in memory.  But it is certain that they do.  One solution is to change the definition of RAM so there is no overlap.  Is that practical?

    Thanks and regards,

    -George

  • I could change the RAM addresses, but I don't get why this is relevant in the use case of a bootloader.

    After the bootloader has finished, I should be able to use all RAM for the application - or do I miss something?

  • I will create a minimal working example and post it here!

  • After the bootloader has finished, I should be able to use all RAM for the application

    Speaking generally, you are correct.  However, the load image feature of armhex does not support that use case.  It requires that no memory overlap be present.  

    I have another solution for you to consider.  There is another utility named armobjcopy that can remove sections from a program file (you call them ELF files).  Use it to remove one or more uninitialized sections from the bootloader program.   Please note that is okay to remove only uninitialized sections, like .bss.  It is not okay to remove initialized sections, like .text.  From the information you have shown, I cannot tell which sections overlap.  But .bss may be one of them.  If so, a command similar to this one removes it ...

    armobjcopy --remove-section=.bss bootloader.elf bootloader_no_bss.elf

    When you use armhex, replace bootloader.elf with bootloader_no_bss.elf.  

    Note that the rest of the code in bootloader_no_bss.elf still thinks the section .bss is present.  In a certain sense, it still is.  The memory that is allocated to .bss from bootloader.elf is still present in the program file application.elf

    I am using TI ARM Hex Converter v20.2.5.LTS

    The bug EXT_EP-10558 is present in version 20.2.5.LTS of armobjcopy.  I don't know if it affects you.  But it might.  Thus, it is best if you upgrade to version 20.2.6.LTS.

    Thanks and regards,

    -George