|
|
|
now I can change my firmware remotely Thursday, January 15 2026
The weather today was cooler and sunnier as a mass of cold dry arctic air arrived. But there was no additional snow on the ground, so my firewood salvaging continued, though at a more leisurely pace.
This afternoon I went out with my firewood-hauling backpack and made a load out of some wood from the big white ash 100 feet upstream from where the Stick Trail crosses the Chamomile. I split up one of the big rounds to make it fit in my backpack and added another quarter of a round, thereby making a typical load (weighing between 80 and 100 pounds). All of this wood went directly into the woodshed, as there wasn't space for additional firewood in the living room.
Yesterday I'd begun work on adding a command to my ESP8266 Remote Control firmware that tells the device to do an over-the-air firmware update using whatever is found at a URL. Today I refined this so that a url not beginning with http:// would be assumed to be local on the server, and if a file didn't even begin with a slash, then it would be handled by the backend by streaming that file (if found) from a location in a hidden flash firmware directory. The actual flashing of the firmware over-the-air had me nervous, but doing it looked extremely easy. All I had to do was call the command ESPhttpUpdate.update() that ChatGPT had told me about. After a few false starts issuing the wrong command, I was able to successfully flash a firmware over-the-air from a directory on my server. This was huge, because it meant that I no longer would have to go to the cabin to code running on the ESP8266s there. It also meant that I could update all the various devices I have from anywhere; there would be no more dragging a laptop out to the ESP8266 running near the propane tank (unless I was dealing with hardware issues).
Later I got bogged down in a maddening problem where a url pasted into Chrome would deliver a flashable image by http, but when that same URL was sent via the ESP8266, it got nothing. I kept asking ChatGPT about it and doing all sorts of debugging, but I was getting nowhere. ChatGPT was insisting there must be spurious characters being introduced into the http data, but that clearly wasn't happening. It was only later, when I gave ChatGPT a little more code context, that it figured out what was happening. My code was using a cookie to lookup a tenant_id, which it needed to lookup a device_type so that it could get the name of the architecture ("ESP8266") so that it would know what strings would be in the names of the flash image files so that it could find the very latest one when I used the word "latest" instead of the name of a file. But the ESP8266 (as well as cURL, which I also tried) doesn't keep cookies on it; all its web transactions are stateless and authenticated with shared secrets. So the lookup was failing and it was never producing a filename, and thus it was never producing any file contents. It was obvious once ChatGPT pointed this out, but up until then it had felt like I was working with an irrational black magic. So I ended up having to rework the data flow so that architecture information flowed to the ESP8266 so that it would have it available when it came time to lookup the latest flash image on the server.
For linking purposes this article's URL is: http://asecular.com/blog.php?260115 feedback previous | next |