Skip to content

Commit 82f4ec8

Browse files
authored
Add version number to the firmware header. && bump version to 2.3.3 (#52)
* Add version number to the firmware header. * bump firmware version to 2.3.3
1 parent 338c2a0 commit 82f4ec8

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

app/firmware_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
0xEEBBEE /**< DUMMY Organisation Unique ID. Will be passed to Device Information Service. You shall use the \
1212
Organisation Unique ID relevant for your Company */
1313
#define HW_REVISION "1.0.0"
14-
#define FW_REVISION "2.3.2"
14+
#define FW_REVISION "2.3.3"
1515
#define SW_REVISION "s132_nrf52_7.0.1"
1616
#define BT_REVISION "1.0.1"
1717

utils/ota_to_onekey_bin.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@
55
import struct
66
import zipfile
77
import click
8+
import re
89

910
# input_file = "../artifacts_signed/ota.zip"
1011
# output_file = "../artifacts_signed/ota.bin"
1112

1213
INIT_DATA_SIZE = 512
1314

1415
OFFSET_MAGIC = 0x00
16+
OFFSET_VERSION_MAJOR = 0x10
17+
OFFSET_VERSION_MINOR = 0x11
18+
OFFSET_VERSION_PATCH = 0x12
1519
OFFSET_HASHES = 0x20
1620
OFFSET_NRF_DAT_SIZE = 0x400
1721
OFFSET_NRF_DAT = 0x404
@@ -50,11 +54,34 @@ def gen_hashes(data: bytes) -> bytes:
5054
return hashes
5155

5256
def gen_onekey_bin(nrf_dat: bytes, nrf_bin: bytes) -> bytes:
57+
58+
header_file = "../app/firmware_config.h"
59+
60+
with open(header_file, "r") as file:
61+
content = file.read()
62+
63+
match = re.search(r'#define\s+FW_REVISION\s+"([^"]+)"', content)
64+
65+
major = 0
66+
minor = 0
67+
patch = 0
68+
69+
if match:
70+
version_string = match.group(1)
71+
major, minor, patch = map(int, version_string.split('.'))
72+
5373
buffer = io.BytesIO()
5474

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

78+
buffer.seek(OFFSET_VERSION_MAJOR, 0)
79+
buffer.write(struct.pack("B", major))
80+
buffer.seek(OFFSET_VERSION_MINOR, 0)
81+
buffer.write(struct.pack("B", minor))
82+
buffer.seek(OFFSET_VERSION_PATCH, 0)
83+
buffer.write(struct.pack("B", patch))
84+
5885
buffer.seek(OFFSET_NRF_DAT_SIZE, 0)
5986
buffer.write(struct.pack("i", len(nrf_dat)))
6087
buffer.seek(OFFSET_NRF_DAT, 0)

0 commit comments

Comments
 (0)