diary at Telent Netowrks

Images of U#

Tue, 17 Jul 2018 16:27:37 +0000

Last week I outlined a plan that uses kexec to reboot into a new image without access to U-Boot or having to flash it. Because I don't think an upgrade path that required popping the top off every device and attaching a serial console cable is much of a path.

Getting kexec to work turned out to involve a little more work than I think I was hoping for, mostly because I want to be able to boot the same uImage from kexec as will be flashed and booted from u-boot, and the kexec userland utility on MIPS doesn't support uImage format.

Conclusion: someone somewhere needs to get a grip, though I'm open to the possibility that it's me.

On MIPS, a uImage file contains a raw binary file - this is not the same thing as an Image - which has optionally been compressed by gzip or by lzma (though, note, not by xz in its lzma compatibility mode, which generates streaming files that u-boot can't load). Which is basically another way of saying "none of the above, and there isn't a lot of code in kexec you can reuse either".

Getting the payload out of the uImage is fairly painless: we just had to add an offset . But then we have to decompress it. The existing lzma decompression code in kexec works only on files, so we can't reuse it here because the data is in memory already. So we have to write a whole new bunch of code to decompress LZMA in RAM.

Some day I will submit this upstream, but I think it could stand some considerable cleanup first. For the moment I've added it as a patch to our kexectools derivation.

Next week: actually implement the kexec reboot/upgrade dance. Then maybe move my archive disk onto the new box, so we can start work on the broadband router.