GCC STM32 ARM Development with Eclipse in Linux

As an daily Linux user, I prefer to have all my development tools under one roof and familiar environment. I favor Debian based Linux operating systems and I’m a huge fan of CrunchBang (now BunsenLabs). Setting up a completely free development IDE with compiler toolchain plus full debugging capabilities was no trivial task. Plenty of online tutorials were available but I had to tweak a considerable amount for my particular setup. For actual products, a commercial compiler is highly recommended for more optimized code. A few commercial toolchain vendors include Atollic, IAR, and Keil.

Knowing that I would have to repeat this feat in the future, I documented the process in my personal wiki (Confluence). My most recent installation was in January, 2016. Please comment if anything is unclear or if additional screenshots are necessary. I did originally write this just for myself.

These steps just entail setting up the IDE for development. Steps to setup a new project are detailed in starting a new project in Eclipse for ARM development

Details

Setting up the IDE

Install eclipse and dependencies

  1. sudo apt-get install eclipse or download from eclipse website: https://www.eclipse.org/downloads/ (version greater than 4 is recommended aka Luna)

Install CDT plugin

  1. go to Help → Install New Software
  2. select Work with: Indigo
  3. if the Group items by category, expand the Programming Languages group
  4. select the C/C++ Development Tools feature
  5. click on the Next button and follow the installation usual procedure

Install ARM dev tools

  1. Eclipse menu: Help → Install New Software
  2. in the Install window, click the Add… button (on future updates, just select the URL)
  3. normally the main window should list a group named CDT GNU Cross Development Tools; expand it
  4. (in case the main window will list There are no categorized items, you are probably on an older version; disable the Group items by category option)
  5. select the GNU ARM C/C++ Development Support
    1. Or select only the following if GNU ARM C/C++ Development Support is not present
      image2015-1-20-23-12-20
  6. click the Next button
  7. accept the unsigned plug-in

Install Zylin Plugin

  1. go to Help → Install New Software
  2. in the Install window, click the Add… button (on future updates, just select the URL)
    1. fill in Location: with http://opensource.zylin.com/zylincdt
    2. click the OK button
  3. if the Group items by category, expand the Zylin Embedded CDT group
  4. select the Zylin Embedded CDT feature
  5. click on the Next button and follow the installation usual procedure

Install GCC toolchain

  1. Download the GCC ARM Embedded installer from website (ex. gcc-arm-none-eabi-<version>-linux.tar.bz2)
  2. Extract the .tar.bz2 archive to /usr/local/
    1. cd /usr/local
    2. sudo tar xjf ~/Downloads/gcc-arm-none-eabi-<version>-linux.tar.bz2
  3. Test that the compiler is functional
    1.  /usr/local/gcc-arm-none-eabi-<version>/bin/arm-none-eabi-gcc --version
      arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 4.9.3 20141119 (release) [ARM/embedded-4_9-branch revision 218278]
      Copyright (C) 2014 Free Software Foundation, Inc.
  4. Add toolchain path to Eclipse
    1. Project > Properties > C/C++ Build > Environment
    2. Add
      1. Variable: PATH
      2. Value: /usr/local/gcc-arm-none-eabi-<version>/bin/
        image2015-1-22-20-50-15

Install texane STLink Debugger port

  1. Install libusb-1.0 and pkg-config if needed
    1. sudo apt-get install libusb-1.0-0 libusb-1.0-0-dev pkg-config dh-autoreconf lib32ncurses5
  2. Clone the repo
    1. git clone https://github.com/texane/stlink.git
    2. cd stlink
  3. Compile the code
    1. ./autogen.sh
    2. ./configure
    3. make
  4. Setup permissions so st-util can access usb without root privileges
    1. sudo cp 49-stlinkv2.rules /etc/udev/rules.d/
    2. sudo udevadm control –reload-rules

Setup st-link as external tool in eclipse

  1. Go to Run -> External Tools -> External Tools Configuration
  2. Click on the “+” to add a new configuration under Programs, and name it “ST-Link GDB Server (SWD)”
  3. MAIN tab
    1. Set the “Location” to where the st-util binary is. (ie. /opt/stlink/st-util)
    2. Set the “Working Directory” to the stlink directory. (ie. /opt/stlink)
  4. COMMON tab
    1. Select “Display in favorites menu”
    2. Select “Launch in Background”

Setup the gdb debugger in Eclipse

  1. In Eclipse, open Run > Debug Configurations… and create a new launch configuration under Zylin Embedded debug (Native). Set the project name and choose the .elf file for the application (depending on the build configuration ie. Debug, Release)
  2. Go to the Debugger tab, and for “GDB Debugger”, set the path to the executable for the toolchain being used:
    1. Set the “GDB Debugger” depending on toolchain used:
      1. GNUARM: arm-elf-gdb
      2. CodeSourcery Lite: arm-none-eabi-gdb
    2. Check “Verbose console mode”
    3. Leave “GDB command file” empty
  3. Uncheck “Stop on Startup at: ____”
  4. Next, go to the Commands tab
    1. Paste in the following ‘Initialize’ commands:
      tar extended-remote :4242
      load
    2. Paste in the following for the “Run” command:
      break main
      run
  5. COMMONS tab
    1. Uncheck “Launch in background”

Setup the compiler settings

Resources and Acknowledgements

Leave a Reply

Your email address will not be published. Required fields are marked *