Board space is a premium on small circuit board designs, and [Alvaro] knows it. So instead of adding a separate programming port, he’s found a niche USB-C feature that lets him use the port that he’s already added both for its primary application and for programming the target microcontroller over JTAG. The result is that he no longer needs to worry about spending precious board space for a tiny programming port; the USB-C port timeshares for both!
In a Twitter thread (Unrolled Link), [Alvaro] walks us through his discovery and progress towards an encapsulated solution. It turns out that the USB-C spec supports a “Debug-Accessory Mode” specification, where some pins are allowed to be repurposed if pins CC1 and CC2 are pulled up to Logic-1. Under these circumstances, the pin functions are released, and a JTAG programmer can step in to borrow them. To expose the port to a programmer, [Alvaro] cooked up a small breakout board with a USB-C plug and separate microcontroller populated on it.
This board also handles a small quirk. Since [Alvaro’s] choice of programming pins aren’t reversible, the USB-C plug will only work one of the two ways it can be plugged in. To keep the user informed, this breakout board sports a red LED for incorrect orientation and a green LED for correct orientation–nifty. While this design quirk sacrifices reversibility, it preserves the USB 2.0 D+ and D- pins while also handling some edge cases with regard to the negotiating for access to the port.
Stick through [Alvaro]’s Twitter thread for progress pics and more details on his rationale behind his pin choices. Who knows? With more eyes on the USB-C feature, maybe we’ll see this sort of programming interface become the norm?
[Alvaro] is no stranger to Hackaday. In fact, take a tour back to our very first Supercon to see him chat about shooting lasers at moving targets to score points on a DEFCON challenge in the past
10 thoughts on “An “unbusy” USB-C Port Doubles-up For JTAG Programming”
This is really nice, I‘ll keep it in mind and do this on the next microcontroller board. Could also be used to break out GPIOs over tje USB-C connector.
Small correction: In this case it‘s SWD – not JTAG.
Second that Rick, nice idea – wasn’t aware of the USB-C option for debug accessory mode and although a good sign & efficiency for developers one would need to review security issues if at least to avoid hacking in to corrupt targets as well as risk of reading back code & data etc
Thanks for posting :-)
I hope he ends up selling them. I would like to play with one ;-)
The pinenote e-ink tablet exposes UART over the usb-c port by I believe the same interface
I bet that’s how the PineCil supports its breakout board too.
Pinecill is “passive”. No MCU there.
it says it has a 32-bit RISC SoC so I’m pretty sure that’s not “passive”
The interface is passive, not the Pinecil itself….
The kindle Paperwhite does too if you put the right resistor on the ID pin. At least the USB chip they used supports it, I never tested it. I wrote a script to send the right command to my semi bricked kindle in the 10 seconds it showed up on my computer when connected by USB, so I didn’t need the uart to unbrick the thing.
Newer Chromebooks with the cr50 chip do the same thing to access its debug interface
Please be kind and respectful to help make the comments section excellent. (Comment Policy)