[FL-2517, FL-2518, FL-2523] Updater UI overhaul (#1196)

* Updater: UI rework initial
* Updater: further updates to UI, added a temporary parrot
* Updater: additional checks on radio stack type before update
* Second iteration of updater UI: additional handling of resource unpacking errors
* updater: removed extra logging, renamed some stages
* Updater: Changed "back" button icon on error screen
* Archive: signed/unsigned fix
* Updater: cancelling update also cancels LFS+resources processing; restored /ext/update/ folder magic to 0
* Updater: root dir fix

Co-authored-by: nminaylov <nm29719@gmail.com>
This commit is contained in:
hedger
2022-05-06 19:26:25 +03:00
committed by GitHub
parent 4d6b170769
commit 37bd0d546a
19 changed files with 275 additions and 179 deletions

View File

@@ -111,19 +111,13 @@ static bool update_task_write_stack_data(UpdateTask* update_task) {
}
bytes_read = storage_file_read(update_task->file, fw_block, n_bytes_to_read);
if(bytes_read == 0) {
break;
}
CHECK_RESULT(bytes_read != 0);
int16_t i_page =
furi_hal_flash_get_page_number(update_task->manifest->radio_address + element_offs);
if(i_page < 0) {
break;
}
CHECK_RESULT(i_page >= 0);
if(!furi_hal_flash_program_page(i_page, fw_block, bytes_read)) {
break;
}
CHECK_RESULT(furi_hal_flash_program_page(i_page, fw_block, bytes_read));
element_offs += bytes_read;
update_task_set_progress(
@@ -142,19 +136,19 @@ static void update_task_wait_for_restart(UpdateTask* update_task) {
static bool update_task_write_stack(UpdateTask* update_task) {
bool success = false;
UpdateManifest* manifest = update_task->manifest;
do {
FURI_LOG_W(TAG, "Writing stack");
update_task_set_progress(update_task, UpdateTaskStageRadioImageValidate, 0);
CHECK_RESULT(update_task_open_file(update_task, update_task->manifest->radio_image));
CHECK_RESULT(update_task_open_file(update_task, manifest->radio_image));
CHECK_RESULT(
crc32_calc_file(update_task->file, &update_task_file_progress, update_task) ==
update_task->manifest->radio_crc);
manifest->radio_crc);
CHECK_RESULT(update_task_write_stack_data(update_task));
update_task_set_progress(update_task, UpdateTaskStageRadioInstall, 0);
CHECK_RESULT(
ble_glue_fus_stack_install(update_task->manifest->radio_address, 0) !=
BleGlueCommandResultError);
ble_glue_fus_stack_install(manifest->radio_address, 0) != BleGlueCommandResultError);
update_task_set_progress(update_task, UpdateTaskStageRadioInstall, 80);
CHECK_RESULT(ble_glue_fus_wait_operation() == BleGlueCommandResultOK);
update_task_set_progress(update_task, UpdateTaskStageRadioInstall, 100);
@@ -280,7 +274,6 @@ bool update_task_validate_optionbytes(UpdateTask* update_task) {
manifest->ob_write_mask.obs[idx].values.base) != 0;
if(can_patch) {
/* patch & restart loop */
const uint32_t patched_value =
/* take all non-writable bits from real value */
(device_ob_value & ~(manifest->ob_write_mask.obs[idx].values.base)) |
@@ -297,8 +290,7 @@ bool update_task_validate_optionbytes(UpdateTask* update_task) {
if(!is_fixed) {
/* Things are so bad that fixing what we are allowed to still doesn't match
* reference value
*/
* reference value */
FURI_LOG_W(
TAG,
"OB #%d is FUBAR (fixed&masked %08X, not %08X)",
@@ -317,11 +309,11 @@ bool update_task_validate_optionbytes(UpdateTask* update_task) {
}
}
if(!match) {
update_task_set_progress(update_task, UpdateTaskStageOBError, 95);
update_task_set_progress(update_task, UpdateTaskStageOBError, 0);
}
if(ob_dirty) {
FURI_LOG_W(TAG, "OB were changed, applying");
FURI_LOG_W(TAG, "OBs were changed, applying");
furi_hal_flash_ob_apply();
}
return match;
@@ -332,24 +324,18 @@ int32_t update_task_worker_flash_writer(void* context) {
UpdateTask* update_task = context;
bool success = false;
update_task->state.current_stage_idx = 0;
update_task->state.total_stages = 0;
do {
CHECK_RESULT(update_task_parse_manifest(update_task));
if(!string_empty_p(update_task->manifest->radio_image)) {
if(update_task->state.groups & UpdateTaskStageGroupRadio) {
CHECK_RESULT(update_task_manage_radiostack(update_task));
}
bool check_ob = update_manifest_has_obdata(update_task->manifest);
if(check_ob) {
update_task->state.total_stages++;
if(update_task->state.groups & UpdateTaskStageGroupOptionBytes) {
CHECK_RESULT(update_task_validate_optionbytes(update_task));
}
if(!string_empty_p(update_task->manifest->firmware_dfu_image)) {
update_task->state.total_stages += 4;
if(update_task->state.groups & UpdateTaskStageGroupFirmware) {
CHECK_RESULT(update_task_write_dfu(update_task));
}
@@ -359,5 +345,10 @@ int32_t update_task_worker_flash_writer(void* context) {
success = true;
} while(false);
return success ? UPDATE_TASK_NOERR : UPDATE_TASK_FAILED;
if(!success) {
update_task_set_progress(update_task, UpdateTaskStageError, 0);
return UPDATE_TASK_FAILED;
}
return UPDATE_TASK_NOERR;
}