EFM32 development environment on Ubuntu Linux


Embedded, Programming, Ubuntu

No comments

These are instructions on how to set up a usable development environment on Ubuntu Linux 13.10 64 bits, complete with GDB debugging over J-Link, for the EFM32 series development boards by Energy Micro.

Start by download the Simplicity Studio beta installer for Linux:

mkdir -p ~/simplicity
cd ~/simplicity
wget http://cdn.energymicro.com/dl/packages/studio_linux.tar.gz
tar -xvf studio_linux.tar.gz
cd energymicro
python studio.py

The script will do its process and eventually it will error out saying that “Simplicity Studio New” was not found. This is ok, the process can continue anyway:

cd studio_new
chmod +x studio.py

Now proceed to install everything you are offered (it’ll take some time).

The next thing you need is the J-Link software to be able to connect to the board via JTAG over USB. Go to Segger’s website and download the package titled “Software and documentation pack for Linux V4.80h, DEB Installer 32-bit version“. Do note that you have to get the 32 bit version even if you have a 64 bit Linux OS.

sudo dpkg -i jlink_4.80.8_i386.deb

You also need a toolchain to compile the examples (and your own code) to ARM. The toolchain required is called arm-none-eabi (ARM processor, no distro/bare metal, “eabi” ABI specification). There’s an Ubuntu PPA that provides this. There’s no packages for Ubuntu 13.10, but those for 13.04 work just fine, so you can do:

sudo add-apt-repository ppa:terry.guo/gcc-arm-embedded

And then edit /etc/apt/sources.list.d/terry_guo-gcc-arm-embedded-saucy.list replacing “saucy” by “raring”, so the file ends up like this:

deb http://ppa.launchpad.net/terry.guo/gcc-arm-embedded/ubuntu raring main


After that:

sudo apt-get update
sudo apt-get install gcc-arm-none-eabi

For convenience, you can set up a few aliases in your ~/.bashrc or ~/.bash_profile file:

alias efm32gdb="/usr/bin/arm-none-eabi-gdb"
alias efm32gdbserver="JLinkGDBServer -if SWD"

The first alias just points the command efm32gdb to the right gdb version and the other alias starts a GDB server over J-Link using the Single Wire protocol.

At this point you should be pretty much set up. If you want to compile Simplicity Studio’s examples, use the armgcc Makefiles provided, setting the LINUXCS environment variable to “/usr”

LINUXCS=/usr Makefile -f Makefile.someproject


If the process completes successfully, you’ll get two files in the exe folder. something.bin is the file you should flash using Simplicity Studio’s Energy Commander “Flash” panel. something.out is the file you can use for debugging.

efm32gdbserver &
efm32gdb -x mygdbinitscript

mygdbinitscript should look like:

file armgcc/exe/something.out
target remote :2331
#set tdesc filename target-m3.xml
mon flash download = 1
#mon flash device = EFM32GG990F1024
set mem inaccessible-by-default off
#set remote memory-read-packet-size 1200
#set remote memory-read-packet-size fixed
mon speed 4000
mon endian little
mon reset 1
tbreak main

As a matter of personal taste I use KDevelop as my IDE, because it makes integrating all this in your own project dead simple. All in all it takes some effort to set up the environment, but once you do everything works like a charm, and you can debug seamlessly from within a top notch IDE. I also did try using QtCreator, but given it does not allow you (as of this writing) to customize the GDB binary, you can not do remote debugging as you do with KDevelop.