Skip to content

Commit

Permalink
ReadME Update (#15)
Browse files Browse the repository at this point in the history
* 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
424778940z authored Aug 9, 2024
1 parent 082d539 commit 1ddc9c5
Showing 1 changed file with 51 additions and 2 deletions.
53 changes: 51 additions & 2 deletions README.md
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

0 comments on commit 1ddc9c5

Please sign in to comment.