|
|
|
LED blink pattern feedback Wednesday, January 21 2026
This morning after I got out of bed, I had some ideas in my head for how next to make progress on my I2C bootloader attempt, which has been mired in various ChatGPT-facilitated quagmires. To properly debug what was happening during the bootloader, I needed feedback, and mostly all I had to work with (at least in my mind) was the single GPIO-controlled LED on the Arduino Nano that was serving as my slave. I couldn't use normal Arduino techniques to make that LED flash, as the bootloader environment doesn't provide access to the normal Arduino conveniences and when it is doing bootloader things, the microcontroller can only be programmed in raw C. I tried using ChatGPT-suggested ways for getting that LED to flash, but they didn't work. So then I looked around in the existing bootloader code and figured out how the authors of that had done it, and eventually I found a place in code where I could reliably make that LED flash a pattern. By seeing whether or not that LED illumination pattern was produced, I was able (over the course of many reflashes of the bootloader firmware) to determine that the technique I was using to pass a value between my slave sketch (the code that does all the slave things) and the bootloader (running on the same microcontroller, but at a different time) was not working. ChatGPT had suggested I add an __attribute__((section(".noinit"))) attribute to a variable, which supposedly would allow it to keep its value through something as severe as a watchdog-initiated reboot. But my tests, using nothing but LED flashes to determine whether or not code was reached, demonstrated that the values I was passing were being erased. So then ChatGPT suggested a different technique where we reserved a couple bytes at the top of physical RAM. But I could see that would never work the moment ChatGPT mentioned that the entire hardware stack would have to be above it (where there are exactly zero bytes). (Interestingly, this somehow didn't occur to ChatGPT as it was telling me this information.) Ultimately I decided to pass values using EEPROM. It wasn't my first choice, since EEPROM, unlike RAM, is subject to wear. But the feature I was using it for would rarely be used, and whenever it was used (the slave's firmware was being changed), there would also be wear from that in the flash, and indeed that wear would be more severe. Using EEPROM, I was finally able to pass values between the bootloader and the slave sketch, meaning I could cause the slave to boot into the bootloader on command. This was a key feature necessary to be able to command the slave to go into a mode where it would receive its new firmware from the master. It felt like I was maing real progress on a project that only yesterday had seemed Sisyphean.
Later, as I tried to figure out why data being blasted from the master was not being written to flash on the slave, I realized I needed a way for the slave to tell me more complicated things than what was possible by flashing a single LED. It occurred to me that the slave has a serial port, so why not just send debugging texts to me that way? That seemed simple in theory, but in practice, all I could get the serial port to do from the bootloader C environment was give me non-deterministic garbage. I thought maybe the baud rate was off due to some timing mixup, but no matter what baud rate I tried to view the data with, it was chaos. ChatGPT tried to help me fix the problem, but none of its suggestions worked, and soon I was stuck in another LLM doom loop.
It was actually nice to be able to take a break to walk Charlotte at around 3:30pm; we went up the Farm Road and then back through the scrub forest in the highlands to its west. There was about six inches of very soft snow on the ground, as temperatures had remained very cold since it fell.
Back at the house, I cooked spaghetti with broccoli again and had a pan full of onions (red and yellow), tofu, and crimini mushrooms. I was only cooking one meal this week, so of course it had to be spaghetti. After watching two episodes of Jeopardy!, I immediately went into the laboratory to resume my I2C bootloader experiments. Later when I came to bed, Gretchen commented that it would be nice in the future if we could have at least one conversation per day, perhaps at the end of the dinner we watch in front of the teevee. I get the feeling my I2C bootloader obsession has made us a bit more into ships passing in the night. I've never even mentioned that I am working on it to her, since I can't imagine her understanding what the hell it does (or why we have a need for I2C slaves to begin with).
For linking purposes this article's URL is: http://asecular.com/blog.php?260121 feedback previous | the future |