Errors building STM32L152 mbed project with GNU GCC

14 Nov 2014

Sorry if this is a double post. Just posted something, thought it was on forum, but I accidentally posted it in "Questions": http://developer.mbed.org/questions/5252/Errors-building-STM32L152RE-mbed-project/

Not sure why there is a "Forum" and "Questions"? I will stick to forum in the future.

15 Nov 2014

Problem resolved, was my linker and startup file. Updated GitHub files.

11 Dec 2014

Hello! I have the same problem with CooCox CoIDE. Can You please tell a little more on what exactly you did with linker and startup file? I'm new to STM32 world so the more basic it is the better. Thank You very much!

11 Dec 2014

Hi, the problem should have been resolved with the latest mbed version. In your online compiler, click on "mbed" in your project view, click on "Revisions" button on top, and update to latest revision. Try again to export, and see if that works. Else, you might have to replace "mbed" with "mbed-src" to get the latest build(for which there is no revision yet) of mbed.

11 Dec 2014

Sorry for really step by step explanation but what am I missing here?

  • 1) In embed compiler online opened new project "Nucleo_blink_led".
  • 2) In "program workspace" tab selected (highlighted with one mouse click) "mbed" folder.
  • 3) On the right side "Library Build Details" pressed "revisions" button.
  • 4) Revision history of "mbed" selected latest (revision 92) and pressed button "Switch".
  • 5) Then opened main.cpp and opened right mouse menu on "Nucleo_build_led" folder in "programm workspace" tab and selected "export program..."
  • 6) From small dialogue box choose Export target: "ST Nucleo L152RE" and Export toolchain: "CooCox CoIDE"
  • 7) Downloaded and extracted zip file with CooCox Project
  • 8) Opened CoIDE (Fresh install)
  • 9) Selected "Project/Open Project..." and opened downloaded project ..\Nucleo_blink_led_coide_nucleo_l152re\Nucleo_blink_led\Nucleo_blink_led.coproj
  • 10) in CoIde pressed button "Build (F7)"
  • 11) Got error: [cc] collect2.exe: error: ld returned 1 exit status

Thanks for the patience!

12 Dec 2014

Hi, that is exactly the same error I got. I think the mbed V92 hasn't been udpated with the fix available on meb-src. Search mbed for details on how to replace mbed with mbed-src.

Alternativel, you can try replacing your startup and linker script with the following:

https://github.com/modtronix-com/Nucleo_blink_led_ls_L152RE_coide/blob/master/mbed-src/targets/cmsis/TARGET_STM/TARGET_STM32L1/TARGET_NUCLEO_L152RE/TOOLCHAIN_GCC_ARM/STM32L152RE_FLASH.ld

and

https://github.com/modtronix-com/Nucleo_blink_led_ls_L152RE_coide/blob/master/mbed-src/targets/cmsis/TARGET_STM/TARGET_STM32L1/TARGET_NUCLEO_L152RE/TOOLCHAIN_GCC_ARM/startup_stm32l152xe.s

12 Dec 2014

Where are start-up and linker files located? Should they be somewhere in side project files exported by mbed?

12 Dec 2014

replace the official library 'mbed' with 'mbed-src'; and you'll find the startup files under libraries/mbed/cmsis/...

12 Dec 2014

So I took ALL this project: https://github.com/modtronix-com/Nucleo_blink_led_ls_L152RE_coide and still get same error: collect2.exe: error: ld returned 1 exit status

12 Dec 2014

Hi, I just tried to export and use a different project with CoIDE, and had similar issues. The project brings the same error as you reported. I tried to update the version of mbed to v92, but still same bug. I know they fixed this bug in latest mbed, but problem is v92 does not have this fix in yet. I got mine to work by using latest mbed-src. Can you try this:

1) Right click on your project, and select "Import Library.." > "From Import Wizard....". Then select "mbed-src", and import it. I imported it as a library, not sure if as program will work the same.

2) Now you should have the latest "non release" version of mbed (Dec 11). This should have the bug fix in for compiling offline.

3) You now have mbed and mbed-src in your project, BUT should only have 1. Right click on mbed, and delete it, leaving only a single mbed.

4) Now try to export your project for GCC ARM, CoIDE or emblocks, it should work.

13 Dec 2014

This is Great! Finally works as advertised. After replacing mbed library with mbed-src library (following your instructions above) exports, builds and loads with no problems. Thank you very much! Now I can finally start coding next big thing in consumer electronics :)