openocd: drop iteration downsampling for keep_alive()

The function keep_alive() is optimized and return immediately if
has nothing to do.
There is no need to overly-complicate the code with extra counters
or time computation plus the relative checks to reduce the number
of calls to keep_alive().

Drop such extra code.

Change-Id: I4574a3f154b5779f44105936c74af8fca1d2c49c
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9064
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
Reviewed-by: Lucien Buchmann <lucien.buchmann@dufour.aero>
This commit is contained in:
Antonio Borneo
2025-08-01 18:02:31 +02:00
parent 37f638bb4c
commit 9fe3780432
7 changed files with 28 additions and 55 deletions

View File

@@ -112,10 +112,10 @@ static int cc26xx_wait_algo_done(struct flash_bank *bank, uint32_t params_addr)
return retval;
elapsed_ms = timeval_ms() - start_ms;
if (elapsed_ms > 500)
keep_alive();
if (elapsed_ms > FLASH_TIMEOUT)
break;
keep_alive();
};
if (status != CC26XX_BUFFER_EMPTY) {
@@ -321,8 +321,6 @@ static int cc26xx_write(struct flash_bank *bank, const uint8_t *buffer,
struct cc26xx_bank *cc26xx_bank = bank->driver_priv;
struct cc26xx_algo_params algo_params[2];
uint32_t size = 0;
long long start_ms;
long long elapsed_ms;
uint32_t address;
uint32_t index;
@@ -343,7 +341,6 @@ static int cc26xx_write(struct flash_bank *bank, const uint8_t *buffer,
/* Write requested data, ping-ponging between two buffers */
index = 0;
start_ms = timeval_ms();
address = bank->base + offset;
while (count > 0) {
@@ -381,9 +378,7 @@ static int cc26xx_write(struct flash_bank *bank, const uint8_t *buffer,
buffer += size;
address += size;
elapsed_ms = timeval_ms() - start_ms;
if (elapsed_ms > 500)
keep_alive();
keep_alive();
}
/* If no error yet, wait for last buffer to finish */

View File

@@ -65,10 +65,10 @@ static int cc3220sf_mass_erase(struct flash_bank *bank)
done = true;
} else {
elapsed_ms = timeval_ms() - start_ms;
if (elapsed_ms > 500)
keep_alive();
if (elapsed_ms > FLASH_TIMEOUT)
break;
keep_alive();
}
}
@@ -152,10 +152,10 @@ static int cc3220sf_erase(struct flash_bank *bank, unsigned int first,
done = true;
} else {
elapsed_ms = timeval_ms() - start_ms;
if (elapsed_ms > 500)
keep_alive();
if (elapsed_ms > FLASH_TIMEOUT)
break;
keep_alive();
}
}

View File

@@ -219,10 +219,10 @@ static int msp432_wait_return_code(struct target *target)
return retval;
elapsed_ms = timeval_ms() - start_ms;
if (elapsed_ms > 500)
keep_alive();
if (elapsed_ms > FLASH_TIMEOUT)
break;
keep_alive();
};
if (return_code != FLASH_SUCCESS) {
@@ -261,10 +261,10 @@ static int msp432_wait_inactive(struct target *target, uint32_t buffer)
return retval;
elapsed_ms = timeval_ms() - start_ms;
if (elapsed_ms > 500)
keep_alive();
if (elapsed_ms > FLASH_TIMEOUT)
break;
keep_alive();
};
if (status_code != BUFFER_INACTIVE) {
@@ -678,8 +678,6 @@ static int msp432_write(struct flash_bank *bank, const uint8_t *buffer,
struct msp432_algo_params algo_params;
uint32_t size;
uint32_t data_ready = BUFFER_DATA_READY;
long long start_ms;
long long elapsed_ms;
bool is_info = bank->base == P4_FLASH_INFO_BASE;
@@ -753,7 +751,6 @@ static int msp432_write(struct flash_bank *bank, const uint8_t *buffer,
}
/* Write requested data, one buffer at a time */
start_ms = timeval_ms();
while (count > 0) {
if (count > ALGO_BUFFER_SIZE)
@@ -786,9 +783,7 @@ static int msp432_write(struct flash_bank *bank, const uint8_t *buffer,
count -= size;
buffer += size;
elapsed_ms = timeval_ms() - start_ms;
if (elapsed_ms > 500)
keep_alive();
keep_alive();
}
/* Confirm that the flash helper algorithm is finished */

View File

@@ -737,10 +737,10 @@ static int mspm0_fctl_wait_cmd_ok(struct flash_bank *bank)
return retval;
elapsed_ms = timeval_ms() - start_ms;
if (elapsed_ms > 500)
keep_alive();
if (elapsed_ms > MSPM0_FLASH_TIMEOUT_MS)
break;
keep_alive();
}
if ((return_code & FCTL_STATCMD_CMDPASS_MASK) != FCTL_STATCMD_CMDPASS_STATPASS) {