From: Øyvind H. <go...@us...> - 2010-05-04 09:19:39
|
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 282e89c878fd43ba90f0a9416adce81c5f596af7 (commit) via 70226c221f5879bb6126ff3f2ec9ae64c68d80d6 (commit) via 8865209545dae9c2745927758a51c60f922e02ca (commit) from 32e647acf40bc11858a524e5ee73183ce0d9449b (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 282e89c878fd43ba90f0a9416adce81c5f596af7 Author: Ãyvind Harboe <oyv...@zy...> Date: Mon May 3 18:11:34 2010 +0200 flash: less bogus errors Removed bogus errors when trying to allocate a large a target memory buffer as possible. Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/src/flash/nor/aduc702x.c b/src/flash/nor/aduc702x.c index 57c591d..82ea2bc 100644 --- a/src/flash/nor/aduc702x.c +++ b/src/flash/nor/aduc702x.c @@ -227,7 +227,7 @@ static int aduc702x_write_block(struct flash_bank *bank, uint8_t *buffer, uint32 } /* memory buffer */ - while (target_alloc_working_area(target, buffer_size, &source) != ERROR_OK) + while (target_alloc_working_area_try(target, buffer_size, &source) != ERROR_OK) { buffer_size /= 2; if (buffer_size <= 256) diff --git a/src/flash/nor/cfi.c b/src/flash/nor/cfi.c index f88f16c..9967652 100644 --- a/src/flash/nor/cfi.c +++ b/src/flash/nor/cfi.c @@ -1116,7 +1116,7 @@ static int cfi_intel_write_block(struct flash_bank *bank, uint8_t *buffer, uint3 /* Get a workspace buffer for the data to flash starting with 32k size. Half size until buffer would be smaller 256 Bytem then fail back */ /* FIXME Why 256 bytes, why not 32 bytes (smallest flash write page */ - while (target_alloc_working_area(target, buffer_size, &source) != ERROR_OK) + while (target_alloc_working_area_try(target, buffer_size, &source) != ERROR_OK) { buffer_size /= 2; if (buffer_size <= 256) @@ -1444,7 +1444,7 @@ static int cfi_spansion_write_block(struct flash_bank *bank, uint8_t *buffer, ui } /* the following code still assumes target code is fixed 24*4 bytes */ - while (target_alloc_working_area(target, buffer_size, &source) != ERROR_OK) + while (target_alloc_working_area_try(target, buffer_size, &source) != ERROR_OK) { buffer_size /= 2; if (buffer_size <= 256) diff --git a/src/flash/nor/lpc2900.c b/src/flash/nor/lpc2900.c index 360c14d..5b00495 100644 --- a/src/flash/nor/lpc2900.c +++ b/src/flash/nor/lpc2900.c @@ -1288,7 +1288,7 @@ static int lpc2900_write(struct flash_bank *bank, uint8_t *buffer, reduced size if that fails. */ struct working_area *warea; uint32_t buffer_size = lpc2900_info->max_ram_block - 1 * KiB; - while( (retval = target_alloc_working_area(target, + while( (retval = target_alloc_working_area_try(target, buffer_size + target_code_size, &warea)) != ERROR_OK ) { diff --git a/src/flash/nor/pic32mx.c b/src/flash/nor/pic32mx.c index 2540342..4ebd256 100644 --- a/src/flash/nor/pic32mx.c +++ b/src/flash/nor/pic32mx.c @@ -322,7 +322,7 @@ static int pic32mx_write_block(struct flash_bank *bank, uint8_t *buffer, return retval; /* memory buffer */ - while (target_alloc_working_area(target, buffer_size, &source) != ERROR_OK) + while (target_alloc_working_area_try(target, buffer_size, &source) != ERROR_OK) { buffer_size /= 2; if (buffer_size <= 256) diff --git a/src/flash/nor/stellaris.c b/src/flash/nor/stellaris.c index 0b7c45a..cce5f37 100644 --- a/src/flash/nor/stellaris.c +++ b/src/flash/nor/stellaris.c @@ -846,7 +846,7 @@ static int stellaris_write_block(struct flash_bank *bank, buffer_size = wcount * 4; /* memory buffer */ - while (target_alloc_working_area(target, buffer_size, &source) != ERROR_OK) + while (target_alloc_working_area_try(target, buffer_size, &source) != ERROR_OK) { buffer_size /= 2; if (buffer_size <= buf_min) diff --git a/src/flash/nor/stm32x.c b/src/flash/nor/stm32x.c index 0fdd148..7afd959 100644 --- a/src/flash/nor/stm32x.c +++ b/src/flash/nor/stm32x.c @@ -481,7 +481,7 @@ static int stm32x_write_block(struct flash_bank *bank, uint8_t *buffer, return retval; /* memory buffer */ - while (target_alloc_working_area(target, buffer_size, &source) != ERROR_OK) + while (target_alloc_working_area_try(target, buffer_size, &source) != ERROR_OK) { buffer_size /= 2; if (buffer_size <= 256) diff --git a/src/flash/nor/str9x.c b/src/flash/nor/str9x.c index 3d8b84b..2208fe3 100644 --- a/src/flash/nor/str9x.c +++ b/src/flash/nor/str9x.c @@ -385,7 +385,7 @@ static int str9x_write_block(struct flash_bank *bank, (uint8_t*)str9x_flash_write_code); /* memory buffer */ - while (target_alloc_working_area(target, buffer_size, &source) != ERROR_OK) + while (target_alloc_working_area_try(target, buffer_size, &source) != ERROR_OK) { buffer_size /= 2; if (buffer_size <= 256) commit 70226c221f5879bb6126ff3f2ec9ae64c68d80d6 Author: Ãyvind Harboe <oyv...@zy...> Date: Mon May 3 15:50:39 2010 +0200 str7x: fix bogus error messages Remove bogus error messages when trying to allocate a large chunk of target memory and then falling back to a smaller one. Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/src/flash/nor/str7x.c b/src/flash/nor/str7x.c index d5e8e28..556dec2 100644 --- a/src/flash/nor/str7x.c +++ b/src/flash/nor/str7x.c @@ -355,10 +355,9 @@ static int str7x_write_block(struct flash_bank *bank, uint8_t *buffer, }; /* flash write code */ - if (target_alloc_working_area(target, sizeof(str7x_flash_write_code), + if (target_alloc_working_area_try(target, sizeof(str7x_flash_write_code), &str7x_info->write_algorithm) != ERROR_OK) { - LOG_WARNING("no working area available, can't do block memory writes"); return ERROR_TARGET_RESOURCE_NOT_AVAILABLE; }; @@ -367,7 +366,7 @@ static int str7x_write_block(struct flash_bank *bank, uint8_t *buffer, (uint8_t*)str7x_flash_write_code); /* memory buffer */ - while (target_alloc_working_area(target, buffer_size, &source) != ERROR_OK) + while (target_alloc_working_area_try(target, buffer_size, &source) != ERROR_OK) { buffer_size /= 2; if (buffer_size <= 256) @@ -499,6 +498,9 @@ static int str7x_write(struct flash_bank *bank, uint8_t *buffer, /* if block write failed (no sufficient working area), * we use normal (slow) single dword accesses */ LOG_WARNING("couldn't use block writes, falling back to single memory accesses"); + } else + { + return retval; } else if (retval == ERROR_FLASH_OPERATION_FAILED) { commit 8865209545dae9c2745927758a51c60f922e02ca Author: Ãyvind Harboe <oyv...@zy...> Date: Mon May 3 15:49:23 2010 +0200 target: clean up target memory allocation error messages target memory allocation can be implemented not to show bogus error messages. E.g. when trying a big allocation first and then a smaller one if that fails. Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/src/target/target.c b/src/target/target.c index 73594fb..a3a1b0a 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -1111,7 +1111,7 @@ int target_call_timer_callbacks_now(void) return target_call_timer_callbacks_check_time(0); } -int target_alloc_working_area(struct target *target, uint32_t size, struct working_area **area) +int target_alloc_working_area_try(struct target *target, uint32_t size, struct working_area **area) { struct working_area *c = target->working_areas; struct working_area *new_wa = NULL; @@ -1189,8 +1189,6 @@ int target_alloc_working_area(struct target *target, uint32_t size, struct worki if (free_size < size) { - LOG_WARNING("not enough working area available(requested %u, free %u)", - (unsigned)(size), (unsigned)(free_size)); return ERROR_TARGET_RESOURCE_NOT_AVAILABLE; } @@ -1231,6 +1229,19 @@ int target_alloc_working_area(struct target *target, uint32_t size, struct worki return ERROR_OK; } +int target_alloc_working_area(struct target *target, uint32_t size, struct working_area **area) +{ + int retval; + + retval = target_alloc_working_area_try(target, size, area); + if (retval == ERROR_TARGET_RESOURCE_NOT_AVAILABLE) + { + LOG_WARNING("not enough working area available(requested %u)", (unsigned)(size)); + } + return retval; + +} + static int target_free_working_area_restore(struct target *target, struct working_area *area, int restore) { if (area->free) diff --git a/src/target/target.h b/src/target/target.h index 0292945..4a48e5a 100644 --- a/src/target/target.h +++ b/src/target/target.h @@ -452,6 +452,14 @@ const char *target_state_name( struct target *target ); */ int target_alloc_working_area(struct target *target, uint32_t size, struct working_area **area); +/* Same as target_alloc_working_area, except that no error is logged + * when ERROR_TARGET_RESOURCE_NOT_AVAILABLE is returned. + * + * This allows the calling code to *try* to allocate target memory + * and have a fallback to another behavior(slower?). + */ +int target_alloc_working_area_try(struct target *target, + uint32_t size, struct working_area **area); int target_free_working_area(struct target *target, struct working_area *area); void target_free_all_working_areas(struct target *target); ----------------------------------------------------------------------- Summary of changes: src/flash/nor/aduc702x.c | 2 +- src/flash/nor/cfi.c | 4 ++-- src/flash/nor/lpc2900.c | 2 +- src/flash/nor/pic32mx.c | 2 +- src/flash/nor/stellaris.c | 2 +- src/flash/nor/stm32x.c | 2 +- src/flash/nor/str7x.c | 8 +++++--- src/flash/nor/str9x.c | 2 +- src/target/target.c | 17 ++++++++++++++--- src/target/target.h | 8 ++++++++ 10 files changed, 35 insertions(+), 14 deletions(-) hooks/post-receive -- Main OpenOCD repository |