diff --git a/src/target/efm32.c b/src/target/efm32.c index 5624832..dd01285 100644 --- a/src/target/efm32.c +++ b/src/target/efm32.c @@ -42,7 +42,6 @@ #include "target_internal.h" #include "cortexm.h" #include "adiv5.h" -#include "gdb_packet.h" #define SRAM_BASE 0x20000000 #define STUB_BUFFER_BASE ALIGN(SRAM_BASE + sizeof(efm32_flash_write_stub), 4) @@ -764,11 +763,7 @@ static bool efm32_mass_erase(target *t) while ((target_mem_read32(t, EFM32_MSC_STATUS(msc)) & EFM32_MSC_STATUS_BUSY)) { if (target_check_error(t)) return false; - - if (platform_timeout_is_expired(&timeout)) { - gdb_out("."); - platform_timeout_set(&timeout, 500); - } + target_print_progress(&timeout); } /* Relock mass erase */ @@ -1037,10 +1032,7 @@ static bool efm32_aap_mass_erase(target *t) /* Read until 0, probably should have a timeout here... */ do { status = adiv5_ap_read(ap, AAP_STATUS); - if (platform_timeout_is_expired(&timeout)) { - gdb_out("."); - platform_timeout_set(&timeout, 500); - } + target_print_progress(&timeout); } while (status & AAP_STATUS_ERASEBUSY); /* Read status */ diff --git a/src/target/nxpke04.c b/src/target/nxpke04.c index b482652..151c38e 100644 --- a/src/target/nxpke04.c +++ b/src/target/nxpke04.c @@ -39,7 +39,6 @@ #include "general.h" #include "target.h" #include "target_internal.h" -#include "gdb_packet.h" /* KE04 registers and constants */ @@ -317,10 +316,8 @@ static bool ke04_command(target *t, uint8_t cmd, uint32_t addr, const uint8_t da if (fstat & (FTMRE_FSTAT_ACCERR | FTMRE_FSTAT_FPVIOL)) return false; - if (cmd == CMD_ERASE_ALL_BLOCKS && platform_timeout_is_expired(&timeout)) { - gdb_out("."); - platform_timeout_set(&timeout, 500); - } + if (cmd == CMD_ERASE_ALL_BLOCKS) + target_print_progress(&timeout); } while (!(fstat & FTMRE_FSTAT_CCIF)); return true; diff --git a/src/target/stm32f1.c b/src/target/stm32f1.c index e568327..8b46866 100644 --- a/src/target/stm32f1.c +++ b/src/target/stm32f1.c @@ -38,7 +38,6 @@ #include "target.h" #include "target_internal.h" #include "cortexm.h" -#include "gdb_packet.h" static bool stm32f1_cmd_option(target *t, int argc, const char **argv); @@ -404,11 +403,7 @@ static bool stm32f1_mass_erase(target *t) while (target_mem_read32(t, FLASH_SR) & FLASH_SR_BSY) { if (target_check_error(t)) return false; - - if (platform_timeout_is_expired(&timeout)) { - gdb_out("."); - platform_timeout_set(&timeout, 500); - } + target_print_progress(&timeout); } /* Check for error */ diff --git a/src/target/target.c b/src/target/target.c index 0a430fb..290d639 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -366,6 +366,14 @@ int target_flash_done_buffered(struct target_flash *f) return ret; } +void target_print_progress(platform_timeout *const timeout) +{ + if (platform_timeout_is_expired(timeout)) { + gdb_out("."); + platform_timeout_set(timeout, 500); + } +} + /* Wrapper functions */ void target_detach(target *t) { diff --git a/src/target/target_internal.h b/src/target/target_internal.h index 93662c3..ff582ca 100644 --- a/src/target/target_internal.h +++ b/src/target/target_internal.h @@ -21,6 +21,8 @@ #ifndef __TARGET_INTERNAL_H #define __TARGET_INTERNAL_H +#include "platform_support.h" + extern target *target_list; target *target_new(void); @@ -142,6 +144,7 @@ struct target_s { void (*priv_free)(void *); }; +void target_print_progress(platform_timeout *timeout); void target_ram_map_free(target *t); void target_flash_map_free(target *t); void target_mem_map_free(target *t);