Close

First Version - STM32L031G6

A project log for Tiny Arduino for Hackers

A dime-sized, ARM-based Arduino complete with a programming/development system.

doctekdoctek 12/22/2020 at 02:040 Comments

For the initial design of a tiny Arduino, I chose the STM32L031G6 microprocessor. I had already determined that the SWD programming and debug port would work with the footprint I had developed for the ATTINY84 (link above in the Description). The 28 pin version seemed to cover all Uno functionality, plus. And I naively thought that 32K of flash (same as an Uno and Teensy2) would be plenty. There was a Nucleo 32 board with a 32 pin version of the L031 which I bought for testing. The first two boards (the tiny version and a breadboard version) were designed and are pictured below.

The resulting tiny version was not quite as small as an ATTINY85, but it's still pretty small! There are only three decoupling caps on the tiny version due to it's small size. Some might quibble with that decision, but it works so far. The BOOT0 pin is tied low since the SWD port is used to load code and debug. Everything else found on an Uno is omitted. I add circuitry if it is needed for a particular application. So far, I have had to add the I2C pull-up resistors.  A voltage source must be provided in the 1.8V to 3.6V range - I use 3 to 3.3V typically. Note the notches on the sides of the board. These are to position the programmer. (Described later.) The breadboard version is also useful as just a low-cost Arduino to use with projects. Here is the schematic and a view of the board design for the tiny version.

Since this version has been deprecated, the KiCAD files are not included.

While I thought the hard part of the design would be the hardware, I expected the software to be easy. I knew that there was a version of the ST software for Arduino (via the usual Library Manager) and I expected to just use that. However, when I tried a simple I2C program, I was shocked and saddened to see that it took 22K of flash (70%)! Since a similar program on a Teensy2 takes only 5K (15%), this was a show stopper! There followed many months of learning much more about the Arduino environment and the internals of the ST32L031 than I ever intended. I won't bore you with details of the forum posts and how to use the LL version of the ST library vice the HAL version, but the result was that the I2C program now ran in only 3.7K  (12%) of memory. More work was required to make analog pins (ADC and PWM) work properly, implement a timer, and have GPIO working. I still needed to implement SPI and the UART. To get things this far, I had modified the STM Arduino Library to use my code and to recognize my unique board. (I'll discuss necessary modifications in the next Build Log.) But I realized there is no future in this path! I don't plan to support custom software which might have to track new versions. And much better integration with the Arduino environment is needed.

Getting to this stage took over a year. I spent another 6 months or so mulling over how to proceed with this project. I really liked the concept, but the software details were killing me. Fortunately, by this time ST had introduced the STML071 series. This series had much more flash: 64K, 128K and even 192K. There was also a new rev of the Arduino Library. A few experiments convinced me that I could use unmodified code and fit it easily into these larger memories. The ST code is still bloated for these small processors, but the additional memory makes them usable. On to the next version!


Discussions