ARMmbed / mbed-os

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

Linker on Nordic nRF51822 `cannot move location counter backwards`. #2467

Closed nuket closed 8 years ago

nuket commented 8 years ago

I'm trying to build a simple project but ld keeps complaining, when tried with both gcc 4.9 and gcc 5.4:

gcc 4.9 says:

./mbed-os/hal/targets/cmsis/TARGET_NORDIC/TARGET_NRF5/TARGET_MCU_NRF51822_UNIFIED/TOOLCHAIN_GCC_ARM/TARGET_MCU_NORDIC_32K/NRF51822.ld:142 cannot move location counter backwards (from 0000000020007fd8 to 0000000020007800) collect2: error: ld returned 1 exit status [ERROR] ./mbed-os/hal/targets/cmsis/TARGET_NORDIC/TARGET_NRF5/TARGET_MCU_NRF51822_UNIFIED/TOOLCHAIN_GCC_ARM/TARGET_MCU_NORDIC_32K/NRF51822.ld:142 cannot move location counter backwards (from 0000000020007fd8 to 0000000020007800) collect2: error: ld returned 1 exit status

All of the code compiles fine, it's only the link step that is erroring out. Is it possible that I'm out of memory?

The mbed-os version number, using the mbed CLI:

mbed-os (8d368775e32a)

I tested the mbed OS Blinky example, and it builds fine.

bridadan commented 8 years ago

I'm pretty sure when I've seen this error it's because I was out of memory.

@pan- Do you think that's the case?

nuket commented 8 years ago

Looks like this could be the case, but if those values returned by the linker are correct, I'm not looking forward to optimizing down 2k worth of code. Things are pretty tight on the chip already and I'm not even close to done with my firmware.

Also asked this question at the Nordic support forum, and they referred to another link with a similar conclusion.

nuket commented 8 years ago

Ok, I figured out where a ton of test code from a library was being pulled in by the mbed compile command. Added an .mbedignore to that folder and the problem went away.

Ticket can be closed.

pan- commented 8 years ago

@nuket @bridadan Yes, there is not enough RAM for the application.

The inclusion of the OS add a non negligible overhead. RAM optimization is a trending topic for mbed OS right now and several patches will help.

You can apply workarounds now:

nuket commented 8 years ago

Thanks for the suggestions, I'll try them out incrementally!

pan- commented 8 years ago

@nuket These optimizations will be gradually included in mbed-os, I think the situation will be better in few weeks.

bridadan commented 8 years ago

@pan- You're right, we're on it :)