From 0b806c23600ebe3c179f92e0883448e4e46950bd Mon Sep 17 00:00:00 2001 From: Sergey Gavrilov Date: Mon, 4 Sep 2023 08:10:07 +0300 Subject: [PATCH] Storage: force mount (#3033) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Storage: count opened files * Storage: sd mount * Storage: prompt to mount SD card if not mounted * F18: update API * F18: update API version * Fix logger naming scheme * Storage: storage_files_count -> storage_open_files_count Co-authored-by: あく --- .../debug/unit_tests/subghz/subghz_test.c | 2 +- .../drivers/subghz/cc1101_ext/cc1101_ext.c | 2 +- .../cc1101_ext/cc1101_ext_interconnect.c | 2 +- .../example_apps_assets/example_apps_assets.c | 2 +- .../example_apps_data/example_apps_data.c | 2 +- .../example_plugins/example_plugins.c | 2 +- .../example_plugins/example_plugins_multi.c | 2 +- .../example_advanced_plugins.c | 2 +- .../main/bad_usb/helpers/ducky_script.c | 2 +- .../bad_usb/helpers/ducky_script_commands.c | 2 +- applications/main/ibutton/ibutton.c | 2 +- .../subghz/scenes/subghz_scene_read_raw.c | 2 +- applications/main/subghz/subghz_cli.c | 2 +- .../main/subghz/views/subghz_read_raw.c | 2 +- applications/main/u2f/u2f.c | 2 +- applications/main/u2f/u2f_data.c | 2 +- applications/main/u2f/u2f_hid.c | 2 +- applications/services/storage/storage.c | 2 +- applications/services/storage/storage.h | 10 +++- .../services/storage/storage_external_api.c | 10 +++- applications/services/storage/storage_glue.c | 7 +++ applications/services/storage/storage_glue.h | 2 + .../services/storage/storage_message.h | 1 + .../services/storage/storage_processing.c | 41 +++++++++++++--- .../services/storage/storages/storage_ext.c | 47 +++++++++++-------- .../services/storage/storages/storage_ext.h | 1 + .../scenes/storage_settings_scene_start.c | 24 +++++++--- .../storage_settings_scene_unmount_confirm.c | 14 ++++-- .../scenes/storage_settings_scene_unmounted.c | 41 +++++++++++----- .../updater/util/update_task_worker_flasher.c | 2 +- firmware/targets/f18/api_symbols.csv | 3 +- firmware/targets/f7/api_symbols.csv | 3 +- firmware/targets/f7/furi_hal/furi_hal_i2c.c | 2 +- .../api_hashtable/api_hashtable.cpp | 2 +- lib/flipper_application/application_assets.c | 2 +- lib/flipper_application/elf/elf_file.c | 2 +- .../plugins/plugin_manager.c | 2 +- lib/lfrfid/lfrfid_raw_file.c | 2 +- lib/lfrfid/lfrfid_raw_worker.c | 2 +- lib/lfrfid/lfrfid_worker_modes.c | 2 +- lib/nfc/protocols/slix.c | 2 +- .../cc1101_int/cc1101_int_interconnect.c | 2 +- lib/subghz/protocols/alutech_at_4n.c | 2 +- lib/subghz/protocols/bett.c | 2 +- lib/subghz/protocols/bin_raw.c | 2 +- lib/subghz/protocols/came.c | 2 +- lib/subghz/protocols/came_twee.c | 2 +- lib/subghz/protocols/chamberlain_code.c | 2 +- lib/subghz/protocols/faac_slh.c | 2 +- lib/subghz/protocols/holtek_ht12x.c | 2 +- lib/subghz/protocols/honeywell_wdb.c | 2 +- lib/subghz/protocols/hormann.c | 2 +- lib/subghz/protocols/ido.c | 2 +- lib/subghz/protocols/kia.c | 2 +- lib/subghz/protocols/kinggates_stylo_4k.c | 2 +- lib/subghz/protocols/nice_flo.c | 2 +- lib/subghz/protocols/phoenix_v2.c | 2 +- lib/subghz/protocols/raw.c | 2 +- lib/subghz/protocols/secplus_v1.c | 2 +- lib/subghz/protocols/secplus_v2.c | 2 +- lib/subghz/protocols/smc5326.c | 2 +- 61 files changed, 201 insertions(+), 99 deletions(-) diff --git a/applications/debug/unit_tests/subghz/subghz_test.c b/applications/debug/unit_tests/subghz/subghz_test.c index e32a5748..1900f204 100644 --- a/applications/debug/unit_tests/subghz/subghz_test.c +++ b/applications/debug/unit_tests/subghz/subghz_test.c @@ -10,7 +10,7 @@ #include #include -#define TAG "SubGhz TEST" +#define TAG "SubGhzTest" #define KEYSTORE_DIR_NAME EXT_PATH("subghz/assets/keeloq_mfcodes") #define CAME_ATOMO_DIR_NAME EXT_PATH("subghz/assets/came_atomo") #define NICE_FLOR_S_DIR_NAME EXT_PATH("subghz/assets/nice_flor_s") diff --git a/applications/drivers/subghz/cc1101_ext/cc1101_ext.c b/applications/drivers/subghz/cc1101_ext/cc1101_ext.c index 0a9599d0..4fb249c6 100644 --- a/applications/drivers/subghz/cc1101_ext/cc1101_ext.c +++ b/applications/drivers/subghz/cc1101_ext/cc1101_ext.c @@ -16,7 +16,7 @@ #include #include -#define TAG "SubGhz_Device_CC1101_Ext" +#define TAG "SubGhzDeviceCc1101Ext" #define SUBGHZ_DEVICE_CC1101_EXT_TX_GPIO &gpio_ext_pb2 diff --git a/applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.c b/applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.c index 51f5a0d1..1f119315 100644 --- a/applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.c +++ b/applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.c @@ -2,7 +2,7 @@ #include "cc1101_ext.h" #include -#define TAG "SubGhzDeviceCC1101Ext" +#define TAG "SubGhzDeviceCc1101Ext" static bool subghz_device_cc1101_ext_interconnect_is_frequency_valid(uint32_t frequency) { bool ret = subghz_device_cc1101_ext_is_frequency_valid(frequency); diff --git a/applications/examples/example_apps_assets/example_apps_assets.c b/applications/examples/example_apps_assets/example_apps_assets.c index f2d0272f..2c2cc8a8 100644 --- a/applications/examples/example_apps_assets/example_apps_assets.c +++ b/applications/examples/example_apps_assets/example_apps_assets.c @@ -4,7 +4,7 @@ #include // Define log tag -#define TAG "example_apps_assets" +#define TAG "ExampleAppsAssets" static void example_apps_data_print_file_content(Storage* storage, const char* path) { Stream* stream = file_stream_alloc(storage); diff --git a/applications/examples/example_apps_data/example_apps_data.c b/applications/examples/example_apps_data/example_apps_data.c index d6104c13..7a297b01 100644 --- a/applications/examples/example_apps_data/example_apps_data.c +++ b/applications/examples/example_apps_data/example_apps_data.c @@ -2,7 +2,7 @@ #include // Define log tag -#define TAG "example_apps_data" +#define TAG "ExampleAppsData" // Application entry point int32_t example_apps_data_main(void* p) { diff --git a/applications/examples/example_plugins/example_plugins.c b/applications/examples/example_plugins/example_plugins.c index acc5903a..7e71e0d2 100644 --- a/applications/examples/example_plugins/example_plugins.c +++ b/applications/examples/example_plugins/example_plugins.c @@ -11,7 +11,7 @@ #include #include -#define TAG "example_plugins" +#define TAG "ExamplePlugins" int32_t example_plugins_app(void* p) { UNUSED(p); diff --git a/applications/examples/example_plugins/example_plugins_multi.c b/applications/examples/example_plugins/example_plugins_multi.c index 12eba01c..3525b39e 100644 --- a/applications/examples/example_plugins/example_plugins_multi.c +++ b/applications/examples/example_plugins/example_plugins_multi.c @@ -11,7 +11,7 @@ #include -#define TAG "example_plugins" +#define TAG "ExamplePlugins" int32_t example_plugins_multi_app(void* p) { UNUSED(p); diff --git a/applications/examples/example_plugins_advanced/example_advanced_plugins.c b/applications/examples/example_plugins_advanced/example_advanced_plugins.c index f27b0a08..2b137e1d 100644 --- a/applications/examples/example_plugins_advanced/example_advanced_plugins.c +++ b/applications/examples/example_plugins_advanced/example_advanced_plugins.c @@ -8,7 +8,7 @@ #include -#define TAG "example_advanced_plugins" +#define TAG "ExampleAdvancedPlugins" int32_t example_advanced_plugins_app(void* p) { UNUSED(p); diff --git a/applications/main/bad_usb/helpers/ducky_script.c b/applications/main/bad_usb/helpers/ducky_script.c index f194178a..11c74c01 100644 --- a/applications/main/bad_usb/helpers/ducky_script.c +++ b/applications/main/bad_usb/helpers/ducky_script.c @@ -9,7 +9,7 @@ #include "ducky_script_i.h" #include -#define TAG "BadUSB" +#define TAG "BadUsb" #define WORKER_TAG TAG "Worker" #define BADUSB_ASCII_TO_KEY(script, x) \ diff --git a/applications/main/bad_usb/helpers/ducky_script_commands.c b/applications/main/bad_usb/helpers/ducky_script_commands.c index d073b4c8..cc713135 100644 --- a/applications/main/bad_usb/helpers/ducky_script_commands.c +++ b/applications/main/bad_usb/helpers/ducky_script_commands.c @@ -171,7 +171,7 @@ static const DuckyCmd ducky_commands[] = { {"WAIT_FOR_BUTTON_PRESS", ducky_fnc_waitforbutton, -1}, }; -#define TAG "BadUSB" +#define TAG "BadUsb" #define WORKER_TAG TAG "Worker" int32_t ducky_execute_cmd(BadUsbScript* bad_usb, const char* line) { diff --git a/applications/main/ibutton/ibutton.c b/applications/main/ibutton/ibutton.c index 67873690..0e4c621b 100644 --- a/applications/main/ibutton/ibutton.c +++ b/applications/main/ibutton/ibutton.c @@ -3,7 +3,7 @@ #include #include -#define TAG "iButtonApp" +#define TAG "IButtonApp" static const NotificationSequence sequence_blink_set_yellow = { &message_blink_set_color_yellow, diff --git a/applications/main/subghz/scenes/subghz_scene_read_raw.c b/applications/main/subghz/scenes/subghz_scene_read_raw.c index bbcc4325..f2ab6577 100644 --- a/applications/main/subghz/scenes/subghz_scene_read_raw.c +++ b/applications/main/subghz/scenes/subghz_scene_read_raw.c @@ -5,7 +5,7 @@ #include #define RAW_FILE_NAME "Raw_signal_" -#define TAG "SubGhzSceneReadRAW" +#define TAG "SubGhzSceneReadRaw" bool subghz_scene_read_raw_update_filename(SubGhz* subghz) { bool ret = false; diff --git a/applications/main/subghz/subghz_cli.c b/applications/main/subghz/subghz_cli.c index fe97c8a0..f7d6b3a1 100644 --- a/applications/main/subghz/subghz_cli.c +++ b/applications/main/subghz/subghz_cli.c @@ -28,7 +28,7 @@ #define SUBGHZ_REGION_FILENAME "/int/.region_data" -#define TAG "SubGhz CLI" +#define TAG "SubGhzCli" static void subghz_cli_radio_device_power_on() { uint8_t attempts = 5; diff --git a/applications/main/subghz/views/subghz_read_raw.c b/applications/main/subghz/views/subghz_read_raw.c index 88ac129c..b074cdc9 100644 --- a/applications/main/subghz/views/subghz_read_raw.c +++ b/applications/main/subghz/views/subghz_read_raw.c @@ -9,7 +9,7 @@ #include #define SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE 100 -#define TAG "SubGhzReadRAW" +#define TAG "SubGhzReadRaw" struct SubGhzReadRAW { View* view; diff --git a/applications/main/u2f/u2f.c b/applications/main/u2f/u2f.c index 0ed5ebb2..ce70212a 100644 --- a/applications/main/u2f/u2f.c +++ b/applications/main/u2f/u2f.c @@ -10,7 +10,7 @@ #include "hmac_sha256.h" #include "micro-ecc/uECC.h" -#define TAG "U2F" +#define TAG "U2f" #define WORKER_TAG TAG "Worker" #define U2F_CMD_REGISTER 0x01 diff --git a/applications/main/u2f/u2f_data.c b/applications/main/u2f/u2f_data.c index 8489ed91..34360f3d 100644 --- a/applications/main/u2f/u2f_data.c +++ b/applications/main/u2f/u2f_data.c @@ -5,7 +5,7 @@ #include #include -#define TAG "U2F" +#define TAG "U2f" #define U2F_DATA_FOLDER EXT_PATH("u2f/") #define U2F_CERT_FILE U2F_DATA_FOLDER "assets/cert.der" diff --git a/applications/main/u2f/u2f_hid.c b/applications/main/u2f/u2f_hid.c index 9b625c1f..d7d7e6cf 100644 --- a/applications/main/u2f/u2f_hid.c +++ b/applications/main/u2f/u2f_hid.c @@ -10,7 +10,7 @@ #include -#define TAG "U2FHID" +#define TAG "U2fHid" #define WORKER_TAG TAG "Worker" #define U2F_HID_MAX_PAYLOAD_LEN ((HID_U2F_PACKET_LEN - 7) + 128 * (HID_U2F_PACKET_LEN - 5)) diff --git a/applications/services/storage/storage.c b/applications/services/storage/storage.c index 1816bf92..a6229af8 100644 --- a/applications/services/storage/storage.c +++ b/applications/services/storage/storage.c @@ -12,7 +12,7 @@ #define ICON_SD_MOUNTED &I_SDcardMounted_11x8 #define ICON_SD_ERROR &I_SDcardFail_11x8 -#define TAG RECORD_STORAGE +#define TAG "Storage" static void storage_app_sd_icon_draw_callback(Canvas* canvas, void* context) { furi_assert(canvas); diff --git a/applications/services/storage/storage.h b/applications/services/storage/storage.h index dccf2959..1abc8ed0 100644 --- a/applications/services/storage/storage.h +++ b/applications/services/storage/storage.h @@ -334,12 +334,20 @@ const char* storage_file_get_error_desc(File* file); */ FS_Error storage_sd_format(Storage* api); -/** Will unmount the SD card +/** Will unmount the SD card. + * Will return FSE_NOT_READY if the SD card is not mounted. + * Will return FSE_DENIED if there are open files on the SD card. * @param api pointer to the api * @return FS_Error operation result */ FS_Error storage_sd_unmount(Storage* api); +/** Will mount the SD card + * @param api pointer to the api + * @return FS_Error operation result + */ +FS_Error storage_sd_mount(Storage* api); + /** Retrieves SD card information * @param api pointer to the api * @param info pointer to the info diff --git a/applications/services/storage/storage_external_api.c b/applications/services/storage/storage_external_api.c index 585ded41..2ba58f9c 100644 --- a/applications/services/storage/storage_external_api.c +++ b/applications/services/storage/storage_external_api.c @@ -11,7 +11,7 @@ #define MAX_EXT_LEN 16 #define FILE_BUFFER_SIZE 512 -#define TAG "StorageAPI" +#define TAG "StorageApi" #define S_API_PROLOGUE FuriApiLock lock = api_lock_alloc_locked(); @@ -781,6 +781,14 @@ FS_Error storage_sd_unmount(Storage* storage) { return S_RETURN_ERROR; } +FS_Error storage_sd_mount(Storage* storage) { + S_API_PROLOGUE; + SAData data = {}; + S_API_MESSAGE(StorageCommandSDMount); + S_API_EPILOGUE; + return S_RETURN_ERROR; +} + FS_Error storage_sd_info(Storage* storage, SDInfo* info) { S_API_PROLOGUE; SAData data = { diff --git a/applications/services/storage/storage_glue.c b/applications/services/storage/storage_glue.c index 63e44c9d..41da6c3f 100644 --- a/applications/services/storage/storage_glue.c +++ b/applications/services/storage/storage_glue.c @@ -1,6 +1,8 @@ #include "storage_glue.h" #include +#define TAG "StorageGlue" + /****************** storage file ******************/ void storage_file_init(StorageFile* obj) { @@ -149,3 +151,8 @@ bool storage_pop_storage_file(File* file, StorageData* storage) { return result; } + +size_t storage_open_files_count(StorageData* storage) { + size_t count = StorageFileList_size(storage->files); + return count; +} diff --git a/applications/services/storage/storage_glue.h b/applications/services/storage/storage_glue.h index f1064034..4323296c 100644 --- a/applications/services/storage/storage_glue.h +++ b/applications/services/storage/storage_glue.h @@ -68,6 +68,8 @@ void* storage_get_storage_file_data(const File* file, StorageData* storage); void storage_push_storage_file(File* file, FuriString* path, StorageData* storage); bool storage_pop_storage_file(File* file, StorageData* storage); +size_t storage_open_files_count(StorageData* storage); + #ifdef __cplusplus } #endif diff --git a/applications/services/storage/storage_message.h b/applications/services/storage/storage_message.h index 9e13bf83..01bc2038 100644 --- a/applications/services/storage/storage_message.h +++ b/applications/services/storage/storage_message.h @@ -141,6 +141,7 @@ typedef enum { StorageCommandSDInfo, StorageCommandSDStatus, StorageCommandCommonResolvePath, + StorageCommandSDMount, } StorageCommand; typedef struct { diff --git a/applications/services/storage/storage_processing.c b/applications/services/storage/storage_processing.c index 70cb7b92..00126af6 100644 --- a/applications/services/storage/storage_processing.c +++ b/applications/services/storage/storage_processing.c @@ -418,12 +418,38 @@ static FS_Error storage_process_sd_format(Storage* app) { static FS_Error storage_process_sd_unmount(Storage* app) { FS_Error ret = FSE_OK; - if(storage_data_status(&app->storage[ST_EXT]) == StorageStatusNotReady) { - ret = FSE_NOT_READY; - } else { - sd_unmount_card(&app->storage[ST_EXT]); - storage_data_timestamp(&app->storage[ST_EXT]); - } + do { + StorageData* storage = &app->storage[ST_EXT]; + if(storage_data_status(storage) == StorageStatusNotReady) { + ret = FSE_NOT_READY; + break; + } + + if(storage_open_files_count(storage)) { + ret = FSE_DENIED; + break; + } + + sd_unmount_card(storage); + storage_data_timestamp(storage); + } while(false); + + return ret; +} + +static FS_Error storage_process_sd_mount(Storage* app) { + FS_Error ret = FSE_OK; + + do { + StorageData* storage = &app->storage[ST_EXT]; + if(storage_data_status(storage) != StorageStatusNotReady) { + ret = FSE_NOT_READY; + break; + } + + ret = sd_mount_card(storage, true); + storage_data_timestamp(storage); + } while(false); return ret; } @@ -630,6 +656,9 @@ void storage_process_message_internal(Storage* app, StorageMessage* message) { case StorageCommandSDUnmount: message->return_data->error_value = storage_process_sd_unmount(app); break; + case StorageCommandSDMount: + message->return_data->error_value = storage_process_sd_mount(app); + break; case StorageCommandSDInfo: message->return_data->error_value = storage_process_sd_info(app, message->data->sdinfo.info); diff --git a/applications/services/storage/storages/storage_ext.c b/applications/services/storage/storages/storage_ext.c index 35b3ee25..080ac4fa 100644 --- a/applications/services/storage/storages/storage_ext.c +++ b/applications/services/storage/storages/storage_ext.c @@ -24,7 +24,7 @@ static FS_Error storage_ext_parse_error(SDError error); /******************* Core Functions *******************/ -static bool sd_mount_card(StorageData* storage, bool notify) { +static bool sd_mount_card_internal(StorageData* storage, bool notify) { bool result = false; uint8_t counter = sd_max_mount_retry_count(); uint8_t bsp_result; @@ -106,6 +106,32 @@ FS_Error sd_unmount_card(StorageData* storage) { return storage_ext_parse_error(error); } +FS_Error sd_mount_card(StorageData* storage, bool notify) { + sd_mount_card_internal(storage, notify); + FS_Error error; + + if(storage->status != StorageStatusOK) { + FURI_LOG_E(TAG, "sd init error: %s", storage_data_status_text(storage)); + if(notify) { + NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION); + sd_notify_error(notification); + furi_record_close(RECORD_NOTIFICATION); + } + error = FSE_INTERNAL; + } else { + FURI_LOG_I(TAG, "card mounted"); + if(notify) { + NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION); + sd_notify_success(notification); + furi_record_close(RECORD_NOTIFICATION); + } + + error = FSE_OK; + } + + return error; +} + FS_Error sd_format_card(StorageData* storage) { #ifdef FURI_RAM_EXEC UNUSED(storage); @@ -222,25 +248,8 @@ static void storage_ext_tick_internal(StorageData* storage, bool notify) { if(sd_data->sd_was_present) { if(hal_sd_detect()) { FURI_LOG_I(TAG, "card detected"); - sd_mount_card(storage, notify); - - if(storage->status != StorageStatusOK) { - FURI_LOG_E(TAG, "sd init error: %s", storage_data_status_text(storage)); - if(notify) { - NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION); - sd_notify_error(notification); - furi_record_close(RECORD_NOTIFICATION); - } - } else { - FURI_LOG_I(TAG, "card mounted"); - if(notify) { - NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION); - sd_notify_success(notification); - furi_record_close(RECORD_NOTIFICATION); - } - } - sd_data->sd_was_present = false; + sd_mount_card(storage, notify); if(!hal_sd_detect()) { FURI_LOG_I(TAG, "card removed while mounting"); diff --git a/applications/services/storage/storages/storage_ext.h b/applications/services/storage/storages/storage_ext.h index 07ddbcf2..18d1f714 100644 --- a/applications/services/storage/storages/storage_ext.h +++ b/applications/services/storage/storages/storage_ext.h @@ -8,6 +8,7 @@ extern "C" { #endif void storage_ext_init(StorageData* storage); +FS_Error sd_mount_card(StorageData* storage, bool notify); FS_Error sd_unmount_card(StorageData* storage); FS_Error sd_format_card(StorageData* storage); FS_Error sd_card_info(StorageData* storage, SDInfo* sd_info); diff --git a/applications/settings/storage_settings/scenes/storage_settings_scene_start.c b/applications/settings/storage_settings/scenes/storage_settings_scene_start.c index 9f41061b..0e667024 100644 --- a/applications/settings/storage_settings/scenes/storage_settings_scene_start.c +++ b/applications/settings/storage_settings/scenes/storage_settings_scene_start.c @@ -31,12 +31,24 @@ void storage_settings_scene_start_on_enter(void* context) { StorageSettingsStartSubmenuIndexSDInfo, storage_settings_scene_start_submenu_callback, app); - submenu_add_item( - submenu, - "Unmount SD Card", - StorageSettingsStartSubmenuIndexUnmount, - storage_settings_scene_start_submenu_callback, - app); + + FS_Error sd_status = storage_sd_status(app->fs_api); + if(sd_status != FSE_OK) { + submenu_add_item( + submenu, + "Mount SD Card", + StorageSettingsStartSubmenuIndexUnmount, + storage_settings_scene_start_submenu_callback, + app); + } else { + submenu_add_item( + submenu, + "Unmount SD Card", + StorageSettingsStartSubmenuIndexUnmount, + storage_settings_scene_start_submenu_callback, + app); + } + submenu_add_item( submenu, "Format SD Card", diff --git a/applications/settings/storage_settings/scenes/storage_settings_scene_unmount_confirm.c b/applications/settings/storage_settings/scenes/storage_settings_scene_unmount_confirm.c index 0c15116b..1b9970f9 100644 --- a/applications/settings/storage_settings/scenes/storage_settings_scene_unmount_confirm.c +++ b/applications/settings/storage_settings/scenes/storage_settings_scene_unmount_confirm.c @@ -12,13 +12,17 @@ void storage_settings_scene_unmount_confirm_on_enter(void* context) { DialogEx* dialog_ex = app->dialog_ex; FS_Error sd_status = storage_sd_status(app->fs_api); - if(sd_status == FSE_NOT_READY) { - dialog_ex_set_icon(dialog_ex, 72, 17, &I_DolphinCommon_56x48); - dialog_ex_set_header(dialog_ex, "SD Card Not Mounted", 64, 3, AlignCenter, AlignTop); + dialog_ex_set_header(dialog_ex, "Mount SD Card?", 64, 10, AlignCenter, AlignCenter); dialog_ex_set_text( - dialog_ex, "Try to reinsert\nor format SD\ncard.", 3, 19, AlignLeft, AlignTop); - dialog_ex_set_center_button_text(dialog_ex, "Ok"); + dialog_ex, + "This may turn off power\nfor external modules", + 64, + 32, + AlignCenter, + AlignCenter); + dialog_ex_set_left_button_text(dialog_ex, "Cancel"); + dialog_ex_set_right_button_text(dialog_ex, "Mount"); } else { dialog_ex_set_header(dialog_ex, "Unmount SD Card?", 64, 10, AlignCenter, AlignCenter); dialog_ex_set_text( diff --git a/applications/settings/storage_settings/scenes/storage_settings_scene_unmounted.c b/applications/settings/storage_settings/scenes/storage_settings_scene_unmounted.c index 486f0760..33bb9552 100644 --- a/applications/settings/storage_settings/scenes/storage_settings_scene_unmounted.c +++ b/applications/settings/storage_settings/scenes/storage_settings_scene_unmounted.c @@ -9,22 +9,41 @@ static void void storage_settings_scene_unmounted_on_enter(void* context) { StorageSettings* app = context; - FS_Error error = storage_sd_unmount(app->fs_api); DialogEx* dialog_ex = app->dialog_ex; + FS_Error sd_status = storage_sd_status(app->fs_api); + if(sd_status == FSE_NOT_READY) { + FS_Error error = storage_sd_mount(app->fs_api); + if(error == FSE_OK) { + dialog_ex_set_header(dialog_ex, "SD Card Mounted", 64, 3, AlignCenter, AlignTop); + dialog_ex_set_text( + dialog_ex, "Flipper can use\nSD card now.", 3, 22, AlignLeft, AlignTop); + notification_message(app->notification, &sequence_blink_green_100); + } else { + dialog_ex_set_header(dialog_ex, "Cannot Mount SD Card", 64, 3, AlignCenter, AlignTop); + dialog_ex_set_text( + dialog_ex, storage_error_get_desc(error), 3, 22, AlignLeft, AlignTop); + notification_message(app->notification, &sequence_blink_red_100); + } + } else { + FS_Error error = storage_sd_unmount(app->fs_api); + if(error == FSE_OK) { + dialog_ex_set_header(dialog_ex, "SD Card Unmounted", 64, 3, AlignCenter, AlignTop); + dialog_ex_set_text( + dialog_ex, "You can remove\nSD card now.", 3, 22, AlignLeft, AlignTop); + notification_message(app->notification, &sequence_blink_green_100); + } else { + dialog_ex_set_header( + dialog_ex, "Cannot Unmount SD Card", 64, 3, AlignCenter, AlignTop); + dialog_ex_set_text( + dialog_ex, storage_error_get_desc(error), 3, 22, AlignLeft, AlignTop); + notification_message(app->notification, &sequence_blink_red_100); + } + } + dialog_ex_set_center_button_text(dialog_ex, "OK"); dialog_ex_set_icon(dialog_ex, 72, 17, &I_DolphinCommon_56x48); - if(error == FSE_OK) { - dialog_ex_set_header(dialog_ex, "SD Card Unmounted", 64, 3, AlignCenter, AlignTop); - dialog_ex_set_text(dialog_ex, "You can remove\nSD card now.", 3, 22, AlignLeft, AlignTop); - notification_message(app->notification, &sequence_blink_green_100); - } else { - dialog_ex_set_header(dialog_ex, "Cannot Unmount SD Card", 64, 3, AlignCenter, AlignTop); - dialog_ex_set_text(dialog_ex, storage_error_get_desc(error), 3, 22, AlignLeft, AlignTop); - notification_message(app->notification, &sequence_blink_red_100); - } - dialog_ex_set_context(dialog_ex, app); dialog_ex_set_result_callback(dialog_ex, storage_settings_scene_unmounted_dialog_callback); diff --git a/applications/system/updater/util/update_task_worker_flasher.c b/applications/system/updater/util/update_task_worker_flasher.c index d6dc13e3..c5603199 100644 --- a/applications/system/updater/util/update_task_worker_flasher.c +++ b/applications/system/updater/util/update_task_worker_flasher.c @@ -11,7 +11,7 @@ #include #include -#define TAG "UpdWorkerRAM" +#define TAG "UpdWorkerRam" #define STM_DFU_VENDOR_ID 0x0483 #define STM_DFU_PRODUCT_ID 0xDF11 diff --git a/firmware/targets/f18/api_symbols.csv b/firmware/targets/f18/api_symbols.csv index a26db882..52f9a4d9 100644 --- a/firmware/targets/f18/api_symbols.csv +++ b/firmware/targets/f18/api_symbols.csv @@ -1,5 +1,5 @@ entry,status,name,type,params -Version,+,36.0,, +Version,+,36.1,, Header,+,applications/services/bt/bt_service/bt.h,, Header,+,applications/services/cli/cli.h,, Header,+,applications/services/cli/cli_vcp.h,, @@ -2002,6 +2002,7 @@ Function,+,storage_int_backup,FS_Error,"Storage*, const char*" Function,+,storage_int_restore,FS_Error,"Storage*, const char*, Storage_name_converter" Function,+,storage_sd_format,FS_Error,Storage* Function,+,storage_sd_info,FS_Error,"Storage*, SDInfo*" +Function,+,storage_sd_mount,FS_Error,Storage* Function,+,storage_sd_status,FS_Error,Storage* Function,+,storage_sd_unmount,FS_Error,Storage* Function,+,storage_simply_mkdir,_Bool,"Storage*, const char*" diff --git a/firmware/targets/f7/api_symbols.csv b/firmware/targets/f7/api_symbols.csv index 6ad88d9b..2222d170 100644 --- a/firmware/targets/f7/api_symbols.csv +++ b/firmware/targets/f7/api_symbols.csv @@ -1,5 +1,5 @@ entry,status,name,type,params -Version,+,36.0,, +Version,+,36.1,, Header,+,applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h,, Header,+,applications/services/bt/bt_service/bt.h,, Header,+,applications/services/cli/cli.h,, @@ -2612,6 +2612,7 @@ Function,+,storage_int_backup,FS_Error,"Storage*, const char*" Function,+,storage_int_restore,FS_Error,"Storage*, const char*, Storage_name_converter" Function,+,storage_sd_format,FS_Error,Storage* Function,+,storage_sd_info,FS_Error,"Storage*, SDInfo*" +Function,+,storage_sd_mount,FS_Error,Storage* Function,+,storage_sd_status,FS_Error,Storage* Function,+,storage_sd_unmount,FS_Error,Storage* Function,+,storage_simply_mkdir,_Bool,"Storage*, const char*" diff --git a/firmware/targets/f7/furi_hal/furi_hal_i2c.c b/firmware/targets/f7/furi_hal/furi_hal_i2c.c index 6c17d6ad..bdfe0b0a 100644 --- a/firmware/targets/f7/furi_hal/furi_hal_i2c.c +++ b/firmware/targets/f7/furi_hal/furi_hal_i2c.c @@ -8,7 +8,7 @@ #include #include -#define TAG "FuriHalI2C" +#define TAG "FuriHalI2c" void furi_hal_i2c_init_early() { furi_hal_i2c_bus_power.callback(&furi_hal_i2c_bus_power, FuriHalI2cBusEventInit); diff --git a/lib/flipper_application/api_hashtable/api_hashtable.cpp b/lib/flipper_application/api_hashtable/api_hashtable.cpp index 6db5fb5f..ef22ee9a 100644 --- a/lib/flipper_application/api_hashtable/api_hashtable.cpp +++ b/lib/flipper_application/api_hashtable/api_hashtable.cpp @@ -3,7 +3,7 @@ #include #include -#define TAG "hashtable_api" +#define TAG "ApiHashtable" bool elf_resolve_from_hashtable( const ElfApiInterface* interface, diff --git a/lib/flipper_application/application_assets.c b/lib/flipper_application/application_assets.c index 083c3ca1..ec3fc22e 100644 --- a/lib/flipper_application/application_assets.c +++ b/lib/flipper_application/application_assets.c @@ -17,7 +17,7 @@ #define BUFFER_SIZE 512 -#define TAG "fap_assets" +#define TAG "FapAssets" #pragma pack(push, 1) diff --git a/lib/flipper_application/elf/elf_file.c b/lib/flipper_application/elf/elf_file.c index bea7c123..7ac4c655 100644 --- a/lib/flipper_application/elf/elf_file.c +++ b/lib/flipper_application/elf/elf_file.c @@ -5,7 +5,7 @@ #include "elf_api_interface.h" #include "../api_hashtable/api_hashtable.h" -#define TAG "elf" +#define TAG "Elf" #define ELF_NAME_BUFFER_LEN 32 #define SECTION_OFFSET(e, n) ((e)->section_table + (n) * sizeof(Elf32_Shdr)) diff --git a/lib/flipper_application/plugins/plugin_manager.c b/lib/flipper_application/plugins/plugin_manager.c index 101471dc..e2a7b83f 100644 --- a/lib/flipper_application/plugins/plugin_manager.c +++ b/lib/flipper_application/plugins/plugin_manager.c @@ -9,7 +9,7 @@ #include -#define TAG "libmgr" +#define TAG "PluginManager" ARRAY_DEF(FlipperApplicationList, FlipperApplication*, M_PTR_OPLIST) #define M_OPL_FlipperApplicationList_t() ARRAY_OPLIST(FlipperApplicationList, M_PTR_OPLIST) diff --git a/lib/lfrfid/lfrfid_raw_file.c b/lib/lfrfid/lfrfid_raw_file.c index 27c6f247..ca29770f 100644 --- a/lib/lfrfid/lfrfid_raw_file.c +++ b/lib/lfrfid/lfrfid_raw_file.c @@ -6,7 +6,7 @@ #define LFRFID_RAW_FILE_MAGIC 0x4C464952 #define LFRFID_RAW_FILE_VERSION 1 -#define TAG "RFID RAW File" +#define TAG "LfRfidRawFile" typedef struct { uint32_t magic; diff --git a/lib/lfrfid/lfrfid_raw_worker.c b/lib/lfrfid/lfrfid_raw_worker.c index aa962a47..344c2afa 100644 --- a/lib/lfrfid/lfrfid_raw_worker.c +++ b/lib/lfrfid/lfrfid_raw_worker.c @@ -10,7 +10,7 @@ #define RFID_DATA_BUFFER_SIZE 2048 #define READ_DATA_BUFFER_COUNT 4 -#define TAG_EMULATE "RAW EMULATE" +#define TAG_EMULATE "RawEmulate" // emulate mode typedef struct { diff --git a/lib/lfrfid/lfrfid_worker_modes.c b/lib/lfrfid/lfrfid_worker_modes.c index 8a266777..32e25325 100644 --- a/lib/lfrfid/lfrfid_worker_modes.c +++ b/lib/lfrfid/lfrfid_worker_modes.c @@ -7,7 +7,7 @@ #include "tools/varint_pair.h" #include "tools/bit_lib.h" -#define TAG "LFRFIDWorker" +#define TAG "LfRfidWorker" /** * if READ_DEBUG_GPIO is defined: diff --git a/lib/nfc/protocols/slix.c b/lib/nfc/protocols/slix.c index 68937d16..dbff2f21 100644 --- a/lib/nfc/protocols/slix.c +++ b/lib/nfc/protocols/slix.c @@ -7,7 +7,7 @@ #include "furi_hal_nfc.h" #include -#define TAG "SLIX" +#define TAG "Slix" ReturnCode slix2_read_nxp_sysinfo(FuriHalNfcDevData* nfc_data, NfcVData* nfcv_data) { furi_assert(nfc_data); diff --git a/lib/subghz/devices/cc1101_int/cc1101_int_interconnect.c b/lib/subghz/devices/cc1101_int/cc1101_int_interconnect.c index 41a0609d..284c717f 100644 --- a/lib/subghz/devices/cc1101_int/cc1101_int_interconnect.c +++ b/lib/subghz/devices/cc1101_int/cc1101_int_interconnect.c @@ -2,7 +2,7 @@ #include #include "../cc1101_configs.h" -#define TAG "SubGhzDeviceCC1101Int" +#define TAG "SubGhzDeviceCc1101Int" static bool subghz_device_cc1101_int_interconnect_is_frequency_valid(uint32_t frequency) { bool ret = furi_hal_subghz_is_frequency_valid(frequency); diff --git a/lib/subghz/protocols/alutech_at_4n.c b/lib/subghz/protocols/alutech_at_4n.c index e8bb8705..16c715f8 100644 --- a/lib/subghz/protocols/alutech_at_4n.c +++ b/lib/subghz/protocols/alutech_at_4n.c @@ -5,7 +5,7 @@ #include "../blocks/generic.h" #include "../blocks/math.h" -#define TAG "SubGhzProtocoAlutech_at_4n" +#define TAG "SubGhzProtocoAlutechAt4n" #define SUBGHZ_NO_ALUTECH_AT_4N_RAINBOW_TABLE 0xFFFFFFFF diff --git a/lib/subghz/protocols/bett.c b/lib/subghz/protocols/bett.c index de13472a..7fce9444 100644 --- a/lib/subghz/protocols/bett.c +++ b/lib/subghz/protocols/bett.c @@ -7,7 +7,7 @@ #include "../blocks/math.h" // protocol BERNER / ELKA / TEDSEN / TELETASTER -#define TAG "SubGhzProtocolBETT" +#define TAG "SubGhzProtocolBett" #define DIP_P 0b11 //(+) #define DIP_O 0b10 //(0) diff --git a/lib/subghz/protocols/bin_raw.c b/lib/subghz/protocols/bin_raw.c index 9509280c..03f4c5bd 100644 --- a/lib/subghz/protocols/bin_raw.c +++ b/lib/subghz/protocols/bin_raw.c @@ -9,7 +9,7 @@ #include #include -#define TAG "SubGhzProtocolBinRAW" +#define TAG "SubGhzProtocolBinRaw" //change very carefully, RAM ends at the most inopportune moment #define BIN_RAW_BUF_RAW_SIZE 2048 diff --git a/lib/subghz/protocols/came.c b/lib/subghz/protocols/came.c index 14b2e010..40ae05ba 100644 --- a/lib/subghz/protocols/came.c +++ b/lib/subghz/protocols/came.c @@ -12,7 +12,7 @@ * */ -#define TAG "SubGhzProtocolCAME" +#define TAG "SubGhzProtocolCame" #define CAME_12_COUNT_BIT 12 #define CAME_24_COUNT_BIT 24 #define PRASTEL_COUNT_BIT 25 diff --git a/lib/subghz/protocols/came_twee.c b/lib/subghz/protocols/came_twee.c index 6fe61581..1d79d220 100644 --- a/lib/subghz/protocols/came_twee.c +++ b/lib/subghz/protocols/came_twee.c @@ -13,7 +13,7 @@ * */ -#define TAG "SubGhzProtocolCAME_Twee" +#define TAG "SubGhzProtocolCameTwee" #define DIP_PATTERN "%c%c%c%c%c%c%c%c%c%c" #define CNT_TO_DIP(dip) \ diff --git a/lib/subghz/protocols/chamberlain_code.c b/lib/subghz/protocols/chamberlain_code.c index be0877fb..0dd0d2b0 100644 --- a/lib/subghz/protocols/chamberlain_code.c +++ b/lib/subghz/protocols/chamberlain_code.c @@ -6,7 +6,7 @@ #include "../blocks/generic.h" #include "../blocks/math.h" -#define TAG "SubGhzProtocolChamb_Code" +#define TAG "SubGhzProtocolChambCode" #define CHAMBERLAIN_CODE_BIT_STOP 0b0001 #define CHAMBERLAIN_CODE_BIT_1 0b0011 diff --git a/lib/subghz/protocols/faac_slh.c b/lib/subghz/protocols/faac_slh.c index d9dd6840..cdee7cd9 100644 --- a/lib/subghz/protocols/faac_slh.c +++ b/lib/subghz/protocols/faac_slh.c @@ -6,7 +6,7 @@ #include "../blocks/generic.h" #include "../blocks/math.h" -#define TAG "SubGhzProtocolFaacSHL" +#define TAG "SubGhzProtocolFaacShl" static const SubGhzBlockConst subghz_protocol_faac_slh_const = { .te_short = 255, diff --git a/lib/subghz/protocols/holtek_ht12x.c b/lib/subghz/protocols/holtek_ht12x.c index 831f824d..302b7859 100644 --- a/lib/subghz/protocols/holtek_ht12x.c +++ b/lib/subghz/protocols/holtek_ht12x.c @@ -12,7 +12,7 @@ * */ -#define TAG "SubGhzProtocolHoltek_HT12X" +#define TAG "SubGhzProtocolHoltekHt12x" #define DIP_PATTERN "%c%c%c%c%c%c%c%c" #define CNT_TO_DIP(dip) \ diff --git a/lib/subghz/protocols/honeywell_wdb.c b/lib/subghz/protocols/honeywell_wdb.c index 7fd8d66d..fcf28220 100644 --- a/lib/subghz/protocols/honeywell_wdb.c +++ b/lib/subghz/protocols/honeywell_wdb.c @@ -6,7 +6,7 @@ #include "../blocks/generic.h" #include "../blocks/math.h" -#define TAG "SubGhzProtocolHoneywellWDB" +#define TAG "SubGhzProtocolHoneywellWdb" /* * diff --git a/lib/subghz/protocols/hormann.c b/lib/subghz/protocols/hormann.c index 4c5c68cc..fc490e9d 100644 --- a/lib/subghz/protocols/hormann.c +++ b/lib/subghz/protocols/hormann.c @@ -6,7 +6,7 @@ #include "../blocks/generic.h" #include "../blocks/math.h" -#define TAG "SubGhzProtocolHormannHSM" +#define TAG "SubGhzProtocolHormannHsm" #define HORMANN_HSM_PATTERN 0xFF000000003 diff --git a/lib/subghz/protocols/ido.c b/lib/subghz/protocols/ido.c index 90c0fb0e..e96e6566 100644 --- a/lib/subghz/protocols/ido.c +++ b/lib/subghz/protocols/ido.c @@ -6,7 +6,7 @@ #include "../blocks/generic.h" #include "../blocks/math.h" -#define TAG "SubGhzProtocol_iDo_117/111" +#define TAG "SubGhzProtocolIdo117/111" static const SubGhzBlockConst subghz_protocol_ido_const = { .te_short = 450, diff --git a/lib/subghz/protocols/kia.c b/lib/subghz/protocols/kia.c index 1d134f7b..9b63271b 100644 --- a/lib/subghz/protocols/kia.c +++ b/lib/subghz/protocols/kia.c @@ -6,7 +6,7 @@ #include "../blocks/generic.h" #include "../blocks/math.h" -#define TAG "SubGhzProtocoKIA" +#define TAG "SubGhzProtocoKia" static const SubGhzBlockConst subghz_protocol_kia_const = { .te_short = 250, diff --git a/lib/subghz/protocols/kinggates_stylo_4k.c b/lib/subghz/protocols/kinggates_stylo_4k.c index cd027b99..0b2a102c 100644 --- a/lib/subghz/protocols/kinggates_stylo_4k.c +++ b/lib/subghz/protocols/kinggates_stylo_4k.c @@ -8,7 +8,7 @@ #include "../blocks/generic.h" #include "../blocks/math.h" -#define TAG "SubGhzProtocoKingGates_stylo_4k" +#define TAG "SubGhzProtocoKingGatesStylo4k" static const SubGhzBlockConst subghz_protocol_kinggates_stylo_4k_const = { .te_short = 400, diff --git a/lib/subghz/protocols/nice_flo.c b/lib/subghz/protocols/nice_flo.c index af81d9f9..f60e07fb 100644 --- a/lib/subghz/protocols/nice_flo.c +++ b/lib/subghz/protocols/nice_flo.c @@ -5,7 +5,7 @@ #include "../blocks/generic.h" #include "../blocks/math.h" -#define TAG "SubGhzProtocolNiceFLO" +#define TAG "SubGhzProtocolNiceFlo" static const SubGhzBlockConst subghz_protocol_nice_flo_const = { .te_short = 700, diff --git a/lib/subghz/protocols/phoenix_v2.c b/lib/subghz/protocols/phoenix_v2.c index 4ed9766e..2416a9d0 100644 --- a/lib/subghz/protocols/phoenix_v2.c +++ b/lib/subghz/protocols/phoenix_v2.c @@ -6,7 +6,7 @@ #include "../blocks/generic.h" #include "../blocks/math.h" -#define TAG "SubGhzProtocolPhoenix_V2" +#define TAG "SubGhzProtocolPhoenixV2" //transmission only static mode diff --git a/lib/subghz/protocols/raw.c b/lib/subghz/protocols/raw.c index 4a8ae1d5..95dff309 100644 --- a/lib/subghz/protocols/raw.c +++ b/lib/subghz/protocols/raw.c @@ -11,7 +11,7 @@ #include #include -#define TAG "SubGhzProtocolRAW" +#define TAG "SubGhzProtocolRaw" #define SUBGHZ_DOWNLOAD_MAX_SIZE 512 static const SubGhzBlockConst subghz_protocol_raw_const = { diff --git a/lib/subghz/protocols/secplus_v1.c b/lib/subghz/protocols/secplus_v1.c index 783351c6..644b2fba 100644 --- a/lib/subghz/protocols/secplus_v1.c +++ b/lib/subghz/protocols/secplus_v1.c @@ -11,7 +11,7 @@ * https://github.com/merbanan/rtl_433/blob/master/src/devices/secplus_v1.c */ -#define TAG "SubGhzProtocoSecPlus_v1" +#define TAG "SubGhzProtocoSecPlusV1" #define SECPLUS_V1_BIT_ERR -1 //0b0000 #define SECPLUS_V1_BIT_0 0 //0b0001 diff --git a/lib/subghz/protocols/secplus_v2.c b/lib/subghz/protocols/secplus_v2.c index 12d2fac7..374c407b 100644 --- a/lib/subghz/protocols/secplus_v2.c +++ b/lib/subghz/protocols/secplus_v2.c @@ -13,7 +13,7 @@ * https://github.com/merbanan/rtl_433/blob/master/src/devices/secplus_v2.c */ -#define TAG "SubGhzProtocoSecPlus_v2" +#define TAG "SubGhzProtocoSecPlusV2" #define SECPLUS_V2_HEADER 0x3C0000000000 #define SECPLUS_V2_HEADER_MASK 0xFFFF3C0000000000 diff --git a/lib/subghz/protocols/smc5326.c b/lib/subghz/protocols/smc5326.c index bfb36b76..0b9755b8 100644 --- a/lib/subghz/protocols/smc5326.c +++ b/lib/subghz/protocols/smc5326.c @@ -12,7 +12,7 @@ * */ -#define TAG "SubGhzProtocolSMC5326" +#define TAG "SubGhzProtocolSmc5326" #define DIP_P 0b11 //(+) #define DIP_O 0b10 //(0)