This repository contains a sort-of an Advent of Code, but it's blinkenlights on various microcontroller boards.
The goal was simple - create a nontrivial project that runs on multiple different platform dating as far back as the 1970'ties. Natuarally, the project couldn't be too complex, as some of these platforms are fairly limited in terms of memory, so a 16-LED strip "blinkenlights" was chosen.
Each board expects to sink current for 16 LEDs connected to the pins listed in main.cpp. There are several time-based animations available that switch each minute. The boards are also logging some stuff on their respective main serial consoles.
Cores: ESP32-C6, High Performance Risc-V and Low Power Risc-V, 32 bit
Core voltage: 3.3V
Clock: 160 MHz for HP, 20 MHz for LP
SRAM: 512K for HP, 16k for LP
FLASH: 320K (internal, expandable externally)
GPIO: 22 (some not available on a convenient header)
Peripherals: 2.4 GHz Wi-Fi 6 (802.11ax), Bluetooth 5 (LE), IEEE 802.15.4 (Zigbee), 3 * SPI (two for external flash), 3 * UART (one low-power), 2 * I2C (one low-power), I2S, RMT, 2 * TWAI, SDIO, Motor Control PWM, 7-channel 12-bit ADC, USB 2.0, WDT, 7 timers (various functions)
Other: Built-in core temperature sensor, built-in AES, RSA and HMAC. JTAG debugger support, LiPo battery charger
Power draw: 0.1W (not changing the LiPo battery, WiFi & BT powered down)
The caveat for this board is the fact that some of the GPIOs available on the headers are used for USB communication, either making it harder to program the board when these pins are used, or having to solder the much less convenient microdot pins.
This board implements the RTC HAL routines with NTP, so it doesn't require setting up the time, but does require a WiFi connection to be set up.
export WIFI_SSID='\"...\"'
export WIFI_PASS='\"...\"'
make supermini-clean && make supermini-upload
Core: STM32L432KC, ARM Cortex-M4, 32 bit
Core voltage: 1.65V - 3.6V
Clock: 80 MHz
SRAM: 64K
FLASH: 256K
GPIO: 20 I/O (some require jumper setting changes)
Peripherals: 2 * SPI, 2 * I2S, 2 * I2C, 2 * 10-channel 12-bit ADC, DAC, 3 * UART, CAN, USB 2.0, 4 timers, HW RNG, RTC (no power backup)
Other: Built-in STLink/v2-1, JTAG debugger support
Power draw: 0.325W
This chip has an RTC built-in, but it does not expose the V_BAT pin, so no backup power-down mode is available.
make nucleo-clean && make nucleo-upload
Core: STM32F103C8T6, ARM Cortex-M3, 32 bit
Core voltage: 2V - 3.6V
Clock: 72 MHz
SRAM: 20K
FLASH: 64K
GPIO: 32 I/O (some only 3V3-capable, PA13, PA14 and PA15 with reduced electrical capability)
Peripherals: 2 * SPI, 2 * I2C, 2 * 10-channel 12-bit ADC, 3 * UART, CAN, USB 2.0, 4 timers, RTC
Other: External batery connection for RTC backup, JTAG debugger support
Power draw: 0.15W
make bluepill-clean && make bluepill-upload
Cores: MSP430 FR2355, 16 bit
Core voltage: 1.8V - 3.6V
Clock: 24 MHz, 32 kHz clock, 10 kHz low power oscillator
SRAM: 4k
ROM: 20k
FRAM: 32k program, 512 data
GPIO: 44, various functions
Peripherals: 12-channel 12-bit ADC, 12-bit DAC, 5 16-bit timers, hardware multiplier, 2 * SPI, 2 * UART, 2 * I2C, 16-bit CRC, 16-bit RTC timer, WDT, JTAG
Other: low-power ferroelectric RAM & other power-related optimization features, Built in eZ-FET debugger, low-power tracing capability, on-board ambient light sensor
Power draw: 0.11W
Initially the project did not build as the vectors section overlapped the text section of the binary - HC11 linker memory map would be picked up by the MSP430 GCC to use instead of the proper MSP one.
The platform uses Platform IO, but requires some additional setup:
- Install
python 2.7as it is required for upload viadsliteto work. - Alternatively, use the
mspdebugupload tool withtilib(aka. MSP Debug Stack):
cd msp430
# wget https://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPDS/3_15_1_001/export/MSPDebugStack_OS_Package_3_15_1_1.zip
mkdir build
cd build
unzip ../MSPDebugStack_OS_Package_3_15_1_1.zip
cd ..
patch -p0 < mspdb.patch
cd build
make
cd ../..
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:`pwd`/msp430/build"
- Alternatively, you can obtain the
libmsp430.sofrom CCS: https://www.ti.com/tool/CCSTUDIO#downloads mspdebugmight need to be update outside of PlatformIO as the version bundled with Platform IO does not detect the eZ-FET probe on the board.
make msp-launchpad-clean && make msp-launchpad-upload
Core: ATmega328p, AVR, 8bit
Core voltage: 5V (can go as low as 2.7V at slower clock)
Clock: 16 MHz
SRAM: 2k
EEPROM: 1k
FLASH: 32k
GPIO: 23
Peripherals: 2 * SPI, I2C, UART, 8-channel 10-bit ADC, 3 timers (2 8-bit and one 16-bit), WDT
Other: On-board serial programmer/debugger based around another ATmega chip.
Power draw: 0.15W
An external I2C DS3231 RTC is supported for this board.
make uno-clean && make uno-upload
Core: MC68HC11A1FN, M68HC11, 8 bit
Core voltage: 5V
Clock: 8 MHz
SRAM: 8k (external), 512 internal
EEPROM: 16k (external), 512 internal
GPIO: 11 I/O (Port D, Port A), 11 input only (Port A, Port E)
Peripherals: UART (with RS232 port), SCI, SPI, 8-channel 8-bit ADC, 5 timers (16-bit, varying functions), WDT
Other: Ports B and C are used for memory bus expansion, board supports up to 32k chips (any mix of EEPROM and SRAM), on-board bootloader and debugger (Bufalo 3.4, occupies 8k of EEPROM), LCD connector, SS keypad connector, expandable memory-mapped peripherals.
Power draw: 0.5W (9V input)
Requires an m68hc11 toolchain:
cd hc11
mkdir -p build/bin
export PATH=$PATH:`pwd`/build/bin
# Binutils
# wget https://ftp.gnu.org/gnu/binutils/binutils-2.39.tar.gz
tar zxvf binutils-2.39.tar.gz
mv binutils-2.39 binutils-m68hc11-elf-2.39
cd binutils-m68hc11-elf-2.39
./configure --prefix=`pwd`/../build --target=m68hc11-elf
make
make install
cd ..
# GCC
# wget https://ftp.gnu.org/gnu/gcc/gcc-3.4.6/gcc-core-3.4.6.tar.gz
tar zxvf gcc-core-3.4.6.tar.gz
# Patch the sources (see below)!
patch -s -p0 < gcc.patch
mv gcc-3.4.6 gcc-m68hc11-elf-3.4.6
cd gcc-m68hc11-elf-3.4.6
./configure --prefix=`pwd`/../build --target=m68hc11-elf
make
make install
cd ..
# GEL LibC
# https://sourceforge.net/projects/gel/files/gel-hc1x/1.6.1/gel-hc1x-1.6.1.tar.gz/download
tar zxvf gel-hc1x-1.6.1.tar.gz
# Patch the sources (see below)!
patch -s -p0 < gel.patch
cd gel-hc1x-1.6.1
make TARGET_BOARD=m68hc11-cme11
cd ..
mkdir -p build/lib
mkdir -p build/include
cp -r gel-hc1x-1.6.1/lib/* build/lib
cp -r gel-hc1x-1.6.1/include/* build/include
The GCC sources need a patch:
-
Patch
config.guessby copying the one from binutils package. -
Patch
intl/configureat line 1151 to changemain(){return(0);}toint main(){return(0);} -
Patch
libiberty/regex.creplacing the bogus declarations ofchar *malloc();andchar *realloc();at lines 132 and 133 with#include <stdlib.h> -
Patch
libiberty/md5.cadding#include <string.h>. -
Patch
libiberty/getcwd.creplacingextern char *getwd();on line 33 withextern char *getwd(char*); -
Patch
libiberty/getpwd.creplacingextern char *getwd();on line 41 withextern char *getwd(char*); -
Patch
libiberty/pex-unix.creplacingextern int execv();on line 47 withextern int execv(const char*, char * const*); -
Patch
libiberty/pex-unix.creplacingextern int execvp();on line 48 withextern int execvp(const char*, char * const*); -
Patch
libiberty/pex-unix.creplacingint (*func)();on line 59 withint (*func)(const char*, char * const*); -
Patch
gcc/collect2.cat line 1537 to add(S_IRUSR|S_IWUSR)as third parameter to open (required with theO_CREATflag, see here for the error you get without patching) -
Patch
gcc/config/m68hc11/larith.asmat line 97 to read.space 2instead of.dc.w 1(to reserve uninitialized space for the virtual regs) -
Patch
gcc/cpplib.creplacingU"#";on line 194 with(const uchar*)U"#" -
Patch
gcc/cpplib.creplacingU"pragma dependency";on line 659 with(const uchar*)U"pragma dependency" -
Patch
gcc/cpplex.cadding(const uchar*)before everyU-prefixed string on line 42 -
Patch
gcc/cpplex.cadding(const uchar*)before everyU-prefixed string on line 42 -
Patch
gcc/cppmacro.cadding(const uchar*)beforeU-prefixed strings on lines 223 and 224 -
Patch
gcc/insn-output.caddingextern int m68hc11_is_far_symbol (rtx);at the top. -
Patch
gcc/insn-output.caddingextern int m68hc11_is_trap_symbol (rtx);at the top.
As a convenience, there is a patch file in the repo: hc11/gcc.patch
The GEL sources also need patching:
- Changing the
m6811-elf-binutils prefix tom68hc11-elf-where appropriate. - Removing any
.ccfiles from the makefiles as C++ is not supported.
As a convenience, there is a patch file in the repo: hc11/gel.patch
Building the project is then a matter of:
make cme11a-clean && make cme11a
truncate --size=8k firmware/cme11a.bin
The project can be uploaded to a CME11-type board via serial and hc11/upload.py script. You may need to upgrade the U5 RAM chip to 32k.
Alternatively, you can update the hc11/memory.x memory map to point the text section to U6 EPROM space and burn it into a ROM chip. You will need to update the reset vector in Buffalo EPROM U7 to point to 0x8000 for the program to start automatically.
If you want to retain the interactive debugging bootloader, a modified Buffalo monitor is provided in hc11/buf341.asm. In can be compiled with asm11 and burned to the U7 ROM chip. It's not exctly the same as the version on the board, but the functionality is complete. The modification causes Buffalo to jump to 0x8000 when pin 0 of PORTE is high at boot.
A modified version of the original Axiom Buffalo 3.4AX ROM is available in hc11/buf34ax.bin and a modified version that allows running ROM code in hc11/buf341ax.bin. This was modified by hand using the hc11/bufpatch.asm
The Buffalo Monitor sources come from this repository: https://github.com/tonypdmtr/buffalo
The code seems to be licensed under the MIT license terms (included in hc11/LICENSE.buffalo).
Core: Z80, 8 bit
Core voltage: 5V
Clock: 2.4576 MHz
SRAM: 8k
EEPROM: 8k
GPIO: 16 I/O via Z80 PIO, 16 input only via memory mapped registers.
Peripherals: 2 * UART (Z80 SIO), RTC (ICM7170IPG), 4 Timers (Z80 CTC), WDT (MAX691CPE).
Other: SRAM & RTC battery backup (MAX691CPE), second EEPROM slot (max 8k).
Power draw: 2.5W (9V input)
More on the card here: https://github.com/Idorobots/temex-reverse
Some caveats with this board:
- Most of the chips on the board had to be replaced due to all kinds of weird failures - the original chips include the CPU, SIO, MAX691CPE and the misc 74XX logic.
- The CPU reset line (from MAX691CPE) had a massive capacitor on it, causing erractic boot up behaviour. Had to be replaced with a smaller value.
- Neither EEPROM nor RAM slots utilize the top two JEDEC-pinout address lines, meaning that no more than 8k of memory is addressable in each slot, despite the memory mapping allowing for 16k addresses. The board can be modified to support 32k ROM and 16 RAM (although, all slots need to be populated with 32k chips).
- RTC/NVRAM battery was not present, not sure what type should be used.
- RTC clock's oscillator circuit is hooked up to the main 5V line, meaning that when there's no power, it does not oscillate. Very real time, much convenient.
- RTC chip requires pullups on RD & WR lines during external backup. These were not present on the board preventing the chip from counting time during backup.
Requires SDCC & related binutils. Tested under the following version:
SDCC : mcs51/z80/z180/r2k/r2ka/r3ka/sm83/tlcs90/ez80_z80/z80n/r800/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8/pdk13/pdk14/pdk15/mos6502/mos65c02/f8 4.5.0 #15242 (Linux)
To build the project:
make temex-clean && make temex
truncate --size=8k firmware/temex.bin
Flash the ROM chip in EEPROM1 position.
Core: None - discrete 74XX series logic, CMOS
Core voltage: 2V - 6V
Clock: 4.194304 MHz
SRAM: None
EPROM: 32k
GPIO: None
Peripherals: None (3 8-bit counters, I guess 🤷)
Other: ---
Power draw: 0.02W at 3V
This version uses 2 EPROM chips to store the animation data and a 4040-counter-based address generator to index those memories. Clock crystal was selected so that the animation timing matches the other boards.
make hw-clean && make hw








