I’m trying to use Black Magic Probe (BMP) to program my NXP MK20FX512VLQ microcontroller. It is Cortex M4F and debugging is done through standard ARM Debug Interface V5 which is supported by BMP.
What is not standard it flash programming. Flash programming is done by controlling the MCU flash programming peripheral using the ADI the same way as we would do it from the MCU code. (For example a bootloader is doing that). There is support for Kinetis MCUs in BMP, but not for my specific part. I added this support to the code.
It was quite simple. The code in BMP supported KL series of MCUs from NXP, but my part is K series. The only difference is alignment of (KL has 4 bytes, K has 8 bytes) and the size of one memory write which is equal to the memory aliment.
I added another switch case to the function that detects the MCU so that BMP can detect my MK20 processor. Also, I defined a new function that specifies the alignment and modified the flash write function accordingly.
With these modifications BMP can write flash for MK20.
Changes are in my Github repository. Pull request has been made.
My gdbinit file is the following:
target extended-remote /dev/ttyACM0 monitor swdp_scan attach 1 set backtrace limit 5 b main start
I had to set the backtrace limit to avoid cycles (I use FreeRTOS and the return address from the thread is set to address 0x0. This caused backtrace to cycle around and crashed the debugger.)
With this configuration the debugging works.
Writing to the flash is VERY slow. My j-link can program the flash in a few seconds but BMP takes half a minute. j-link probably uses some king of buffering of writes (write the entire sector or so).
This should be fixed.