Hello!
As promissed in last post, I'll show you how to setup eclipse to work with the our STM32F0 discovery board + open source toolchain.
1) Open eclipse. First of all we need to install (if not already installed) two new software. So go to menu Help/Install New Software. In work with, type "http://download.eclipse.org/tools/cdt/releases/juno" and in the list below choose CDT Optional Features/ C/C++ GDB Hardware Debugging". Next in http://gnuarmeclipse.sourceforge.net/updates, select "GNU ARM C/C++ Development Support".
2) Create a new C Project. Go to menu File/New Project and select C/C++ - C Project. Click next.
3) In next window Choose under ARM Cross Target Application - Empty project. Select your toolchain (Sourcery G++ Lite) or (GNUARM).
4) Go to menu Project/Properties. In C/C++ Build / Settings select Tool settings. In Target Processor change "Processor" to cortex-m0.
5) Now in the same Tool Settings tab go to ARM Sourcery Linux GCC C Compiler / Preprocessor and add the following values:
USE_STDPERIPH_DRIVER
USE_STM32F0_DISCOVERY
STM32F0XX
6) Still in Tool Settings tab go to ARM Sourcery Linux GCC C Linker / General and uncheck "Do not use standard start file (-nostartfiles) and check "Remove unused sections (-Xlinker --gc-sections). In Script file (-T) set path: /home/stm32/workspace/Template/src/stm32f0.ld
7) In C/C++ General, select Path and Symbols and add the following paths (in both Assembly and GNU C):
/Template/Libraries/CMSIS/ST/STM32F0xx/Include
/Template/Libraries/
/Template/src
/Template/Libraries/STM32F0xx_StdPeriph_Driver/inc
/Template/Libraries/CMSIS/Include
8) Configure GDB by clicking in the small arrow in the right of the bug. Select "Debug Configurations... ". Select "GDB Hardware Debugging" right click and select new. Change name to GDB-OpenOCD and in the bottom of the window click in "Select other..." and select "GDB (DSF) Hardware Debugging Launcher".
9) Under tab Debugger, uncheck everything and set the path of your gdb from your toolchain: /home/user/stm32/gcc-arm-none-eabi/bin/arm-none-eabi-gdb
10) Under tab Start Up, uncheck everything and in "Run commands" add:
target remote localhost:3333
monitor reset init
monitor stm_flash /home/user/stm32/workspace/Template/Debug/Template.elf
load /home/user/stm32/workspace/Template/Debug/Template.elf
symbol-file /home/user/stm32/workspace/Template/Debug/Template.elf
cont
11) Now configure OpenOCD by clicking in the small arrow in the right of the play with toolbox (external tools). Select "External Tool Configurations... ". Select "Program" right click and select new. Change name to OpenOCD. Set openocd path: /usr/bin/openocd and working directory: /home/user/stm32/openocd-0.6.0-rc1/tcl
In "Arguments" write: -f /home/user/stm32/workspace/Template/extra/stm32f0discovery.cfg -f /home/user/stm32/workspace/Template/extra/stm32f0-openocd.cfg
If everything is OK, compile your hello world program. Go to "External Tools" and select "OpenOCD". It should show de following message in Console:
Open On-Chip Debugger 0.6.0-rc1 (2012-09-03-20:37)
Licensed under GNU GPL v2
[...]
Now, the great moment, put a breakpoint in your main and select the bug icon "GDB - OpenOCD". It should stop your code like this:
That's all for today!
Marcelo
Great work. I have got the build to work but debugging fails. Template.elf is missing. How is Template.elf generated?
ReplyDeleteHello! Template.elf is generate by your compiler. Try to compile your code!
DeleteAlan - Thats the output of the compilation. Go through your build log, if the compilation actually succeeded you should have the elf file. (or just search for *.elf)
ReplyDeleteI think the instruction, while detailed, missed the part where we add source files to the project. (I am new to Eclipse.. struggling to understand).
Marcelo, great set of instructions. Now if only I could get the debugging to work..
When I click the GDB button, I get a 'Launching GDB-OpenOCD' has encountered a problem. Program file does not exist'
Maybe we could tempt you to create a video walk-through? :)
Yes, you're right! I should explain how to add add source files to the project!
DeleteThis error is because you configured not correctly the path to your gdb (from your toolchain). Check if your arm-none-eabi-gdb is in this path:
/home/user/stm32/gcc-arm-none-eabi/bin/arm-none-eabi-gdb
or try to find where you have installed it!
Marcelo
Hi, i have a stm32f10e-Eval board.. where do i get the ldscripts as mentioned in step 6.
ReplyDeleteHello, sorry for the delay. I think your email went to spam!
DeletePlease go to first post (http://marcelojoeng.blogspot.ca/2012/08/stm32f0-discovery-gcc-eclipse-openocd.html) at step 6.
Hello,
ReplyDeleteI use Eclipse Indigo. I followed by yours tutorial, everything works, except step 10. I don't have any runtime options. Do you know what is wrong and how to fix it? I can not find any solution.
Thank you in advance,
Regards,
Marcin
Hello, which runtime options? In step 10 you should only configure to start GDB. Could you tell me what is the error?
DeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
Delete