Download and install
Example project
GDB Server
Trouble shooting


This is a small tutorial which shows you how to debug your application with Eclipse using J-Link, J-LInk EDU or a SAM-ICE for the JTAG interface.

It is highly recommended that you installed the YAGARTO Tools and read part 2 and part 3 of the
GNU ARM toolchain tutorial. Furthermore a GNU ARM toolchain and Eclipse must be installed (Some more information in the next section).

What is J-Link?

J-Link is a USB powered JTAG emulator developed by SEGGER supporting a large number of CPU cores. Based on a 32-bit RISC CPU, it can communicate at high speed with the supported target CPUs. J-Link has a built-in 20-pin JTAG connector, which is compatible with the standard 20-pin connector defined by ARM.

If you need more general information about the
J-Link, take a look at the J-Link page.

What is J-Link EDU?

SEGGER offers now a new package for educational pupose, which is available at a discounted price for everybody who does not use the software to develop a product for sale.

The offer includes free use of the GDB Server, Flash download and Flash breakpoints. The only limitation is that it may not be used to develop a product. More information about the EDU version of the J-Link can be found here.

What is SAM-ICE?

SAM-ICE is an OEM version of J-Link, sold by Atmel. SAM-ICE works with Atmel devices only. This limitation can NOT be lifted, if you would like to use J-Link with a device from an other manufacturer, you need a "normal" J-Link.

Licenses for RDI and GDB Server are included. Other licenses can be added.

Download and install

For a complete C/C++ development system we need the following components:

  1. J-Link "Software and documention pack"
  2. YAGARTO Tools (like make, sh, rm, cp and mkdir)
  3. GNU ARM toolchain
  4. Integrated Development Environment (Eclipse + Eclipse CDT)

1. J-Link "Software and documention pack":

The J-Link / SAM-ICE is developed by SEGGER, therefore you can download the latest software from the SEGGER J-Link ARM software page.

Download the "Software and documentation pack", expand the zip file, and start the setup program. For more information about how to install and setup the J-Link itself, take a look in the J-Link manual (pdf, 3 MB), which can be found at the following SEGGER page.

If you already installed the YAGARTO Tools, GNU ARM toolchain and IDE, you can go to the next section.

2. YAGARTO Tools:

If you do not have the utilities like make, sh, rm, cp and mkdir, I recomended to use these tools from the latest YAGARTO Tools (20121018) installer, which can be found here.

Start the installer, at the "Choose Components" page you can accept the defaults:

Press the "Next >" button and follow the instruction of the installer.

3. GNU ARM toolchain:

If you did not already install the toolchain, you can download the installer from the front page.

Start the installer, at the "Choose Components" page you can accept the defaults:

Press the "Next >" button and follow the instruction of the installer.

4. Integrated Development Environment:

More information about the Integrated Development Enviroment and how to install can be found in this tutorial here.


For the STM32F407 project the following hardware was used:

This is an Olimex STM32-E407 development board, which is equipped with a STM32F407ZG cpu.

Example projects

Here I will show you, how to compile your first program. These examples was tested with J-Link ARM v4.58a and can be used to debug in RAM and ROM.

Download the example you need and expand the zip file to your working directory.

I will show you the next steps with the STM32F407Test example, and expanded it in the following directory:


This directory is only an example, choose what is the best for you. For the next steps I will use this directory.

Open a command prompt and change in the C:\temp\STM32F407Test directory. First you must clean the project, therefore type:

C:\temp\STM32F407Test>make clean

The result should look like:

rm -f ./cmsis/device/startup_stm32f4xx.o ./cmsis/device/system_stm32f4xx.o ./src
/syscalls.o ./src/main.o
rm -f test_ram.elf
rm -f test_ram.map
rm -f test_ram.hex
rm -f ./cmsis/device/system_stm32f4xx.c.bak ./src/syscalls.c.bak ./src/main.c.bak
rm -f ./cmsis/device/system_stm32f4xx.lst ./src/syscalls.lst ./src/main.lst
rm -f ./cmsis/device/startup_stm32f4xx.s.bak
rm -f ./cmsis/device/startup_stm32f4xx.lst
rm -fR .dep

All list and object files are deleted, now we want to compile the program, type:

C:\temp\STM32F407Test>make all

The output should look like:

