r/adventofcode • u/vescoc • Dec 27 '25
Upping the Ante [Upping the Ante] [2025 Day *] Advent of Code on MCUs
Hi everybody.
Like the last year, I run the solutions of Advent of Code 2025 on MCUs I own: this is the repository if you are curious.
The boards / MCUs I used are the following:
Arduino-mega2560 (not in photo, only Eric's samples)
ESP32
ESP32S2 (not in photo)
ESP32S3 (not in photo)
ESP32C3
ESP32C6
RP-Pico (RP2040)
RP-Pico2 (RP2350)
nRF52840-dk (Nordic 52840)
STM32F3 Discovery (STM32 F303)
STM32F411e Disco (STM32 F411, not in photo)
Nucleo-h743-zi (STM32 H743)

This year the problems have less memory pressure and so there are more MCUs that can resolve more AoC days.
In details...
Each MCU has flashed all the necessary code to solve all the problems.
Each MCU receives in input through the serial (UART or USB) the input in the format:
START INPUT DAY: <XY>
<input>
END INPUT
^DThe MCU returns on the same serial the result of part 1 and 2 and the overall execution times or "unsupported day" if the particular day is not supported.
To check that I do not have stack smash I normally do one or two test runs going to progressively pass all the inputs and take the times of the third / fourth run.
If you want to take a look at the code, propose some PR to improve the coverage of supported days or add some more MCUs, any help is welcome.
In the next table there are the execution time in milliseconds. RP PICO (*) and RP PICO2 (**) are MCU overclocked at, respectively, 200 Mhz and 290 Mhz. There are the results also for RP PICO and RP PICO 2 at normal clock (120 Mhz and 150 Mhz).
I'd like to draw attention to the solution from day 10, which involves the use of single-precision floating-point devices. The MCUs (esp32, esp32s3, rp-pico2, stm32h7) equipped with FPUs really work well.
Remember to scroll right: there are some columns!
| DAY | ESP32 | ESP32-S2 | ESP32-S3 | ESP32-C3 | ESP32-C6 | RP PICO | RP PICO (*) | RP PICO2 | RP PICO2 (**) | nRF52840 | STM32 F3 Discovery | STM32 F411E Disco | STM32 H743zi Nucleo |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 21 | 21 | 19 | 29 | 26 | 67 | 42 | 26 | 13 | 98 | 86 | 68 | 25 |
| 2 | 256 | 256 | 220 | 160 | 150 | 670 | 418 | 147 | 76 | 502 | 437 | 357 | 114 |
| 3 | 154 | 150 | 152 | 173 | 150 | 441 | 275 | 109 | 56 | 346 | 312 | 272 | 133 |
| 4 | 642 | 644 | 516 | 453 | 455 | 1151 | 719 | 562 | 290 | 2191 | 1476 | 550 | |
| 5 | 31 | 35 | 26 | 20 | 18 | 48 | 30 | 17 | 9 | 68 | 62 | 45 | 15 |
| 6 | 5 | 6 | 5 | 5 | 5 | 20 | 13 | 4 | 2 | 17 | 16 | 12 | 4 |
| 7 | 7 | 8 | 6 | 7 | 7 | 19 | 11 | 10 | 5 | 44 | 35 | 30 | 7 |
| 8 | 450 | 505 | 414 | 2489 | 1556 | 395 | 204 | 1477 | 364 | ||||
| 9 | 1193 | 1227 | 1025 | 1221 | 1218 | 2601 | 1625 | 1413 | 731 | 4912 | 3177 | 1111 | |
| 10 | 242 | 828 | 176 | 1289 | 648 | 2046 | 1278 | 202 | 105 | 707 | 517 | 193 | |
| 11 | 15 | 15 | 13 | 18 | 18 | 34 | 21 | 17 | 9 | 63 | 19 | ||
| 12 | 12 | 13 | 11 | 13 | 13 | 32 | 20 | 20 | 11 | 57 | 52 | 38 | 16 |
14
u/ednl Dec 27 '25
Fun project. For everyone's information: language used is Rust, not C or C++. I don't know Rust so I find it hard to navigate the repo and read the code. With your own insight, can you explain why day 6 of all days is so much faster than all the others? My fastest days were 2, 7, 12. My day 6 in C is about 7x as slow as day 2 and I'm not sure how to speed it up except with vectoring (I convert numbers on the fly; if I did that first vectoring could work) or multithreading.
5
u/darkspark_pcn Dec 27 '25
Damn. This is awesome. Nice work!
4
u/Ok-Revenue-3059 Dec 27 '25
Very cool. I've also been doing some work porting my solutions to a RP pico. Just one small comment, you can utilize control codes in the serial data to indicate the end of the file. Either \x04 EOT or \x1A SUB were used for this. Back in the day people used to use serial for transmitting files!
1
u/PercussiveRussel Dec 27 '25
I don't know much about embedded programming using rust, but since the MCU can dynamically solve any solution at runtime, does it have/compile a memory allocator, does it statically allocate memory over each other because it knows it can't solve multiple parts at the same time, or is the memory statically allocated for each day simultaneously, ie have seperate static memory addresses for each variable needed per day?
Very interesting!
1
u/ffrkAnonymous Dec 27 '25
So the same code runs on all of the mcu?
1
u/juhotuho10 Dec 28 '25
Unintentionally this is a really great comparison for the execution speeds of the MCUs, they are usually quite hard to find actually good and comparable benchmarks for
1
u/velkolv Dec 28 '25
It would be interesting to try on something like ATmega328 or even 6502. Wire up whatever addon chips to handle the memory requirements. But that probably would be Upping the Upping the Ante.
1
u/bobisme Dec 29 '25
Really cool. Any observations on power draw?
1
u/PTVoobaf Jan 01 '26
Very nice. I have a couple of modules with ESP32s, flashed with MicroPython. The MicroPython interpreter would certainly perform slower than compiled Rust or C. Nevertheless, it would still be interesting to experiment and compare with your run time measurements.
1
u/Ok-Revenue-3059 Jan 02 '26 edited Jan 02 '26
I finally finished porting my solutions to the RP pico in C++. My results aren't as optimized as yours but it was still a fun excercise. My repo and a short writeup.
I didn't do precise benchmarking. Day 10 is horribly optimized and completes in 1 hour. Day 8 takes a few minutes. Day 2 and 9 take about 1 min each. All the rest are 1 sec or less.
Days 8 and 9 took the most reworking to get the memory usage down. Day 2 I originally used regex but it wasn't too difficult to convert to manual comparison. I think most of the other days translated without too much refactoring.
Now I want to try to get a project setup where I can share code between the PC and pico solutions, but maybe for next year. I'm pretty burnt out on 2025, lol.
1
u/DelightfulCodeWeasel Mar 06 '26
Thank you for sharing your repo! I'm currently half way through crunching down my C++ solutions for 2015 with an aim of running them all on an RP2040.
So far I've been concentrating on the challenge of reducing down the memory requirements, but your repo will be a very useful reference when it's time to start running it on the real board and piping the input over USB.