Finally the right Eclipse project configuration!

I don't want a fully fledged Eclipse project or depend on heavy Eclipse for anything.~

I don't know if you have the same feeling, but it doesn't look like a good idea to depend on one heavy tool for anything in your electronic project. Having easy-to-understand scripts for building or debugging the project will make the life easier to newcomers (...or to yourself when you come back 3 years later and all the tools you used initially are now outdated).

Of course, from a former continuous integration engineer, I would also rise the obvious problem of automating your project in a CI environment. Yes, Eclipse can run headless, but this this is a dirty solution. Simple command-line tools are the way to go.

But, you still want a modern IDE where you can program and debug in the same tool. Proprietary debuggers such as Greenhills MULTI [1], Lauterbach Trace32 [2], iSystem WinIdea [3], PLS UDE [4]... are very well integrated for debugging, but not very much for programming. Also they are very expensive. Still have a look at iSystem WinIdea Open, which is free for ARM development and comes with a nice DIY hardware debugger board (see the do-it-yourself iTAG.ZERO and the 50€ iTAG.FIFTY at [5]). Unfortunately this last option only works with Microsoft Windows.

By the way, I discovered there is a standalone eclipse debugger [6].

I like Greenhills MULTI and it works under GNU/Linux as well, but there is no free/non-commercial version.

For the hardware debugger probe, don't forget to check the famous and always well-supported SEGGER J-Link [7]. Also see the "Why J-Link?" section of GNU ARM Eclipse project at [8] for explanations about the advantages of this probe (e.g., 15MHz JTAG). The education/non-commercial version named "SEGGER J-Link EDU" costs about 60€ (without VAT), see at Farnel [9].

There are Chinese copies of the J-Link easily found on eBay or Taobao for about 10€, but be careful that SEGGER invests a lot of efforts into fighting illegal Chinese copies. The official J-Link software [10] will brick your Chinese J-Link probe by flashing a new (brocken) firmware automatically.

How to architecture your embedded project?

If you want an all-in-eclipse project, I suggest to follow the 4-part tutorial from Akhmad Hendriawan at [13], [14], [15] and [16]. The problem is, as explained a the beginning of this post, that everything depends on eclipse, which is bad (R)

In addition, I am targetting a bare-metal solution, excluding any compiler start-up and standard C or C++ library (newlib).

Create a new empty project:

By disabling the default build command, all the GNU ARM Ecplise auto build is removed:

For example, the build script could be like this:

#!/bin/sh
# Simple build script

GCC_BIN_PATH=/usr/bin

$GCC_BIN_PATH/arm-none-eabi-g++ -g -std=gnu++0x -fno-exceptions -mcpu=cortex-m3 -mthumb --specs=nosys.specs -I inc/ -T myEmbeddedProject.ld \
myEmbeddedProject.cpp \
-o myEmbeddedProject.elf

# for debug purposes only
$GCC_BIN_PATH/arm-none-eabi-objdump -xmyEmbeddedProject.elf > objdump.log

# convert elf into hex for flashing
$GCC_BIN_PATH/arm-none-eabi-objcopy -O ihex myEmbeddedProject.elf myEmbeddedProject.hex

You can create External Tools Configurations to flash the target, or run the OpenOCD gdb server:

For example, the flash script could be like this:

#!/bin/sh
# Simple flash script

OPENOCD_BIN_PATH=/usr/bin/
OPENOCD_TCL_PATH=/usr/share/openocd/scripts

$OPENOCD_BIN_PATH/openocd -f $OPENOCD_TCL_PATH/interface/stlink-v2.cfg -f $OPENOCD_TCL_PATH/target/stm32f1x_stlink.cfg -c init -c targets -c "halt" -c "flash write_image erase myEmbeddedProject.elf" -c "verify_image myEmbeddedProject.elf" -c "reset run" -c shutdown

The debug configuration for OpenOCD:

For example, the debug script could be like this:

#!/bin/sh
# Simple script for gdb server

OPENOCD_BIN_PATH=/usr/bin/
OPENOCD_TCL_PATH=/usr/share/openocd/scripts

$OPENOCD_BIN_PATH/openocd -f $OPENOCD_TCL_PATH/interface/stlink-v2.cfg -f $OPENOCD_TCL_PATH/target/stm32f1x_stlink.cfg

Result

If you install EmbSysRegister for eclipse, you can have a nice special functions registers (SFR) view matching your microcontroller.

Enjoy programming, flashing and debugging with eclipse, without relying on eclipse in your project!

References

[1]Greenhills MULTI, http://www.ghs.com/products/MULTI_IDE.html
[2]Lauterbach Trace32, http://www.lauterbach.com
[3]iSystem WinIdea, http://www.isystem.com/products/software/winidea
[4]PLS UDE, http://www.pls-mc.com
[5]iSystem, iTAG family, http://www.isystem.com/index.php/products/hardware/cortex-debugger/itag
[6]Eclipse, CDT/StandaloneDebugger, https://wiki.eclipse.org/CDT/StandaloneDebugger
[7]SEGGER J-Link base, https://www.segger.com/jlink_base.html
[8]de.farnell.com/segger/8-08-90-j-link-edu/emulator-j-link-edu/dp/2098545
[9]GNU ARM Eclipse, "How to install the SEGGER J-Link?", http://gnuarmeclipse.github.io/debug/jlink/install/
[10]SEGGER, J-Link software, https://www.segger.com/jlink-software.html
[11]ST, STM32F0 discovery board, http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/PF253215?sc=internet/evalboard/product/253215.jsp
[12]Andy's Workshop, http://andybrown.me.uk/2014/09/09/stlinkv2/
[13]Waveshare Electronics, ST-Link/V2 mini, http://www.wvshare.com/product/ST-LINK-V2-mini-STM8.htm
[14]Akhmad Hendriawan, (part 1/4) https://www.youtube.com/watch?v=HKX12hJApZM
[15]Akhmad Hendriawan, (part 2/4) https://www.youtube.com/watch?v=ZeUQXjTg-8c
[16]Akhmad Hendriawan, (part 3/4) https://www.youtube.com/watch?v=epivFDMmHI8
[17]Akhmad Hendriawan, (part 4/4) https://www.youtube.com/watch?v=WeH02tC2MZY
[18]https://launchpad.net/gcc-arm-embedded
[19]https://www.eclipse.org/downloads/
[20]http://gnuarmeclipse.github.io
[21]http://gnuarmeclipse.sourceforge.net/updates
[22]http://embsysregview.sourceforge.net/