The Teensy 3.6 is a lovely little board. Full of promise and excitement. Compatible with Arduino by using Teensyduino, utterly loaded with CPU horsepower and peripherals, and for not much money.
BUT… there’s no immediate SWD hardware debugging support. Or, rather, there appears to be hardware SWD support on the underside through the pins
DD, DC, DE, Reset.
It is a big shame this doesn’t work out-of-the-box.
Still, I love a challenge, and thanks to a very helpful BBenj on this thread: https://forum.pjrc.com/threads/42728-Debugging-strategies/page2 there was light.
Before describing what I’ve done, it’s worth highlighting some background information that I’ve gleaned from this exercise. It’ll shed some light on things.
The Teensy boards work by having a tiny (physically!) MKL02 Cortex-M0 CPU that can shove a USB-HID bootloader directly into the main MK66 Cortex-M4 CPU. When you hit the button, the MKL02 CPU grabs hold of the MK66 SWD pins, has a probe around and takes action.
If the MK66 is locked (i.e. security locked), then the MKL02 has only one option — full erase. WHOP! Out goes all the MK66 code.
Once it has access, the MKL02 shoves a small bootloader into RAM of the MK66 and lets it run. The Teensyduino programmer GUI detects this and then passes the binary flash data up your USB cable (using USB-HID) and into the MK66 flash.
By putting the bootloader into RAM, you can instantly reboot without having to re-flash the main application all over again.
Having burned the real code (it’s the MK66 bootloader itself that does this, not the MKL02) then all systems are “Go” and the main CPU will just run — as if the tiny MKL02 wasn’t there.
Now, the problem comes when we want to control the MK66’s SWD pins directly. The MKL02 should have let go if the
DE pin is low… but PJRC haven’t got round to that. Sigh.
So, we have to go with BBenj’s suggestion of slamming reset on the MKL02 to keep it out of the way 👊
As I mentioned in the PJRC forum thread, all would have been fine if the
DEpin was itself the pin 15 of the MKL02 (i.e. reset). Maybe there’ll be a PCB modification at some point 😝
This is very fine work, but possible with a magnifying glass and a steady hand.
The process is thus:
- solder a very fine wire to pin 15 of the MKL02
- take it to a 2-pin header that has the other side connected to GND (next to pin 13 of the module)
- Now you can just jumper across, or wire a Dupont connector to breadboard.
Simply remove the link or wire (or tie to 3V3) to let the MKL02 have its life back again.
And viewing on breadboard:
The TFT test was built using Segger’s Embedded Studio using my project that allows Teensyduino/Arduino development, flashed with the J-Link, and allowing full hardware debugging. Yahaaaay!
Next step… to show you how to setup Segger’s tools for Teensyduino.