A penny debugger: making ST-Link from Maple Mini

  • Tutorial


Starting my acquaintance with STM32 with the Chinese Leaf Maple Mini clones (because the cheapest option, $ 4), I ran into a nuisance. Since you should not count on the Maple IDE, it means you have to work with the bare STM32. And since I don’t have ST-Link, I can upload the program only by UART, which is inconvenient (and there is no debugging feature).

But imwode , exactly 9 hours after my publication, wrote a response material from which I learned great things: the ST-Link debugger is based on the same STM microcontroller. At the same time, the debugger firmware has been pulled out by the craftsmen and is ready to be downloaded to non-native devices. Maple Mini fits perfectly: nothing more, USB is soldered, you just need to connect a few resistors.


Need :

1. Connect PA5 and PB13 (D6 and D30 on Maple Mini). This will be the SWСLK line.
2. Between PB14 and PB12 (D29 and D31) put a resistor of 220 ohms. PB14 (D29) is the SWDIO line.
3. Connect PA0 (D11) to the divider of two resistors at 4.7 kOhm between + 3.3V and GND.

And here, too, a rake!

After the firmware, in theory, the PC should recognize the board as ST-Link. But no. As if nothing is connected at all. A certain amount of time was spent searching for the rake, but it was only necessary to take a closer look at the Maple Mini scheme, and specifically, at the implementation of the USB D + line. It is pulled to + 3.3V through a 1.5K ohm resistor, but the pull-up is turned on by a transistor switch. Which is controlled from the MK foot and is turned off by default. And if so, the PC simply does not understand what is connected to the USB port. We will not interfere with the board, but simply “hang” another 1.5 KΩ resistor between + 3.3V and D + (D23).

Now we have a ST-Link device. We put ST-Link Utility, and there is a driver there. We update the firmware of our ST-Link (through this utility), and you can start working with the debugger. At least I connected a second Maple Mini to it: SWCLK to PA14 (D21), SWDIO to PA13 (D22), and I successfully uploaded the compiled Blink and debugged it with Coocox.

In principle, the device can already be equipped with a normal connector and stuffed into the case. Before forgetting to get the "normal" resistors, and not what turned up by the arm. Some kind of LED indication will not hurt. I think many do-it-yourselfers will confirm that the transition from “matches, acorns, blue electrical tape” to the finished device is the most difficult and longest, because “why, it works even though the wires stick out in all directions”.

And, yes, Chinese ST-Link can be bought for the same $ 4 on Aliexpress, for example .

Foundational theme at Easyelectionics.
Firmware (also Easyelectronics).
Description Leaf Maple Mini
ST-Link Utility
Manual on the "native" ST-Link

Also popular now: