One attraction of the STM32F103 series microcontrollers, is that there are lots of them available on eBay at ridiculously low prices. There are many variants of this µC, with flash memory sizes from 64K to 512K (and beyond, even), and with anything from 36 pins to 144 pins.
If you search on eBay for “stm32f103 board”, the first one that might pop up is perhaps this one:
Here are a few more, all running Mecrisp Forth 2.2.2:
There is no USB driver support in Mecrisp at the moment, so these have each been wired up with USB-serial interfaces. This will be needed as first step anyway, to flash Mecrisp onto the boards.
The procedure to upload Forth to such “Dime-A-Dozen” STM32F103 boards is always similar (although there are several alternatives):
- set the BOOT0 jumper to “1” (i.e. VCC)
- reset the board to put it into ROM-based serial boot mode
- get the latest
mecrisp-stellaris-stm32f103.bin
from SourceForge
And, lastly, run a command such as this to perform the upload:
python stm32loader.py -ewv -b 115200 -a 0x08000000 \
-p /dev/<your-tty-port> mecrisp-stellaris-stm32f103.bin
(or use one of the alternative tools listed in the above article, such as BMP or ST-Link)
Once loaded, restore the BOOT0 jumper to “0” (i.e. GND) and then press reset. You should now see a prompt such as this show up on the serial port (USART1 is on PA9 and PA10):
Mecrisp-Stellaris 2.2.2 for STM32F303 by Matthias Koch
Press return and you’ll get Mecrisp’s standard “ok.
” prompt. You’re in
business!
Something to keep in mind is that there is a single STM32F103 firmware image on SourceForge, which has been built for 64 KB flash and 20 KB RAM. Chips with more memory will work just fine, but Mecrisp won’t be aware of it - flash memory beyond 64K won’t be used for compiled code storage, and RAM beyond 20 KB won’t be allocated or used by Mecrisp (which could actually be an advantage if you want to manually allocate some large buffers).
This is just the tip of Mecrisp’s iceberg, though: there are over a dozen different builds for STM32 chips, including STM’s F3, F4, and F7 series. Each build makes assumptions about the serial port it starts up on, and may depend on having a crystal of a specific frequency installed - but these settings are fairly easily changed in the source code (even though it’s in assembler !).
Some other boards which have been verified to work are:
- the HY-MiniSTM32V board, with 3.2” LCD
- the RedDragon407 board from eBay, with USART3, 25 MHz crystal, and 3.2” LCD
- the Nucleo-32 F303 board, using USART2 instead of USART1, on PA2 and PA15
- the Nucleo-64 F302 board, using USART2 instead of USART1, on PA2 and PA3
The above boards are particularly convenient since they include a serial port to USB interface (all Nucleo boards also have ST-Link support for uploading).