From: OpenOCD-Gerrit <ope...@us...> - 2022-09-27 08:48:32
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 931b357466ba029d9984ade1f1598371e20871f4 (commit) from 53611d8055d1130a925010b3feb39c7c8fa20a14 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 931b357466ba029d9984ade1f1598371e20871f4 Author: Tomas Vanek <va...@fb...> Date: Wed Sep 21 07:46:15 2022 +0200 flash/nor/rp2040: check target halted before flash operation Flash read_id/erase/write operation on running target failed in target_run_algorithm() anyway. It generated lot of error messages. Check the target state and bail out early if target is running. Change-Id: I903f5f38c8e61016e5002b235e5f07803bd2ec4e Signed-off-by: Tomas Vanek <va...@fb...> Reviewed-on: https://review.openocd.org/c/openocd/+/7215 Tested-by: jenkins Reviewed-by: Antonio Borneo <bor...@gm...> Reviewed-by: Jonathan Bell <jon...@ra...> diff --git a/src/flash/nor/rp2040.c b/src/flash/nor/rp2040.c index 7cc6434ff..f131a3039 100644 --- a/src/flash/nor/rp2040.c +++ b/src/flash/nor/rp2040.c @@ -211,6 +211,12 @@ static int rp2040_flash_write(struct flash_bank *bank, const uint8_t *buffer, ui struct rp2040_flash_bank *priv = bank->driver_priv; struct target *target = bank->target; + + if (target->state != TARGET_HALTED) { + LOG_ERROR("Target not halted"); + return ERROR_TARGET_NOT_HALTED; + } + struct working_area *bounce = NULL; int err = rp2040_stack_grab_and_prep(bank); @@ -266,6 +272,13 @@ cleanup: static int rp2040_flash_erase(struct flash_bank *bank, unsigned int first, unsigned int last) { struct rp2040_flash_bank *priv = bank->driver_priv; + struct target *target = bank->target; + + if (target->state != TARGET_HALTED) { + LOG_ERROR("Target not halted"); + return ERROR_TARGET_NOT_HALTED; + } + uint32_t start_addr = bank->sectors[first].offset; uint32_t length = bank->sectors[last].offset + bank->sectors[last].size - start_addr; LOG_DEBUG("RP2040 erase %d bytes starting at 0x%" PRIx32, length, start_addr); @@ -294,7 +307,7 @@ static int rp2040_flash_erase(struct flash_bank *bank, unsigned int first, unsig */ int timeout_ms = 2000 * (last - first) + 1000; - err = rp2040_call_rom_func(bank->target, priv, priv->jump_flash_range_erase, + err = rp2040_call_rom_func(target, priv, priv->jump_flash_range_erase, args, ARRAY_SIZE(args), timeout_ms); cleanup: @@ -362,6 +375,11 @@ static int rp2040_flash_probe(struct flash_bank *bank) struct rp2040_flash_bank *priv = bank->driver_priv; struct target *target = bank->target; + if (target->state != TARGET_HALTED) { + LOG_ERROR("Target not halted"); + return ERROR_TARGET_NOT_HALTED; + } + int err = rp2040_lookup_symbol(target, FUNC_DEBUG_TRAMPOLINE, &priv->jump_debug_trampoline); if (err != ERROR_OK) { LOG_ERROR("Debug trampoline not found in RP2040 ROM."); ----------------------------------------------------------------------- Summary of changes: src/flash/nor/rp2040.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) hooks/post-receive -- Main OpenOCD repository |