The Blue Pill is a wonderful little board, and my first choice for many projects requiring a small and very low-cost µC board. Especially with PlatformIO’s excellent support for it.
Even for retrocomputing – the hobby of emulating old computers from decades ago – a Blue Pill can be used: see my recent Turning a Blue Pill into a Z80 article for an example. This could easily be extended further: adding more (external) RAM, flash, an SD card, etc.
But there’s another more advanced range of STM32 µC’s which is also widely available online, from all the usual Chinese websites and outlets: the STM32F40x series.
Of these, by far the most widespread is the F407 (I’ll leave the STM32 prefix off most of the time, since the context is usually clear). It can run considerably faster, has quite a bit more memory, and includes a lot more peripherals that the basic F103 µC on a Blue Pill:
- it’s based on the ARM Cortex M4 design with hardware floating point
- maximum clock speed up to 168 MHz, with built-in 16 MHz RC clock
- 512..1024 KBytes of flash memory and 196 KBytes of RAM
- a plethora of UART / SPI / I2C / PWM peripherals
- 2x USB, 2x CAN bus, SDIO card interface
- Ethernet controller (this requires external hardware)
- multiple ADCs and DACs, for fast analog I/O conversions
- multi-channel DMA controller for most peripherals
- a Flexible Static Memory Controller (FSMC)
The FSMC exposes the internal address and data buses in such a way that external memory chips can be hooked up, with fast access from the CPU and DMA controller.
A good fit for retro use
A major benefit of the F407 over the medium-size F103 in the Blue Pill, is the amount of built-in RAM: 196 KB. This is more than sufficient for supporting a Z80 with not just 64 KB, but even with banked memory.
With banked memory, up to 3 banks of 48 KB plus one common bank of 16 KB could be allocated, or alternately 4 banks of 32 KB plus a common bank of 32 KB. This requires 160 KB, leaving a very comfortable 36 KB for other emulator and interface uses.
Another useful aspect of the F407, is that it comes in variants with 512 KB to 1024 KB of flash memory. This allows emulating 1 to 3 small floppy disks (using the 8” SSSD format as reference, which is 251 KB each). In other words, a bare F407 chip could emulate a CP/M system, including one or more (virtual) floppy disks for permanent data storage.
But this is not (yet?) about soldering SMD chips - let’s look at some ready-made boards.
The DIY MORE F407VG
One of the lowest-cost F407 boards on eBay is the “DIY MORE” board with 100-pin F407:
Note the typo in the name, English is no doubt as hard for someone from China to read and understand, as Chinese is for the rest of the world! Here is the (labeled) back side:
This board is as minimal as it gets: there are 8 MHz and 32768 Hz crystals, RESET and USER (PD15) buttons, a power LED and a user LED (PE0), and a micro-USB jack. There’s neither a JTAG / SWD connector, nor a USART header - even though these I/O pins are present, they have not been broken out as separate connectors.
The DIYMORE F407 board has the “VG” variant F407, i.e. 100-pin and with 1024 KB flash built-in. Which is nice, most low-end F407 boards are “VE” and only have 512 KB flash.
The Black F407VE
Another slightly larger board, and now in fact my favourite step up from the Blue Pill, is the “Black F407” (that’s not an official name, but what the STM32duino wiki page calls it):
This board includes a lot of interesting and useful add-ons:
- a 2 MB flash memory chip (via SPI)
- a µSD card socket (via SPI or SDIO)
- a backup battery for the F407’s Real Time Clock
- a JTAG header, which includes all the SWD pins
- a 2x4 header for an NRF24L01 radio module
- a 2x16 header for a 320x240 TFT-LCD screen
- a pair of user LEDs (PA6+PA7) and 3 buttons (PA0+PE3+PE4)
- a mini-USB jack (see comments below)
- a beefy 3.3V regulator, for powering extra add-ons
- proper pin labels on the “right” side of the board, i.e. on top
The flash memory chip and especially the SD card socket will be very handy for storing a virtually unlimited number of virtual floppy- and hard-disk images.
The JTAG connector is a standard 2x10 pin sideways header, which I hardly ever use. Instead, I’ve hacked together a custom “converter plug” for my preferred 6-pin hookup, with (from left to right): GND, SWD CLK/DIO, USART RX/TX, and +3.3V.
It may not be the prettiest, but it works splendidly.
Uploads over USB
A big advantage of the F407 over the F103, is that it supports Device Firmware Upgrades (DFU) over USB. This means that for simple first-use installation, no special programmer, Black Magic Probe, or other SWD / JTAG / serial upload tool is needed. You just need to put the board into boot mode via the two red jumpers shown above, and use the open-source dfu-util tool to upload a firmware image to the F407.
That’s perfect for novice use and field updates - but for development, an SWD + serial link is more effective. Hence my cobbled-together hack in the picture above.
Another great use for the USB port, is to supply power and connect to a serial-over-USB console for retro use. This requires a driver for the F407’s built-in USB hardware.