freeRTOS w/ Eclipse and JLink

shorsh83 wrote on Wednesday, February 03, 2010:


I want to use freeRtos with Jlink-Debugging. Is anyone outthere who uses the same setup? The standard environment wont work as delivered in the freertos package…


edwards3 wrote on Wednesday, February 03, 2010:

I think you would have to get the GDB server from Segger to do that, unless anybody knows of any open source implementations?

shorsh83 wrote on Thursday, February 04, 2010:


i have the gdb debug server from segger -thats not the problem.
the real issue is that the freertos debug config is setup for openocd and i dont know what to change to get it working with j-link
what do i habe to change, or has anyone this configuration done thereselves?


davedoors wrote on Thursday, February 04, 2010:

I don’t think this is FreeRTOS specific. You are better off asking the people who supplied you the debug server.

spotdott wrote on Thursday, February 04, 2010:

Hi,  I got j-link working with eclipse in linux yesterday.  I’ll explain quick while it’s still fresh in memory:

I followed the instructions provided by Stefano from here: (if ur a windows user a similar then go here  Be sure to download the latest OpenOCD (I’m using 0.4.0) and use the jlink.cfg and ‘target’.cfg that came with the new version (old version .cfg files wont work…)   This will be perfect if you’re using an STM32 microcontroller.  However you are not, then get a demo project that is specific to your core and configure the debugger and openocd Stefano’s way. 

Hope this helps

quackdb wrote on Wednesday, March 03, 2010:


can you please post your config files? I followed the linked instructions as you too. I’ve compiled openocd 0.4.0rc2 with “-enable jlink” (i don’t know the command exactly any more) as the only configuration option. Then I replaced the jtag config with the jlink version and the smt32_mdb (or something like that) with the stm32 config file.

Now Eclipse reports an error, it doesn’t know the commands “halt” and “poll halt” in the eclipse program config. I’ve played a while around but i didn’t work :slight_smile:

Thanks for your help
Greetz Simon

spotdott wrote on Thursday, March 04, 2010:

Of course.  Here are my config files

# Segger J-Link
interface jlink


# JTAG speed should be <= F_CPU/6. F_CPU after reset is 8MHz, so use F_JTAG = 1MHz
jtag_khz 565
jtag_nsrst_delay 100
jtag_ntrst_delay 100
#jtag scan chain
if { [info exists CPUTAPID ] } {
} else {
  # See STM Document RM0008
  # Section 26.6.3
   set _CPUTAPID 0x3ba00477
jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
if { [info exists BSTAPID ] } {
   # FIXME this never gets used to override defaults...
} else {
  # See STM Document RM0008
  # Section 29.6.2
  # Low density devices, Rev A
  set _BSTAPID1 0x06412041
  # Medium density devices, Rev A
  set _BSTAPID2 0x06410041
  # Medium density devices, Rev B and Rev Z
  set _BSTAPID3 0x16410041
  # High density devices, Rev A
  set _BSTAPID4 0x06414041
  # Connectivity line devices, Rev A and Rev Z
  set _BSTAPID5 0x06418041
jtag newtap $_CHIPNAME bs -irlen 5 -expected-id $_BSTAPID1 \
	-expected-id $_BSTAPID2 -expected-id $_BSTAPID3 \
	-expected-id $_BSTAPID4 -expected-id $_BSTAPID5
target create $_TARGETNAME cortex_m3 -endian $_ENDIAN -chain-position $_TARGETNAME
$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0
flash bank $_FLASHNAME stm32x 0 0 0 0 $_TARGETNAME
# For more information about the configuration files, take a look at:
# openocd.texi


# default ports
telnet_port 4444
gdb_port 3333
tcl_port 6666
jtag_khz 565
reset init
verify_ircapture disable

Also, please make sure that you have libusb installed and running Eclipse as root. 

In the External Tools Configurations you should have OpenODB Programmer and OpenODB Server pass in arguments of “-f jlink.cfg -f stm32.cfg -f stm32_program_eclipse.cfg” and “-f jlink.cfg -f stm32.cfg -f stm32_gdb.cfg”, respectively.  Make sure that Eclipse knows where you installed OpenODB.  This is also done in the External Tools Configurations’ Main tab under Location  (for me it’s /usr/local/bin/openocd). 

In Debug Configurations make sure that under the Debugger tab only GDB Command has a value (for me it’s /home/lsong/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-eabi-gdb) and under the Startup tab only Initialize Commands is filled as follows:

target extended-remote localhost:3333
b main
monitor soft_reset_halt
monitor sleep 500
clear main

Hope this will get rid of your error messages.