# ARM Kinetis-Based Custom Microcontroller Design - USB Programming Interface?

#### ZCochran98

Joined Jul 24, 2018
4
First-time poster here, so if this is asked in the wrong location, please redirect me.

I'm currently working on (attempting) to design a custom microcontroller (or, rather, a form of embedded system) for a project, and need some assistance with how to actually incorporate a USB/JTAG/SWD-type interface (preferably USB) to, when it gets to that point, be able to flash/upload programs onto the microcontroller. I'm considering using an K60- or K20-series ARM Cortex M4 microprocessor (in particular, I am looking at a processor such as MK64FN1M0VLL12 or MK20DX128VFM5, if that helps).

I know that these microprocessors have USB ports (for instance, on the MK64-series, pins 10 and 11 are USB0_DP and USB0_DM). My primary confusion comes from the fact that every single development board schematics I see, there is also the openSDA implementation added in, which implies to me that the first USB (the one that actually connects to those pins) is for some other purpose (like serial communication), and will not work to actually be able to upload a program onto the chip; instead, that's what the openSDA does. But then the main confusion sets in when I see that the chip used to implement openSDA for all of these is a K20, which is ALSO an ARM chip like K60-series chips.

In short (tl;dr), what I need assistance with is with the programming/flash interface of one of these chips. Can it be done simply through the USB pins on the chip (or via JTAG/SWD, which I don't know how to do at the moment), or do I need to implement something similar to openSDA myself? And if it can be done just by the USB pins on the chip, how would I actually then upload a program onto the chip, as I imagine that bootloaders are not preloaded onto the chip from the manufacturer (unless I'm mistaken).

I have yet to actually find some clear information on this, despite several days of searching. As far as I can tell, there really aren't particularly many questions about Kinetis or ARM chips here - the ones I have seen thus far are for ATMEGA/ATMEL chips; not ARM specifically. Any assistance would be greatly appreciated!

If this question has been answered before, then I would appreciate a pointer to said thread.

Attached is an example of one of the schematics of a Kinetis microcontroller that I am using as a reference.

#### Attachments

• 208.4 KB Views: 0

#### mckenney

Joined Nov 10, 2018
70
1) All the Cortex proper understands is the SWD pins.
2) OpenSDA (and equivalent) serves to talk a high(-ish) serial protocol with the PC and translate that into SWD.
3) Loading code via the USB directly is a "definite maybe". Look for the term "boot loader" in your chip's User Guide. Some Arduino-ish boot loaders talk directly to the USB.
4) The OpenSDA on the FRDM boards is done on a Kinetis since that's what they had lying around. The LPC boards have LPCs doing the programming. TI uses a TI chip. They all sit in the same spot architecturally (see (2)).

If you have a FRDM board, it probably has a DAP connector (5x2 itty bitty pins) which you can connect to your board to do the programming via the OpenSDA on the FRDM board. (I don't know that all of them do.) Even if you don't have one, buying one might be the simplest/cheapest approach. (In theory, you can program a Cortex from any DAP, but the people who built the DAP board might have, um, forgotten to put your chip's ID into their host software.)

The simplest and most future-proof method is to get a J-Link. The Segger folk are very good about keeping up with the latest, and have a support list a mile long. But they're pricey (just under $200 as I recall, but check). If you swear you're a student/professor/home-hobbyist you can get one for (as I recall) about$70, and the nag-screen only pops up once per day.

#### ZCochran98

Joined Jul 24, 2018
4
Thank you very much! Considering how many other "custom microcontrollers" I had seen used almost exclusively JTAG or SDW, it makes sense that they would be the simplest solution in the long run. I will definitely have to take a look at the Segger J-Link; I have a suspicion that it will be quite handy in the future....

And indeed, per your suggestion, the user manuals did have, buried deep within the labyrinth of application notes, information about a USB bootloader, alongside the serial bootloader information.

Thanks again!

#### mckenney

Joined Nov 10, 2018
70
Keep in mind that Boot Loaders only load code, they don't provide debug.

I suggest you make a point to fit either a DAP or (at minimum) a 4-pin SWD+VCC+GND connector on your board. You'll want it sooner or later.