Black pill

WeAct STM32F411CEU6 BlackPill v3.0

After being disappointed by the low quality of various blue pill clones, I decided to order some black pills. These boards are made by WeAct and give the impression of quality already from the careful packaging and they have a USB-C connecter. They contain very powerful chips from ST Microelectronics which are based on the high-performance Arm Cortex-M4 32-bit RISC core which features a Floating point unit (FPU) single precision.

Specs: 32-bit, 100 MHz, 512 kB flash memory and 128 kB SRAM, native USB built into the chip, USB-C connector

WeAct sell these boards for $5.40 on AliExpress (plus ca. $4 for shipping). Shipping from China has become a lot more expensive lately and is still extremly slow. I bought these boards from Digikey instead ($12.50 incl. shipping) and got them after two days (Europe).

If you want to program this board over USB DFU (instead of ST-Link) using Windows 10, the easiest way to get the correct WinUSB drivers for the board is to install the STM32CubeProgrammer from ST. In PlatformIO, the ST STM32 platform has to be installed to program these boards. Further, WeAct distribute MicroPython firmware that can easily be uploaded with the STM32CubeProgrammer software (and Adafruit provides CircuitPython firmware for the board).

After some initial starting problems, that I documented below, I am very impressed with these boards. It is possible to solder external flash memory onto the board but it would be nice if they could do that for you and sell a version of the board with extra memory.

WeAct BlackPill v3.0 with USB-C compared to Blue Pill

STM32F411CEU6 chip

Date code 2020 week 32

Getting started with PlatformIO

In theory, the big advantage of this board over the Blue Pill is the ability to upload code directly via USB DFU (Device Firmware Update). No need to buy a ST-Link adaptor or flash a bootloader first. The first time I connected the board via USB cable to the computer, the board registered as WeAct Studio HID Bootloader. The red power LED is on. The blue LED is flashing slowly (blinky program running)

The first time, if you haven't uploaded a program yet, you can:

-"Long press" the KEY key; the blue LED blinks fast; release key and board enters STM32 Bootloader (and blue LED stops flashing)

This is the standard method and works always:
-Press and hold reset
-Press and hold boot
-Release reset and then release boot
Again, the board registers as STM32 Bootloader.

However, looking in the device manager (Windows 10), I see a WARNING:

Device USB\VID_0483&PID_DF11\3677385F3030 was not migrated due to partial or ambiguous match.

In Win10, this usually indicates that the driver must be updated. I tried uploading a test program anyway:

You have to install the correct Core in PlatformIO first. There is an official "Arduino" core from ST Microelectronics: ST STM32. Launch PlatformIO, go to PlatformIO home and click on Platforms. Search and install ST STM32.

Now, create a new project. Go to platformio projects -> create new project. Search for the board WeAct BlackPill V2.0 (BlackPill F411CE) . Choose Framework: Arduino and save the project.

To use USB DFU uploading, the platformio.ini file has to be edited:

[env:blackpill_f411ce]

platform = ststm32

board = blackpill_f411ce

framework = arduino


upload_protocol = dfu

Not surprisingly, the program didn't upload and the following error message appeared instead:

Invalid DFU suffix signature

A valid DFU suffix will be required in a future dfu-util release!!!

No DFU capable USB device available

*** [upload] Error 74

Not much to go on. I located dfu-util in the platformio packages and run it:

C:\Users\Name\.platformio\packages\tool-dfuutil\bin>dfu-util --list

dfu-util 0.9


Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.

Copyright 2010-2020 Tormod Volden and Stefan Schmidt

This program is Free Software and has ABSOLUTELY NO WARRANTY

Please report bugs to http://sourceforge.net/p/dfu-util/tickets/


Cannot open DFU device 0483:df11

This is still not encouraging but there is a user out there that seems to have some insight:

https://www.hanselman.com/blog/how-to-fix-dfuutil-stm-winusb-zadig-bootloaders-and-other-firmware-flashing-issues-on-windows

He says, that I have to exchange the driver with the WinUSB driver with the help of a utility called Zadic. There is however a better solution. You can download and install the STM32CubeProgrammer from ST:

https://www.st.com/en/development-tools/stm32cubeprog.html#overview

It is a small install. The installer will install the correct WinUSB drivers. If this doesn't happen automatically, the ST wiki describes solutions:

https://wiki.st.com/stm32mpu/wiki/STM32CubeProgrammer#Preparing_the_USB_serial_link_for_flashing

Now, this seems to have solved the problem:

