I got my first Freescale board, FRDM-KL25Z, for my Raspberry Pi CNC project. But the small board can do much beyond that, and I need a development environment for it!
The following steps are basically a summary of Erich Styger’s series tutorial at MCU on Eclipse.
- Download and unpack the arm-none-aebi-gcc tool chain from https://launchpad.net/gcc-arm-embedded/+download
- Download and unpack eclipse-cpp from www.eclipse.org, it can start from its own directory and does not have to be installed into system.
- Download Microcontroller Driver Suite plugin for existing eclipse from Freescale http://www.freescale.com/zh-Hans/webapp/sps/site/prod_summary.jsp?code=PE_DRIVER_SUITE&fpsp=1&tab=Design_Tools_Tab
Unpack and install the plugin into eclipse from Help=>Install New Software - Download GNU arm eclipse plugin from http://sourceforge.net/projects/gnuarmeclipse/files/Current%20Releases/2.x/
Unpack and install the plugin into eclipse from Help=>Install New Software - Download McuOnEclipse Processor Expert Components from https://github.com/ErichStyger/mcuoneclipse either the PEupd files or via git
Install the PEupd files from Processor Expert=>Import Component(s)
The tricky part is to compile OpenOCD with CMSIS-DAP support.
I am using OSX 10.9.2 with Macports and Xcode 5.1. Macports has openocd-0.7, which does not have CMSIS-DAP support. I have to compile from source.
Before we start, OpenOCD needs hidapi, which is not in Macports. I failed to compile from source, so used a work around by installing via brew and linked to /opt/local/lib.
I cloned OpenOCD from a couple of sources with failure at bootstrap or configure stage. The following is the what works for my system. So let’s start:
$> git clone https://git.gitorious.org/openocd/openocd.git
$> cd openocd
$> ./bootstrap
$> LDFLAGS=-L/opt/local/lib CPPFLAGS=-I/opt/local/include ./configure –enable-maintainer-mode –enable-cmsis-dap –enable-hidapi-libusb –disable-werror
If you use brew, LDFLAGS and CPPFLAGS are not needed. The current version of OpenOCD-0.8.0-rc1 will fail to make without the –disable-werror switch. Hope it will clear the bug in release.
$> make -j4 && sudo make install
Before we run openocd, let’s create openocd.cfg with the following content:
reset_config srst_only srst_nogate
interface cmsis-dap
adapter_khz 50
source [find /usr/local/share/openocd/scripts/board/frdm-kl25z.cfg]
init
reset init
Now, plug in the board to test if it works.
$> openocd -f openocd.cfg
The final part is to configure Eclipse to use OpenOCD.
To enalbe FRDM-KL25Z CMSIS-DAP debugging, put the board to bootloader mode and install mbed firmware.
Set the openocd_path variable in the preferences as shown below.
Select the project to debug, menu Run=>Debug Configurations…, as shown in below.
OK, move on to development.
I am putting the hidapi and openocd binaries at the following links. They work on OSX 10.9.2 with Macports. You will need to install libusb from Macports before running openocd.
$> sudo port install libusb
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