1
mirror of https://github.com/flipperdevices/flipperzero-firmware.git synced 2025-12-12 12:51:22 +04:00

[FL-3882] Clean up of LFS traces (#3849)

* updater, storage: removed mentions of LFS from public APIs; updated corresponding strings
* rpc: updated include path

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
hedger
2024-09-05 20:44:22 +03:00
committed by GitHub
parent c9791a280a
commit feb1b2f349
12 changed files with 54 additions and 53 deletions

View File

@@ -7,7 +7,7 @@
#include <storage/storage.h> #include <storage/storage.h>
#include <lib/toolbox/md5_calc.h> #include <lib/toolbox/md5_calc.h>
#include <lib/toolbox/path.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 <toolbox/tar/tar_archive.h>
#include <pb_decode.h> #include <pb_decode.h>
@@ -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); 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_storage->api, request->content.storage_backup_create_request.archive_path);
rpc_send_and_release_empty( rpc_send_and_release_empty(
@@ -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); 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_storage->api, request->content.storage_backup_restore_request.archive_path);
rpc_send_and_release_empty( rpc_send_and_release_empty(

View File

@@ -504,7 +504,7 @@ FS_Error storage_sd_info(Storage* storage, SDInfo* info);
*/ */
FS_Error storage_sd_status(Storage* storage); FS_Error storage_sd_status(Storage* storage);
/******************* Internal LFS Functions *******************/ /************ Internal Storage Backup/Restore ************/
typedef void (*StorageNameConverter)(FuriString*); typedef void (*StorageNameConverter)(FuriString*);

View File

@@ -8,7 +8,7 @@
#include <toolbox/tar/tar_archive.h> #include <toolbox/tar/tar_archive.h>
#include <toolbox/args.h> #include <toolbox/args.h>
#include <update_util/update_manifest.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> #include <update_util/update_operation.h>
typedef void (*cmd_handler)(FuriString* args); typedef void (*cmd_handler)(FuriString* args);
@@ -35,7 +35,7 @@ static void updater_cli_install(FuriString* manifest_path) {
static void updater_cli_backup(FuriString* args) { static void updater_cli_backup(FuriString* args) {
printf("Backup /int to '%s'\r\n", furi_string_get_cstr(args)); printf("Backup /int to '%s'\r\n", furi_string_get_cstr(args));
Storage* storage = furi_record_open(RECORD_STORAGE); 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); furi_record_close(RECORD_STORAGE);
printf("Result: %s\r\n", success ? "OK" : "FAIL"); printf("Result: %s\r\n", success ? "OK" : "FAIL");
} }
@@ -43,7 +43,7 @@ static void updater_cli_backup(FuriString* args) {
static void updater_cli_restore(FuriString* args) { static void updater_cli_restore(FuriString* args) {
printf("Restore /int from '%s'\r\n", furi_string_get_cstr(args)); printf("Restore /int from '%s'\r\n", furi_string_get_cstr(args));
Storage* storage = furi_record_open(RECORD_STORAGE); 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); furi_record_close(RECORD_STORAGE);
printf("Result: %s\r\n", success ? "OK" : "FAIL"); printf("Result: %s\r\n", success ? "OK" : "FAIL");
} }

View File

@@ -22,8 +22,8 @@ static const char* update_task_stage_descr[] = {
[UpdateTaskStageRadioInstall] = "Installing radio FW", [UpdateTaskStageRadioInstall] = "Installing radio FW",
[UpdateTaskStageRadioBusy] = "Core 2 busy", [UpdateTaskStageRadioBusy] = "Core 2 busy",
[UpdateTaskStageOBValidation] = "Validating opt. bytes", [UpdateTaskStageOBValidation] = "Validating opt. bytes",
[UpdateTaskStageLfsBackup] = "Backing up LFS", [UpdateTaskStageIntBackup] = "Backing up configuration",
[UpdateTaskStageLfsRestore] = "Restoring LFS", [UpdateTaskStageIntRestore] = "Restoring configuration",
[UpdateTaskStageResourcesFileCleanup] = "Cleaning up files", [UpdateTaskStageResourcesFileCleanup] = "Cleaning up files",
[UpdateTaskStageResourcesDirCleanup] = "Cleaning up directories", [UpdateTaskStageResourcesDirCleanup] = "Cleaning up directories",
[UpdateTaskStageResourcesFileUnpack] = "Extracting resources", [UpdateTaskStageResourcesFileUnpack] = "Extracting resources",
@@ -82,7 +82,7 @@ static const struct {
}, },
#ifndef FURI_RAM_EXEC #ifndef FURI_RAM_EXEC
{ {
.stage = UpdateTaskStageLfsBackup, .stage = UpdateTaskStageIntBackup,
.percent_min = 0, .percent_min = 0,
.percent_max = 100, .percent_max = 100,
.descr = "FS R/W error", .descr = "FS R/W error",
@@ -193,10 +193,10 @@ static const struct {
#endif #endif
#ifndef FURI_RAM_EXEC #ifndef FURI_RAM_EXEC
{ {
.stage = UpdateTaskStageLfsRestore, .stage = UpdateTaskStageIntRestore,
.percent_min = 0, .percent_min = 0,
.percent_max = 100, .percent_max = 100,
.descr = "LFS I/O error", .descr = "SD card I/O error",
}, },
{ {
.stage = UpdateTaskStageResourcesFileCleanup, .stage = UpdateTaskStageResourcesFileCleanup,
@@ -245,7 +245,7 @@ static const UpdateTaskStageGroupMap update_task_stage_progress[] = {
[UpdateTaskStageProgress] = STAGE_DEF(UpdateTaskStageGroupMisc, 0), [UpdateTaskStageProgress] = STAGE_DEF(UpdateTaskStageGroupMisc, 0),
[UpdateTaskStageReadManifest] = STAGE_DEF(UpdateTaskStageGroupPreUpdate, 45), [UpdateTaskStageReadManifest] = STAGE_DEF(UpdateTaskStageGroupPreUpdate, 45),
[UpdateTaskStageLfsBackup] = STAGE_DEF(UpdateTaskStageGroupPreUpdate, 5), [UpdateTaskStageIntBackup] = STAGE_DEF(UpdateTaskStageGroupPreUpdate, 5),
[UpdateTaskStageRadioImageValidate] = STAGE_DEF(UpdateTaskStageGroupRadio, 15), [UpdateTaskStageRadioImageValidate] = STAGE_DEF(UpdateTaskStageGroupRadio, 15),
[UpdateTaskStageRadioErase] = STAGE_DEF(UpdateTaskStageGroupRadio, 25), [UpdateTaskStageRadioErase] = STAGE_DEF(UpdateTaskStageGroupRadio, 25),
@@ -259,7 +259,7 @@ static const UpdateTaskStageGroupMap update_task_stage_progress[] = {
[UpdateTaskStageFlashWrite] = STAGE_DEF(UpdateTaskStageGroupFirmware, 100), [UpdateTaskStageFlashWrite] = STAGE_DEF(UpdateTaskStageGroupFirmware, 100),
[UpdateTaskStageFlashValidate] = STAGE_DEF(UpdateTaskStageGroupFirmware, 20), [UpdateTaskStageFlashValidate] = STAGE_DEF(UpdateTaskStageGroupFirmware, 20),
[UpdateTaskStageLfsRestore] = STAGE_DEF(UpdateTaskStageGroupPostUpdate, 5), [UpdateTaskStageIntRestore] = STAGE_DEF(UpdateTaskStageGroupPostUpdate, 5),
[UpdateTaskStageResourcesFileCleanup] = STAGE_DEF(UpdateTaskStageGroupResources, 100), [UpdateTaskStageResourcesFileCleanup] = STAGE_DEF(UpdateTaskStageGroupResources, 100),
[UpdateTaskStageResourcesDirCleanup] = STAGE_DEF(UpdateTaskStageGroupResources, 50), [UpdateTaskStageResourcesDirCleanup] = STAGE_DEF(UpdateTaskStageGroupResources, 50),

View File

@@ -16,7 +16,7 @@ typedef enum {
UpdateTaskStageProgress = 0, UpdateTaskStageProgress = 0,
UpdateTaskStageReadManifest, UpdateTaskStageReadManifest,
UpdateTaskStageLfsBackup, UpdateTaskStageIntBackup,
UpdateTaskStageRadioImageValidate, UpdateTaskStageRadioImageValidate,
UpdateTaskStageRadioErase, UpdateTaskStageRadioErase,
@@ -30,7 +30,7 @@ typedef enum {
UpdateTaskStageFlashWrite, UpdateTaskStageFlashWrite,
UpdateTaskStageFlashValidate, UpdateTaskStageFlashValidate,
UpdateTaskStageLfsRestore, UpdateTaskStageIntRestore,
UpdateTaskStageResourcesFileCleanup, UpdateTaskStageResourcesFileCleanup,
UpdateTaskStageResourcesDirCleanup, UpdateTaskStageResourcesDirCleanup,
UpdateTaskStageResourcesFileUnpack, UpdateTaskStageResourcesFileUnpack,

View File

@@ -7,7 +7,7 @@
#include <desktop/helpers/slideshow_filename.h> #include <desktop/helpers/slideshow_filename.h>
#include <toolbox/path.h> #include <toolbox/path.h>
#include <update_util/dfu_file.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/update_operation.h>
#include <update_util/resources/manifest.h> #include <update_util/resources/manifest.h>
#include <toolbox/tar/tar_archive.h> #include <toolbox/tar/tar_archive.h>
@@ -21,14 +21,14 @@ static bool update_task_pre_update(UpdateTask* update_task) {
backup_file_path = furi_string_alloc(); backup_file_path = furi_string_alloc();
path_concat( path_concat(
furi_string_get_cstr(update_task->update_path), furi_string_get_cstr(update_task->update_path),
LFS_BACKUP_DEFAULT_FILENAME, INT_BACKUP_DEFAULT_FILENAME,
backup_file_path); backup_file_path);
update_task_set_progress(update_task, UpdateTaskStageLfsBackup, 0); update_task_set_progress(update_task, UpdateTaskStageIntBackup, 0);
/* to avoid bootloops */ /* to avoid bootloops */
furi_hal_rtc_set_boot_mode(FuriHalRtcBootModeNormal); furi_hal_rtc_set_boot_mode(FuriHalRtcBootModeNormal);
if((success = 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); furi_hal_rtc_set_boot_mode(FuriHalRtcBootModeUpdate);
} }
@@ -145,12 +145,12 @@ static bool update_task_post_update(UpdateTask* update_task) {
do { do {
path_concat( path_concat(
furi_string_get_cstr(update_task->update_path), furi_string_get_cstr(update_task->update_path),
LFS_BACKUP_DEFAULT_FILENAME, INT_BACKUP_DEFAULT_FILENAME,
file_path); 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) { if(update_task->state.groups & UpdateTaskStageGroupResources) {
TarUnpackProgress progress = { TarUnpackProgress progress = {

View File

@@ -341,7 +341,7 @@ int32_t update_task_worker_flash_writer(void* context) {
} }
furi_hal_rtc_set_boot_mode(FuriHalRtcBootModePostUpdate); 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); furi_hal_rtc_set_flag(FuriHalRtcFlagStorageFormatInternal);
#ifdef FURI_NDEBUG #ifdef FURI_NDEBUG
// Production // Production

View File

@@ -83,7 +83,7 @@ Even if something goes wrong, updater allows you to retry failed operations and
| | | **50** | Package has mismatching HW target | | | | **50** | Package has mismatching HW target |
| | | **60** | Missing DFU file | | | | **60** | Missing DFU file |
| | | **80** | Missing radio firmware 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 | | Checking radio FW | **3** | **0-99** | Error reading radio firmware file |
| | | **100** | CRC mismatch | | | | **100** | CRC mismatch |
| Uninstalling radio FW | **4** | **0** | SHCI Delete command error | | Uninstalling radio FW | **4** | **0** | SHCI Delete command error |
@@ -101,7 +101,7 @@ Even if something goes wrong, updater allows you to retry failed operations and
| | | **99-100** | Corrupted DFU file | | | | **99-100** | Corrupted DFU file |
| Writing flash | **10** | **0-100** | Block read/write error | | Writing flash | **10** | **0-100** | Block read/write error |
| Validating flash | **11** | **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 | | Updating resources | **13-15** | **0-100** | SD card read/write error |
## Building update packages ## Building update packages

View File

@@ -1,4 +1,4 @@
#include "lfs_backup.h" #include "int_backup.h"
#include <toolbox/tar/tar_archive.h> #include <toolbox/tar/tar_archive.h>
@@ -9,7 +9,7 @@
#include <desktop/desktop_settings_filename.h> #include <desktop/desktop_settings_filename.h>
#include <notification/notification_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) { static void backup_name_converter(FuriString* filename) {
if(furi_string_empty(filename) || (furi_string_get_char(filename, 0) == '.')) { if(furi_string_empty(filename) || (furi_string_get_char(filename, 0) == '.')) {
@@ -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 = 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; return storage_int_backup(storage, final_destination) == FSE_OK;
} }
bool lfs_backup_exists(Storage* storage, const char* source) { bool int_backup_exists(Storage* storage, const char* source) {
const char* final_source = source && strlen(source) ? source : LFS_BACKUP_DEFAULT_LOCATION; const char* final_source = source && strlen(source) ? source : INT_BACKUP_DEFAULT_LOCATION;
return storage_common_stat(storage, final_source, NULL) == FSE_OK; return storage_common_stat(storage, final_source, NULL) == FSE_OK;
} }
bool lfs_backup_unpack(Storage* storage, const char* source) { bool int_backup_unpack(Storage* storage, const char* source) {
const char* final_source = source && strlen(source) ? source : LFS_BACKUP_DEFAULT_LOCATION; const char* final_source = source && strlen(source) ? source : INT_BACKUP_DEFAULT_LOCATION;
return storage_int_restore(storage, final_source, backup_name_converter) == FSE_OK; return storage_int_restore(storage, final_source, backup_name_converter) == FSE_OK;
} }

View File

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

View File

@@ -1,18 +0,0 @@
#pragma once
#include <stdbool.h>
#include <storage/storage.h>
#define LFS_BACKUP_DEFAULT_FILENAME "backup.tar"
#ifdef __cplusplus
extern "C" {
#endif
bool lfs_backup_create(Storage* storage, const char* destination);
bool lfs_backup_exists(Storage* storage, const char* source);
bool lfs_backup_unpack(Storage* storage, const char* source);
#ifdef __cplusplus
}
#endif

View File

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