From 5b4cf53d8a74ca8ab44aad5b96eb14554c0b7808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Thu, 2 Jun 2022 14:14:16 +0200 Subject: [PATCH] [tools] uf2ota: embed build date in extension tags --- arduino/libretuya/libraries/Update/uf2ota/uf2types.h | 1 + docs/ota/README.md | 1 + tools/uf2ota/models.py | 1 + tools/uf2ota/uf2ota.py | 3 +++ 4 files changed, 6 insertions(+) diff --git a/arduino/libretuya/libraries/Update/uf2ota/uf2types.h b/arduino/libretuya/libraries/Update/uf2ota/uf2types.h index c8d09e4..2ecf80a 100644 --- a/arduino/libretuya/libraries/Update/uf2ota/uf2types.h +++ b/arduino/libretuya/libraries/Update/uf2ota/uf2types.h @@ -72,6 +72,7 @@ typedef enum { UF2_TAG_OTA_VERSION = 0x5D57D0, // format version UF2_TAG_BOARD = 0xCA25C8, // board name (lowercase code) UF2_TAG_FIRMWARE = 0x00DE43, // firmware description / name + UF2_TAG_BUILD_DATE = 0x822F30, // build date/time as Unix timestamp UF2_TAG_LT_VERSION = 0x59563D, // LT version (semver) UF2_TAG_PART_1 = 0x805946, // OTA1 partition name UF2_TAG_PART_2 = 0xA1E4D7, // OTA2 partition name diff --git a/docs/ota/README.md b/docs/ota/README.md index f2fa38b..35e638d 100644 --- a/docs/ota/README.md +++ b/docs/ota/README.md @@ -49,6 +49,7 @@ Name | ID | Type | Description `OTA_VERSION` | 0x5D57D0 | int 8-bit | format version (for simple compatibility checks) `BOARD` | 0xCA25C8 | string | board name / code (lowercase) `FIRMWARE` | 0x00DE43 | string | firmware description / name +`BUILD_DATE` | 0x822F30 | int 32-bit | build date/time as Unix timestamp `LT_VERSION` | 0x59563D | semver | LT version `LT_PART_1` | 0x805946 | string | OTA1 partition name `LT_PART_2` | 0xA1E4D7 | string | OTA2 partition name diff --git a/tools/uf2ota/models.py b/tools/uf2ota/models.py index 680d0b7..0fd7621 100644 --- a/tools/uf2ota/models.py +++ b/tools/uf2ota/models.py @@ -65,6 +65,7 @@ class Tag(IntEnum): OTA_VERSION = 0x5D57D0 # format version BOARD = 0xCA25C8 # board name (lowercase code) FIRMWARE = 0x00DE43 # firmware description / name + BUILD_DATE = 0x822F30 # build date/time as Unix timestamp LT_VERSION = 0x59563D # LT version (semver) LT_PART_1 = 0x805946 # OTA1 partition name LT_PART_2 = 0xA1E4D7 # OTA2 partition name diff --git a/tools/uf2ota/uf2ota.py b/tools/uf2ota/uf2ota.py index 229aaf2..b829e6d 100644 --- a/tools/uf2ota/uf2ota.py +++ b/tools/uf2ota/uf2ota.py @@ -1,6 +1,7 @@ # Copyright (c) Kuba SzczodrzyƄski 2022-05-27. from argparse import ArgumentParser +from datetime import datetime from zlib import crc32 from dump import uf2_dump @@ -21,6 +22,7 @@ def cli(): parser.add_argument("--board", help="Board name/code", type=str) parser.add_argument("--version", help="LibreTuya core version", type=str) parser.add_argument("--fw", help="Firmware name:version", type=str) + parser.add_argument("--date", help="Build date (Unix, default now)", type=int) args = parser.parse_args() if args.action == "info": @@ -70,6 +72,7 @@ def cli(): uf2.put_int8(Tag.OTA_VERSION, 1) uf2.put_str(Tag.DEVICE, "LibreTuya") + uf2.put_int32le(Tag.BUILD_DATE, args.date or int(datetime.now().timestamp())) any_ota1 = False any_ota2 = False