-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* readme update Signed-off-by: Adam BZH <[email protected]> * update readme for firmware hash check --------- Signed-off-by: Adam BZH <[email protected]>
- Loading branch information
1 parent
082d539
commit 1ddc9c5
Showing
1 changed file
with
51 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,51 @@ | ||
# bluetooth-firmware-classic | ||
BLE firmware used by classic devices. | ||
# OneKey Classic 1/1S Bluetooth Firmware | ||
|
||
This repo contains bluetooth firmware for OneKey Classic 1 and 1S | ||
|
||
The firmware is based on NRF5 SDK 16.0.0, and build with Makefile | ||
|
||
## How to build | ||
|
||
```shell | ||
# make sure you have cmake, Python 3, amd aarm-none-eabi toolchain available in PATH | ||
|
||
# export your OWN key for firmware signing | ||
export BT_SIG_PK=$(cat <<EOF | ||
-----BEGIN EC PRIVATE KEY----- | ||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | ||
-----END EC PRIVATE KEY----- | ||
EOF | ||
) | ||
|
||
# build binaries first | ||
./make_binaries.sh | ||
|
||
# then convert binaries to images with signature | ||
./make_images.sh | ||
``` | ||
|
||
## How to verify firmware hash | ||
|
||
Install Python 3.x | ||
|
||
Download latest `ota.bin`, open a terminal in the same folder, invoke python, then run following code | ||
|
||
```python | ||
import struct, hashlib | ||
|
||
with open("ota.bin", mode="br") as f: | ||
f.seek(0x0C) | ||
codelen = struct.unpack("i", f.read(4))[0] - 512 | ||
f.seek(0x600) | ||
print("".join(format(x, "02x") for x in hashlib.sha256(f.read(codelen)).digest())) | ||
``` | ||
|
||
Single line version | ||
|
||
```python | ||
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""") | ||
``` | ||
|
||
## License | ||
|
||
Please check License.md for details |