Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nuket opened this issue Aug 16, 2016 · 7 comments
Closed

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

nuket opened this issue Aug 16, 2016 · 7 comments

Comments

@nuket
Copy link
Contributor

nuket commented Aug 16, 2016

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
Copy link
Contributor

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
Copy link
Contributor Author

nuket commented Aug 17, 2016

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
Copy link
Contributor Author

nuket commented Aug 17, 2016

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-
Copy link
Member

pan- commented Aug 17, 2016

@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:

  • disable utest overhead: If you don't use utest and/or unity in your application you can disable them totally, this will FLASH and RAM in your application. To do that, at the root of your application create a file named .mbedignore and add this content in it: mbed-os/features/frameworks/*. It will save you around ~1K of RAM. Efforts are made to solve this issue cleanly (see here).
  • Compile with NDEBUG. mbed cli does not pass NDEBUG flag for release builds, this can help regarding memory consumption (pass -DNDEBUG) in the command line.
  • If you don't use RTOS capabilities, it is possible to use nanolib instead of newlib. To do that, apply this PR: Allow 'small-build' and 'big-build' to be used as options. #2409 and pass the option -o small-build on the command line.

@nuket
Copy link
Contributor Author

nuket commented Aug 17, 2016

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

@pan-
Copy link
Member

pan- commented Aug 17, 2016

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

@bridadan
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants