STM32 (STM32F103VC), Eclipse i Jlink – tips

After several trials I have managed to setup a working environment which is able to build, flash and debug without any hassle :)

The environment is based on ODev idea

  1. We need to download ODev configured Eclipse and Code Sourcery Lite ARM Toolchain
  2. We need to setup up the environment as described in here, the setup should be based on Cortex_STM32F1xx_CPP_Template 
  3. After import the template into eclipse (Import->Team-> Team Set project) we get a demo application called Cortex_STM32F1xx_CPP_Template 
  4. We should rename it first, and disconnect from SVN as we are going to apply some changes
  5. As The template is being set up for different platform (STM32F107CL) we need to apply following changes to project configuration:
  1. You need to modify preprocesor setting from STM32F10X_CL to STM32F10X_HD in C/C++/Assembler settings  – this will choose different set of files from CMSIS
  2. Change the startup file from runtime/startup_stm32f10x_cl.S to runtime/startup_stm32f10x_hd.S – you need to copy aprioprate file form CMSIS/CM3/DeviceSupport/ST/STM32F10x/startup/TrueStudio/startup_stm32f10x_hd.S
  • Setup gdb – since it is configured to use config file stored in OpenOCD directory and as we are not going to use OpenOCD we will simply replace the contents of the file with and change the file name to the project name (it is important to set the gdm to little endian mode …)
After that the code will be flashed every time we start to debuging session from eclipse.
#
# J-LINK GDB SERVER initialization
#
# This connects to a GDB Server listening
# for commands on localhost at tcp port 2331
target remote localhost:2331
# Set JTAG speed to 30 kHz
monitor speed 30
# Set GDBServer to big endian
monitor endian little
# Reset the chip to get to a known state.
monitor reset
#
# CPU core initialization (to be done by user)
#
# Set auto JTAG speed
monitor speed auto
# Setup GDB FOR FASTER DOWNLOADS
set remote memory-write-packet-size 1024
set remote memory-write-packet-size fixed
monitor flash device = STM32F103VC
monitor flash breakpoints = 1
monitor flash download = 1
# Load the program executable called "image.elf"
load Debug/YourProjectNameHere.elf
# Initializing PC and stack pointer
monitor reg r13 = (0x08000000)
monitor reg pc = (0x08000004)
monitor reset 0