Tools/Eclipse4STM32

(Difference between revisions)
Jump to: navigation, search
(Windows)
(Project Setup)
Line 115: Line 115:
 
* C/C++ build > settings -> Settings tab : "Cross GCC compiler" :
 
* C/C++ build > settings -> Settings tab : "Cross GCC compiler" :
 
** Symbols :
 
** Symbols :
*** STM32F4XX=1
+
*** BOARD_STM32_CAMERA or BOARD_STM32F4_GEVAL or BOARD_STM32_CAMERA or BOARD_ARMEBS4 depending on your board
*** ARM_MATH_CM4=1
+
*** __FPU_PRESENT=1
+
*** USE_STM324xG_EVAL=1
+
 
** Includes :
 
** Includes :
 
*** "${workspace_loc:/${ProjName}/libheivs_stm32/include}"
 
*** "${workspace_loc:/${ProjName}/libheivs_stm32/include}"
 
*** "${workspace_loc:/${ProjName}}"
 
*** "${workspace_loc:/${ProjName}}"
 +
** Optimization : -O2 for normal use and -O0 for laboratories
 
** Debugging:  
 
** Debugging:  
 
*** Maximum -g3
 
*** Maximum -g3
Line 132: Line 130:
 
**** No shared libraries (-static)
 
**** No shared libraries (-static)
 
*** Libraries
 
*** Libraries
**** m
+
**** "m", "c" and "nosys"
 
*** Miscellaneous
 
*** Miscellaneous
 
**** Linker flags : "-T "${workspace_loc:/${ProjName}/libheivs_stm32/stm32f407ig_flash.ld}" -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16"
 
**** Linker flags : "-T "${workspace_loc:/${ProjName}/libheivs_stm32/stm32f407ig_flash.ld}" -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16"
Line 149: Line 147:
 
**** GDB command (Windows) : "C:\xdev\tools\gcc-arm\4.7_2013q2\bin\arm-none-eabi-gdb.exe"
 
**** GDB command (Windows) : "C:\xdev\tools\gcc-arm\4.7_2013q2\bin\arm-none-eabi-gdb.exe"
 
**** Use remote target : checked
 
**** Use remote target : checked
**** JTAG Device (via pipe)
+
**** JTAG Device : Generic TCP/IP, localhost 3333
**** GDB Connection string (stlink): "| openocd -f interface/stlink-v2.cfg -f target/stm32f4x_stlink.cfg -c "gdb_port pipe""
+
**** GDB Connection string (jtagkey2): "| openocd -f interface/jtagkey2.cfg -f board/stm3241g_eval.cfg -c "gdb_port pipe""
+
 
*** Startup tab
 
*** Startup tab
 
**** [[File:eclipse-gdb_hardware_debugging-startup.png]]
 
**** [[File:eclipse-gdb_hardware_debugging-startup.png]]

Revision as of 13:47, 23 October 2013

Contents

Goal

Install a click-and-run IDE for stm32f4 based boards.

This HOWTO has been tested on:

* ubuntu 13.04 64 bits
* windows xp sp3

Using :

* HEIVs armebs4 revision minus1 (stm32_camera board).
* ST's stm32f4discovery board.

It will be tested ASAP on windows 7 64 bits, which will be our next OS in labs. Feel free to contribute (by editing or by email).

The big picture

Here is an overview of the tools :

Eclipse stm32.png

Detailed description

Hardware:

* JTAG adapter
  * Connects physically the host computer to the target, usually from USB to JTAG.
  * Can be integrated into the target
* Target board
  * HEIVs ARMEBS4 integrates a "jtagusb" JTAG adapter
  * ST stm32f4discovery integrates a st-link v2 JTAG adapter

Software:

* Eclipse + CDT
  * IDE with c/c++ support
* make
  * The classical program builder
* gcc, ld, as, ...
  * GNU compiler, linker, assembler, ...
* gdb
  * GNU debugger
* openocd
  * Tranlate GDB orders into JTAG commands

Source files

* Application source file
  * Your application
* libheivs_stm32
  * Collection of source files from various vendors (ST, ARM, ..., HEIVs) to be used on stm32 boards

Toolchain

The toolchain we use comes from https://launchpad.net/gcc-arm-embedded. This is a toolchain maintained by ARM employees and is available for Linux, Windows and OS X.

Linux (Ubuntu based)

There is a PPA for gcc-arm-embedded.

sudo add-apt-repository ppa:terry.guo/gcc-arm-embedded
sudo apt-get update
sudo apt-get install build-essential gcc-arm-none-eabi

Linux (generic)

Windows

openocd

Linux

  • install openocd (should be in the repository of your favorite distribution)
  • create the file /etc/udev/rules.d/10-jtag.rules whith the following content:
# AMREBS4-like (ftdi) integrated debugger
ATTRS{idProduct}=="3100", ATTRS{idVendor}=="08ee", MODE="666", GROUP="plugdev"
 
