Meta

Autor: sadman

~ 31/12/08

Setting programming and debugging enviroment in Linux is frequently a serious problem to new linux/embedded programming users. So I decided to write a little HOWTO. I write this also for me, to not forget how to do this :).
I am very begging in embedded world so some my suggestions could be stupid. I Will try to explain some settings and describe some configuration possibilities. To more sophisticated configrations I send You to documentation.

Hardware

First we need some hardware. Programming without hardware I will describe in my next comming soon text :). I hope. I have OLIMEX ARM-USB-OCD JTAG and board with STM32 Cortex-M3 microcontroller.

This JTAG is quite cheap and good decision solution, becouse we only need an USB port to connect to our computer. This is important if we have laptop without serial port – my case. He has inself FTDI2232 chipset to connect to full RS232 port over our USB port. Note that connecting this input directly to UARTs outputs from STM32 will not be working, becouse RS232 is +-15V level, and we need something like MAX3232 to convert this levels to 3.3V. Both devices JTAG and RS232 converter are seened like composite device on USB bus.

Software

Needed software. We will use GNU Toolchain. Only available GNU Tollchain with support to Cortex-M3 is toolchain from here codesourcery. So we go to link download, then choose EABI, then IA32 GNU/Linux Installer. I recomended also download all the documentation, becouse it can be helpfull.

Second needed software will be OPENOCD. Openocd needs some library to speak with hardware connected through USB bus. We have two choices:
– libftdi
– libftd2xx

I prefere to use libftdi, becouse libfd2xx comes in binary form, and it is ugly to use black boxes :). So we need to make package with libftdi.

After this we need logout. Now we can check that openocd sees our jtag. From few versions of openocd it goes with prepered config files. Those files are sperated to interface and target parts. This very simplifies configuration of openocd to our needs and safe us a lot of time. For example when something changes in configuration options with newer version, our call will be probably working:

In this case we want to connect with stm32 processor using Olimex ARM JTAG. Default configuration files are installed at OPENOCD_DESTDIR/lib/openocd/target and OPENOCD_DESTDIR/lib/openocd/interface directory. We can find there many interfaces and many microcontrollers. To get the most out-date documentation to openocd we need to do:

In new command prompt we need to write „target remote localhost 3333″. In this way we connect to openocd gdb server running on ours localhost interface on default 3333 port. We can use text version of gdb, but this not convinient. I recommended to use Insight or Embeded CDT Plugin to Eclipse. Below I will show correct configration of debugging under Eclipse.

First we need configure external tool which will start openocd.

Next we open Debug Configuration and fill all the fields like in this screenshots.

We can click Apply and Run. After this we should see screen like this (note: we need to click resume button in Eclipse):

I hope that this text will be helpfull to somebody. I know that some things are missing. I plan to update this HOWTO with some Makefiles and .c sources. Any suggestions will be pleased.