February 27, 2025

Black Pill boards - back in the saddle, 2025

It is February of 2025. It has been 4 years since I even touched a F411 or F103 board. I had to dig through some boxes, fortunately fairly well labeled, to find my boards.

I found a chunk of aluminum with one of my Cuisw black pills mounted to it. The Cuisw boards are the ones with mounting holes (nice!) and 19 pins on each side.

Having it mounted on a block of aluminum (or on something with a bit of weight) is highly recommended. It makes things more civilized having it sit in one place on my desk, rather than dangling at the end of a cable. Or worse, being dragged off my desk onto the floor by the weight of a cable.

Also in my boxes I found a blue pill on a protoboard with two handy things attached. One is a ST-Link V2 dongle, which I will need. The other is a USB to serial gadget, which I will also need.

Just for the record, on the blue pill, the serial dongle is connected as follows:

Brown wire -- ground
Red wire -- Rx on the USB to pin "A9"
Purple wire -- Tx on the USB to pin "A10"

IMPORTANT -- on these Cuisw black pill boards, the SWD connector is reversed from how it is on the blue pill boards!!
On the blue pill, if the connector is towards you, ground is on the right.
On the black pill, if the connector is towards you, ground is on the left..

NOTE -- the diagram for the WeAct boards shows the ground on the right, like the F103 blue pill.

Try things with just the ST-Link

I pull the ST-Link cable off the blue pill, flip it, and plug it into the black pill. I plug in the USB and get the expected messages in my /var/log/messages file:
Feb 27 19:02:55 trona kernel: usb 4-1.1: New USB device found, idVendor=0483, idProduct=3748, bcdDevice= 1.00
Feb 27 19:02:55 trona kernel: usb 4-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Feb 27 19:02:55 trona kernel: usb 4-1.1: Product: STM32 STLink
Now I go to the directory that holds my bare metal "blink1" demo and type:
make
make flash
And presto! A blue LED near the SWD connector starts blinking. There is a red LED nearby that came on as soon as I plugged in the ST-Link.

What about a serial console?

I will need to find 3 different wires to use for the USB dongle (female on both ends). And I need to figure out where to connect them. It looks like there are 3 choices for TX1 and RX1. I look at my "serial1" demo and in gpio.c I find the clue. Tx is on A9 and Rx is on A10. Amusingly, these are the same pins as the F103 blue pill.
I change a wire color (purple to orange) and make connections as follows:
Brown wire -- ground
Red wire -- Rx on the USB to pin "A9"
Orange wire -- Tx on the USB to pin "A10"
I use a little USB hub to connect both the ST-Link and my USB to serial dongle. This reduces the tangle of cables on my desk. Pretty soon I will have a third cable for USB itself, making this even more beneficial.

When I plug things in, it sets up the serial dongle as /dev/ttyUSB1, and I set it to 115200 baud. Then I go to my "serial1" bare metal demo and:

cd serial1
make
make flash
No LED flashing now, but on the serial console I see:
Testing 1
Testing 2
Testing 3
Testing 4
Testing 5
For fun, I try my "serial2" demo also and it works as expected.

Power questions

A final note regarding all of these cables. When I add a USB cable, I will have power coming to the board from two sources, the ST-Link and USB itself. This may or may not be a problem, but is worth thinking about. Since this 5 volt power comes from the same source (the cable feeding my USB hub) I am not terribly concerned. I could consider disconnecting the power from the ST-Link, as that is easy to do.

Note however that power from the ST-Link is 3.3 volts, while the power from USB is 5 volts. My Cuiisw unit has a nice big diode near the USB connector, which gives me a better feeling about having both power sources connected. However this feeds a 5v to 3.3 volt regulator which drives the 3.3 volt rail that is also connected to the ST-Link, which could lead to a disagreement about who is actually running the 3.3 volt rail.

I'll probably just let laziness rule the day and leave both connected. If bad things happen, I can replace the unit and reevaluate. Note that the WeAct units are different and have no diode from USB.

Conclusions

I am back to where I was 4 years ago after about an hour of getting reoriented.


Feedback? Questions? Drop me a line!

Tom's Computer Info / tom@mmto.org