# Amontec JTAGkey 2
ATTRS{idProduct}=="cff8", ATTRS{idVendor}=="0403", MODE="666", GROUP="plugdev"
 
# STM32F4 discovery board (stlink-v2 and DFU)
ATTRS{idProduct}=="3748", ATTRS{idVendor}=="0483", MODE="666", GROUP="plugdev"
ATTRS{idProduct}=="df11", ATTRS{idVendor}=="0483", MODE="666", GROUP="plugdev"
  • make sure you're in the plugdev group

Windows

  • Download and install openocd-0.7.0
  • Unzip into c:\xdev\tools\openocd\0.7 (openocd-0.7.0.exe should be in C:\xdev\tools\openocd\0.7.0\bin)
  • rename openocd-0.7.0.exe into openocd.exe
  • For stm32f4discovery : download and run zadig from zadig site
 * There is a version for XP and another for newer windows.
 * Connect the usb discovery board to the host machine
 * Run zadig
 * Show all devices (options->List all devices)
 * Select the "stlink" from the list
 * Select "WinUSB" driver
 * Install it

Eclipse

Tested with eclipse 4.3 (Kepler), but at least works with Juno (4.2) and Indigo (4.1)

  • Help -> Install new software ... -> work with "-- All available sites --" and add at least :
    • Programming Languages : C/C++ development Tools
    • Mobile and Device Development : C/C++ Hardware Debugging
    • Mobile and Device Development : C/C++ Cross compiler support
    • Subversive SVN Team provider + subversive connector
  • After setup and restart, subversive should ask to choose a connector, choose:
    • SVNkit 1.7.9

Project Setup

In the project properties make sure

  • C/C++ build > settings -> Settings tab : "Cross settings" :
    • prefix : "arm-none-eabi-"
    • path (windows) : "C:\xdev\tools\gcc-arm\4.7_2013q2\bin"
    • path (Linux generic) : "/opt/xdev/gcc-arm-none-eabi-4_7-2013q2/bin/"
    • path (Unbutu based) : arm-none-eabi- tools are in the PATH.
  • C/C++ build > settings -> Settings tab : "Cross GCC compiler" :
    • Symbols :
      • BOARD_STM32_CAMERA or BOARD_STM32F4_GEVAL or BOARD_STM32_CAMERA or BOARD_ARMEBS4 depending on your board
    • Includes :
      • "${workspace_loc:/${ProjName}/libheivs_stm32/include}"
      • "${workspace_loc:/${ProjName}}"
    • Optimization : -O2 for normal use and -O0 for laboratories
    • Debugging:
      • Maximum -g3
      • Warnings:
        • -Wall
      • Miscellaneous
        • "-c -fmessage-length=0 -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16"
    • C/C++ build > settings -> Settings tab : "Cross GCC linker" :
      • General :
        • No shared libraries (-static)
      • Libraries
        • "m", "c" and "nosys"
      • Miscellaneous
        • Linker flags : "-T "${workspace_loc:/${ProjName}/libheivs_stm32/stm32f407ig_flash.ld}" -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16"
        • Other options (-Xlinker [option])
        • -Map=linker.map
        • --gc-sections
    • C/C++ build > settings -> Settings tab : "Cross GCC assembler" :
      • General:
        • Assembler flags : "-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -g3"
    • Debug settings
      • Debug configuration -> GDB Hardware debugging
        • At the bottom of the page, make sure the project uses "Standard Hardware Debugging Laucher" (DSF won't work).
      • Debugger tab
        • GDB command (Ubuntu based) : "arm-none-eabi-gdb"
        • GDB command (Linux generic) : "/opt/xdev/gcc-arm-none-eabi-4_7-2013q2/bin/arm-none-eabi-gdb"
        • GDB command (Windows) : "C:\xdev\tools\gcc-arm\4.7_2013q2\bin\arm-none-eabi-gdb.exe"
        • Use remote target : checked
        • JTAG Device : Generic TCP/IP, localhost 3333
      • Startup tab
        • Eclipse-gdb hardware debugging-startup.png
        • disable Reset and delay (this command is not supported by openocd)
        • disable halt
        • commands (This will make sure the core is in a known state)
          • monitor reset halt
          • monitor flash erase_sector 0 0 0
          • monitor reset halt
        • Load image : use project binary (this will load the software to flash)
        • Load symbols : use project binary (no debugging without symbols)
        • Set breakpoint at main
        • Run commands ( 1) reset the cpu -> reload PC 2) enable clock when in WFI 3) run to main
          • monitor reset halt
          • set *(uint32_t *)0xe0042004 = 0x00000001
          • continue
      • Common tab
        • Save as shared file, so the debugging parameters will be saved into the project.
Personal tools
Namespaces
Variants
Actions
Navigation
Browse
Toolbox