mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-20 04:54:45 -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:
@@ -3,6 +3,7 @@
|
||||
#include <furi_hal_serial_control.h>
|
||||
|
||||
#include <furi.h>
|
||||
#include <storage/storage.h>
|
||||
#include <toolbox/api_lock.h>
|
||||
|
||||
#include "expansion_worker.h"
|
||||
@@ -23,6 +24,7 @@ typedef enum {
|
||||
ExpansionMessageTypeEnable,
|
||||
ExpansionMessageTypeDisable,
|
||||
ExpansionMessageTypeSetListenSerial,
|
||||
ExpansionMessageTypeReloadSettings,
|
||||
ExpansionMessageTypeModuleConnected,
|
||||
ExpansionMessageTypeModuleDisconnected,
|
||||
} ExpansionMessageType;
|
||||
@@ -86,10 +88,8 @@ static void
|
||||
return;
|
||||
}
|
||||
|
||||
ExpansionSettings settings = {0};
|
||||
if(!expansion_settings_load(&settings)) {
|
||||
expansion_settings_save(&settings);
|
||||
}
|
||||
ExpansionSettings settings;
|
||||
expansion_settings_load(&settings);
|
||||
|
||||
if(settings.uart_index < FuriHalSerialIdMax) {
|
||||
instance->state = ExpansionStateEnabled;
|
||||
@@ -104,7 +104,6 @@ static void
|
||||
static void
|
||||
expansion_control_handler_disable(Expansion* instance, const ExpansionMessageData* data) {
|
||||
UNUSED(data);
|
||||
|
||||
if(instance->state == ExpansionStateDisabled) {
|
||||
return;
|
||||
} else if(instance->state == ExpansionStateRunning) {
|
||||
@@ -122,9 +121,10 @@ static void
|
||||
static void expansion_control_handler_set_listen_serial(
|
||||
Expansion* instance,
|
||||
const ExpansionMessageData* data) {
|
||||
furi_check(data->serial_id < FuriHalSerialIdMax);
|
||||
if(instance->state != ExpansionStateDisabled && instance->serial_id == data->serial_id) {
|
||||
return;
|
||||
|
||||
if(instance->state == ExpansionStateRunning) {
|
||||
} else if(instance->state == ExpansionStateRunning) {
|
||||
expansion_worker_stop(instance->worker);
|
||||
expansion_worker_free(instance->worker);
|
||||
|
||||
@@ -141,6 +141,26 @@ static void expansion_control_handler_set_listen_serial(
|
||||
FURI_LOG_D(TAG, "Listen serial changed to %s", expansion_uart_names[instance->serial_id]);
|
||||
}
|
||||
|
||||
static void expansion_control_handler_reload_settings(
|
||||
Expansion* instance,
|
||||
const ExpansionMessageData* data) {
|
||||
UNUSED(data);
|
||||
|
||||
ExpansionSettings settings;
|
||||
expansion_settings_load(&settings);
|
||||
|
||||
if(settings.uart_index < FuriHalSerialIdMax) {
|
||||
const ExpansionMessageData data = {
|
||||
.serial_id = settings.uart_index,
|
||||
};
|
||||
|
||||
expansion_control_handler_set_listen_serial(instance, &data);
|
||||
|
||||
} else {
|
||||
expansion_control_handler_disable(instance, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void expansion_control_handler_module_connected(
|
||||
Expansion* instance,
|
||||
const ExpansionMessageData* data) {
|
||||
@@ -178,6 +198,7 @@ static const ExpansionControlHandler expansion_control_handlers[] = {
|
||||
[ExpansionMessageTypeEnable] = expansion_control_handler_enable,
|
||||
[ExpansionMessageTypeDisable] = expansion_control_handler_disable,
|
||||
[ExpansionMessageTypeSetListenSerial] = expansion_control_handler_set_listen_serial,
|
||||
[ExpansionMessageTypeReloadSettings] = expansion_control_handler_reload_settings,
|
||||
[ExpansionMessageTypeModuleConnected] = expansion_control_handler_module_connected,
|
||||
[ExpansionMessageTypeModuleDisconnected] = expansion_control_handler_module_disconnected,
|
||||
};
|
||||
@@ -214,6 +235,22 @@ static Expansion* expansion_alloc(void) {
|
||||
return instance;
|
||||
}
|
||||
|
||||
static void expansion_storage_callback(const void* message, void* context) {
|
||||
furi_assert(context);
|
||||
|
||||
const StorageEvent* event = message;
|
||||
Expansion* instance = context;
|
||||
|
||||
if(event->type == StorageEventTypeCardMount) {
|
||||
ExpansionMessage em = {
|
||||
.type = ExpansionMessageTypeReloadSettings,
|
||||
.api_lock = NULL,
|
||||
};
|
||||
|
||||
furi_check(furi_message_queue_put(instance->queue, &em, FuriWaitForever) == FuriStatusOk);
|
||||
}
|
||||
}
|
||||
|
||||
void expansion_on_system_start(void* arg) {
|
||||
UNUSED(arg);
|
||||
|
||||
@@ -221,6 +258,14 @@ void expansion_on_system_start(void* arg) {
|
||||
furi_record_create(RECORD_EXPANSION, instance);
|
||||
furi_thread_start(instance->thread);
|
||||
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
furi_pubsub_subscribe(storage_get_pubsub(storage), expansion_storage_callback, instance);
|
||||
|
||||
if(storage_sd_status(storage) != FSE_OK) {
|
||||
FURI_LOG_D(TAG, "SD Card not ready, skipping settings");
|
||||
return;
|
||||
}
|
||||
|
||||
expansion_enable(instance);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user