Maclain Lobdell

gdb debugging on Kinetis with Segger gdb server on Linux

Discussion created by Maclain Lobdell Employee on Dec 6, 2013
Latest reply on May 14, 2014 by Manish Baing


I'm a Kinetis guy with most of my embedded experience with CodeWarrior or IAR IDEs on Windows.  However, I just started to work with free GNU tools on a Linux host for compiling, & debugging code for Kinetis MCUs.  With gcc and gdb client from ARM, and gdb server and J-Link pod from Segger, you can compile, flash, and debug Kinetis devices with just command line operations. For me, it’s a different and very powerful model to work in. 


If you are interested in Kinetis development using gdb and Segger's gdb server and j-link, here are steps I used to get started.  This does not cover makefiles and compiling with gcc.


I'm using Ubuntu 12.04 running in VirtualBox.  I have a J-Link connected to a FRDM-KL25Z.


1. Install gcc (comes with gdb for ARM) maintained by ARM

(Details at )


mac@mac-VirtualBox:/$ sudo add-apt-repository ppa:terry.guo/gcc-arm-embedded

mac@mac-VirtualBox:/$sudo apt-get update

mac@mac-VirtualBox:/$sudo apt-get install gcc-arm-none-eabi


2. Install Segger J-Link software and documentation pack for Linux (DEB Installer 32-bit version)


3. Start GDB Server

mac@mac-VirtualBox:/$ JLinkGDBServer -device MKL25Z128xxx4 -if SWD -speed 1000 -endian little &


For the FRDM-KL25Z, select MKL25Z128xxx4 as the device.  See list of all Segger supported devices here.

Kinetis L-series devices use SWD for debugging, so that is selected as the interface.


4. Start GDB client (command line):

mac@mac-VirtualBox:/$ arm-none-eabi-gdb


5. Connect to GDB Server

(gdb) target remote localhost: 2331


There are many references to gdb commands online.


6. flash target

(gdb) load myapp.elf


7. Set symbols for debugger

(gdb) file myapp.elf


8. Use target specific commands.  Here are some examples.


(gdb) monitor reset

(gdb) monitor go

(gdb) monitor halt

(gdb) dump srec memory file 0x0000 0x1000


For target specific commands the gdb client can pass commands to the gdb server by adding “monitor” in front on the gdb server command.  This is shown above.  See Segger gdb server documentation for list of gdb server commands.


See other great posts and blogs on related topics.


DIY Free Toolchain for Kinetis: Part 1 – GNU ARM Build Tools | MCU on Eclipse


Good luck!