The Sparkdog PF-DI daughter-board is fitted with an NXP MK10DX512 MCU. For reprogramming, the standard ARM SWD/JTAG 10-pin connector is used.
While any ARM Cortex programming utility can be used, we recommend using the Olimex ARM-USB-TINY-H programmer along with Visual GDB and OpenOCD.
Although the Sparkdog PF-DI daughter-board ships fully tested and programmed, reprogramming can be done to install bug fixes or add new features.
Plugging in the Olimex programmer usually results in a failed installation of USB drivers. We found that using the Zadig UDB driver tool v2.9 fixes this issue.
One at a time, select both channels of the Olimex OpenOCD debugger and install the WinUSB (v6.1.7600.16385) driver. This can take a while, just be patient.
Visual GDB is great for cross-platform and embedded systems development. With the addition of an OpenOCD debugger, reprogramming and even debugging of embedded applications is made possible at low cost.
In this use-case, an LED flashing application is created. The Olimex programmer can be tested, then the ELF file swapped out with a new PF-DI firmware for permanent programming.
With Visual Studio Community and Visual GDB installed, you can create a project. It won’t be necessary to add all of the source code from a Git repository, because the purpose of the project is just for installing a firmware that is already compiled.
Follow these 5 steps to create an embedded project for the PF-DI NXP MK10DX512. Please choose MK10DN512VLK10 device.
Please note, sometimes problems can arise, and these are almost always solved by using the resolve wizard of Visual GDB, or Googling for a resolution. Allow the Visual GDB to assist in installing the ARM Toolchain and the OpenOCD drivers if you do not already have these installed.
The first time you program the flash memory, you will see a programming script problem.
This issue is caused by the latest OpenOCD builds having a out-of-date programming script for Kinetis MCUs.
The offending file is either named kinetis_generic.cfg or kx.cfg and can be found at:
C:\Users\YOURNAME\AppData\Local\VisualGDB\EmbeddedDebugPackages\com.sysprogs.arm.openocd\share\openocd\scripts\target
There are 3 lines that need to be edited.
Change these lines:
set _TARGETNAME $_CHIPNAME.cpu
swj_newdap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
target create $_TARGETNAME cortex_m -chain-position $_CHIPNAME.cpu
To this:
swj_newdap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME cortex_m -dap $_CHIPNAME.dap
Then save the file. The VisualGDB project can now reprogram the Kinetis MK10 MCU using the menu option Debug->Program and Start Without Debugging. You will be programming in the compiled LED blink project.
Up to this point, you have programmed the LED blink project. The LED blink project output is the ELF file. There are also accompanying bin and hex files in the LED blink output folder:
C:\projects\EmbeddedProject\VisualGDB\Debug
Please note, your project output folder might be a little different.
Because we created a project named “EmbeddedProject”, the ELF file is a file of the same name, with no extension. It is also the largest file in the debug folder.
To program the Sparkdog PF-DI ELF file, simply replace the “EmbeddedProject” file with the Sparkdog PF-DI file. As long as the filename is the same, the next time you select Debug->Program and Start Without Debugging, the Sparkdog PF-DI ELF file (renamed) will be programmed.
If this is not clear, watch the video below.