mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-07-30 02:18:11 -07:00
Storage: remove LFS (#3577)
* Storage: drop internal storage * Storage: rollback some unnecessary changes * Storage: rollback some unnecessary changes part 2 * Storage: cleanup various defines and int handling. Ble: allow short connection interval if internal flash is not used. * Storage: do not return storage if it is not ready * Save PIN code to RTC, update settings * Simplify the code, clean up includes * Rearrange some code * apps: storage_move_to_sd: conditionally enable with --extra-define=STORAGE_INT_ON_LFS * Load Desktop settings automatically * Redirect /any to /ext * Abolish storage_move_to_sd app * Remove as many mentions of ANY_PATH as possible * Fix desktop settings wrongly not loading * Improve desktop settings handling and strings * Load BLE settings and keys automatically * Improve BLE configuration procedure * Do not load bluetooth keys twice if they were already loaded * Load dolphin state automatically * Fix merge artifact * Load notification settings automatically * Update desktop settings strings * Load expansion settings automatically * Do not use thread signals to reload desktop settings * Load region data automatically, separate to its own hook * Improve ble behaviour with no keys * Fix Dolphin state not resetting correctly * Add a status check * Make Desktop save its own settings * Check result when taking and releasing mutex * Improve default thread signal handling in FuriEventLoop * Make bt service in charge of saving settings, add settings api * Fix a deadlock due to timer thread not receiving time * Lock core2 when reinitialising bt * Update clang-format * Revert "Update clang-format" This reverts commit d61295ac063c6ec879375ceeab54d6ff2c90a9a1. * Format sources with clang-format * Revert old stack size for desktop settings * Allocate big struct dynamically * Simplify PIN comparison * Save pointer to storage in Desktop object * Fix region provisioning for hardware regions * Remove stale TODO + siimplify code * Clean up region.c * Use sizeof instead of macro define * Limit PIN length to 10 for consistency * Emit a warning upon usage of /any * Add delay after finding flipper * Remove unnecessary delay * Remove all mentions of STORAGE_INT_ON_LFS * Remove littlefs and internal storage * Remove all possible LittleFS mentions * Fix browser tab in Archive * Ble: fix connection interval explanation * Bump API Symbols * BLE: Update comments interval connection comments * Storage: clear FuriHalRtcFlagStorageFormatInternal if set --------- Co-authored-by: Georgii Surkov <georgii.surkov@outlook.com> Co-authored-by: hedger <hedger@nanode.su> Co-authored-by: Georgii Surkov <37121527+gsurkov@users.noreply.github.com>
This commit is contained in:
@@ -4,7 +4,6 @@ App(
|
||||
apptype=FlipperAppType.METAPACKAGE,
|
||||
provides=[
|
||||
"updater_app",
|
||||
"storage_move_to_sd",
|
||||
"js_app",
|
||||
"js_app_start",
|
||||
# "archive",
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
App(
|
||||
appid="storage_move_to_sd",
|
||||
name="StorageMoveToSd",
|
||||
apptype=FlipperAppType.SYSTEM,
|
||||
entry_point="storage_move_to_sd_app",
|
||||
requires=["gui", "storage"],
|
||||
provides=["storage_move_to_sd_start"],
|
||||
stack_size=2 * 1024,
|
||||
order=30,
|
||||
)
|
||||
|
||||
App(
|
||||
appid="storage_move_to_sd_start",
|
||||
apptype=FlipperAppType.STARTUP,
|
||||
entry_point="storage_move_to_sd_start",
|
||||
requires=["storage"],
|
||||
order=120,
|
||||
)
|
||||
@@ -1,30 +0,0 @@
|
||||
#include "storage_move_to_sd_scene.h"
|
||||
|
||||
// Generate scene on_enter handlers array
|
||||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter,
|
||||
void (*const storage_move_to_sd_on_enter_handlers[])(void*) = {
|
||||
#include "storage_move_to_sd_scene_config.h"
|
||||
};
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_event handlers array
|
||||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_event,
|
||||
bool (*const storage_move_to_sd_on_event_handlers[])(void* context, SceneManagerEvent event) = {
|
||||
#include "storage_move_to_sd_scene_config.h"
|
||||
};
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_exit handlers array
|
||||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_exit,
|
||||
void (*const storage_move_to_sd_on_exit_handlers[])(void* context) = {
|
||||
#include "storage_move_to_sd_scene_config.h"
|
||||
};
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Initialize scene handlers configuration structure
|
||||
const SceneManagerHandlers storage_move_to_sd_scene_handlers = {
|
||||
.on_enter_handlers = storage_move_to_sd_on_enter_handlers,
|
||||
.on_event_handlers = storage_move_to_sd_on_event_handlers,
|
||||
.on_exit_handlers = storage_move_to_sd_on_exit_handlers,
|
||||
.scene_num = StorageMoveToSdSceneNum,
|
||||
};
|
||||
@@ -1,29 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <gui/scene_manager.h>
|
||||
|
||||
// Generate scene id and total number
|
||||
#define ADD_SCENE(prefix, name, id) StorageMoveToSd##id,
|
||||
typedef enum {
|
||||
#include "storage_move_to_sd_scene_config.h"
|
||||
StorageMoveToSdSceneNum,
|
||||
} StorageMoveToSdScene;
|
||||
#undef ADD_SCENE
|
||||
|
||||
extern const SceneManagerHandlers storage_move_to_sd_scene_handlers;
|
||||
|
||||
// Generate scene on_enter handlers declaration
|
||||
#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_enter(void*);
|
||||
#include "storage_move_to_sd_scene_config.h"
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_event handlers declaration
|
||||
#define ADD_SCENE(prefix, name, id) \
|
||||
bool prefix##_scene_##name##_on_event(void* context, SceneManagerEvent event);
|
||||
#include "storage_move_to_sd_scene_config.h"
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_exit handlers declaration
|
||||
#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_exit(void* context);
|
||||
#include "storage_move_to_sd_scene_config.h"
|
||||
#undef ADD_SCENE
|
||||
@@ -1,2 +0,0 @@
|
||||
ADD_SCENE(storage_move_to_sd, confirm, Confirm)
|
||||
ADD_SCENE(storage_move_to_sd, progress, Progress)
|
||||
@@ -1,70 +0,0 @@
|
||||
#include "../storage_move_to_sd.h"
|
||||
#include <gui/canvas.h>
|
||||
#include <gui/modules/widget_elements/widget_element_i.h>
|
||||
#include <storage/storage.h>
|
||||
|
||||
static void storage_move_to_sd_scene_confirm_widget_callback(
|
||||
GuiButtonType result,
|
||||
InputType type,
|
||||
void* context) {
|
||||
StorageMoveToSd* app = context;
|
||||
furi_assert(app);
|
||||
if(type == InputTypeShort) {
|
||||
if(result == GuiButtonTypeRight) {
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, MoveToSdCustomEventConfirm);
|
||||
} else if(result == GuiButtonTypeLeft) {
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, MoveToSdCustomEventExit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void storage_move_to_sd_scene_confirm_on_enter(void* context) {
|
||||
StorageMoveToSd* app = context;
|
||||
|
||||
widget_add_button_element(
|
||||
app->widget,
|
||||
GuiButtonTypeLeft,
|
||||
"Cancel",
|
||||
storage_move_to_sd_scene_confirm_widget_callback,
|
||||
app);
|
||||
widget_add_button_element(
|
||||
app->widget,
|
||||
GuiButtonTypeRight,
|
||||
"Confirm",
|
||||
storage_move_to_sd_scene_confirm_widget_callback,
|
||||
app);
|
||||
|
||||
widget_add_string_element(
|
||||
app->widget, 64, 10, AlignCenter, AlignCenter, FontPrimary, "SD card inserted");
|
||||
widget_add_string_multiline_element(
|
||||
app->widget,
|
||||
64,
|
||||
32,
|
||||
AlignCenter,
|
||||
AlignCenter,
|
||||
FontSecondary,
|
||||
"Move data from\ninternal storage to SD card?");
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, StorageMoveToSdViewWidget);
|
||||
}
|
||||
|
||||
bool storage_move_to_sd_scene_confirm_on_event(void* context, SceneManagerEvent event) {
|
||||
StorageMoveToSd* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == MoveToSdCustomEventConfirm) {
|
||||
scene_manager_next_scene(app->scene_manager, StorageMoveToSdProgress);
|
||||
consumed = true;
|
||||
} else if(event.event == MoveToSdCustomEventExit) {
|
||||
view_dispatcher_stop(app->view_dispatcher);
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void storage_move_to_sd_scene_confirm_on_exit(void* context) {
|
||||
StorageMoveToSd* app = context;
|
||||
widget_reset(app->widget);
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
#include "../storage_move_to_sd.h"
|
||||
|
||||
void storage_move_to_sd_scene_progress_on_enter(void* context) {
|
||||
StorageMoveToSd* app = context;
|
||||
|
||||
widget_add_string_element(
|
||||
app->widget, 64, 10, AlignCenter, AlignCenter, FontPrimary, "Moving...");
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, StorageMoveToSdViewWidget);
|
||||
|
||||
storage_move_to_sd_perform();
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, MoveToSdCustomEventExit);
|
||||
}
|
||||
|
||||
bool storage_move_to_sd_scene_progress_on_event(void* context, SceneManagerEvent event) {
|
||||
StorageMoveToSd* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
view_dispatcher_stop(app->view_dispatcher);
|
||||
} else if(event.type == SceneManagerEventTypeBack) {
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void storage_move_to_sd_scene_progress_on_exit(void* context) {
|
||||
StorageMoveToSd* app = context;
|
||||
widget_reset(app->widget);
|
||||
}
|
||||
@@ -1,188 +0,0 @@
|
||||
#include "storage_move_to_sd.h"
|
||||
|
||||
#include <core/common_defines.h>
|
||||
#include <core/log.h>
|
||||
#include <loader/loader.h>
|
||||
#include <toolbox/dir_walk.h>
|
||||
#include <toolbox/path.h>
|
||||
|
||||
#define TAG "MoveToSd"
|
||||
|
||||
#define MOVE_SRC STORAGE_INT_PATH_PREFIX
|
||||
#define MOVE_DST STORAGE_EXT_PATH_PREFIX
|
||||
|
||||
static bool storage_move_to_sd_check_entry(const char* name, FileInfo* fileinfo, void* ctx) {
|
||||
UNUSED(ctx);
|
||||
if(file_info_is_dir(fileinfo)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return name && (*name != '.');
|
||||
}
|
||||
|
||||
bool storage_move_to_sd_perform(void) {
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
|
||||
DirWalk* dir_walk = dir_walk_alloc(storage);
|
||||
dir_walk_set_recursive(dir_walk, false);
|
||||
dir_walk_set_filter_cb(dir_walk, storage_move_to_sd_check_entry, NULL);
|
||||
|
||||
FuriString *path_src, *path_dst;
|
||||
|
||||
path_dst = furi_string_alloc();
|
||||
path_src = furi_string_alloc();
|
||||
|
||||
if(dir_walk_open(dir_walk, STORAGE_INT_PATH_PREFIX)) {
|
||||
while(dir_walk_read(dir_walk, path_src, NULL) == DirWalkOK) {
|
||||
furi_string_set(path_dst, path_src);
|
||||
furi_string_replace_at(
|
||||
path_dst, 0, strlen(STORAGE_INT_PATH_PREFIX), STORAGE_EXT_PATH_PREFIX);
|
||||
|
||||
storage_common_merge(
|
||||
storage, furi_string_get_cstr(path_src), furi_string_get_cstr(path_dst));
|
||||
storage_simply_remove_recursive(storage, furi_string_get_cstr(path_src));
|
||||
}
|
||||
}
|
||||
|
||||
dir_walk_free(dir_walk);
|
||||
furi_string_free(path_dst);
|
||||
furi_string_free(path_src);
|
||||
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool storage_move_to_sd_check(void) {
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
|
||||
bool should_migrate = false;
|
||||
|
||||
DirWalk* dir_walk = dir_walk_alloc(storage);
|
||||
dir_walk_set_recursive(dir_walk, false);
|
||||
dir_walk_set_filter_cb(dir_walk, storage_move_to_sd_check_entry, NULL);
|
||||
|
||||
FuriString* name;
|
||||
name = furi_string_alloc();
|
||||
|
||||
if(dir_walk_open(dir_walk, STORAGE_INT_PATH_PREFIX)) {
|
||||
// if at least 1 entry is present, we should migrate
|
||||
should_migrate = (dir_walk_read(dir_walk, name, NULL) == DirWalkOK);
|
||||
}
|
||||
|
||||
dir_walk_free(dir_walk);
|
||||
furi_string_free(name);
|
||||
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
return should_migrate;
|
||||
}
|
||||
|
||||
static bool storage_move_to_sd_custom_event_callback(void* context, uint32_t event) {
|
||||
furi_assert(context);
|
||||
StorageMoveToSd* app = context;
|
||||
return scene_manager_handle_custom_event(app->scene_manager, event);
|
||||
}
|
||||
|
||||
static bool storage_move_to_sd_back_event_callback(void* context) {
|
||||
furi_assert(context);
|
||||
StorageMoveToSd* app = context;
|
||||
return scene_manager_handle_back_event(app->scene_manager);
|
||||
}
|
||||
|
||||
static void storage_move_to_sd_unmount_callback(const void* message, void* context) {
|
||||
StorageMoveToSd* app = context;
|
||||
furi_assert(app);
|
||||
const StorageEvent* storage_event = message;
|
||||
|
||||
if((storage_event->type == StorageEventTypeCardUnmount) ||
|
||||
(storage_event->type == StorageEventTypeCardMountError)) {
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, MoveToSdCustomEventExit);
|
||||
}
|
||||
}
|
||||
|
||||
static StorageMoveToSd* storage_move_to_sd_alloc(void) {
|
||||
StorageMoveToSd* app = malloc(sizeof(StorageMoveToSd));
|
||||
|
||||
app->gui = furi_record_open(RECORD_GUI);
|
||||
app->notifications = furi_record_open(RECORD_NOTIFICATION);
|
||||
|
||||
app->view_dispatcher = view_dispatcher_alloc();
|
||||
app->scene_manager = scene_manager_alloc(&storage_move_to_sd_scene_handlers, app);
|
||||
|
||||
view_dispatcher_enable_queue(app->view_dispatcher);
|
||||
view_dispatcher_set_event_callback_context(app->view_dispatcher, app);
|
||||
|
||||
view_dispatcher_set_custom_event_callback(
|
||||
app->view_dispatcher, storage_move_to_sd_custom_event_callback);
|
||||
view_dispatcher_set_navigation_event_callback(
|
||||
app->view_dispatcher, storage_move_to_sd_back_event_callback);
|
||||
|
||||
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
|
||||
|
||||
app->widget = widget_alloc();
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher, StorageMoveToSdViewWidget, widget_get_view(app->widget));
|
||||
|
||||
scene_manager_next_scene(app->scene_manager, StorageMoveToSdConfirm);
|
||||
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
app->sub = furi_pubsub_subscribe(
|
||||
storage_get_pubsub(storage), storage_move_to_sd_unmount_callback, app);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
static void storage_move_to_sd_free(StorageMoveToSd* app) {
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
furi_pubsub_unsubscribe(storage_get_pubsub(storage), app->sub);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
furi_record_close(RECORD_NOTIFICATION);
|
||||
|
||||
view_dispatcher_remove_view(app->view_dispatcher, StorageMoveToSdViewWidget);
|
||||
widget_free(app->widget);
|
||||
view_dispatcher_free(app->view_dispatcher);
|
||||
scene_manager_free(app->scene_manager);
|
||||
|
||||
furi_record_close(RECORD_GUI);
|
||||
|
||||
free(app);
|
||||
}
|
||||
|
||||
int32_t storage_move_to_sd_app(void* p) {
|
||||
UNUSED(p);
|
||||
|
||||
if(storage_move_to_sd_check()) {
|
||||
StorageMoveToSd* app = storage_move_to_sd_alloc();
|
||||
notification_message(app->notifications, &sequence_display_backlight_on);
|
||||
view_dispatcher_run(app->view_dispatcher);
|
||||
storage_move_to_sd_free(app);
|
||||
} else {
|
||||
FURI_LOG_I(TAG, "Nothing to move");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void storage_move_to_sd_mount_callback(const void* message, void* context) {
|
||||
UNUSED(context);
|
||||
|
||||
const StorageEvent* storage_event = message;
|
||||
|
||||
if(storage_event->type == StorageEventTypeCardMount) {
|
||||
Loader* loader = furi_record_open(RECORD_LOADER);
|
||||
loader_start(loader, "StorageMoveToSd", NULL, NULL);
|
||||
furi_record_close(RECORD_LOADER);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t storage_move_to_sd_start(void* p) {
|
||||
UNUSED(p);
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
|
||||
furi_pubsub_subscribe(storage_get_pubsub(storage), storage_move_to_sd_mount_callback, NULL);
|
||||
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
return 0;
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
#pragma once
|
||||
#include <gui/gui.h>
|
||||
#include <gui/view.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
#include <gui/scene_manager.h>
|
||||
#include <gui/modules/widget.h>
|
||||
#include <gui/modules/popup.h>
|
||||
#include <gui/modules/widget_elements/widget_element_i.h>
|
||||
|
||||
#include <notification/notification_messages.h>
|
||||
#include <storage/storage.h>
|
||||
#include <storage/storage_sd_api.h>
|
||||
#include <furi.h>
|
||||
|
||||
#include "scenes/storage_move_to_sd_scene.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
MoveToSdCustomEventExit,
|
||||
MoveToSdCustomEventConfirm,
|
||||
} MoveToSdCustomEvent;
|
||||
|
||||
typedef struct {
|
||||
// records
|
||||
Gui* gui;
|
||||
Widget* widget;
|
||||
NotificationApp* notifications;
|
||||
|
||||
// view management
|
||||
SceneManager* scene_manager;
|
||||
ViewDispatcher* view_dispatcher;
|
||||
|
||||
FuriPubSubSubscription* sub;
|
||||
|
||||
} StorageMoveToSd;
|
||||
|
||||
typedef enum {
|
||||
StorageMoveToSdViewWidget,
|
||||
} StorageMoveToSdView;
|
||||
|
||||
bool storage_move_to_sd_perform(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <storage/storage.h>
|
||||
#include <toolbox/path.h>
|
||||
#include <update_util/dfu_file.h>
|
||||
#include <update_util/lfs_backup.h>
|
||||
#include <update_util/update_operation.h>
|
||||
|
||||
#define TAG "UpdWorker"
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <storage/storage.h>
|
||||
#include <toolbox/path.h>
|
||||
#include <update_util/dfu_file.h>
|
||||
#include <update_util/lfs_backup.h>
|
||||
#include <update_util/update_operation.h>
|
||||
#include <toolbox/tar/tar_archive.h>
|
||||
#include <toolbox/crc32_calc.h>
|
||||
|
||||
Reference in New Issue
Block a user