Skip to content

Commit

Permalink
Add version number to the firmware header. && bump version to 2.3.3 (#52
Browse files Browse the repository at this point in the history
)

* Add version number to the firmware header.

* bump firmware version to 2.3.3
  • Loading branch information
lihuanhuan authored Dec 6, 2024
1 parent 338c2a0 commit 82f4ec8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/firmware_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
0xEEBBEE /**< DUMMY Organisation Unique ID. Will be passed to Device Information Service. You shall use the \
Organisation Unique ID relevant for your Company */
#define HW_REVISION "1.0.0"
#define FW_REVISION "2.3.2"
#define FW_REVISION "2.3.3"
#define SW_REVISION "s132_nrf52_7.0.1"
#define BT_REVISION "1.0.1"

Expand Down
27 changes: 27 additions & 0 deletions utils/ota_to_onekey_bin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
import struct
import zipfile
import click
import re

# input_file = "../artifacts_signed/ota.zip"
# output_file = "../artifacts_signed/ota.bin"

INIT_DATA_SIZE = 512

OFFSET_MAGIC = 0x00
OFFSET_VERSION_MAJOR = 0x10
OFFSET_VERSION_MINOR = 0x11
OFFSET_VERSION_PATCH = 0x12
OFFSET_HASHES = 0x20
OFFSET_NRF_DAT_SIZE = 0x400
OFFSET_NRF_DAT = 0x404
Expand Down Expand Up @@ -50,11 +54,34 @@ def gen_hashes(data: bytes) -> bytes:
return hashes

def gen_onekey_bin(nrf_dat: bytes, nrf_bin: bytes) -> bytes:

header_file = "../app/firmware_config.h"

with open(header_file, "r") as file:
content = file.read()

match = re.search(r'#define\s+FW_REVISION\s+"([^"]+)"', content)

major = 0
minor = 0
patch = 0

if match:
version_string = match.group(1)
major, minor, patch = map(int, version_string.split('.'))

buffer = io.BytesIO()

buffer.seek(OFFSET_MAGIC, 0)
buffer.write(b"5283")

buffer.seek(OFFSET_VERSION_MAJOR, 0)
buffer.write(struct.pack("B", major))
buffer.seek(OFFSET_VERSION_MINOR, 0)
buffer.write(struct.pack("B", minor))
buffer.seek(OFFSET_VERSION_PATCH, 0)
buffer.write(struct.pack("B", patch))

buffer.seek(OFFSET_NRF_DAT_SIZE, 0)
buffer.write(struct.pack("i", len(nrf_dat)))
buffer.seek(OFFSET_NRF_DAT, 0)
Expand Down

0 comments on commit 82f4ec8

Please sign in to comment.