After the driver install, I tried again to upload the first test program, which uploaded without problems now. Program execution started immediately afterwards, no need to reset the board.

Configuring upload protocol...

AVAILABLE: blackmagic, dfu, jlink, serial, stlink

CURRENT: upload_protocol = dfu

Uploading .pio\build\blackpill_f411ce\firmware.bin

dfu-util 0.9


Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.

Copyright 2010-2020 Tormod Volden and Stefan Schmidt

This program is Free Software and has ABSOLUTELY NO WARRANTY

Please report bugs to http://sourceforge.net/p/dfu-util/tickets/


Opening DFU capable USB device...

ID 0483:df11

Run-time device DFU version 011a

Claiming USB DFU Interface...

Setting Alternate Setting #0 ...

Determining device status: state = dfuERROR, status = 10

dfuERROR, clearing status

Determining device status: state = dfuIDLE, status = 0

dfuIDLE, continuing

DFU mode device DFU version 011a

Device returned transfer size 2048

DfuSe interface name: "Internal Flash "

Downloading to address = 0x08000000, size = 12740


Erase [ ] 0% 0 bytes

Erase [==== ] 16% 2048 bytes

Erase [======== ] 32% 4096 bytes

Erase [============ ] 48% 6144 bytes

Erase [================ ] 64% 8192 bytes

Erase [==================== ] 80% 10240 bytes

Erase [======================== ] 96% 12288 bytes

Download [ ] 0% 0 bytes

Download [==== ] 16% 2048 bytes

Download [======== ] 32% 4096 bytes

Download [============ ] 48% 6144 bytes

Download [================ ] 64% 8192 bytes

Download [==================== ] 80% 10240 bytes

Download [======================== ] 96% 12288 bytes

Download [=========================] 100% 12740 bytes

Download done.

File downloaded successfully

Transitioning to dfuMANIFEST state

Invalid DFU suffix signature

A valid DFU suffix will be required in a future dfu-util release!!!

Now, with my first program running, the board does no longer register as WeAct Studio HID bootloader. It doesn't register at all on USB. Let's correct that in the next step and start using USB serial:

First test program with USB serial in PlatformIO

I like microcontrollers that give me USB serial so I can connect them to my cell phone (USB-C). We have to modify the platformio.ini file:

[env:blackpill_f411ce]

platform = ststm32

board = blackpill_f411ce

framework = arduino


upload_protocol = dfu


build_flags =

-D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC

-D USBCON

-D USBD_VID=0x0483

-D USBD_PID=0x5740

-D USB_MANUFACTURER="Unknown"

-D USB_PRODUCT="\"BLACKPILL_411CE\""

-D HAL_PCD_MODULE_ENABLED

And here a first test program:

#include <Arduino.h>


void setup() {

// put your setup code here, to run once:

pinMode(PC13, OUTPUT);

Serial.begin(9600);

}


void loop() {

// put your main code here, to run repeatedly:

Serial.println("Hello world!");

digitalWrite(PC13, HIGH); // turn the LED off (HIGH is the voltage level)

delay(1000); // wait for a second

digitalWrite(PC13, LOW); // turn the LED on by making the voltage LOW

delay(1000); // wait for a second

}

Now the board shows up as USB Serial Device (under Ports in the Device manager in Win10) with the message: The device is working properly, and the serial terminal opens in PlatformIO.

Flashing Micropython (for internal ROM)

This board is so powerful that it is a good candidate for MicroPython and WeAct provide MicroPython firmware for the board:

First, download the whole github repository:

https://github.com/WeActTC/MiniSTM32F4x1

Unzip the download and find the image to upload:

C:\Users\Username\Downloads\MiniSTM32F4x1-master\MiniSTM32F4x1-master\SDK\STM32F411CEU6\MicroPython\firmwares-v1.14

We want the .hex file for internal ROM: firmware_internal_rom_stm32f411_v1.14-7.hex

I plugged in the board and set it in STM32 bootloader mode. I then started STM32CubeProgrammer, chose the USB method (DFU) and pressed connect. The chip connection opens. Next, I pressed the download icon, which opens the Erase and Programming tab, and clicked on file path and selected the HEX file. Then, I pressed Start Automatic Mode and waited for the process to finish. When the program asked for the next board to program, I pressed Disconnect and unplugged the board.

When I plugged the board back in, the board showed up in two ways:

  1. It turned up as USB drive F: containing boot.py and main.py and README.txt (and ca. 40 kB free space):

