[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:
@@ -14,54 +14,139 @@ static const char* update_task_stage_descr[] = {
|
||||
[UpdateTaskStageReadManifest] = "Loading update manifest",
|
||||
[UpdateTaskStageValidateDFUImage] = "Checking DFU file",
|
||||
[UpdateTaskStageFlashWrite] = "Writing flash",
|
||||
[UpdateTaskStageFlashValidate] = "Validating",
|
||||
[UpdateTaskStageRadioImageValidate] = "Checking radio image",
|
||||
[UpdateTaskStageRadioErase] = "Removing radio stack",
|
||||
[UpdateTaskStageRadioWrite] = "Writing radio stack",
|
||||
[UpdateTaskStageRadioInstall] = "Installing radio stack",
|
||||
[UpdateTaskStageRadioBusy] = "Core2 is updating",
|
||||
[UpdateTaskStageFlashValidate] = "Validating flash",
|
||||
[UpdateTaskStageRadioImageValidate] = "Checking radio FW",
|
||||
[UpdateTaskStageRadioErase] = "Uninstalling radio FW",
|
||||
[UpdateTaskStageRadioWrite] = "Writing radio FW",
|
||||
[UpdateTaskStageRadioInstall] = "Installing radio FW",
|
||||
[UpdateTaskStageRadioBusy] = "Radio is updating",
|
||||
[UpdateTaskStageOBValidation] = "Validating opt. bytes",
|
||||
[UpdateTaskStageLfsBackup] = "Backing up LFS",
|
||||
[UpdateTaskStageLfsRestore] = "Restoring LFS",
|
||||
[UpdateTaskStageResourcesUpdate] = "Updating resources",
|
||||
[UpdateTaskStageCompleted] = "Completed!",
|
||||
[UpdateTaskStageCompleted] = "Restarting...",
|
||||
[UpdateTaskStageError] = "Error",
|
||||
[UpdateTaskStageOBError] = "OB error, pls report",
|
||||
[UpdateTaskStageOBError] = "OB Err, report",
|
||||
};
|
||||
|
||||
static void update_task_set_status(UpdateTask* update_task, const char* status) {
|
||||
if(!status) {
|
||||
if(update_task->state.stage >= COUNT_OF(update_task_stage_descr)) {
|
||||
status = "...";
|
||||
} else {
|
||||
status = update_task_stage_descr[update_task->state.stage];
|
||||
}
|
||||
typedef struct {
|
||||
UpdateTaskStageGroup group;
|
||||
uint8_t weight;
|
||||
} UpdateTaskStageGroupMap;
|
||||
|
||||
#define STAGE_DEF(GROUP, WEIGHT) \
|
||||
{ .group = (GROUP), .weight = (WEIGHT), }
|
||||
|
||||
static const UpdateTaskStageGroupMap update_task_stage_progress[] = {
|
||||
[UpdateTaskStageProgress] = STAGE_DEF(UpdateTaskStageGroupMisc, 0),
|
||||
|
||||
[UpdateTaskStageReadManifest] = STAGE_DEF(UpdateTaskStageGroupPreUpdate, 5),
|
||||
[UpdateTaskStageLfsBackup] = STAGE_DEF(UpdateTaskStageGroupPreUpdate, 30),
|
||||
|
||||
[UpdateTaskStageRadioImageValidate] = STAGE_DEF(UpdateTaskStageGroupRadio, 30),
|
||||
[UpdateTaskStageRadioErase] = STAGE_DEF(UpdateTaskStageGroupRadio, 50),
|
||||
[UpdateTaskStageRadioWrite] = STAGE_DEF(UpdateTaskStageGroupRadio, 100),
|
||||
[UpdateTaskStageRadioInstall] = STAGE_DEF(UpdateTaskStageGroupRadio, 5),
|
||||
[UpdateTaskStageRadioBusy] = STAGE_DEF(UpdateTaskStageGroupRadio, 70),
|
||||
|
||||
[UpdateTaskStageOBValidation] = STAGE_DEF(UpdateTaskStageGroupOptionBytes, 10),
|
||||
|
||||
[UpdateTaskStageValidateDFUImage] = STAGE_DEF(UpdateTaskStageGroupFirmware, 100),
|
||||
[UpdateTaskStageFlashWrite] = STAGE_DEF(UpdateTaskStageGroupFirmware, 200),
|
||||
[UpdateTaskStageFlashValidate] = STAGE_DEF(UpdateTaskStageGroupFirmware, 50),
|
||||
|
||||
[UpdateTaskStageLfsRestore] = STAGE_DEF(UpdateTaskStageGroupPostUpdate, 30),
|
||||
|
||||
[UpdateTaskStageResourcesUpdate] = STAGE_DEF(UpdateTaskStageGroupResources, 255),
|
||||
|
||||
[UpdateTaskStageCompleted] = STAGE_DEF(UpdateTaskStageGroupMisc, 1),
|
||||
[UpdateTaskStageError] = STAGE_DEF(UpdateTaskStageGroupMisc, 1),
|
||||
[UpdateTaskStageOBError] = STAGE_DEF(UpdateTaskStageGroupMisc, 1),
|
||||
};
|
||||
|
||||
static UpdateTaskStageGroup update_task_get_task_groups(UpdateTask* update_task) {
|
||||
UpdateTaskStageGroup ret = UpdateTaskStageGroupPreUpdate | UpdateTaskStageGroupPostUpdate;
|
||||
UpdateManifest* manifest = update_task->manifest;
|
||||
if(!string_empty_p(manifest->radio_image)) {
|
||||
ret |= UpdateTaskStageGroupRadio;
|
||||
}
|
||||
string_set_str(update_task->state.status, status);
|
||||
if(update_manifest_has_obdata(manifest)) {
|
||||
ret |= UpdateTaskStageGroupOptionBytes;
|
||||
}
|
||||
if(!string_empty_p(manifest->firmware_dfu_image)) {
|
||||
ret |= UpdateTaskStageGroupFirmware;
|
||||
}
|
||||
if(!string_empty_p(manifest->resource_bundle)) {
|
||||
ret |= UpdateTaskStageGroupResources;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void update_task_calc_completed_stages(UpdateTask* update_task) {
|
||||
uint32_t completed_stages_points = 0;
|
||||
for(UpdateTaskStage past_stage = UpdateTaskStageProgress;
|
||||
past_stage < update_task->state.stage;
|
||||
++past_stage) {
|
||||
const UpdateTaskStageGroupMap* grp_descr = &update_task_stage_progress[past_stage];
|
||||
if((grp_descr->group & update_task->state.groups) == 0) {
|
||||
continue;
|
||||
}
|
||||
completed_stages_points += grp_descr->weight;
|
||||
}
|
||||
update_task->state.completed_stages_points = completed_stages_points;
|
||||
}
|
||||
|
||||
void update_task_set_progress(UpdateTask* update_task, UpdateTaskStage stage, uint8_t progress) {
|
||||
if(stage != UpdateTaskStageProgress) {
|
||||
// do not override more specific error states
|
||||
if((update_task->state.stage < UpdateTaskStageError) || (stage < UpdateTaskStageError)) {
|
||||
update_task->state.stage = stage;
|
||||
/* do not override more specific error states */
|
||||
if((stage >= UpdateTaskStageError) && (update_task->state.stage >= UpdateTaskStageError)) {
|
||||
return;
|
||||
}
|
||||
/* Build error message with code "[stage_idx-stage_percent]" */
|
||||
if(stage >= UpdateTaskStageError) {
|
||||
string_printf(
|
||||
update_task->state.status,
|
||||
"%s #[%d-%d]",
|
||||
update_task_stage_descr[stage],
|
||||
update_task->state.stage,
|
||||
update_task->state.stage_progress);
|
||||
} else {
|
||||
string_set_str(update_task->state.status, update_task_stage_descr[stage]);
|
||||
}
|
||||
/* Store stage update */
|
||||
update_task->state.stage = stage;
|
||||
/* If we are still alive, sum completed stages weights */
|
||||
if((stage > UpdateTaskStageProgress) && (stage < UpdateTaskStageCompleted)) {
|
||||
update_task_calc_completed_stages(update_task);
|
||||
}
|
||||
update_task->state.current_stage_idx++;
|
||||
update_task_set_status(update_task, NULL);
|
||||
}
|
||||
|
||||
if(progress > 100) {
|
||||
progress = 100;
|
||||
/* Store stage progress for all non-error updates - to provide details on error state */
|
||||
if(!update_stage_is_error(stage)) {
|
||||
update_task->state.stage_progress = progress;
|
||||
}
|
||||
|
||||
update_task->state.progress = progress;
|
||||
/* Calculate "overall" progress, based on stage weights */
|
||||
uint32_t adapted_progress = 1;
|
||||
if(update_task->state.total_progress_points != 0) {
|
||||
if(stage < UpdateTaskStageCompleted) {
|
||||
adapted_progress = MIN(
|
||||
(update_task->state.completed_stages_points +
|
||||
(update_task_stage_progress[update_task->state.stage].weight * progress / 100)) *
|
||||
100 / (update_task->state.total_progress_points),
|
||||
100u);
|
||||
|
||||
} else {
|
||||
adapted_progress = update_task->state.overall_progress;
|
||||
}
|
||||
}
|
||||
update_task->state.overall_progress = adapted_progress;
|
||||
|
||||
if(update_task->status_change_cb) {
|
||||
(update_task->status_change_cb)(
|
||||
string_get_cstr(update_task->state.status),
|
||||
progress,
|
||||
update_task->state.current_stage_idx,
|
||||
update_task->state.total_stages,
|
||||
update_task->state.stage >= UpdateTaskStageError,
|
||||
adapted_progress,
|
||||
update_stage_is_error(update_task->state.stage),
|
||||
update_task->status_change_cb_state);
|
||||
}
|
||||
}
|
||||
@@ -106,8 +191,7 @@ static void update_task_worker_thread_cb(FuriThreadState state, void* context) {
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t op_result = furi_thread_get_return_code(update_task->thread);
|
||||
if(op_result == UPDATE_TASK_NOERR) {
|
||||
if(furi_thread_get_return_code(update_task->thread) == UPDATE_TASK_NOERR) {
|
||||
osDelay(UPDATE_DELAY_OPERATION_OK);
|
||||
furi_hal_power_reset();
|
||||
}
|
||||
@@ -117,7 +201,8 @@ UpdateTask* update_task_alloc() {
|
||||
UpdateTask* update_task = malloc(sizeof(UpdateTask));
|
||||
|
||||
update_task->state.stage = UpdateTaskStageProgress;
|
||||
update_task->state.progress = 0;
|
||||
update_task->state.stage_progress = 0;
|
||||
update_task->state.overall_progress = 0;
|
||||
string_init(update_task->state.status);
|
||||
|
||||
update_task->manifest = update_manifest_alloc();
|
||||
@@ -163,6 +248,12 @@ void update_task_free(UpdateTask* update_task) {
|
||||
|
||||
bool update_task_parse_manifest(UpdateTask* update_task) {
|
||||
furi_assert(update_task);
|
||||
update_task->state.stage_progress = 0;
|
||||
update_task->state.overall_progress = 0;
|
||||
update_task->state.total_progress_points = 0;
|
||||
update_task->state.completed_stages_points = 0;
|
||||
update_task->state.groups = 0;
|
||||
|
||||
update_task_set_progress(update_task, UpdateTaskStageReadManifest, 0);
|
||||
bool result = false;
|
||||
string_t manifest_path;
|
||||
@@ -180,19 +271,31 @@ bool update_task_parse_manifest(UpdateTask* update_task) {
|
||||
UPDATE_MANIFEST_DEFAULT_NAME,
|
||||
manifest_path);
|
||||
update_task_set_progress(update_task, UpdateTaskStageProgress, 30);
|
||||
if(!update_manifest_init(update_task->manifest, string_get_cstr(manifest_path))) {
|
||||
|
||||
UpdateManifest* manifest = update_task->manifest;
|
||||
if(!update_manifest_init(manifest, string_get_cstr(manifest_path))) {
|
||||
break;
|
||||
}
|
||||
|
||||
update_task->state.groups = update_task_get_task_groups(update_task);
|
||||
for(size_t stage_counter = 0; stage_counter < COUNT_OF(update_task_stage_progress);
|
||||
++stage_counter) {
|
||||
const UpdateTaskStageGroupMap* grp_descr = &update_task_stage_progress[stage_counter];
|
||||
if((grp_descr->group & update_task->state.groups) != 0) {
|
||||
update_task->state.total_progress_points += grp_descr->weight;
|
||||
}
|
||||
}
|
||||
|
||||
update_task_set_progress(update_task, UpdateTaskStageProgress, 50);
|
||||
if(!string_empty_p(update_task->manifest->firmware_dfu_image) &&
|
||||
!update_task_check_file_exists(update_task, update_task->manifest->firmware_dfu_image)) {
|
||||
if((update_task->state.groups & UpdateTaskStageGroupFirmware) &&
|
||||
!update_task_check_file_exists(update_task, manifest->firmware_dfu_image)) {
|
||||
break;
|
||||
}
|
||||
|
||||
update_task_set_progress(update_task, UpdateTaskStageProgress, 70);
|
||||
if(!string_empty_p(update_task->manifest->radio_image) &&
|
||||
!update_task_check_file_exists(update_task, update_task->manifest->radio_image)) {
|
||||
if((update_task->state.groups & UpdateTaskStageGroupRadio) &&
|
||||
(!update_task_check_file_exists(update_task, manifest->radio_image) ||
|
||||
(manifest->radio_version.version.type == 0))) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@@ -10,46 +10,63 @@ extern "C" {
|
||||
#include <stdbool.h>
|
||||
#include <m-string.h>
|
||||
|
||||
#define UPDATE_DELAY_OPERATION_OK 600
|
||||
#define UPDATE_DELAY_OPERATION_OK 300
|
||||
#define UPDATE_DELAY_OPERATION_ERROR INT_MAX
|
||||
|
||||
typedef enum {
|
||||
UpdateTaskStageProgress,
|
||||
UpdateTaskStageProgress = 0,
|
||||
|
||||
UpdateTaskStageReadManifest,
|
||||
UpdateTaskStageValidateDFUImage,
|
||||
UpdateTaskStageFlashWrite,
|
||||
UpdateTaskStageFlashValidate,
|
||||
UpdateTaskStageLfsBackup,
|
||||
|
||||
UpdateTaskStageRadioImageValidate,
|
||||
UpdateTaskStageRadioErase,
|
||||
UpdateTaskStageRadioWrite,
|
||||
UpdateTaskStageRadioInstall,
|
||||
UpdateTaskStageRadioBusy,
|
||||
|
||||
UpdateTaskStageOBValidation,
|
||||
UpdateTaskStageLfsBackup,
|
||||
|
||||
UpdateTaskStageValidateDFUImage,
|
||||
UpdateTaskStageFlashWrite,
|
||||
UpdateTaskStageFlashValidate,
|
||||
|
||||
UpdateTaskStageLfsRestore,
|
||||
UpdateTaskStageResourcesUpdate,
|
||||
|
||||
UpdateTaskStageCompleted,
|
||||
UpdateTaskStageError,
|
||||
UpdateTaskStageOBError
|
||||
UpdateTaskStageOBError,
|
||||
UpdateTaskStageMAX
|
||||
} UpdateTaskStage;
|
||||
|
||||
inline bool update_stage_is_error(const UpdateTaskStage stage) {
|
||||
return stage >= UpdateTaskStageError;
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
UpdateTaskStageGroupMisc = 0,
|
||||
UpdateTaskStageGroupPreUpdate = 1 << 1,
|
||||
UpdateTaskStageGroupFirmware = 1 << 2,
|
||||
UpdateTaskStageGroupOptionBytes = 1 << 3,
|
||||
UpdateTaskStageGroupRadio = 1 << 4,
|
||||
UpdateTaskStageGroupPostUpdate = 1 << 5,
|
||||
UpdateTaskStageGroupResources = 1 << 6,
|
||||
} UpdateTaskStageGroup;
|
||||
|
||||
typedef struct {
|
||||
UpdateTaskStage stage;
|
||||
uint8_t progress;
|
||||
uint8_t current_stage_idx;
|
||||
uint8_t total_stages;
|
||||
uint8_t overall_progress, stage_progress;
|
||||
string_t status;
|
||||
UpdateTaskStageGroup groups;
|
||||
uint32_t total_progress_points;
|
||||
uint32_t completed_stages_points;
|
||||
} UpdateTaskState;
|
||||
|
||||
typedef struct UpdateTask UpdateTask;
|
||||
|
||||
typedef void (*updateProgressCb)(
|
||||
const char* status,
|
||||
const uint8_t stage_pct,
|
||||
const uint8_t idx_stage,
|
||||
const uint8_t total_stages,
|
||||
bool failed,
|
||||
void* state);
|
||||
typedef void (
|
||||
*updateProgressCb)(const char* status, const uint8_t stage_pct, bool failed, void* state);
|
||||
|
||||
UpdateTask* update_task_alloc();
|
||||
|
||||
|
@@ -27,7 +27,6 @@ static bool update_task_pre_update(UpdateTask* update_task) {
|
||||
path_concat(
|
||||
string_get_cstr(update_task->update_path), LFS_BACKUP_DEFAULT_FILENAME, backup_file_path);
|
||||
|
||||
update_task->state.total_stages = 1;
|
||||
update_task_set_progress(update_task, UpdateTaskStageLfsBackup, 0);
|
||||
/* to avoid bootloops */
|
||||
furi_hal_rtc_set_boot_mode(FuriHalRtcBootModeNormal);
|
||||
@@ -62,22 +61,18 @@ static bool update_task_post_update(UpdateTask* update_task) {
|
||||
string_t file_path;
|
||||
string_init(file_path);
|
||||
|
||||
/* status text is too long, too few stages to bother with a counter */
|
||||
update_task->state.total_stages = 0;
|
||||
|
||||
TarArchive* archive = tar_archive_alloc(update_task->storage);
|
||||
do {
|
||||
CHECK_RESULT(update_task_parse_manifest(update_task));
|
||||
path_concat(
|
||||
string_get_cstr(update_task->update_path), LFS_BACKUP_DEFAULT_FILENAME, file_path);
|
||||
|
||||
bool unpack_resources = !string_empty_p(update_task->manifest->resource_bundle);
|
||||
|
||||
update_task_set_progress(update_task, UpdateTaskStageLfsRestore, 0);
|
||||
furi_hal_rtc_set_boot_mode(FuriHalRtcBootModeNormal);
|
||||
update_operation_disarm();
|
||||
|
||||
CHECK_RESULT(lfs_backup_unpack(update_task->storage, string_get_cstr(file_path)));
|
||||
|
||||
if(unpack_resources) {
|
||||
if(update_task->state.groups & UpdateTaskStageGroupResources) {
|
||||
TarUnpackProgress progress = {
|
||||
.update_task = update_task,
|
||||
.total_files = 0,
|
||||
@@ -90,20 +85,19 @@ static bool update_task_post_update(UpdateTask* update_task) {
|
||||
string_get_cstr(update_task->manifest->resource_bundle),
|
||||
file_path);
|
||||
|
||||
TarArchive* archive = tar_archive_alloc(update_task->storage);
|
||||
tar_archive_set_file_callback(archive, update_task_resource_unpack_cb, &progress);
|
||||
success = tar_archive_open(archive, string_get_cstr(file_path), TAR_OPEN_MODE_READ);
|
||||
if(success) {
|
||||
progress.total_files = tar_archive_get_entries_count(archive);
|
||||
if(progress.total_files > 0) {
|
||||
tar_archive_unpack_to(archive, EXT_PATH);
|
||||
}
|
||||
CHECK_RESULT(
|
||||
tar_archive_open(archive, string_get_cstr(file_path), TAR_OPEN_MODE_READ));
|
||||
|
||||
progress.total_files = tar_archive_get_entries_count(archive);
|
||||
if(progress.total_files > 0) {
|
||||
CHECK_RESULT(tar_archive_unpack_to(archive, EXT_PATH));
|
||||
}
|
||||
tar_archive_free(archive);
|
||||
}
|
||||
success = true;
|
||||
} while(false);
|
||||
|
||||
tar_archive_free(archive);
|
||||
string_clear(file_path);
|
||||
return success;
|
||||
}
|
||||
@@ -116,18 +110,17 @@ int32_t update_task_worker_backup_restore(void* context) {
|
||||
FuriHalRtcBootMode boot_mode = furi_hal_rtc_get_boot_mode();
|
||||
if((boot_mode != FuriHalRtcBootModePreUpdate) && (boot_mode != FuriHalRtcBootModePostUpdate)) {
|
||||
/* no idea how we got here. Clear to normal boot */
|
||||
furi_hal_rtc_set_boot_mode(FuriHalRtcBootModeNormal);
|
||||
update_operation_disarm();
|
||||
return UPDATE_TASK_NOERR;
|
||||
}
|
||||
|
||||
update_task->state.current_stage_idx = 0;
|
||||
|
||||
if(!update_operation_get_current_package_path(update_task->storage, update_task->update_path)) {
|
||||
return UPDATE_TASK_FAILED;
|
||||
}
|
||||
|
||||
/* Waiting for BT service to 'start', so we don't race for boot mode */
|
||||
/* Waiting for BT service to 'start', so we don't race for boot mode flag */
|
||||
furi_record_open("bt");
|
||||
furi_record_close("bt");
|
||||
|
||||
if(boot_mode == FuriHalRtcBootModePreUpdate) {
|
||||
success = update_task_pre_update(update_task);
|
||||
@@ -135,13 +128,11 @@ int32_t update_task_worker_backup_restore(void* context) {
|
||||
success = update_task_post_update(update_task);
|
||||
}
|
||||
|
||||
furi_record_close("bt");
|
||||
|
||||
if(success) {
|
||||
update_task_set_progress(update_task, UpdateTaskStageCompleted, 100);
|
||||
} else {
|
||||
update_task_set_progress(update_task, UpdateTaskStageError, update_task->state.progress);
|
||||
if(!success) {
|
||||
update_task_set_progress(update_task, UpdateTaskStageError, 0);
|
||||
return UPDATE_TASK_FAILED;
|
||||
}
|
||||
|
||||
return success ? UPDATE_TASK_NOERR : UPDATE_TASK_FAILED;
|
||||
update_task_set_progress(update_task, UpdateTaskStageCompleted, 100);
|
||||
return UPDATE_TASK_NOERR;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user