Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 10 months ago.
Code does not start correctly using GCC
I've got working gcc toolchain based upon the latest gcc ARM embedded compiler (4.8) and the export option for Blinky. I've setup my toolchain using Code::Blocks ide which is calling the compiler with the following build log
build log
-------------- Build: Debug in controller (compiler: GNU GCC Compiler for ARM Embedded)--------------- arm-none-eabi-gcc.exe -Wall -mcpu=cortex-m3 -Iinclude/mbed -Iinclude/mbed/TARGET_LPC1768 -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections -DTARGET_LPC1768 -mcpu=cortex-m3 -mthumb -g -Iinclude\mbed -I.\include\mbed\TARGET_LPC1768 -c main.cpp -o obj\Debug\main.o arm-none-eabi-gcc.exe -L.\mbed -L.\mbed\TARGET_LPC1768 -L"C:\ARM Workspace\mbed-dc225afb6914" -L"C:\ARM Workspace\mbed-dc225afb6914\TARGET_LPC1768\TOOLCHAIN_GCC_ARM" -o bin\Debug\controller.elf obj\Debug\main.o include/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/cmsis_nvic.o include/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/system_LPC17xx.o include/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/startup_LPC17xx.o include/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/retarget.o -Linclude/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/ -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys -lmbed -Tinclude/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/LPC1768.ld -mcpu=cortex-m3 -mthumb -Wl,--gc-sections --specs=nano.specs Output file is bin\Debug\controller.elf with size 90.51 KB Running target post-build steps arm-none-eabi-objcopy -O binary bin\Debug\controller.elf bin\Debug\controller.bin Process terminated with status 0 (0 minute(s), 0 second(s)) 0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
The correct LED is coming on (if I change blinky from LED1 to LED3) but the program simply doesn't seem to start and I'm left with one none blinking LED.
Any thoughts?
1 Answer
10 years, 10 months ago.
Found the problem by using the Serial class. -lmbed has to be linked first! So the libraries line is now:
-lmbed -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys
Otherwhise the definition of wait() is not the correct one!
Can you share your makefile exported ? at least the command where we can see that mbed library was after the other libraries.
This is output from KL25Z exported demo (only the last part where are libraries)
mbed/TARGET _KL25Z/TOOLCHAIN_GCC_ARM/retarget.o -lmbed -lstdc++ -lsupc++ -lm -lc -lgcc -lno sys -lmbed -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys
Hey Martin
I don't use makesfiles. I'm using the GCC for Embedded toolchain I've setup myself using the Code::Blocks IDE.
The original order for linking my libraries was: -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys -lmbed
And by moving -lmbed to the front of that list I'm now getting one happy Blinky LED. Next will by trying to use the newlib optimized for size included in the 4.8 release of gcc. I'll post my findings if I can get it to work decently.
posted by 11 Jan 2014That explains it. I initially thought something is wrong with exported project which uses a generated makefile. I suggest using makefiles, make your life easier. If you avoid using makefiles, they at least can serve as a base for your own commands. For example I wrote a makefile for mbed https://github.com/0xc0170/mbed_gcc_makefile or a generated makefile when you export any project from online compiler.
What webpage did you follow to set-up code blocks? I would like to try it soon.
Regards,
0xc0170
I'm normaly not a fan of makefiles. I did use the exported one as a guide to setting up Code::Blocks correctly; I try to keep a uniform IDE and quite like Code::Blocks with the autocompletion based on Doxygen comments.
I just used the included GNU ARM template as a base. Most followed this guide: http://www.hackvandedam.nl/blog/?p=707 without debugging (for now)
posted by 11 Jan 2014