Skip to content
storagebits

A 2020 watch, a complete firmware, three days

A 2020 T-Watch was sitting in a corner: developing for it took too much effort. In three days, with an agent, it got a firmware written from scratch and released under the MIT license.

4 min read#devlog#agents#esp32

I bought a LilyGO T-Watch 2020 six years ago, because it was cheap and ideal for testing and tinkering. Developing for it, on the other hand, took a real investment: C/C++, a framework to learn, some embedded know-how. It ended up in a corner, with other unfinished side projects.

With AI, all those brakes come off: within a few minutes, I had a complete firmware, written from scratch. Without AI, I would not have taken it out of the drawer: building anything on it took too much effort.

What devices are sleeping at your place? Imagine what you could make of them, in record time.

The post about the four days already told the story of the first flash. Here, I stay with the watch.

# What I wanted

An aviation chronograph dial and 7-segment displays in the style of “time circuits”. Then the weather, the buses and the iPhone notifications. The full list of apps is in the repository’s README.

My method comes down to two moves. I simply lay out the features I want. Then I immediately ask for a first end-to-end version, to get a short feedback loop. The result becomes convincing very quickly.

I steered the development in natural language, by stating intentions. Reading the generated code, I also learned a lot, about the language as much as about the frameworks and embedded concepts. The teaching value is huge!

# The beginning

First commit at 3:22 am. The mission prompt set two rules: back up the original 16 MB of flash before any write, and never touch the eFuses or the core voltage.

The backup nearly failed. At 921,600 baud, the USB port vanished in the middle of a read. The agent started over at 230,400 baud, in 1 MB blocks checked one by one, because above that the cable introduced errors. At 3:46 am, the full backup was verified and its SHA-256 hash recorded. At 3:48 am, the first verified flash on the watch.

I was a bit afraid of bricking the watch. I didn’t know where the fault came from; probably the cable. The agent took care of everything, down to trying a slow, chunked flash to work around that faulty cable (!). Its questions and its methods were relevant and precise, and that is what gave me confidence.

At 4:09 am, the aviator dial was on screen, with a second hand ticking at 8 Hz.

The aviation chronograph dial, captured from the real watch over the serial port: graduated bezel, three sub-dials for battery, minutes and steps, orange second hand

The aviator dial, captured on the real watch over the serial port. Capture already published in the previous post.

# The moment it broke

Plugged into USB, the watch held up. On battery, it crashed every single time after a few seconds. During the morning, I feared it was bricked, and I was pushing the agent to hurry before the next crash. I had to power it off and on again three times.

There were two causes, found one after the other. First, the processor’s watchdog stayed armed during light sleep. It is now suspended before going to sleep and re-armed on wake-up. Second, a press on the button froze the watch. The power chip’s interrupt line stays low until it is read, and the interrupt kept firing endlessly. GPIO interrupts are now disabled during sleep, and I saw that the watch held up very well.

# A decision: stop depending on the cable

The USB drop-outs kept coming back during flashes. There were two options: wait for the port to come back, or make the cable optional. The agent proposed a “workshop mode”: when the watch is powered over USB and Wi-Fi is configured, it stays connected, accepts over-the-air updates (OTA) and exposes a TCP console. Wi-Fi left on all the time is normally an anti-pattern. On mains power, the battery is not at stake, and the option can be turned off.

Since the cable kept failing, the agent switched to Wi-Fi updates (OTA) on its own. Magic! Later, the drop-outs also showed up while the processor was in its ROM bootloader: so the problem is hardware, not software. A safe mode followed: after three crashes in a row within the first minute, Bluetooth does not start, so the watch can always be repaired remotely.

The real T-Watch 2020 lying on the table: Kronograf diagnostic screen, memory, sensors detected in green, battery at 100%

The real watch on the diagnostic screen, the first screen flashed. Photo already published in the previous post.

# Where I stand

The cable problem (B2 in BLOCKERS.md) is still open: the micro-USB connection remains fragile. The double tap that wakes the screen is still a bit hit-and-miss, but it works. The wrist gesture to wake the watch still needs tuning. Battery life over a full day has not been measured yet.

What impressed me most is how quickly the agent flashed the watch on its own and showed me concrete results. I can’t wait to try it on other devices. In fact, I’ll soon be taking my micro:bits out again: I have an idea for a project!