icedream / denon-prime4

Fork of @ghuntley's Denon Prime 4 firmware research repository for experimental purposes.
MIT License
14 stars 1 forks source link

Implement updater tool #60

Open icedream opened 4 months ago

icedream commented 4 months ago

This tool is entirely written from scratch to replace the original Denon one we have been using thus far for releases of the custom firmware.

Implementation

The updater uses Google's Go wrapper around libusb to reimplement FastBoot, the protocol used for flashing inMusic devices (and various other Linux-based devices).

It can be built with either a purely Go implementation of xz or, if go build tag libxz is set, a cgo wrapper around the native xz library for efficient on-the-fly image decompression. The variable in go/Makefile defaults to setting the libxz tag. Some code had to be copied over to my repository to allow determining the exact amount of data to be transferred to the device as it is required for the flashing procedure. This is also then used for progress display purposes.

Matching device IDs as well as firmware version is read from the generated Device Tree Blob file, SHA1 checksum verification for the images contained in the DTB is also implemented. All other info is read from a supplied config.toml file of which its entire structure is packed into a Go struct type.

The GUI is implemented using gioui. This allows clear separation of state and UI rendering without over-complications usually encountered with other frameworks I've so far tried. A Go-side built-in font is used for rendering the UI to avoid system font rendering issues in Wine during testing. It was originally even slower while I was using a data copy buffer in the FastBoot code of 4096 bytes, increasing that to 16384 bytes helped. I suspect I could set it even higher for more performance but didn't test it yet.

This is not the most optimized implementation as the fastboot CLI is able to flash the entire firmware within 30 seconds whereas this implementation takes slightly over twice as long.

The updater generation script has been modified to use this file and to not copy the updater file to manipulate 7z to include all files without paths anymore.

The devices list also has been updated to carry proper display names for every device, the name is used as part of the generated config.toml file for the new updater.

Screenshots

image

Known issues

References