2025 One Hertz Challenge: STM32 Blinks In Under 50 Bytes

Many of us have run a Blink program on a microcontroller before. It’s effectively the “Hello, World!” of the embedded space. However, few of us have ever thought about optimizing our Blink code to be as miniscule as possible. But that’s precisely what [Rudra Lad] did for this entry into the 2025 One Hertz Challenge!

This example of Blink, delay_blinky_13, is built specifically for the STM32F4 Discovery microcontroller development board. [Rudra] notes the code is “highly optimized” and compiles down to a binary size of under 50 bytes. The code doesn’t even use RAM, and it aims to get the blink as close to 1 Hz as possible. Many optimizations were used to crunch it down as small as possible. For example, the standard startup code isn’t used, with the entire program instead written in the Reset_Handler to save space. Bit-band is also used to write to peripheral registers to blink the LED, since this uses less instructions than the typical methods. Meanwhile, with many tweaks to the delay counting routine, [Rudra] was eventually able to get the blink frequency to 1.00019 Hz, as measured on a logic analyzer. That’s pretty darn close!

While it’s rare that you have only 50 bytes of binary space to blink an LED, work like this is a great way to flex your coding muscles. Code is on Github for the curious, and if you’ve worked up your own impressive tiny binaries, don’t hesitate to let us know!

Continue Reading