The 2boots bootloader is a lovely bootloader, developed by Thomas Seiler that is
- Just 2kb of flash, fits into normal 2kb bootblock of most atmega chips
- Serial (stk500v1) bootloader, compatible with avrdude and Arduino IDE
- Additional MMC bootloader, can read directly a intel .hex format file from an MMC/SD
What is appealing here is the ability to upload firmware without a programmer, simply by inserting a SD card with the .HEX file and performing a reset. That is a nice feature to have when having to remotely update the firmware – imagine that you have multiple nodes at clients in many locations: they can upgrade firmware quite easily now.
I (and many others) have previously tried to get it working, but couldn’t; we ended up using another bootloader that is SD card only (and .bin, not .hex compatible) and 4Kb.. I shared my experience here and here. Clearly 2boots is better..if only it was working. After failing to get it run, I have abandoned the project until recently I noticed some activity in Thomas’ github repository. There seems to be some fixes introduced and I decided to give it a new try. It didn’t work again, so I took a deeper look. It seems that he had another branch (new-makefile) in the repository that was having quite a bunch of changes, I tested it too and noticed that there is improvement: it did update the firmware from SD card, but only after a successful serial upload..odd? After couple days of debugging and testing, it turns out that there is a logical problem in the stk500v1.c file – it performs a WDT reset after timing out on serial, therefore the MMC upload procedure was never called unless preceded by a successful serial sketch upload.. duh. I fixed that by using a “break;” instead of performing watch-dog reset and Voila – it worked!