Gadgetbridge: Programmatically determine version of Mi Band 2 firmware files

Created on 8 Mar 2017  路  4Comments  路  Source: Freeyourgadget/Gadgetbridge

In order to improve the firmware update UX, we need to determine the version of Mi Band 2 firmware files Mili_pro.fw and maybe even the font files (*.ft and *.ft.en).

At the moment, we hardcode hashes of the firmware and associate them with a version, so this only works for firmware known prior to a Gadgetbridge release.

Help appreciated, even if it's just a description "read byte at offset x, jump to the read value and the next x bytes are the version.

device mi band 2 help wanted

All 4 comments

I found it via "strings".
strings /home/tim/Backups/Mili_pro.fw > fw.txt
fw.txt
Searching for "34" in this output shows you the version. But I do not know how to program anything.
I hope it helped.

Thanks for your help. There should be a way to find the position of this string, though. E.g by looking at a fixed offset, then reading a specifc value there which holds the position of the firmware version. Then you can read the value at that position.

A workaround would be to look for strings with numbers and 3 dots in them, right :-]

Well there is the following option for strings:
-t --radix={o,d,x} Print the location of the string in base 8, 10 or 16
So i can get a log with the location in the correct format and then we can look further.
Which "base"(I even don't know what that means) do you need?

EDIT:
Well or like this:
fw_d.txt
fw_o.txt
fw_x.txt

EDIT2: Here is the same from FW version 1.0.0.39, so you can compare the locations
fwold_d.txt
fwold_o.txt
fwold_x.txt

@cpfeiffer
A fresh idea: I tried opening the files in a hex editor, and what did I see:
The firmware version formatting is always defined before, so we can take this as a starting point for the read out:
Here the part in character form: .V%d.%d.%d.%d.V%s.1.0.1.39
Here the same in hex: 00 56 25 64 2E 25 64 2E 25 64 2E 25 64 00 56 25 73 00 31 2E 30 2E 31 2E 33 39
As I see this sequence is just this one time in the file and identical in all firmware files.
So the firmware is located directly after: .V%d.%d.%d.%d.V%s.
Or in hex: 00 56 25 64 2E 25 64 2E 25 64 2E 25 64 00 56 25 73 00

Unfortunately I am not a programmer and can not write any code. Thats just an idea. Are you able to do that, or are there some limitations?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Jiack214 picture Jiack214  路  4Comments

yarons picture yarons  路  7Comments

gianlucapir picture gianlucapir  路  7Comments

MagicFab picture MagicFab  路  7Comments

wYhyzByH picture wYhyzByH  路  4Comments