Add run firmware in RAM feature

This commit is contained in:
Marek Kraus
2024-06-19 18:09:16 +02:00
parent 7a85414ece
commit b583ec46f9
11 changed files with 145 additions and 13 deletions
+9 -5
View File
@@ -19,7 +19,7 @@ static blisp_return_t blisp_easy_transport_read(
transport->data.memory.current_position += size;
return size;
} else {
return fread(buffer, size, 1, transport->data.file_handle);
return fread(buffer, size, 1, transport->data.file.file_handle);
}
}
@@ -28,9 +28,13 @@ static blisp_return_t blisp_easy_transport_size(
if (transport->type == 0) {
return transport->data.memory.data_size;
} else {
// TODO: Implement
printf("%s() Warning: calling non-implemented function\n", __func__);
return BLISP_ERR_NOT_IMPLEMENTED;
if (transport->data.file.file_size == -1) {
FILE* handle = transport->data.file.file_handle;
fseek(handle, 0, SEEK_END);
transport->data.file.file_size = ftell(handle);
rewind(handle);
}
return transport->data.file.file_size;
}
}
@@ -43,7 +47,7 @@ static void blisp_easy_report_progress(blisp_easy_progress_callback callback,
}
struct blisp_easy_transport blisp_easy_transport_new_from_file(FILE* file) {
struct blisp_easy_transport transport = {.type = 1, .data.file_handle = file};
struct blisp_easy_transport transport = {.type = 1, .data.file.file_handle = file, .data.file.file_size = -1};
return transport;
}