[realtek-ambz2] Flash bootloader & partition table in UF2

This commit is contained in:
Kuba Szczodrzyński
2023-07-13 17:00:42 +02:00
parent a3bbdf1c16
commit 4d81fcac26
4 changed files with 13 additions and 5 deletions

View File

@@ -416,6 +416,8 @@ if not isfile(image_ota_clear):
queue.BuildLibraries()
# Main firmware outputs and actions
image_part_table = "${BUILD_DIR}/image_part_table.${FLASH_PART_TABLE_OFFSET}.bin"
image_bootloader = "${BUILD_DIR}/image_bootloader.${FLASH_BOOT_OFFSET}.bin"
image_firmware_is = "${BUILD_DIR}/image_firmware_is.${FLASH_OTA1_OFFSET}.bin"
env.Replace(
# linker command (dual .bin outputs)
@@ -424,6 +426,9 @@ env.Replace(
UF2OTA=[
# same OTA images for flasher and device
f"{image_firmware_is},{image_firmware_is}=device:ota1,ota2;flasher:ota1,ota2",
# having flashed an application image, update the bootloader and partition table (incl. keys)
f"{image_bootloader}=device:boot;flasher:boot",
f"{image_part_table}=device:part_table;flasher:part_table",
# clearing headers of the "other" OTA image (hence the indexes are swapped)
f"{image_ota_clear},{image_ota_clear}=device:ota2,ota1;flasher:ota2,ota1",
],

View File

@@ -36,6 +36,11 @@ bool UpdateClass::begin(
__attribute__((unused)) uint8_t ledOn,
__attribute__((unused)) const char *label
) {
#if !LT_HAS_OTA
LT_E("OTA is not yet supported on this chip!");
this->errArd = UPDATE_ERROR_BAD_ARGUMENT;
return false;
#endif
if (this->ctx) {
return false;
}
@@ -165,7 +170,7 @@ size_t UpdateClass::writeStream(Stream &data) {
// read data to fit in the remaining buffer space
auto bufSize = this->ctx->buf_pos - this->ctx->buf;
auto read = data.readBytes(this->ctx->buf_pos, UF2_BLOCK_SIZE - bufSize);
auto read = data.readBytes(this->ctx->buf_pos, UF2_BLOCK_SIZE - bufSize);
// increment buffer writing head
this->ctx->buf_pos += read;
// process the block if complete

View File

@@ -4,8 +4,6 @@
#include <uf2ota/uf2ota.h>
#define UF2_CTX_SIZE (sizeof(uf2_ota_t) + sizeof(uf2_info_t))
static inline size_t lt_ota_buf_left(lt_ota_ctx_t *ctx) {
return ctx->buf + UF2_BLOCK_SIZE - ctx->buf_pos;
}
@@ -18,7 +16,7 @@ void lt_ota_begin(lt_ota_ctx_t *ctx, size_t size) {
if (!ctx)
return;
memset((void *)ctx + UF2_CTX_SIZE, 0, sizeof(lt_ota_ctx_t) - UF2_CTX_SIZE);
memset(ctx, 0, sizeof(lt_ota_ctx_t));
uf2_ctx_init(&ctx->uf2, lt_ota_get_uf2_scheme(), lt_cpu_get_family());
uf2_info_init(&ctx->info);
ctx->buf_pos = ctx->buf;

View File

@@ -17,7 +17,7 @@ from platformio.platform.base import PlatformBase
from platformio.platform.board import PlatformBoardConfig
from semantic_version import SimpleSpec, Version
LTCHIPTOOL_VERSION = "^4.0.1"
LTCHIPTOOL_VERSION = "^4.2.3"
# Install & import tools