Browse Source

Release Candidate 0.48.0 Bug Fixes (#991)

* Power: wait a little bit till message displayed on screen when executing power off. FuriCore: do not use bkpt in release builds(causing HardFault when SPI is active).
* Cleanup BSS section: add more consty consts to be more constish.
* Desktop: properly handle autostarted applications.
あく 3 years ago
parent
commit
939998a8c8

+ 2 - 2
applications/accessor/helpers/wiegand.cpp

@@ -11,8 +11,8 @@ volatile int WIEGAND::_bitCount = 0;
 int WIEGAND::_wiegandType = 0;
 
 constexpr uint32_t clocks_in_ms = 64 * 1000;
-const GpioPin* pinD0 = &gpio_ext_pa4;
-const GpioPin* pinD1 = &gpio_ext_pa7;
+const GpioPin* const pinD0 = &gpio_ext_pa4;
+const GpioPin* const pinD1 = &gpio_ext_pa7;
 
 WIEGAND::WIEGAND() {
 }

+ 1 - 1
applications/debug_tools/display_test/view_display_test.c

@@ -89,7 +89,7 @@ static void view_display_test_draw_callback_move(Canvas* canvas, void* _model) {
     canvas_draw_box(canvas, x, y, block, block);
 }
 
-ViewDrawCallback view_display_test_tests[] = {
+const ViewDrawCallback view_display_test_tests[] = {
     view_display_test_draw_callback_intro,
     view_display_test_draw_callback_fill,
     view_display_test_draw_callback_hstripe,

+ 5 - 0
applications/desktop/animations/animation_manager.c

@@ -408,6 +408,11 @@ static StorageAnimation*
     return selected;
 }
 
+bool animation_manager_is_animation_loaded(AnimationManager* animation_manager) {
+    furi_assert(animation_manager);
+    return animation_manager->current_animation;
+}
+
 void animation_manager_unload_and_stall_animation(AnimationManager* animation_manager) {
     furi_assert(animation_manager);
     furi_assert(animation_manager->current_animation);

+ 6 - 0
applications/desktop/animations/animation_manager.h

@@ -133,6 +133,12 @@ void animation_manager_set_interact_callback(
  */
 void animation_manager_interact_process(AnimationManager* animation_manager);
 
+/** Check if animation loaded
+ *
+ * @animation_manager   instance
+ */
+bool animation_manager_is_animation_loaded(AnimationManager* animation_manager);
+
 /**
  * Unload and Stall animation actions. Draw callback in view
  * paints first frame of current animation until

+ 2 - 2
applications/desktop/animations/animation_storage.c

@@ -261,7 +261,7 @@ static void animation_storage_free_frames(BubbleAnimation* animation) {
         }
     }
 
-    free(icon->frames);
+    free((void*)icon->frames);
 }
 
 static bool animation_storage_load_frames(
@@ -317,7 +317,7 @@ static bool animation_storage_load_frames(
             break;
         }
 
-        icon->frames[i] = furi_alloc(file_info.size);
+        FURI_CONST_ASSIGN_PTR(icon->frames[i], furi_alloc(file_info.size));
         if(storage_file_read(file, (void*)icon->frames[i], file_info.size) != file_info.size) {
             FURI_LOG_E(TAG, "Read failed: \'%s\'", string_get_cstr(filename));
             break;

+ 2 - 2
applications/desktop/animations/views/bubble_animation_view.c

@@ -266,7 +266,7 @@ static Icon* bubble_animation_clone_first_frame(const Icon* icon_orig) {
      * for compressed header
      */
     size_t max_bitmap_size = ROUND_UP_TO(icon_orig->width, 8) * icon_orig->height + 1;
-    icon_clone->frames[0] = furi_alloc(max_bitmap_size);
+    FURI_CONST_ASSIGN_PTR(icon_clone->frames[0], furi_alloc(max_bitmap_size));
     memcpy((void*)icon_clone->frames[0], icon_orig->frames[0], max_bitmap_size);
     FURI_CONST_ASSIGN(icon_clone->frame_count, 1);
 
@@ -278,7 +278,7 @@ static void bubble_animation_release_frame(Icon** icon) {
     furi_assert(*icon);
 
     free((void*)(*icon)->frames[0]);
-    free((*icon)->frames);
+    free((void*)(*icon)->frames);
     free(*icon);
     *icon = NULL;
 }

+ 10 - 2
applications/desktop/desktop.c

@@ -3,8 +3,8 @@
 #include <gui/view_stack.h>
 #include <furi.h>
 #include <furi_hal.h>
-#include <portmacro.h>
-#include <stdint.h>
+
+#include <loader/loader.h>
 
 #include "animations/animation_manager.h"
 #include "desktop/scenes/desktop_scene.h"
@@ -121,6 +121,14 @@ Desktop* desktop_alloc() {
     view_port_enabled_set(desktop->lock_viewport, false);
     gui_add_view_port(desktop->gui, desktop->lock_viewport, GuiLayerStatusBarLeft);
 
+    // Special case: autostart application is already running
+    Loader* loader = furi_record_open("loader");
+    if(loader_is_locked(loader) &&
+       animation_manager_is_animation_loaded(desktop->animation_manager)) {
+        animation_manager_unload_and_stall_animation(desktop->animation_manager);
+    }
+    furi_record_close("loader");
+
     return desktop;
 }
 

+ 7 - 2
applications/desktop/scenes/desktop_scene_lock_menu.c

@@ -11,6 +11,8 @@
 #include "desktop_scene_i.h"
 #include "desktop_scene.h"
 
+#define TAG "DesktopSceneLock"
+
 void desktop_scene_lock_menu_callback(DesktopEvent event, void* context) {
     Desktop* desktop = (Desktop*)context;
     view_dispatcher_send_custom_event(desktop->view_dispatcher, event);
@@ -58,12 +60,15 @@ bool desktop_scene_lock_menu_on_event(void* context, SceneManagerEvent event) {
                     desktop->scene_manager, DesktopSceneLocked, SCENE_LOCKED_FIRST_ENTER);
                 scene_manager_next_scene(desktop->scene_manager, DesktopSceneLocked);
             } else {
-                scene_manager_set_scene_state(desktop->scene_manager, DesktopSceneLockMenu, 1);
                 Loader* loader = furi_record_open("loader");
                 LoaderStatus status =
                     loader_start(loader, "Desktop", DESKTOP_SETTINGS_RUN_PIN_SETUP_ARG);
-                furi_check(status == LoaderStatusOk);
                 furi_record_close("loader");
+                if(status == LoaderStatusOk) {
+                    scene_manager_set_scene_state(desktop->scene_manager, DesktopSceneLockMenu, 1);
+                } else {
+                    FURI_LOG_E(TAG, "Unable to start desktop settings");
+                }
             }
 
             consumed = true;

+ 0 - 6
applications/desktop/scenes/desktop_scene_main.c

@@ -87,12 +87,6 @@ void desktop_scene_main_on_enter(void* context) {
     Loader* loader = furi_record_open("loader");
     desktop->app_start_stop_subscription = furi_pubsub_subscribe(
         loader_get_pubsub(loader), desktop_scene_main_app_started_callback, desktop);
-
-    // Special case: application is already running (autostart application)
-    if(loader_is_locked(loader)) {
-        animation_manager_unload_and_stall_animation(desktop->animation_manager);
-    }
-
     furi_record_close("loader");
 
     desktop_main_set_callback(main_view, desktop_scene_main_callback, desktop);

+ 5 - 4
applications/dolphin/passport/passport.c

@@ -12,19 +12,20 @@
 #define MOODS_TOTAL 3
 #define BUTTHURT_MAX 3
 
-static const Icon* portrait_happy[BUTTHURT_MAX] = {
+static const Icon* const portrait_happy[BUTTHURT_MAX] = {
     &I_passport_happy1_46x49,
     &I_passport_happy2_46x49,
     &I_passport_happy3_46x49};
-static const Icon* portrait_ok[BUTTHURT_MAX] = {
+static const Icon* const portrait_ok[BUTTHURT_MAX] = {
     &I_passport_okay1_46x49,
     &I_passport_okay2_46x49,
     &I_passport_okay3_46x49};
-static const Icon* portrait_bad[BUTTHURT_MAX] = {
+static const Icon* const portrait_bad[BUTTHURT_MAX] = {
     &I_passport_bad1_46x49,
     &I_passport_bad2_46x49,
     &I_passport_bad3_46x49};
-static const Icon** portraits[MOODS_TOTAL] = {portrait_happy, portrait_ok, portrait_bad};
+
+static const Icon* const* portraits[MOODS_TOTAL] = {portrait_happy, portrait_ok, portrait_bad};
 
 static void input_callback(InputEvent* input, void* ctx) {
     osSemaphoreId_t semaphore = ctx;

+ 1 - 1
applications/gui/icon_i.h

@@ -11,5 +11,5 @@ struct Icon {
     const uint8_t height;
     const uint8_t frame_count;
     const uint8_t frame_rate;
-    const uint8_t** frames;
+    const uint8_t* const* frames;
 };

+ 1 - 1
applications/music_player/music_player.c

@@ -102,7 +102,7 @@ typedef struct {
     uint8_t volume_id_max;
 } State;
 
-float volumes[] = {0, 0.02, 0.05, 0.1, 0.5};
+const float volumes[] = {0, 0.02, 0.05, 0.1, 0.5};
 
 bool is_white_note(const MelodyEventRecord* note_record, uint8_t id) {
     if(note_record == NULL) return false;

+ 1 - 0
applications/power/power_cli.c

@@ -8,6 +8,7 @@
 void power_cli_off(Cli* cli, string_t args) {
     Power* power = furi_record_open("power");
     printf("It's now safe to disconnect USB from your flipper\r\n");
+    osDelay(666);
     power_off(power);
 }
 

+ 5 - 5
assets/compiled/assets_dolphin_blocking.c

@@ -22,7 +22,7 @@ const uint8_t _A_L0_NoDb_128x51_3[] = {
 };
 
 
-const uint8_t *_A_L0_NoDb_128x51[] = {
+const uint8_t * const _A_L0_NoDb_128x51[] = {
 
     _A_L0_NoDb_128x51_0,
 
@@ -68,7 +68,7 @@ const uint8_t _A_L0_SdBad_128x51_1[] = {
 };
 
 
-const uint8_t *_A_L0_SdBad_128x51[] = {
+const uint8_t * const _A_L0_SdBad_128x51[] = {
 
     _A_L0_SdBad_128x51_0,
 
@@ -118,7 +118,7 @@ const uint8_t _A_L0_SdOk_128x51_3[] = {
 };
 
 
-const uint8_t *_A_L0_SdOk_128x51[] = {
+const uint8_t * const _A_L0_SdOk_128x51[] = {
 
     _A_L0_SdOk_128x51_0,
 
@@ -172,7 +172,7 @@ const uint8_t _A_L0_Url_128x51_3[] = {
 };
 
 
-const uint8_t *_A_L0_Url_128x51[] = {
+const uint8_t * const _A_L0_Url_128x51[] = {
 
     _A_L0_Url_128x51_0,
 
@@ -226,7 +226,7 @@ const uint8_t _A_L0_NewMail_128x51_3[] = {
 };
 
 
-const uint8_t *_A_L0_NewMail_128x51[] = {
+const uint8_t * const _A_L0_NewMail_128x51[] = {
 
     _A_L0_NewMail_128x51_0,
 

+ 3 - 3
assets/compiled/assets_dolphin_internal.c

@@ -38,7 +38,7 @@ const uint8_t _A_L1_Tv_128x47_7[] = {
 };
 
 
-const uint8_t *_A_L1_Tv_128x47[] = {
+const uint8_t * const _A_L1_Tv_128x47[] = {
 
     _A_L1_Tv_128x47_0,
 
@@ -136,7 +136,7 @@ const uint8_t _A_L1_BadBattery_128x47_1[] = {
 };
 
 
-const uint8_t *_A_L1_BadBattery_128x47[] = {
+const uint8_t * const _A_L1_BadBattery_128x47[] = {
 
     _A_L1_BadBattery_128x47_0,
 
@@ -220,7 +220,7 @@ const uint8_t _A_L1_NoSd_128x49_5[] = {
 };
 
 
-const uint8_t *_A_L1_NoSd_128x49[] = {
+const uint8_t * const _A_L1_NoSd_128x49[] = {
 
     _A_L1_NoSd_128x49_0,
 

File diff suppressed because it is too large
+ 2 - 2
assets/compiled/assets_icons.c


+ 12 - 9
core/furi/check.c

@@ -4,7 +4,7 @@
 #include <furi_hal_rtc.h>
 #include <stdio.h>
 
-static void __furi_print_name() {
+void __furi_print_name() {
     if(task_is_isr_context()) {
         furi_hal_console_puts("[ISR] ");
     } else {
@@ -19,14 +19,17 @@ static void __furi_print_name() {
     }
 }
 
-static void __furi_halt() {
-    asm volatile("loop:      \n"
-                 "bkpt 0x00  \n"
-                 "wfi        \n"
-                 "b loop     \n"
-                 :
-                 :
-                 : "memory");
+void __furi_halt() {
+    asm volatile(
+#ifdef FURI_DEBUG
+        "bkpt 0x00  \n"
+#endif
+        "loop:      \n"
+        "wfi        \n"
+        "b loop     \n"
+        :
+        :
+        : "memory");
 }
 
 void furi_crash(const char* message) {

+ 2 - 2
firmware/targets/f6/furi_hal/furi_hal_vcp.c

@@ -216,7 +216,7 @@ size_t furi_hal_vcp_rx_with_timeout(uint8_t* buffer, size_t size, uint32_t timeo
 
         size_t len = xStreamBufferReceive(vcp->rx_stream, buffer, batch_size, timeout);
 #ifdef FURI_HAL_USB_VCP_DEBUG
-        FURI_LOG_D(TAG, "%u ", batch_size);
+        FURI_LOG_D(TAG, "rx %u ", batch_size);
 #endif
         if(len == 0) break;
         osThreadFlagsSet(furi_thread_get_thread_id(vcp->thread), VcpEvtStreamRx);
@@ -251,7 +251,7 @@ void furi_hal_vcp_tx(const uint8_t* buffer, size_t size) {
         xStreamBufferSend(vcp->tx_stream, buffer, batch_size, osWaitForever);
         osThreadFlagsSet(furi_thread_get_thread_id(vcp->thread), VcpEvtStreamTx);
 #ifdef FURI_HAL_USB_VCP_DEBUG
-        FURI_LOG_D(TAG, "%u ", batch_size);
+        FURI_LOG_D(TAG, "tx %u", batch_size);
 #endif
 
         size -= batch_size;

+ 2 - 2
firmware/targets/f7/furi_hal/furi_hal_vcp.c

@@ -216,7 +216,7 @@ size_t furi_hal_vcp_rx_with_timeout(uint8_t* buffer, size_t size, uint32_t timeo
 
         size_t len = xStreamBufferReceive(vcp->rx_stream, buffer, batch_size, timeout);
 #ifdef FURI_HAL_USB_VCP_DEBUG
-        FURI_LOG_D(TAG, "%u ", batch_size);
+        FURI_LOG_D(TAG, "rx %u ", batch_size);
 #endif
         if(len == 0) break;
         osThreadFlagsSet(furi_thread_get_thread_id(vcp->thread), VcpEvtStreamRx);
@@ -251,7 +251,7 @@ void furi_hal_vcp_tx(const uint8_t* buffer, size_t size) {
         xStreamBufferSend(vcp->tx_stream, buffer, batch_size, osWaitForever);
         osThreadFlagsSet(furi_thread_get_thread_id(vcp->thread), VcpEvtStreamTx);
 #ifdef FURI_HAL_USB_VCP_DEBUG
-        FURI_LOG_D(TAG, "%u ", batch_size);
+        FURI_LOG_D(TAG, "tx %u", batch_size);
 #endif
 
         size -= batch_size;

+ 6 - 4
lib/ST25RFAL002/platform.c

@@ -4,7 +4,12 @@
 #include <furi.h>
 #include <furi_hal_spi.h>
 
-static osThreadAttr_t platform_irq_thread_attr;
+static const osThreadAttr_t platform_irq_thread_attr = {
+    .name = "RfalIrqWorker",
+    .stack_size = 1024,
+    .priority = osPriorityRealtime,
+};
+
 static volatile osThreadId_t platform_irq_thread_id = NULL;
 static volatile PlatformIrqCallback platform_irq_callback = NULL;
 static const GpioPin pin = {ST25R_INT_PORT, ST25R_INT_PIN};
@@ -36,9 +41,6 @@ void platformDisableIrqCallback() {
 
 void platformSetIrqCallback(PlatformIrqCallback callback) {
     platform_irq_callback = callback;
-    platform_irq_thread_attr.name = "RfalIrqWorker";
-    platform_irq_thread_attr.stack_size = 1024;
-    platform_irq_thread_attr.priority = osPriorityRealtime;
     platform_irq_thread_id = osThreadNew(platformIrqWorker, NULL, &platform_irq_thread_attr);
     hal_gpio_add_int_callback(&pin, nfc_isr, NULL);
     // Disable interrupt callback as the pin is shared between 2 apps

+ 2 - 2
lib/flipper_file/flipper_file_helper.c

@@ -1,7 +1,7 @@
 #include "flipper_file_helper.h"
 
-const char* flipper_file_filetype_key = "Filetype";
-const char* flipper_file_version_key = "Version";
+const char* const flipper_file_filetype_key = "Filetype";
+const char* const flipper_file_version_key = "Version";
 const char flipper_file_delimiter = ':';
 const char flipper_file_comment = '#';
 

+ 2 - 2
lib/flipper_file/flipper_file_helper.h

@@ -8,8 +8,8 @@
 extern "C" {
 #endif
 
-extern const char* flipper_file_filetype_key;
-extern const char* flipper_file_version_key;
+extern const char* const flipper_file_filetype_key;
+extern const char* const flipper_file_version_key;
 extern const char flipper_file_delimiter;
 extern const char flipper_file_comment;
 

+ 1 - 1
lib/nfc_protocols/emv_decoder.c

@@ -21,7 +21,7 @@ const PDOLValue pdol_transaction_cert = {0x98, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; // Transaction cert
 const PDOLValue pdol_unpredict_number = {0x9F37, {0x82, 0x3D, 0xDE, 0x7A}}; // Unpredictable number
 
-const PDOLValue* pdol_values[] = {
+const PDOLValue* const pdol_values[] = {
     &pdol_term_info,
     &pdol_term_type,
     &pdol_merchant_type,

+ 1 - 1
lib/nfc_protocols/emv_decoder.h

@@ -26,7 +26,7 @@ typedef struct {
     uint8_t data[];
 } PDOLValue;
 
-extern const PDOLValue* pdol_values[];
+extern const PDOLValue* const pdol_values[];
 
 typedef struct {
     uint8_t size;

+ 1 - 1
scripts/assets.py

@@ -23,7 +23,7 @@ ICONS_TEMPLATE_C_HEADER = """#include \"assets_icons.h\"
 
 """
 ICONS_TEMPLATE_C_FRAME = "const uint8_t {name}[] = {data};\n"
-ICONS_TEMPLATE_C_DATA = "const uint8_t *{name}[] = {data};\n"
+ICONS_TEMPLATE_C_DATA = "const uint8_t* const {name}[] = {data};\n"
 ICONS_TEMPLATE_C_ICONS = "const Icon {name} = {{.width={width},.height={height},.frame_count={frame_count},.frame_rate={frame_rate},.frames=_{name}}};\n"
 
 

+ 1 - 1
scripts/flipper/assets/templates/dolphin.c.tmpl

@@ -10,7 +10,7 @@ const uint8_t _A_{{ animation.name }}_{{ frame_number }}[] = {
 };
 {% :endfor %}
 
-const uint8_t *_A_{{animation.name}}[] = {
+const uint8_t * const _A_{{animation.name}}[] = {
 {% for frame_number, frame in enumerate(animation.frames): %}
     _A_{{ animation.name }}_{{ frame_number }},
 {% :endfor %}

Some files were not shown because too many files changed in this diff