ARMmbed / mbed-os

Arm Mbed OS is a platform operating system designed for the internet of things
https://mbed.com
Other
4.65k stars 2.97k forks source link

Linking with error: "cannot move location counter backwards" #15481

Closed lefebvresam closed 7 months ago

lefebvresam commented 7 months ago

Description of defect

When compiling and linking I get the error:

:~/git/hmipanel/mbed-os$ mbed-tools compile -m HMC20 -t GCC_ARM
...
/home/sam/git/hmipanel/cmake_build/HMC20/develop/GCC_ARM/source/hmipanel.elf.map
/usr/lib/gcc/arm-none-eabi/10.3.1/../../../arm-none-eabi/bin/ld:/home/sam/git/hmipanel/cmake_build/HMC20/develop/GCC_ARM/mbed-os/targets/TARGET_STM/TARGET_STM32U5/TARGET_STM32U575xG/mbed-stm32u575xg.link_script.ld:90 cannot move location counter backwards (from 0000000020005640 to 000000001ffffc00)
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
ERROR: CMake invocation failed!

I created my own device and updated pinning files as described in the howto’s.

custom_targets.json:

{
    "MCU_STM32U575xG": {
        "inherits": [
            "MCU_STM32U5"
        ],
        "public": false,
        "extra_labels_add": [
            "STM32U575xG"
        ],
        "macros_add": [
            "STM32U575xx"
        ],
        "device_has_remove": [
            "ANALOGOUT",
            "CAN",
            "CRC",
            "FLASH",
            "TRNG",
            "SERIAL_ASYNCH"
        ]
    },
    "HMC20": {
        "inherits": [
            "MCU_STM32U575xG"
        ],
        "clock_source": {
            "value": "USE_PLL_HSE_EXTC|USE_PLL_HSI"
        },
        "components" : ["SD", "SPIF"],
        "overrides": {
            "hse_value": 10000000
        },
        "detect_code": [
            "0000"
        ],
        "device_name": "HMC20"
    }
}

Target(s) affected by this defect ?

Custom target

Toolchain(s) (name and version) displaying this defect ?

mbed-tools

What version of Mbed-os are you using (tag or sha) ?

baf6a3022a328b91713e03fd88f65126a9a53f01 origin/master

What version(s) of tools are you using. List all that apply (E.g. mbed-cli)

Mbed 7.59.0

How is this defect reproduced ?

Cannot be reproduced because of private project.

lefebvresam commented 7 months ago

Solved by defining RAM and ROM size.

    "MCU_STM32U575xG": {
        "inherits": [
            "MCU_STM32U5"
        ],
        "public": false,
        "mbed_rom_size": "0x100000",
        "mbed_ram_size": "0xc0000",        
        "extra_labels_add": [
            "STM32U575xG"
        ],
        "macros_add": [
            "STM32U575xx"
        ]
    },