For everyone who wants to build a Do-It-Yourself toolchain for Kinetis on Linux, I recommend to read the following excellent post by Karibe:
Setting up Linux opensource build and debug tools for freescale freedom board FRDM-KL25Z
He describes how to get OpenOCD with CMSIS-DAP working with Eclipse on Ubuntu to debug the FRDM-KL25Z board.
List of Tutorials
- Part 1: Setting up ARM GNU tool chain
- Part 2: Setting up Eclipse IDE
- Part 3: Setting up the debugger (P&E and Segger)
- Part 4: Setting up Processor Expert
- Part 5: Setting up FreeRTOS Kernel Awareness
- Part 6: Linux Host Support with OpenOCD and CMSIS-DAP
- Part 7: GNU ARM Eclipse Plugins
- Part 8: Processor Expert with GNU ARM Eclipse Plugins
- Part 9: DIY Free Toolchain for Kinetis: Part 9 – Express Setup in 8 Steps
- Part 10 – Project Creation with GNU ARM Eclipse 2.1.1
Happy Linuxing 🙂
Pingback: DIY Free Toolchain for Kinetis: Part 5 – FreeRTOS Eclipse Kernel Awareness with GDB | MCU on Eclipse
Pingback: DIY Free Toolchain for Kinetis: Part 1 – GNU ARM Build Tools | MCU on Eclipse
Pingback: DIY Free Toolchain for Kinetis: Part 2 – Eclipse IDE | MCU on Eclipse
Pingback: DIY Free Toolchain for Kinetis: Part 3 – Debugger (GDB Server with P&E and Segger) | MCU on Eclipse
Pingback: DIY Free Toolchain for Kinetis: Part 4 – Processor Expert for Eclipse | MCU on Eclipse
Awesome! I’ve been looking for this. Thanks, Eric 😀
LikeLike
Hi Erich
Awesome!!! Going to try this out over the weekend. Have got a Olimex ARM-USB-TINY-H (https://www.olimex.com/Products/ARM/JTAG/ARM-USB-TINY-H) with a ARM-JTAG-20-10 adapter(https://www.olimex.com/Products/ARM/JTAG/ARM-JTAG-20-10). Just waiting on my .05″ daul headers to solder onto the board.
Georg
LikeLike
Hi Georg,
let us know the result!
LikeLike
Looks like the CMSIS-DAP support has finally been pulled into a branch of the official OpenOCD repository and is starting to get tested and code reviewed, maybe it will be included by default when OpenOCD v0.8 comes out. Presumably openocd+cmsis-dap will become the best “free toolchain” choice even on windows, since it’s so widely used (in the “free toolchain” world).
I assume it will have none of the restrictions of the P&E Micro or SEGGER “lite” / eval-boards-only versions. I wonder if it will even let us debug non-Freescale Cortex-Ms using a Freedom Board’s OpenSDA as just a “debug access port”?
LikeLike
That’s outstanding news, and will make the adoption of OpenOCD even easier. And yes, it is already possible today to debug another board, because it should only rely on the physical connection to the other board. I have sucessfully used it with Segger and USBDM OpenSDA firmware, for example in https://mcuoneclipse.com/2013/04/27/debug-external-processors-with-usbdm-and-freedom-board/
LikeLike
I managed to build OpenOCD 0.8-rc1 with CMSIS-DAP support on MacOSX and have the DIY free toolchain following your series of tutorial running on Mac for my FRDM-KL25Z board.
LikeLike
Outstanding! Thanks for sharing! You might consider to publish the binaries so other users do not need to build them?
LikeLike
I am putting up a tutorial on my blog here: http://alexgallery.wordpress.com/2014/04/14/setting-up-open-source-ide-with-eclipse-for-freescale-mcus-on-mac-osx/
Also here’s the download link to the Mac OSX binaries:
hidapi: https://dl.dropboxusercontent.com/u/91597842/openocd/hidapi_0.8.0-rc1.tgz
openocd: https://dl.dropboxusercontent.com/u/91597842/openocd/openocd_0.8.0-rc1.tgz
LikeLike
Many thanks for sharing!
LikeLike
Pingback: DIY Free Toolchain for Kinetis: Part 7 – GNU ARM Eclipse Plugins | MCU on Eclipse
Pingback: DIY Free Toolchain for Kinetis: Part 8 – Processor Expert, Eclipse and GNU ARM Eclipse Plugins | MCU on Eclipse
Pingback: DIY Free Toolchain for Kinetis: Part 9 – Express Setup in 8 Steps | MCU on Eclipse
Pingback: DIY Free Toolchain for Kinetis: Part 10 – Project Creation with GNU ARM Eclipse 2.1.1 | MCU on Eclipse
I follow all the steps and it work well for me. The problem, which I’m facing now is that I can’t flash my FRDM-KL25Z board. I start opeocd and after I start gdb, I get this error:
Open On-Chip Debugger 0.8.0-dev-00175-g8b7acca-dirty (2015-02-15-10:15)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.sourceforge.net/doc/doxygen/bugs.html
Info : only one transport option; autoselect ‘cmsis-dap’
Info : CMSIS-DAP: SWD Supported
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : add flash_bank kinetis kl25.flash
cortex_m reset_config sysresetreq
adapter speed: 50 kHz
Info : CMSIS-DAP: FW Version = 1.0
Info : SWCLK/TCK = 0 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 0
Info : DAP_SWJ Sequence (reset: 50+ ‘1’ followed by 0)
Info : CMSIS-DAP: Interface ready
Info : clock speed 50 kHz
Info : IDCODE 0x0bc11477
Info : kl25.cpu: hardware has 2 breakpoints, 2 watchpoints
Error: CMSIS-DAP: Read Error (0x04)
Polling target kl25.cpu failed, GDB will be halted. Polling again in 100ms
Polling target kl25.cpu succeeded again
Info : accepting ‘gdb’ connection from 3333
Error: CMSIS-DAP: Read Error (0x04)
in procedure ‘halt’
Warn : Cannot communicate… target not halted.
Error: auto_probe failed
Error: Connect failed. Consider setting up a gdb-attach event for the target to prepare target for GDB connect, or use ‘gdb_memory_map disable’.
Error: attempted ‘gdb’ connection rejected
Error: CMSIS-DAP: Read Error (0x04)
Polling target kl25.cpu failed, GDB will be halted. Polling again in 100ms
Polling target kl25.cpu succeeded again
Info : Halt timed out, wake up GDB.
Any help appreciated
LikeLike
is this on Windows or on Linux? You might try out the Kinetis Design Studio which includes a port of OpenOCD, both for Windows and Linux.
LikeLike
Sorry, I’m working with Kubuntu 14.10
LikeLike
After some googling, I have suspicion, that this problem of mine could be related with hardware issues. Just can’t find any remedies for it…
I’ll take a try on your proposal and will see how it works out…
LikeLike
I had this happening to me, when you write a binary with a mistake, like wrong clock configurations, openocd isn’t able to halt the CPU, among other things. One solution is to use alternative debug server like PE or USBDM first , needs changing the firmware, then flash a sample known to work binary from apllication note or something with that debug server, then openocd behaves. Openocd is not that bruteforce when there are issues at startup.
Another trick is to add gdb events in the openocd initialization target scripts, like this:
adapter_khz 500
$_TARGETNAME configure -event gdb-attach {
halt
}
$_TARGETNAME configure -event gdb-attach {
reset init
}
kinda try to catch the target early on.
Also, try to use hot air gently around the microcontroller chips, may be you have a hardware problem after all.
LikeLiked by 1 person
oh, that sounds like a really good thing. I was running today into such a problem where OpenOCD was not able to halt the CPU. I need to add this one to my kinetis.cfg file to see if it will help me in the future 🙂
LikeLike
Hi,
Thanks for replay. Since my last post I switched to Kinetis Design Studio. Although I’m not very satisfied with workflow, but it does its job and I have my kl25z board working with it perfectly.
I made changes to kl25z.cfg file as you advised, but I got different error now 😦 :
Error message from debugger back end:
Error erasing flash with vFlashErase packet
Error erasing flash with vFlashErase packet
…..
Info : only one transport option; autoselect ‘cmsis-dap’
Info : CMSIS-DAP: SWD Supported
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : add flash_bank kinetis kl25.flash
cortex_m reset_config sysresetreq
adapter speed: 500 kHz
Info : CMSIS-DAP: FW Version = 1.0
Info : SWCLK/TCK = 0 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 0
Info : DAP_SWJ Sequence (reset: 50+ ‘1’ followed by 0)
Info : CMSIS-DAP: Interface ready
Info : clock speed 500 kHz
Info : IDCODE 0x0bc11477
Info : kl25.cpu: hardware has 2 breakpoints, 2 watchpoints
Error: CMSIS-DAP: Read Error (0x04)
Polling target kl25.cpu failed, GDB will be halted. Polling again in 100ms
Polling target kl25.cpu succeeded again
Info : accepting ‘gdb’ connection from 3333
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0xfffffffe msp: 0xfffffffc
Info : Probing flash info for bank 0
Warn : acknowledgment received, but no packet pending
Error: CMSIS-DAP: Write Error (0x04)
Warn : erase sector 0 failed
Error: failed erasing sectors 0 to 0
Error: flash_erase returned -902
Info : dropped ‘gdb’ connection
LikeLike
First change the value of adapter_khz from 500 to 50 in the config file.
Then for the purpose of clarity, just run openocd from terminal:
openocd -c “interface cmsis-dap” -f /path-to-kl25.cfg
and on another terminal run the following gdb commands:
arm-none-eabi-gdb
target remote localhost:3333
monitor reset init
file /path-to.elf
load
without any IDE, . This will allow you to at least run individual gdb commands and see at what step the error will occur, from the output above, target was halted, but erasing flash didn’t work. Try a working binary from somewhere else other than your project.
LikeLike
Great, thanks for all these steps! Right on time because I’m right now writing an short article about using OpenOCD on Windows 🙂
LikeLike
Strange, I just copied CMSIS-DAP_OpenSDA.s19 file to be kl25z board, compiled the same project and debug just started working. Can’t recall now what was the sequence of my actions previous time, probably some problems with my environment, but now it works 🙂 So your last changes in cfg file really helped. Thanks 😉
p.s. Cloud you help to configure eclipse so it would print binary file size, I just can’t make it with Cross gcc tool chain
LikeLike
about printing code size information: That checkbox might be in different places:
https://mcuoneclipse.com/2014/04/11/gnu-additional-tools-create-flash-image-print-size-and-extended-listing-options/
https://mcuoneclipse.com/2014/05/04/printing-code-size-information-in-eclipse/
https://mcuoneclipse.com/2013/04/14/text-data-and-bss-code-and-data-size-explained/
I hope this helps.
LikeLike
Pingback: OpenOCD/CMSIS-DAP Debugging with Eclipse and without an IDE | MCU on Eclipse
Karibe’s comment was helpful when faced with “Cannot communicate… target not halted.” issue. Added this to .cfg:
$_TARGETNAME configure -event gdb-attach {
halt
}
$_TARGETNAME configure -event gdb-attach {
reset init
}
LikeLike
Thanks for reminding about this one: I had a similar issue with OpenOCD just recently about this.
LikeLike