Skip to content

Commit

Permalink
[FL-3882] Clean up of LFS traces (#3849)
Browse files Browse the repository at this point in the history
* updater, storage: removed mentions of LFS from public APIs; updated corresponding strings
* rpc: updated include path

Co-authored-by: あく <[email protected]>
  • Loading branch information
hedger and skotopes authored Sep 5, 2024
1 parent c9791a2 commit feb1b2f
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 53 deletions.
6 changes: 3 additions & 3 deletions applications/services/rpc/rpc_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <storage/storage.h>
#include <lib/toolbox/md5_calc.h>
#include <lib/toolbox/path.h>
#include <update_util/lfs_backup.h>
#include <update_util/int_backup.h>
#include <toolbox/tar/tar_archive.h>

#include <pb_decode.h>
Expand Down Expand Up @@ -656,7 +656,7 @@ static void rpc_system_storage_backup_create_process(const PB_Main* request, voi

rpc_system_storage_reset_state(rpc_storage, session, true);

bool backup_ok = lfs_backup_create(
bool backup_ok = int_backup_create(
rpc_storage->api, request->content.storage_backup_create_request.archive_path);

rpc_send_and_release_empty(
Expand All @@ -676,7 +676,7 @@ static void rpc_system_storage_backup_restore_process(const PB_Main* request, vo

rpc_system_storage_reset_state(rpc_storage, session, true);

bool backup_ok = lfs_backup_unpack(
bool backup_ok = int_backup_unpack(
rpc_storage->api, request->content.storage_backup_restore_request.archive_path);

rpc_send_and_release_empty(
Expand Down
2 changes: 1 addition & 1 deletion applications/services/storage/storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ FS_Error storage_sd_info(Storage* storage, SDInfo* info);
*/
FS_Error storage_sd_status(Storage* storage);

/******************* Internal LFS Functions *******************/
/************ Internal Storage Backup/Restore ************/

typedef void (*StorageNameConverter)(FuriString*);

Expand Down
6 changes: 3 additions & 3 deletions applications/system/updater/cli/updater_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <toolbox/tar/tar_archive.h>
#include <toolbox/args.h>
#include <update_util/update_manifest.h>
#include <update_util/lfs_backup.h>
#include <update_util/int_backup.h>
#include <update_util/update_operation.h>

typedef void (*cmd_handler)(FuriString* args);
Expand All @@ -35,15 +35,15 @@ static void updater_cli_install(FuriString* manifest_path) {
static void updater_cli_backup(FuriString* args) {
printf("Backup /int to '%s'\r\n", furi_string_get_cstr(args));
Storage* storage = furi_record_open(RECORD_STORAGE);
bool success = lfs_backup_create(storage, furi_string_get_cstr(args));
bool success = int_backup_create(storage, furi_string_get_cstr(args));
furi_record_close(RECORD_STORAGE);
printf("Result: %s\r\n", success ? "OK" : "FAIL");
}

static void updater_cli_restore(FuriString* args) {
printf("Restore /int from '%s'\r\n", furi_string_get_cstr(args));
Storage* storage = furi_record_open(RECORD_STORAGE);
bool success = lfs_backup_unpack(storage, furi_string_get_cstr(args));
bool success = int_backup_unpack(storage, furi_string_get_cstr(args));
furi_record_close(RECORD_STORAGE);
printf("Result: %s\r\n", success ? "OK" : "FAIL");
}
Expand Down
14 changes: 7 additions & 7 deletions applications/system/updater/util/update_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ static const char* update_task_stage_descr[] = {
[UpdateTaskStageRadioInstall] = "Installing radio FW",
[UpdateTaskStageRadioBusy] = "Core 2 busy",
[UpdateTaskStageOBValidation] = "Validating opt. bytes",
[UpdateTaskStageLfsBackup] = "Backing up LFS",
[UpdateTaskStageLfsRestore] = "Restoring LFS",
[UpdateTaskStageIntBackup] = "Backing up configuration",
[UpdateTaskStageIntRestore] = "Restoring configuration",
[UpdateTaskStageResourcesFileCleanup] = "Cleaning up files",
[UpdateTaskStageResourcesDirCleanup] = "Cleaning up directories",
[UpdateTaskStageResourcesFileUnpack] = "Extracting resources",
Expand Down Expand Up @@ -82,7 +82,7 @@ static const struct {
},
#ifndef FURI_RAM_EXEC
{
.stage = UpdateTaskStageLfsBackup,
.stage = UpdateTaskStageIntBackup,
.percent_min = 0,
.percent_max = 100,
.descr = "FS R/W error",
Expand Down Expand Up @@ -193,10 +193,10 @@ static const struct {
#endif
#ifndef FURI_RAM_EXEC
{
.stage = UpdateTaskStageLfsRestore,
.stage = UpdateTaskStageIntRestore,
.percent_min = 0,
.percent_max = 100,
.descr = "LFS I/O error",
.descr = "SD card I/O error",
},
{
.stage = UpdateTaskStageResourcesFileCleanup,
Expand Down Expand Up @@ -245,7 +245,7 @@ static const UpdateTaskStageGroupMap update_task_stage_progress[] = {
[UpdateTaskStageProgress] = STAGE_DEF(UpdateTaskStageGroupMisc, 0),

[UpdateTaskStageReadManifest] = STAGE_DEF(UpdateTaskStageGroupPreUpdate, 45),
[UpdateTaskStageLfsBackup] = STAGE_DEF(UpdateTaskStageGroupPreUpdate, 5),
[UpdateTaskStageIntBackup] = STAGE_DEF(UpdateTaskStageGroupPreUpdate, 5),

[UpdateTaskStageRadioImageValidate] = STAGE_DEF(UpdateTaskStageGroupRadio, 15),
[UpdateTaskStageRadioErase] = STAGE_DEF(UpdateTaskStageGroupRadio, 25),
Expand All @@ -259,7 +259,7 @@ static const UpdateTaskStageGroupMap update_task_stage_progress[] = {
[UpdateTaskStageFlashWrite] = STAGE_DEF(UpdateTaskStageGroupFirmware, 100),
[UpdateTaskStageFlashValidate] = STAGE_DEF(UpdateTaskStageGroupFirmware, 20),

[UpdateTaskStageLfsRestore] = STAGE_DEF(UpdateTaskStageGroupPostUpdate, 5),
[UpdateTaskStageIntRestore] = STAGE_DEF(UpdateTaskStageGroupPostUpdate, 5),

[UpdateTaskStageResourcesFileCleanup] = STAGE_DEF(UpdateTaskStageGroupResources, 100),
[UpdateTaskStageResourcesDirCleanup] = STAGE_DEF(UpdateTaskStageGroupResources, 50),
Expand Down
4 changes: 2 additions & 2 deletions applications/system/updater/util/update_task.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ typedef enum {
UpdateTaskStageProgress = 0,

UpdateTaskStageReadManifest,
UpdateTaskStageLfsBackup,
UpdateTaskStageIntBackup,

UpdateTaskStageRadioImageValidate,
UpdateTaskStageRadioErase,
Expand All @@ -30,7 +30,7 @@ typedef enum {
UpdateTaskStageFlashWrite,
UpdateTaskStageFlashValidate,

UpdateTaskStageLfsRestore,
UpdateTaskStageIntRestore,
UpdateTaskStageResourcesFileCleanup,
UpdateTaskStageResourcesDirCleanup,
UpdateTaskStageResourcesFileUnpack,
Expand Down
14 changes: 7 additions & 7 deletions applications/system/updater/util/update_task_worker_backup.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <desktop/helpers/slideshow_filename.h>
#include <toolbox/path.h>
#include <update_util/dfu_file.h>
#include <update_util/lfs_backup.h>
#include <update_util/int_backup.h>
#include <update_util/update_operation.h>
#include <update_util/resources/manifest.h>
#include <toolbox/tar/tar_archive.h>
Expand All @@ -21,14 +21,14 @@ static bool update_task_pre_update(UpdateTask* update_task) {
backup_file_path = furi_string_alloc();
path_concat(
furi_string_get_cstr(update_task->update_path),
LFS_BACKUP_DEFAULT_FILENAME,
INT_BACKUP_DEFAULT_FILENAME,
backup_file_path);

update_task_set_progress(update_task, UpdateTaskStageLfsBackup, 0);
update_task_set_progress(update_task, UpdateTaskStageIntBackup, 0);
/* to avoid bootloops */
furi_hal_rtc_set_boot_mode(FuriHalRtcBootModeNormal);
if((success =
lfs_backup_create(update_task->storage, furi_string_get_cstr(backup_file_path)))) {
int_backup_create(update_task->storage, furi_string_get_cstr(backup_file_path)))) {
furi_hal_rtc_set_boot_mode(FuriHalRtcBootModeUpdate);
}

Expand Down Expand Up @@ -145,12 +145,12 @@ static bool update_task_post_update(UpdateTask* update_task) {
do {
path_concat(
furi_string_get_cstr(update_task->update_path),
LFS_BACKUP_DEFAULT_FILENAME,
INT_BACKUP_DEFAULT_FILENAME,
file_path);

update_task_set_progress(update_task, UpdateTaskStageLfsRestore, 0);
update_task_set_progress(update_task, UpdateTaskStageIntRestore, 0);

CHECK_RESULT(lfs_backup_unpack(update_task->storage, furi_string_get_cstr(file_path)));
CHECK_RESULT(int_backup_unpack(update_task->storage, furi_string_get_cstr(file_path)));

if(update_task->state.groups & UpdateTaskStageGroupResources) {
TarUnpackProgress progress = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ int32_t update_task_worker_flash_writer(void* context) {
}

furi_hal_rtc_set_boot_mode(FuriHalRtcBootModePostUpdate);
// Format LFS before restoring backup on next boot
// Clean up /int before restoring backup on next boot
furi_hal_rtc_set_flag(FuriHalRtcFlagStorageFormatInternal);
#ifdef FURI_NDEBUG
// Production
Expand Down
4 changes: 2 additions & 2 deletions documentation/OTA.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Even if something goes wrong, updater allows you to retry failed operations and
| | | **50** | Package has mismatching HW target |
| | | **60** | Missing DFU file |
| | | **80** | Missing radio firmware file |
| Backing up LFS | **2** | **0-100** | FS read/write error |
| Backing up configuration| **2** | **0-100** | FS read/write error |
| Checking radio FW | **3** | **0-99** | Error reading radio firmware file |
| | | **100** | CRC mismatch |
| Uninstalling radio FW | **4** | **0** | SHCI Delete command error |
Expand All @@ -101,7 +101,7 @@ Even if something goes wrong, updater allows you to retry failed operations and
| | | **99-100** | Corrupted DFU file |
| Writing flash | **10** | **0-100** | Block read/write error |
| Validating flash | **11** | **0-100** | Block read/write error |
| Restoring LFS | **12** | **0-100** | FS read/write error |
| Restoring configuration | **12** | **0-100** | FS read/write error |
| Updating resources | **13-15** | **0-100** | SD card read/write error |

## Building update packages
Expand Down
16 changes: 8 additions & 8 deletions lib/update_util/lfs_backup.c → lib/update_util/int_backup.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "lfs_backup.h"
#include "int_backup.h"

#include <toolbox/tar/tar_archive.h>

Expand All @@ -9,7 +9,7 @@
#include <desktop/desktop_settings_filename.h>
#include <notification/notification_settings_filename.h>

#define LFS_BACKUP_DEFAULT_LOCATION EXT_PATH(LFS_BACKUP_DEFAULT_FILENAME)
#define INT_BACKUP_DEFAULT_LOCATION EXT_PATH(INT_BACKUP_DEFAULT_FILENAME)

static void backup_name_converter(FuriString* filename) {
if(furi_string_empty(filename) || (furi_string_get_char(filename, 0) == '.')) {
Expand All @@ -34,18 +34,18 @@ static void backup_name_converter(FuriString* filename) {
}
}

bool lfs_backup_create(Storage* storage, const char* destination) {
bool int_backup_create(Storage* storage, const char* destination) {
const char* final_destination =
destination && strlen(destination) ? destination : LFS_BACKUP_DEFAULT_LOCATION;
destination && strlen(destination) ? destination : INT_BACKUP_DEFAULT_LOCATION;
return storage_int_backup(storage, final_destination) == FSE_OK;
}

bool lfs_backup_exists(Storage* storage, const char* source) {
const char* final_source = source && strlen(source) ? source : LFS_BACKUP_DEFAULT_LOCATION;
bool int_backup_exists(Storage* storage, const char* source) {
const char* final_source = source && strlen(source) ? source : INT_BACKUP_DEFAULT_LOCATION;
return storage_common_stat(storage, final_source, NULL) == FSE_OK;
}

bool lfs_backup_unpack(Storage* storage, const char* source) {
const char* final_source = source && strlen(source) ? source : LFS_BACKUP_DEFAULT_LOCATION;
bool int_backup_unpack(Storage* storage, const char* source) {
const char* final_source = source && strlen(source) ? source : INT_BACKUP_DEFAULT_LOCATION;
return storage_int_restore(storage, final_source, backup_name_converter) == FSE_OK;
}
18 changes: 18 additions & 0 deletions lib/update_util/int_backup.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once

#include <stdbool.h>
#include <storage/storage.h>

#define INT_BACKUP_DEFAULT_FILENAME "backup.tar"

#ifdef __cplusplus
extern "C" {
#endif

bool int_backup_create(Storage* storage, const char* destination);
bool int_backup_exists(Storage* storage, const char* source);
bool int_backup_unpack(Storage* storage, const char* source);

#ifdef __cplusplus
}
#endif
18 changes: 0 additions & 18 deletions lib/update_util/lfs_backup.h

This file was deleted.

3 changes: 2 additions & 1 deletion targets/f7/furi_hal/furi_hal_rtc.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <stdbool.h>

#include <datetime/datetime.h>
#include <core/common_defines.h>

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -44,7 +45,7 @@ typedef enum {
FuriHalRtcRegisterHeader, /**< RTC structure header */
FuriHalRtcRegisterSystem, /**< Various system bits */
FuriHalRtcRegisterVersion, /**< Pointer to Version */
FuriHalRtcRegisterLfsFingerprint, /**< LFS geometry fingerprint */
FuriHalRtcRegisterLfsFingerprint FURI_DEPRECATED, /**< LFS geometry fingerprint */
FuriHalRtcRegisterFaultData, /**< Pointer to last fault message */
FuriHalRtcRegisterPinFails, /**< Failed PINs count */
/* Index of FS directory entry corresponding to FW update to be applied */
Expand Down

0 comments on commit feb1b2f

Please sign in to comment.