Преглед изворни кода

Merge video_game_module_tool from https://github.com/flipperdevices/flipperzero-good-faps

Willy-JL пре 1 година
родитељ
комит
ee6e40f604

+ 3 - 0
video_game_module_tool/.catalog/CHANGELOG.md

@@ -1,3 +1,6 @@
+## 1.2
+ - Fix crash due to log output in critical section
+ - Fix crash when built with DEBUG=1
 ## 1.1
  - Description update
 ## 1.0

+ 1 - 1
video_game_module_tool/application.fam

@@ -9,7 +9,7 @@ App(
     ],
     stack_size=2048,
     fap_description="This app is a standalone firmware updater/installer for the Video Game Module",
-    fap_version="1.1",
+    fap_version="1.2",
     fap_icon="vgm_tool.png",
     fap_category="GPIO",
     fap_icon_assets="icons",

+ 8 - 29
video_game_module_tool/flasher/flasher.c

@@ -32,34 +32,22 @@ bool flasher_init(void) {
     FURI_LOG_D(TAG, "Attaching the target");
 
     board_init();
+    swd_init();
 
-    bool success = false;
-    FURI_CRITICAL_ENTER();
-    do {
-        swd_init();
-        if(!target_attach(RP2040_CORE0_ADDR)) {
-            FURI_LOG_E(TAG, "Failed to attach target");
-            break;
-        }
-        success = true;
-    } while(false);
-    FURI_CRITICAL_EXIT();
-
-    if(!success) {
+    if(!target_attach(RP2040_CORE0_ADDR)) {
+        FURI_LOG_E(TAG, "Failed to attach target");
         flasher_deinit();
+        return false;
     }
 
-    return success;
+    return true;
 }
 
 void flasher_deinit(void) {
     FURI_LOG_D(TAG, "Detaching target and restoring pins");
 
-    FURI_CRITICAL_ENTER();
     target_detach();
     swd_deinit();
-    FURI_CRITICAL_EXIT();
-
     board_reset();
     board_deinit();
 }
@@ -70,24 +58,15 @@ void flasher_set_callback(FlasherCallback callback, void* context) {
 }
 
 static inline bool flasher_init_chip(void) {
-    FURI_CRITICAL_ENTER();
-    const bool success = rp2040_init();
-    FURI_CRITICAL_EXIT();
-    return success;
+    return rp2040_init();
 }
 
 static inline bool flasher_erase_sector(uint32_t address) {
-    FURI_CRITICAL_ENTER();
-    const bool success = rp2040_flash_erase_sector(address);
-    FURI_CRITICAL_EXIT();
-    return success;
+    return rp2040_flash_erase_sector(address);
 }
 
 static inline bool flasher_program_page(uint32_t address, const void* data, size_t data_size) {
-    FURI_CRITICAL_ENTER();
-    const bool success = rp2040_flash_program_page(address, data, data_size);
-    FURI_CRITICAL_EXIT();
-    return success;
+    return rp2040_flash_program_page(address, data, data_size);
 }
 
 static void flasher_emit_progress(uint8_t start, uint8_t weight, uint8_t progress) {

+ 0 - 3
video_game_module_tool/flasher/swd.c

@@ -146,8 +146,6 @@ static uint32_t __attribute__((optimize("-O3"))) swd_rx(uint32_t n_cycles) {
 }
 
 static bool __attribute__((optimize("-O3"))) swd_rx_parity(uint32_t* data, uint32_t n_cycles) {
-    furi_assert(data);
-
     const uint32_t rx_value = swd_rx(n_cycles);
     swd_delay_half_cycle();
 
@@ -196,7 +194,6 @@ void swd_init(void) {
 
 void swd_deinit(void) {
     swd_enter_dormant_state();
-
     furi_hal_gpio_init_simple(&gpio_swclk, GpioModeAnalog);
     furi_hal_gpio_init_simple(&gpio_swdio, GpioModeAnalog);
 }