Remote Updates of Sipeed NanoKVM firmware
The Sipeed NanoKVM is a pretty neat device. Level 1 Techs review:
The procedure to update firmware however, is a little obscure.
The system has two components:
- The Firmware - the embedded linux image that boots the device; and
- The NanoKVM application - which runs the Web UI and does video encoding etc etc.
The application itself can be updated within the Web UI, but the firmware itself is a little more invasive. The officially supported way to do this is to pull out the microSD card and reflash the entire device. If you’ve got the device installed somewhere remote, or can’t easily get the device apart, this is a pain in the butt. So, here’s a bit of a hacky way to update the device without actually pulling it apart.
Step 1: Grab the latest firmware image from the github releases page. At the time of writing this, the latest firmware is 1.3.0.
Step 2: Mount the image file to get access to the goodies inside:
1
2
3
4
$ mkdir -p tmp/boot tmp/rootfs
$ sudo kpartx -a 20241120_NanoKVM_Rev1_3_0.img
$ sudo mount /dev/mapper/loop0p1 tmp/boot
$ sudo mount /dev/mapper/loop0p2 tmp/rootfs
Step 3: Get the NanoKVM ready. Log in via SSH and then do the following - making sure not to reboot from now on, or you will have to reflash the SD manually…
Make sure you do this on the NanoKVM - not your desktop!
1
# rm -fR /boot/*
Step 4: Back on your desktop, copy everything from the mounted image to the NanoKVM:
1
2
3
$ scp tmp/boot/* root@<kvm ip>:/boot/
$ cd tmp/rootfs/
$ sudo rsync -axv --delete-before . root@<kvm ip>:/
Step 5: Validate that your filesystem on the NanoKVM looks good - if you mess up here, you’re back to flashing the SD card anyway.
On the NanoKVM, ensure that your boot partition looks like:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# ls -l /boot/
total 11728
-rwxr-xr-x 1 root root 11553428 Jan 10 17:31 boot.sd
-rwxr-xr-x 1 root root 439808 Jan 10 17:31 fip.bin
-rwxr-xr-x 1 root root 0 Jan 10 17:31 gt9xx
-rwxr-xr-x 1 root root 3621 Jan 10 17:31 logo.jpeg
-rwxr-xr-x 1 root root 132 Jan 10 17:39 resolv.conf
-rwxr-xr-x 1 root root 0 Jan 10 17:31 usb.dev
-rwxr-xr-x 1 root root 0 Jan 10 17:31 usb.disk0
-rwxr-xr-x 1 root root 0 Jan 10 17:31 usb.rndis0
-rwxr-xr-x 1 root root 28 Jan 10 17:31 ver
-rwxr-xr-x 1 root root 1 Jan 10 17:31 wifi.pass
-rwxr-xr-x 1 root root 1 Jan 10 17:31 wifi.ssid
-rwxr-xr-x 1 root root 0 Jan 10 17:31 wifi.sta
Make sure the /
path looks like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# ls -l /
total 100
lrwxrwxrwx 1 root root 7 Sep 20 06:00 bin -> usr/bin
drwxr-xr-x 2 root root 16384 Jan 1 1970 boot
drwxr-xr-x 2 root root 32768 Jan 1 1980 data
drwxr-xr-x 11 root root 4780 Jan 10 17:39 dev
drwxr-xr-x 19 root root 4096 Jan 10 17:39 etc
drwxr-xr-x 6 root root 4096 Jan 10 17:39 kvmapp
lrwxrwxrwx 1 root root 7 Sep 20 06:00 lib -> usr/lib
lrwxrwxrwx 1 root root 3 Sep 20 06:00 lib64 -> lib
lrwxrwxrwx 1 root root 11 Sep 20 06:00 linuxrc -> bin/busybox
drwx------ 2 root root 16384 Nov 13 01:58 lost+found
drwxr-xr-x 2 root root 4096 Sep 20 06:00 media
drwxr-xr-x 5 root root 4096 Sep 20 06:00 mnt
drwxr-xr-x 2 root root 4096 Sep 20 06:00 opt
dr-xr-xr-x 140 root root 0 Jan 1 1970 proc
drwx------ 3 root root 4096 Jan 10 17:39 root
drwxr-xr-x 8 root root 440 Jan 10 17:37 run
lrwxrwxrwx 1 root root 8 Sep 20 06:00 sbin -> usr/sbin
dr-xr-xr-x 11 root root 0 Jan 1 1970 sys
drwxrwxrwt 5 root root 180 Jan 10 17:39 tmp
drwxr-xr-x 7 root root 4096 Sep 20 06:00 usr
drwxr-xr-x 5 root root 4096 Sep 20 06:00 var
If all goes well, reboot the IP KVM and it should boot, then start loading the app back onto the device. After a little wait, the device should work as normal again but with an updated firmware…
Step 6: Clean up your PC…
1
2
3
4
$ cd ../..
$ sudo umount tmp/boot tmp/rootfs
$ sudo kpartx -d 20241120_NanoKVM_Rev1_3_0.img
$ rmdir tmp/boot tmp/rootfs
I hope this saves the hassle that is disassembling the NanoKVM to get at the microSD card!