Sunday, January 3, 2016

ARM Development Suite



In this post, I will make a guide, on how you can set up development environment for embedded C programming.

In order to be able to write an embedded C program, and execute it, you need four things:

  1. An IDE, from which you can write the code, navigate through it, perform compilation, debugging, ..etc
  2. The tool chain (Compiler - Linker - Debugger)
  3. In circuit debugger, if you will download this to your real target. If not, you can use a simulator.
  4. The target.
In the following lines, I will illustrate how could I got each of these things

The Target:

I am using STM32F103DEV development Kit.


Microcontroller is, ARM Cortex M3 Family Micro-controller, namely: STM32F103. From ST Microelectronics.











In circuit debugger:


I am using ARM-USB-TINY-H from Olimex,
It is a JTAG debugger supported by OpenOCD (Open On-Chip Debugger). OpenOCD is open source software supporting JTAG debuggers for different Targets.

OpenOCD license is GNU GPL (GNU General Public License)

How to install OpenOCD for ARM-USB-TINY-H?

  Host machine:
  • Connect your ARM-USB-TINY-H Debugger to the machine
  • Download Zadig, Open it, Choose your device (Interface 0), Choose WinUSB > Install

  • In  ARM-USB-TINY-H page, download "OpenOCD for windows".
  • Extract it to any local directory.
  • Make a batch file, write the following in it:
@echo
cd <extract-path>\openocd-0.9.0-rc1\bin
openocd.exe -f ../scripts/interface/ftdi/olimex-arm-usb-tiny-h.cfg -f ../scripts/target/stm32f1x.cfg
@echo
  • To start debugging, Run the batch.
  Client machine:
  • From any other machine, you can configure your IDE to use GDBServer, and provide the IP of the host. 
  • You can use the same host machine as client, in this case the IP will be the localhost with port number 3333 (localhost,3333)


The IDE, and the Tool Chain

I will demonstrate three (free) alternatives:
  1. IDE: IAR IDE with Tool chain: IAR (Free version limited code size)
  2. IDE: Eclipse   with Tool chain: IAR (Free version limited code size)
  3. IDE: Eclipse   with Tool chain: GNU
1. IDE: IAR IDE  with Tool chain: IAR (Free version limited code size)
  • Just go to IAR site, download EWARM (Embedded Workbench for ARM) installer, run it.  It is a normal installation.
  • After installation, when you first open the IDE, it will ask you for a license if you have.
  • If you do not have a license, click "register", you will be asked if you want a free license with limited time, or limited code size, choose what you prefer.
  • Now, you successfully downloaded:
    • IAR IDE
    • IAR Compiler for ARM
    • IAR Linker for ARM
    • IAR Debugger for ARM
2. IDE: Eclipse  with Tool chain: IAR (Free version limited code size)
  • Tool chain: please refer to point 1
  • IDE: Eclipse and Eclipse IAR plugin
    • Install Eclipse
      • From Eclipse web site. You will need to download and install eclipse Indigo or newer. (I installed Mars)
        • Each eclipse version requires a minimum version of Java Runtime Environment.
        • When installing Eclipse, the installer will detect automatically if you need a newer version of JRE, and will direct you to Oracle website to download and install it.
        • Finish installing Eclipse
    • Install Eclipse IAR Plugin
      • Launch Eclipse
      • Help > Install New Software
      • There is a guide on IAR website, for eclipse plugin installation. Please follow it to complete the installation.
Now you can create a project that uses IAR tool chain:
  • Click on menu: File > New > C Project















  • Choose Executable (IAR) > Project with empty main()
  • Finish























To Choose your target device:
  • Project > Select Device
  • Browse > select a device (In my case I select ST > STM32F103x6)
For Debugging:
  • Select the project
  • Run menu > Debug Configuration
  • On the left tree, expand C/C++ Application, and select your project (If you did not find your project, make a "New launch configuration" from the up left button)
  • By default, GDB is used, Click "Select Other", choose "IAR C-SPY Debugger for ARM Launcher" > OK

  • From Setup Tab
    • Simulator, if you want to use the simulator
    • The debugger you are using to download and debug on target


Unfortunately, I was not able to find GDB server within the available drivers, although it exists in IAR IDE! This means, that in this case, we will be able only to use the simulator.


3. IDE: Eclipse  with Tool chain: GNU
  • Install GNU Tools for ARM
    • From launchpad downloads page
    • Download and install
    • At the installation end, choose to add registry stuff, and to add the path to the path environment variable
  • Download windows build tools (make):
    • Go to source-forge arena
    • Download the most recent file of gnuarmeclipse-build-tools-win32-2.*-*-setup.exe
    • Install
  • Install the GNU ARM plugins to eclipse
    • Open eclipse > Help > Install new SW > Add
      • Name: GNU ARM Eclipse Plug-ins
      • URL: http://gnuarmeclipse.sourceforge.net/updates
      • Press OK, and continue installation


  • Create a new C project
    • From Eclipse: File > New > C Project
      • Executable > STM32F10x C/C++ Project > Cross ARM GCC
      • Fill in the Project name



      • Next > Next > Next > Next
      • Add GNU Tools for ARM installation path.
      • Finish


  • Select the project > Project > Properties > C/C++ Build > Set the build path and the tool chain path

For Debugging:
  • Window > Preferences

  • Select the project > Run > Debug Configuration
  • Please follow the screenshots to build a debug configuration





  • Press debug

Summary:

We discussed three configurations:

Configuration 1:

------------------------------------------------------------------------------------
                                             IAR IDE
------------------------------------------------------------------------------------
                                        C-SPY Debugger
------------------------------------------------------------------------------------
Instruction Set Simulator | C-SPY Debugger OpenOCD Server Driver
------------------------------------------------------------------------------------
                                         | Ethernet
                                        ------------------------------------------------------
                                         | OpenOCD driver for ARM-USB-TINY-H
                                        ------------------------------------------------------
                                         | ARM-USB-TINY-H JTAG
                                        ------------------------------------------------------
                                         | TARGET
                                        ------------------------------------------------------


Configuration 2:

------------------------------------------------------------------------------------
                                    Eclipse with IAR Plugin
------------------------------------------------------------------------------------
                                        C-SPY Debugger
------------------------------------------------------------------------------------
Instruction Set Simulator | C-SPY Debugger OpenOCD Server Driver
------------------------------------------------------------------------------------
                                         | Ethernet
                                        ------------------------------------------------------
                                         | OpenOCD driver for ARM-USB-TINY-H
                                        ------------------------------------------------------
                                         | ARM-USB-TINY-H JTAG
                                        ------------------------------------------------------
                                         | TARGET
                                        ------------------------------------------------------

Configuration 3:

------------------------------------------------------------------------------------
                               Eclipse with GNU ARM plugin
------------------------------------------------------------------------------------
                                        GNU Debugger
------------------------------------------------------------------------------------
                              GNU Client OpenOCD driver
------------------------------------------------------------------------------------
                                              Ethernet
------------------------------------------------------------------------------------
                      OpenOCD driver for ARM-USB-TINY-H
------------------------------------------------------------------------------------
                                ARM-USB-TINY-H JTAG
------------------------------------------------------------------------------------
                                          TARGET
------------------------------------------------------------------------------------

No comments:

Post a Comment