arm-none-eabi-gcc -x assembler-with-cpp -c -mthumb -mcpu=cortex-m4 -mfloat-abi=h
ard -mfpu=fpv4-sp-d16 -D__FPU_USED=1 -O0 -g -gdwarf-2 -Wa,-amhls=cmsis/device/s
tartup_stm32f4xx.lst -D__HEAP_SIZE=8192 -D__STACK_SIZE=2048 cmsis/device/start
up_stm32f4xx.s -o cmsis/device/startup_stm32f4xx.o
arm-none-eabi-gcc -c -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16
-D__FPU_USED=1 -O0 -gdwarf-2 -Wall -Wstrict-prototypes -fverbose-asm -ffunctio
n-sections -fdata-sections -Wa,-ahlms=cmsis/device/system_stm32f4xx.lst -DRUN_
FROM_FLASH=0 -DVECT_TAB_SRAM -MD -MP -MF .dep/system_stm32f4xx.o.d -I . -I./inc
-I./cmsis/core -I./cmsis/device cmsis/device/system_stm32f4xx.c -o cmsis/device/
arm-none-eabi-gcc -c -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16
-D__FPU_USED=1 -O0 -gdwarf-2 -Wall -Wstrict-prototypes -fverbose-asm -ffunctio
n-sections -fdata-sections -Wa,-ahlms=src/syscalls.lst -DRUN_FROM_FLASH=0 -DVE
CT_TAB_SRAM -MD -MP -MF .dep/syscalls.o.d -I . -I./inc -I./cmsis/core -I./cmsis/
device src/syscalls.c -o src/syscalls.o
arm-none-eabi-gcc -c -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16
-D__FPU_USED=1 -O0 -gdwarf-2 -Wall -Wstrict-prototypes -fverbose-asm -ffunctio
n-sections -fdata-sections -Wa,-ahlms=src/main.lst -DRUN_FROM_FLASH=0 -DVECT_T
AB_SRAM -MD -MP -MF .dep/main.o.d -I . -I./inc -I./cmsis/core -I./cmsis/device s
rc/main.c -o src/main.o
arm-none-eabi-gcc ./cmsis/device/startup_stm32f4xx.o ./cmsis/device/system_stm32
f4xx.o ./src/syscalls.o ./src/main.o -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -m
fpu=fpv4-sp-d16 -D__FPU_USED=1 -nostartfiles -T./prj/stm32f4xx_ram.ld -Wl,-Map=t
est_ram.map,--cref,--gc-sections,--no-warn-mismatch -o test_ram.elf
arm-none-eabi-objcopy -O ihex test_ram.elf test_ram.hex

A file test_ram.elf should now be created in your build directory. If you could find it, congratulations! You have compiled your first ARM program with the new toolchain.

Now we want to start the J-Link GDB Server.

GDB Server

The GNU Project Debugger (GDB) is a freely available debugger, distributed under the terms of the GPL. It connects to an emulator via a TCP/IP connection. It can connect to every emulator for which a GDB Server software is available.

For debuging with Eclipse we will use the GDB, therefore we need a GDB Server too.

At this point you must install the J-Link "Software and documention pack". Connect the J-Link to the PC and to the target (do not forget to power the target) and start the J-Link GDB Server.

You will find the J-Link GDB Server in the "SEGGER \ J-Link ARM" program goup.
When the GDB Server will be started you should see the following window:

Here you can select some options, e.g. the "Target interface". Make your selections, and press "OK". The next window will look like:

Remove the checkmark of the "Stay on top" option. Then set the checkmark at "Show log window", "Cache reads" and "Init regs on start".

The "Show log window" options can help us if we will get in trouble with Eclipse.
"Cache reads" will enable a memory read-ahead optimization which can speed up debugging. If you have a big screen resolution you can let the checkmark at "Stay on top", but we need all the available screen space for the next step. Debugging with Eclipse.


Lets try to debug with Eclipse. The J-Link GDB Server must be running and be connected to the J-Link and the target, before you start the debug sesion. It is best to start the GDB Server before you start Eclipse.

Here I use the fast way, and do not demonstrate step by step. The detailed tutorial how to use Eclipse and how to setup a project can be found in part3. If you are not very familiar with Eclipse, take a look at part3 too.

Download the STM32F407Test project and expand the zip file to your temp directory.
I expanded it in the following directory:


For the next steps I will refer to it. Now you can start Eclipse.

To create an Eclipse project use "File / New / Standard Make C Project". For the project name use "STM32F407Test".

Now use "Project / Properties" select "C/C++ Build" and change the "Compiler invocation command", on the "Discovery Options" tab, to your compiler executable arm-none-eabi-gcc. Press "OK" to finish this dialog.

Your project is empty, and you must import the project files to Eclipse.
Use the "File / Import..." menu and select the "File System" as input source. You will find the "File System" under "General".

Browse to your temp directory C:\temp\STM32F407Test and select all files with the checkmark, press "Finish" to close the dialog.

For more information on how to create a project, take a look at part3.

You can build your project with "Project / Build Project" now, the result of the build process will be displayed in the "Console" window. A file "test_ram.elf" should be created.

Change to the "Debug Perspective" and configure the debugger.

(Click inside the picture to expand)

Select the "Debugger" tab and use arm-none-eabi-gdb for the "GDB debugger".

For the debugger "Commands" copy and paste the content of the stm32_ram_jlink_1.gdb text file into the window. The stm32_ram_jlink_1.gdb file is part of the example (.\prj\stm32_ram_jlink_1.gdb).

For more information on how to configure the debugger, take a look at part3.

The debugger is configured, and the GDB Server is hopefully running. You may start your debug session now, which could look like:

(Click inside the picture to expand)

Trouble shooting

In case Eclipse refuse to download the code to the target (seems like something is blocked), take the following steps:

  1. Close Eclipse
  2. Reset the target
  3. Start Eclipse again

Now debugging should be possible again.


If you need support, take a look here: