Embedded Signal Processing
Apple/Mac OsX Yosemite
"Improvised" FRDM-K64F Eclipse/Platformio Setup
Overview
Note: the preferred setup is FRDM-K64F
KDS
(Kinetis Design Studio) , rather than the homebrew setup
described below.
This page describes setup of setting up an improvided
FRDM-K64F Eclipse/Platformio setup .
The following instructions are particularly
targeted to Apple/mac systems, and may need to be adjusted
for other machines/platforms.
Improvised FRDM-K64F Eclipse/Platformio Setup and Software
Installation
- The following instructions are to install the software on a
laptop or home computer
- The following instructions are
particularly targeted to Apple/mac systems, and may
need to be adjusted for other machines/platforms.
- 0) Before you do anything, make sure that the firmware on your
bed board is updated to the m]latest version,
- for FRDM-K64F boards check here:
https://developer.mbed.org/handbook/Firmware-FRDM-K64F
- and here: https://developer.mbed.org/platforms/FRDM-K64F/
- 1) get and install platformio
- http://platformio.org/#!/
- FYI, on a mac, use this command to get and install:
- sudo -H python -c "$(curl -fsSL
https://raw.githubusercontent.com/platformio/platformio/master/scripts/get-platformio.py)"
- on mac, platformio is installed in hidden directory
~/.platformio
- 2) get and install Eclipse IDE for C/C++ Developers:
-
http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers/marsr
- 3) use platformio to create a simple hello project as follows:
- a) create a directory blink_pe
- b) in a command window, move into that directory and
from the command line, then run
- “platformio init --ide eclipse -b
frdm_k64f”
- and answer no to auto-uploading
- and yes to accept the default directory structure
- you should see “Project has been successfully
initialized!”
- c) edit the newly created platformio.ini as follows:
[env:frdm_k64f]
platform = freescalekinetis
framework = mbed
board = frdm_k64f
targets = upload
src_build_flags = -Wall -g -no-integrated-cpp -save-temps
-fverbose-asm -Wa,-aghlmns=assembly.s
- d) create the following file main.cpp in the src
subdirectory:
#include "mbed.h"
DigitalOut myled(LED1);
int main() {
while(1) {
myled = 1;
wait(1);
myled = 0;
wait(1);
}
}
- 4) Run eclipse and import the blink_pe project
using
MenuBar::File::Import::General::ExistingProjectsintoWorkspace
- and in the popUp navigating to the blink_pe directory
- and select the “search for embedded projectts” and “copy
into workspace” options
- 5) go to the workbench view by clicking on the workbench icon
in the upper right of eclipse or by MenuBar::Window::NewWindow
- 6) update Eclipse $PATH variable.
- In Eclipse IDE right click on the created project in the
ProjectExplorerPane (leftmost pane) and select
Properties::C/C++ Build::Environment
- then click the selectButton and check the path variable in
the popup, and OK,
- then select PATH and edit it to append /usr/local/bin to
enable eclipse to find the platformio command on your system
(in a command window you can type “which platformio” in a
terminal window to confirm the location), then click
applyButton
- 7) update the C/C++ Build to upload the binary to the
FRDM-K64F by telling where the USB directory appears in the
computer filesystem,
- for example on mac this may be in Properties::C/C++
Build::BehaviorTab changing the “Build (incremental build)”
line to“--force run --upload-port /Volumes/MBED” and
click applyButton
- 8) plug your FRDM-K64F into the USB port of your computer
- 9a) when you first use platformio to build your project, it
automatically downloads and installs software for your board,
- so it is best to do your first build from a terminal command
line,
- so change to your project directory that was just imported
into eclipse,
- and run the command “platformio —force run”
- and it may take a while to download the needed additional
software to platformio
- 9b) Next, when you build the project, it should automatically
download to your FRDM-K64F
- (you should see the green LED blink as the code is
downloaded)
- build the project by clicking the hammer-button in the
menuBar
- or build it by right-clicking the blink_pe in the
ProjectExplorerPane (leftmost pane)
- NOTE: at the bottom of the window after building, you
will likely get a warning about an Invalid project path such
as
/Users/tpw/.platformio/packages/framework-mbed/variant/K64F/env
. The easiest workaround is to simply create a dummy
directory from the command line of a terminal by typing
- “mkdir
/Users/tpw/.platformio/packages/framework-mbed/variant/K64F/env”
- then rebuild and this warning should disappear.
- 9c) Once the green LED stops blinking, press the reset
button near the green LED.
- The red LED at the opposite end of the board should
blink per your “blink_pe/src/main.cpp” program code
- 10) once you have the basic software running, install the
debugger as follows
- a) use MenuBar::Help::InstallNewSoftware, select “work with
all available sites,”
- type gdb into the search query,
- select the “C/C++ GDB Hardware Debug” checkbox,
- and click next twice to install gdb and restart eclipse
- 11a) install pyocd
- see: https://github.com/mbedmicro/pyOCD
- run this first because pip bug causes failure of proceed
install:
sudo -H pip install Cython
sudo -H pip install --pre -U pyocd
- 11b) plug in your FRDM-K64F board, press reset, and in a
command terminal test your pyocd by running the commands:
pyocd-gdbserver --help
pyocd-gdbserver -l
- and you should see something like:
tpwmac12:local tpw$ pyocd-gdbserver -l
INFO:root:new board id detected: 02400221AA524E54578CB3EC
0 => MBED MBED CMSIS-DAP (0xd28, 0x204) [k64f] boardId
=> 02400221AA
- 12) verify that the very basiscs are properly running for
debug, by opening 2 different terminals and running the
following sessions:
In terminal window 1
————————————
run pyocd-gdbserver to obtain this session
tpwmac12:~ tpw$ pyocd-gdbserver
INFO:root:new board id detected:
02400221AA524E54578CB3EC
INFO:root:board allows 5 concurrent packets
INFO:root:DAP SWD MODE initialised
INFO:root:IDCODE: 0x2BA01477
INFO:root:K64F not in secure state
INFO:root:6 hardware breakpoints, 4 literal
comparators
INFO:root:CPU core is Cortex-M4
INFO:root:FPU present
INFO:root:4 hardware watchpoints
INFO:root:GDB server started at port:3333
INFO:root:One client connected!
[====================] 100%
In terminal window 2
run arm-none-eabi-gdb on your compiled elf file for your
projectas follows
————————————
tpwmac12:~ tpw$
~/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gdb
/Users/tpwece/Documents/00_platformioEclipseProjects/blink_pe/.pioenvs/frdm_k64f/firmware.elf
GNU gdb (GNU Tools for ARM Embedded
Processors) 7.6.0.20140731-cvs
Copyright (C) 2013 Free Software
Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to
change and redistribute it.
There is NO WARRANTY, to the extent
permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as
"--host=x86_64-apple-darwin10 --target=arm-none-eabi".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from
/Users/tpw/tp_frdm_blink_3.elf...done.
(gdb) target remote localhost:3333
Remote debugging using localhost:3333
0x00000eb2 in wait_us ()
(gdb) load
Loading section .isr_vector, size 0x1f0 lma
0x0
Loading section .flash_protect, size 0x10
lma 0x400
Loading section .text, size 0x8548 lma
0x410
Loading section .ARM.exidx, size 0x8 lma
0x8958
Loading section .data, size 0x8b4 lma
0x8960
Start address 0x198, load size 36868
Transfer rate: 14 KB/sec, 1602 bytes/write.
(gdb) quit
- 13) create your debug configuration:
MenuBar::Run::debugConfiguration and double-clcik
GDBhardwareDebugging
- 13a) in MainTab:
- C.C++Application browse to your firmware.elf location in
~/.platformio, such as:
- /Users/tpwece/Documents/00_platformioEclipseProjects/blink_pe/.pioenvs/frdm_k64f/firmware.elf
- … note you may not be able to use shortcuts and
need full path (not ./.pioenvs )
- click applyButton
- 13b) in debuggerTab,
- use remote target:
- remoteTargetJtagGenericTcpIp localhost:3333 (same
port as printed from pyocd-gdbserver)
- set full path t ARM GDBCommand:
- /Users/tpwece/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gdb
- click applyButton
- 13c) in startupTab
- uncheck initilizationCommandResetDelaty
- uncheck initilizationCommandHalt
- check LoadImage and loadSymbols
- and make sure useProjectBinary points to your
firmware.elf
- check runtimeOptionSetBreakpointAt and enter "setup" in
the box
- check runtimeOptionsResume
- click applyButton
- 13d) in commonTab
- check saveAsSharedFile
- check displayFavoritesDebug
- click applyButton
- 14) in eclipse, add 2 breakpooints to main.cpp
- open main,cpp and add 2 breakpoints at the “myled” lined
- by double-clicking in the bar to the left of the 2 lines
(little buttons wil appear)
- 15) To debug, first make sure your FRDM-K64F mbed board is
plugged in, and press the reset button to reset the board
- 15a) in the terminal running pyocd-gdbserver use “control-c”
to kill it
- 15b) make sure main.cpp is open and visible in eclipse, so
that it apppears whenever the debugger takes over
- 15c) MenuBar::Project::clean
- 15d) MenuBar::Project::buildAll
- the green LED should flicker as it uploads to the
FRDM-K64F
- 15e) run pyocd-gdbserver in a terminal and make sure
it reports port 3333 when it runs
- 15f) make sure main.cpp is open and visible in eclipse, so
that it apppears whenever the debugger takes over
- 15g) run debug in the main eclipse window,
- by clicking the dropdown arrow of the debug icon and run
blink_pe Default,
- or MenuBar::Run::DebugConfigurations
- Note: if you get “problem occurred” details: localhost3333
timeout, go back to the terminal and make sure
pyocd-gdbserver ran on port 3333
- 15h) the debugPerspective should appear, otherwise use
MenuBar::Window::Perspective::Open::Other::debug
- select main.cpp view and note the disassemblyView at
programcounter 2000000
- click the resumeButton ( yellow Green Arrow icon )
- and the breakpoints should highlight in main.coo and
dissassembly as the program executes.
- the LED should also flash on the board as you cycle
throuhg the program with resumeButton
- note the register view also contains the program counter
register ”pc"
If you received this message: “Error: Program
“platformio” not found in PATH”, then you need to update Eclipse
$PATH variable. In Eclipse IDE make right click on the created
project (“Project Explorer“) : “Properties → C/C++ Build →
Environment → PATH → Edit” and set to
/usr/local/bin:/bin:/usr/bin:/usr/sbin:/sbin .
If all goes well, you should see a successful IDE debug
environment like the following:
Copyright 2015 T. Weldon
Freescale, Kinetis are registered trademarks of Freescale
Semiconductor, Inc. Texas Instruments, TI, C2000,
and Code Composer Studio are a registered trademarks of Texas
Instruments Incorporated. Adafruit is a registered
TradeMark of Limor Fried. ARM, Cortex and Keil are
registered trademarks of ARM Limited (or its
subsidiaries). Apple, Yosemite, Mac OS, iPhone, iPad,
MacBook, Mac, iTunes, and Xcode are trademarks of Apple inc. All
other product or service names are the property of their
respective owners. Arduino is a registered trademark of
Arduino.