Skip to content

Commit

Permalink
update vgm tool
Browse files Browse the repository at this point in the history
  • Loading branch information
xMasterX committed Feb 22, 2024
1 parent 09f1688 commit fe71187
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 33 deletions.
2 changes: 1 addition & 1 deletion non_catalog_apps/video_game_module_tool/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
37 changes: 8 additions & 29 deletions non_catalog_apps/video_game_module_tool/flasher/flasher.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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) {
Expand Down
3 changes: 0 additions & 3 deletions non_catalog_apps/video_game_module_tool/flasher/swd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit fe71187

Please sign in to comment.