Skip to content

Commit be3739f

Browse files
authored
update readme for firmware hash check (#50)
1 parent b723ef0 commit be3739f

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,28 @@ OnekeyProBTFW_FACTORY_HEX
3737
OnekeyProBTFW_FLASH_FACTORY
3838
```
3939

40+
## How to verify firmware hash
41+
42+
Install Python 3.x
43+
44+
Download latest `ota.bin`, open a terminal in the same folder, invoke python, then run following code
45+
46+
```python
47+
import struct, hashlib
48+
49+
with open("ota.bin", mode="br") as f:
50+
f.seek(0x0C)
51+
codelen = struct.unpack("i", f.read(4))[0] - 512
52+
f.seek(0x600)
53+
print("".join(format(x, "02x") for x in hashlib.sha256(f.read(codelen)).digest()))
54+
```
55+
56+
Single line version
57+
58+
```python
59+
exec("""\nimport struct, hashlib\nwith open("ota.bin", mode="br") as f:\n f.seek(0x0C)\n codelen = struct.unpack("i", f.read(4))[0] - 512\n f.seek(0x600)\n print("".join(format(x, "02x") for x in hashlib.sha256(f.read(codelen)).digest()))\n""")
60+
```
61+
4062
## License
4163

42-
Please check License.md for details
64+
Please check License.md for details

0 commit comments

Comments
 (0)