F103 + USB = Swiss Army Knife May 2017

The USB driver for STM32F103 has been around for months and it’s proving to be very stable and usable. The current Mecrisp release now includes it, and there’s an F303 port available.

The original code and inspiration for this driver came from Eckhart Köppen’s early CoreForth implementation. While changes and a whole lot of head-scratching was needed, his code was proof that implementing a serial port driver in Forth was worth trying, and ulitmately: doable!

Having a Forth implementation interacting via serial USB is a big deal, because of the large variety of very low-cost F103-based boards on eBay. With Forth installed, and some utility code such as from the Embello project, you end up with a plug-and-play jack-of-all-trades gadget:

The no toolchain aspect is quite important, as it means that you can take such a board with you, and use it to start trying out physical-computing related stuff wherever you are:

… as well as all the obvious tasks of reading out button states, encoders, driving LEDs, connecting relay-, motor-, or stepper-drivers and … making real things “happen”.

When you need more I/O pins and more interfaces than the TQFP-48 package on the low-end F103 boards provide: there are also 100-pin and 144-pin packages, with considerably more I/O, more h/w interfaces, and more features (like DACs) - search for “STM32F103 board” on eBay.

To use a Blue Pill and others for all sorts of quick / ad-hoc projects requires:

  1. A simple way to upload Mecrisp and additional Forth code onto each new board
  2. Access to easy-to-use documentation for the (over 750!) pre-loaded “words”

Part one is handled by Folie, which can upload a USB firmware image IF you have a BUB III, modified BUB, or SerPlus-enabled board (or else a BMP or ST-Link, with proper software).

For details on how to upload a complete USB-enabled image to one of several common F103 boards with Folie, see this README on GitHub. There is a nasty chicken-and-egg problem involved in creating a suitable BUB- or SerPlus-like interface, but once you have such a thing, turning an F103-based µC board into this Swiss Army Knife will be a piece of cake.

Part two has not yet been covered as well, unfortunately. There’s a new documentation area in the Embello repository on GitHub, used to generate this site - but it’s still early days.

The main words in the Mecrisp core are (tersely) documented on the official glossary page.

If you would like to help improve on this, by improving the documentation, or by contributing general-purpose code, or drivers for some USART/I2C/SPI device, please consider submitting a pull request, which is GitHub’s powerful way of collaborating on open source projects. With a pull request, your contribution will not only show up among all the others, Git also archives the complete logs of who contributed what and when, i.e. giving full attribution to everyone.

As well as an honourable mention, as a small-but-sincere token of appreciation.

Weblog © Jean-Claude Wippler. Generated by Hugo.