From a397a3f9bd602cf66ddff06627cfccf80f220d26 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Wed, 26 Jul 2023 21:58:36 +0200 Subject: [PATCH] Improve flipper init and add logging + led --- furi/flipper.c | 31 +++++++++++++++++++++++-------- lib/xtreme/assets.c | 4 ---- lib/xtreme/settings.c | 4 ---- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/furi/flipper.c b/furi/flipper.c index 14a25e7ed..ce9493f88 100644 --- a/furi/flipper.c +++ b/furi/flipper.c @@ -39,19 +39,21 @@ static void flipper_print_version(const char* target, const Version* version) { } void flipper_migrate_files() { - if(!furi_hal_is_normal_boot()) return; Storage* storage = furi_record_open(RECORD_STORAGE); // Revert cringe + FURI_LOG_I(TAG, "Migrate: Remove unused files"); storage_common_remove(storage, INT_PATH(".passport.settings")); storage_common_remove(storage, INT_PATH(".region_data")); // Migrate files + FURI_LOG_I(TAG, "Migrate: Renames on external"); storage_common_copy(storage, ARCHIVE_FAV_OLD_PATH, ARCHIVE_FAV_PATH); storage_common_remove(storage, ARCHIVE_FAV_OLD_PATH); storage_common_copy(storage, DESKTOP_KEYBINDS_OLD_PATH, DESKTOP_KEYBINDS_PATH); storage_common_remove(storage, DESKTOP_KEYBINDS_OLD_PATH); // Int -> Ext + FURI_LOG_I(TAG, "Migrate: Internal to External"); storage_common_copy(storage, BT_SETTINGS_OLD_PATH, BT_SETTINGS_PATH); storage_common_remove(storage, BT_SETTINGS_OLD_PATH); storage_common_copy(storage, DOLPHIN_STATE_OLD_PATH, DOLPHIN_STATE_PATH); @@ -63,10 +65,12 @@ void flipper_migrate_files() { storage_common_copy(storage, NOTIFICATION_SETTINGS_OLD_PATH, NOTIFICATION_SETTINGS_PATH); storage_common_remove(storage, NOTIFICATION_SETTINGS_OLD_PATH); // Ext -> Int + FURI_LOG_I(TAG, "Migrate: External to Internal"); storage_common_copy(storage, DESKTOP_SETTINGS_OLD_PATH, DESKTOP_SETTINGS_PATH); storage_common_remove(storage, DESKTOP_SETTINGS_OLD_PATH); // Special care for U2F + FURI_LOG_I(TAG, "Migrate: U2F"); FileInfo file_info; if(storage_common_stat(storage, U2F_CNT_OLD_FILE, &file_info) == FSE_OK && file_info.size > 200) { // Is on Int and has content @@ -74,6 +78,7 @@ void flipper_migrate_files() { } storage_common_copy(storage, U2F_KEY_OLD_FILE, U2F_KEY_FILE); // Ext -> Int + FURI_LOG_I(TAG, "Migrate: Asset Packs"); storage_common_migrate(storage, XTREME_ASSETS_OLD_PATH, XTREME_ASSETS_PATH); furi_record_close(RECORD_STORAGE); @@ -91,20 +96,30 @@ void flipper_start_service(const FlipperInternalApplication* service) { } void flipper_init() { + furi_hal_light_sequence("rgb WB"); flipper_print_version("Firmware", furi_hal_version_get_firmware_version()); - - FURI_LOG_I(TAG, "Boot mode %d, starting services", furi_hal_rtc_get_boot_mode()); + FURI_LOG_I(TAG, "Boot mode %d", furi_hal_rtc_get_boot_mode()); // Start storage service first, thanks OFW :/ + FURI_LOG_I(TAG, "Initialize Storage"); flipper_start_service(&FLIPPER_SERVICES[0]); - flipper_migrate_files(); - - NAMESPOOF_INIT(); - XTREME_SETTINGS_LOAD(); - XTREME_ASSETS_LOAD(); + if(furi_hal_is_normal_boot()) { + FURI_LOG_I(TAG, "Start Migrate"); + flipper_migrate_files(); + FURI_LOG_I(TAG, "Start Namespoof"); + NAMESPOOF_INIT(); + FURI_LOG_I(TAG, "Load Xtreme Settings"); + XTREME_SETTINGS_LOAD(); + furi_hal_light_sequence("rgb WRB"); + FURI_LOG_I(TAG, "Load Xtreme Assets"); + XTREME_ASSETS_LOAD(); + } else { + FURI_LOG_I(TAG, "Special boot, skipping optional components"); + } // Everything else + FURI_LOG_I(TAG, "Initialize services"); for(size_t i = 1; i < FLIPPER_SERVICES_COUNT; i++) { flipper_start_service(&FLIPPER_SERVICES[i]); } diff --git a/lib/xtreme/assets.c b/lib/xtreme/assets.c index 821665ec4..df28ebbc9 100644 --- a/lib/xtreme/assets.c +++ b/lib/xtreme/assets.c @@ -102,8 +102,6 @@ void free_icon(const Icon* icon) { } void XTREME_ASSETS_LOAD() { - if(!furi_hal_is_normal_boot()) return; - const char* pack = XTREME_SETTINGS()->asset_pack; XTREME_SETTINGS()->is_nsfw = !strncmp(pack, "NSFW", strlen("NSFW")); if(pack[0] == '\0') return; @@ -133,8 +131,6 @@ void XTREME_ASSETS_LOAD() { } void XTREME_ASSETS_FREE() { - if(!furi_hal_is_normal_boot()) return; - for(size_t i = 0; i < ICON_PATHS_COUNT; i++) { if(ICON_PATHS[i].icon->original != NULL) { free_icon(ICON_PATHS[i].icon); diff --git a/lib/xtreme/settings.c b/lib/xtreme/settings.c index 7e6ba6413..24aa07f4e 100644 --- a/lib/xtreme/settings.c +++ b/lib/xtreme/settings.c @@ -37,8 +37,6 @@ XtremeSettings xtreme_settings = { }; void XTREME_SETTINGS_LOAD() { - if(!furi_hal_is_normal_boot()) return; - XtremeSettings* x = &xtreme_settings; Storage* storage = furi_record_open(RECORD_STORAGE); FlipperFormat* file = flipper_format_file_alloc(storage); @@ -169,8 +167,6 @@ void XTREME_SETTINGS_LOAD() { } void XTREME_SETTINGS_SAVE() { - if(!furi_hal_is_normal_boot()) return; - XtremeSettings* x = &xtreme_settings; Storage* storage = furi_record_open(RECORD_STORAGE); FlipperFormat* file = flipper_format_file_alloc(storage);