[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

@@ -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;