-
Adding firmware update OTA
02/08/2019 at 21:19 • 1 commentThis week i added a new functionnality to Binky : Software Update OTA (over the air). Over the wires for me, as binky is using ethernet cable, but you get it.
The idea, is to be able to launch a complete update of Binky when i'm doing changes on the software without having to dissassemble it.
I want the F-OTA as simple as possible. The Linux image running on the Rasberry-PI is build with buildroot. It's easy with it to build a Linux kernel image with a root filesystem bundled. The goal of such system, is to have in one piece of binary the whole software you want to use. So you get in a zImage, the Linux kernel as well as the root filesystem containing squeezebox, squeezeznfc, and all the softwares needs to run Binky.
As we are running all this stuff on a Raspberrypi, we are relying on the proprieraty bootloader wich have to be run from a Fat32 partition.
We are so using buildroot to generate the whole SDCARD the firstime, and when we want to upgrade, we only have to change the zImage.
The Fw OTA is designed arroundca Web service runing on any machine on your local network and a shell script running on the radio.
The webservice is writtin in go, and is answering to this :
- the API point /latest : returning a json containing the latest know version of Binky, and where the fw can be downloaded
- The fw path : /fw/binky_v2.ota, wich returns the whole file
The shell script is comparing the current version of the software it is running on, and the latest version returned by the Web Service. If a new version is present, the script donwload it, check SHA256 of the file, and change zImage of the Fat32 partition with the new file downloaded.
And finally reboot the board.
That's really easy and simple, you have to trigger the upgrade from binky itself. The script can be found here : https://github.com/naguirre/binky_buildroot/blob/master/br_external/board/raspberrypi3/rootfs_overlay/usr/sbin/upgrade.sh
The webservice can be found here : https://github.com/naguirre/binky_update_ws