2. At the same time, a USB Serial Device (COM6) appeared. (According to the Readme on the drive, if this device is unknown in Windows you can use pybcdc.inf to update the driver software but in my case it just worked).

Next, I started PuTTY on COM6 with 115200 baud and got immediately a MicroPython prompt (REPL) and toggled successfully the blue LED:

MicroPython v1.14-7-g60612bb53-dirty on 2021-02-13; WeAct Studio Core with STM32F411CE

Type "help()" for more information.

>>> import pyb

>>> pyb.LED(1).toggle()

>>> pyb.LED(1).toggle()

>>> pyb.LED(1).toggle()

>>> help()

Welcome to MicroPython!


For online help please visit http://micropython.org/help/.


Quick overview of commands for the board:

pyb.info() -- print some general information

pyb.delay(n) -- wait for n milliseconds

pyb.millis() -- get number of milliseconds since hard reset

pyb.Switch() -- create a switch object

Switch methods: (), callback(f)

pyb.LED(n) -- create an LED object for LED n (n=1,2,3,4)

LED methods: on(), off(), toggle(), intensity(<n>)

pyb.Pin(pin) -- get a pin, eg pyb.Pin('X1')

pyb.Pin(pin, m, [p]) -- get a pin and configure it for IO mode m, pull mode p

Pin methods: init(..), value([v]), high(), low()

pyb.ExtInt(pin, m, p, callback) -- create an external interrupt object

pyb.ADC(pin) -- make an analog object from a pin

ADC methods: read(), read_timed(buf, freq)

pyb.DAC(port) -- make a DAC object

DAC methods: triangle(freq), write(n), write_timed(buf, freq)

pyb.RTC() -- make an RTC object; methods: datetime([val])

pyb.rng() -- get a 30-bit hardware random number

pyb.Servo(n) -- create Servo object for servo n (n=1,2,3,4)

Servo methods: calibration(..), angle([x, [t]]), speed([x, [t]])

pyb.Accel() -- create an Accelerometer object

Accelerometer methods: x(), y(), z(), tilt(), filtered_xyz()


Pins are numbered X1-X12, X17-X22, Y1-Y12, or by their MCU name

Pin IO modes are: pyb.Pin.IN, pyb.Pin.OUT_PP, pyb.Pin.OUT_OD

Pin pull modes are: pyb.Pin.PULL_NONE, pyb.Pin.PULL_UP, pyb.Pin.PULL_DOWN

Additional serial bus objects: pyb.I2C(n), pyb.SPI(n), pyb.UART(n)


Control commands:

CTRL-A -- on a blank line, enter raw REPL mode

CTRL-B -- on a blank line, enter normal REPL mode

CTRL-C -- interrupt a running program

CTRL-D -- on a blank line, do a soft reset of the board

CTRL-E -- on a blank line, enter paste mode


For further help on a specific object, type help(obj)

For a list of available modules, type help('modules')

>>>

This worked without flaws. Very impressive. With the internal memory of 512 kB, there are however only 40 kB left for programming and data storage. It is possible to add a SPI flash chip (4/8/16 MB) to the bottom of the board. Surface mounting of such a chip is difficult, therefore I think I might try with an external SPI flash module instead. The alternative would be to install CircuitPython instead. Adafruit provide firmware for the board.


MicroPython demonstration

on Serial USB Terminal App (Kai Morich)

connected with USB-C cable


(N.B. the phone does not manage to read the USB drive correctly)

Conclusion

The WeAct BlackPill boards are of much better quality than the various Blue Pills out there and they have a powerful chip with lots of memory. There is however strong competition from the ESP32 boards. The ESP32 has everything the BlackPill doesn't have: Wifi, Bluetooth and 4 MB flash memory but it has also a much higher power consumption. The BlackPill might be interesting for low power applications and the possibility to show up as USB drive in MicroPython is something the ESP32 can't do (at least right now). There is unfortunately not a lot of support for the BlackPill in the Arduino and MicroPython worlds. This might be the largest problem. There is the Arduino for STM32 site with many discussion forums but this seems to be for more advanced users. If you don't need as many GPIO pins for your project, you can use the Seeeduino Xiao instead, which is smaller and comes with a detailed wiki. Time will show if there is "enough project space" between the Xiao and the ESP32 for the BlackPill. Especially as there is another very similar newcomer: the Raspberry Pico, which certainly will come with very good documentation and support.

32-bit line-up with the more powerful ESP32 (with Wifi and bluetooth), the Black Pill and the smaller Seeeduino Xiao

© 2021 notthemarsian