target: Refactored out the progress printer to reduce Flash usage

This commit is contained in:
dragonmux 2022-07-11 19:54:25 -04:00 committed by Piotr Esden-Tempski
parent b8ca831cfb
commit 9d46d0c5c6
5 changed files with 16 additions and 21 deletions

View File

@ -42,7 +42,6 @@
#include "target_internal.h" #include "target_internal.h"
#include "cortexm.h" #include "cortexm.h"
#include "adiv5.h" #include "adiv5.h"
#include "gdb_packet.h"
#define SRAM_BASE 0x20000000 #define SRAM_BASE 0x20000000
#define STUB_BUFFER_BASE ALIGN(SRAM_BASE + sizeof(efm32_flash_write_stub), 4) #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)) { while ((target_mem_read32(t, EFM32_MSC_STATUS(msc)) & EFM32_MSC_STATUS_BUSY)) {
if (target_check_error(t)) if (target_check_error(t))
return false; return false;
target_print_progress(&timeout);
if (platform_timeout_is_expired(&timeout)) {
gdb_out(".");
platform_timeout_set(&timeout, 500);
}
} }
/* Relock mass erase */ /* Relock mass erase */
@ -1037,10 +1032,7 @@ static bool efm32_aap_mass_erase(target *t)
/* Read until 0, probably should have a timeout here... */ /* Read until 0, probably should have a timeout here... */
do { do {
status = adiv5_ap_read(ap, AAP_STATUS); status = adiv5_ap_read(ap, AAP_STATUS);
if (platform_timeout_is_expired(&timeout)) { target_print_progress(&timeout);
gdb_out(".");
platform_timeout_set(&timeout, 500);
}
} while (status & AAP_STATUS_ERASEBUSY); } while (status & AAP_STATUS_ERASEBUSY);
/* Read status */ /* Read status */

View File

@ -39,7 +39,6 @@
#include "general.h" #include "general.h"
#include "target.h" #include "target.h"
#include "target_internal.h" #include "target_internal.h"
#include "gdb_packet.h"
/* KE04 registers and constants */ /* 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)) if (fstat & (FTMRE_FSTAT_ACCERR | FTMRE_FSTAT_FPVIOL))
return false; return false;
if (cmd == CMD_ERASE_ALL_BLOCKS && platform_timeout_is_expired(&timeout)) { if (cmd == CMD_ERASE_ALL_BLOCKS)
gdb_out("."); target_print_progress(&timeout);
platform_timeout_set(&timeout, 500);
}
} while (!(fstat & FTMRE_FSTAT_CCIF)); } while (!(fstat & FTMRE_FSTAT_CCIF));
return true; return true;

View File

@ -38,7 +38,6 @@
#include "target.h" #include "target.h"
#include "target_internal.h" #include "target_internal.h"
#include "cortexm.h" #include "cortexm.h"
#include "gdb_packet.h"
static bool stm32f1_cmd_option(target *t, int argc, const char **argv); 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) { while (target_mem_read32(t, FLASH_SR) & FLASH_SR_BSY) {
if (target_check_error(t)) if (target_check_error(t))
return false; return false;
target_print_progress(&timeout);
if (platform_timeout_is_expired(&timeout)) {
gdb_out(".");
platform_timeout_set(&timeout, 500);
}
} }
/* Check for error */ /* Check for error */

View File

@ -366,6 +366,14 @@ int target_flash_done_buffered(struct target_flash *f)
return ret; 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 */ /* Wrapper functions */
void target_detach(target *t) void target_detach(target *t)
{ {

View File

@ -21,6 +21,8 @@
#ifndef __TARGET_INTERNAL_H #ifndef __TARGET_INTERNAL_H
#define __TARGET_INTERNAL_H #define __TARGET_INTERNAL_H
#include "platform_support.h"
extern target *target_list; extern target *target_list;
target *target_new(void); target *target_new(void);
@ -142,6 +144,7 @@ struct target_s {
void (*priv_free)(void *); void (*priv_free)(void *);
}; };
void target_print_progress(platform_timeout *timeout);
void target_ram_map_free(target *t); void target_ram_map_free(target *t);
void target_flash_map_free(target *t); void target_flash_map_free(target *t);
void target_mem_map_free(target *t); void target_mem_map_free(target *t);