From: Øyvind H. <go...@us...> - 2010-04-30 03:03:08
|
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 da9f72ca0a3305cf6f961834dc441496a36c85de (commit) via 5e79f999bcc898d94a2d7751831e9f7aee24fbd5 (commit) via 78248f1df67d1b4feefd8ac4e459acd7599d6af2 (commit) from 49b7905cae66ee9e011c71aff758fafba823f87f (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 da9f72ca0a3305cf6f961834dc441496a36c85de Author: Ãyvind Harboe <oyv...@zy...> Date: Fri Apr 30 02:51:05 2010 +0200 zy1000: it has a CFI chip, no need for the ecosflash driver The ecosflash driver is no longer used by any of the config scripts. It is more useful to get more testing of CFI. Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/tcl/board/zy1000.cfg b/tcl/board/zy1000.cfg index 17594c2..ee7afcd 100644 --- a/tcl/board/zy1000.cfg +++ b/tcl/board/zy1000.cfg @@ -39,7 +39,8 @@ arm7_9 fast_memory_access enable arm7_9 dcc_downloads enable set _FLASHNAME $_CHIPNAME.flash -flash bank $_FLASHNAME ecosflash 0x01000000 0x200000 2 2 $_TARGETNAME ecos/at91eb40a.elf +flash bank $_FLASHNAME cfi 0x01000000 0x200000 2 2 $_TARGETNAME + $_TARGETNAME configure -event reset-init { # Set up chip selects & timings mww 0xFFE00000 0x0100273D commit 5e79f999bcc898d94a2d7751831e9f7aee24fbd5 Author: Ãyvind Harboe <oyv...@zy...> Date: Thu Apr 29 17:42:47 2010 +0200 flash: write_image would fail for certain images Fix a bug where write_image would fail if the sections in the image were not in ascending order. This has previously been fixed in gdb load. Solved by sorting the image sections before running flash write_image erase unlock foo.elf. Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/src/flash/nor/core.c b/src/flash/nor/core.c index 1ff4193..9a77353 100644 --- a/src/flash/nor/core.c +++ b/src/flash/nor/core.c @@ -509,6 +509,25 @@ static int flash_unlock_address_range(struct target *target, uint32_t addr, uint addr, length, &flash_driver_unprotect); } +static int compare_section (const void * a, const void * b) +{ + struct imageection *b1, *b2; + b1=*((struct imageection **)a); + b2=*((struct imageection **)b); + + if (b1->base_address == b2->base_address) + { + return 0; + } else if (b1->base_address > b2->base_address) + { + return 1; + } else + { + return -1; + } +} + + int flash_write_unlock(struct target *target, struct image *image, uint32_t *written, int erase, bool unlock) { @@ -536,6 +555,19 @@ int flash_write_unlock(struct target *target, struct image *image, /* allocate padding array */ padding = calloc(image->num_sections, sizeof(*padding)); + /* This fn requires all sections to be in ascending order of addresses, + * whereas an image can have sections out of order. */ + struct imageection **sections = malloc(sizeof(struct imageection *) * + image->num_sections); + int i; + for (i = 0; i < image->num_sections; i++) + { + sections[i] = &image->sections[i]; + } + + qsort(sections, image->num_sections, sizeof(struct imageection *), + compare_section); + /* loop until we reach end of the image */ while (section < image->num_sections) { @@ -543,11 +575,11 @@ int flash_write_unlock(struct target *target, struct image *image, uint8_t *buffer; int section_first; int section_last; - uint32_t run_address = image->sections[section].base_address + section_offset; - uint32_t run_size = image->sections[section].size - section_offset; + uint32_t run_address = sections[section]->base_address + section_offset; + uint32_t run_size = sections[section]->size - section_offset; int pad_bytes = 0; - if (image->sections[section].size == 0) + if (sections[section]->size == 0) { LOG_WARNING("empty section %d", section); section++; @@ -570,7 +602,7 @@ int flash_write_unlock(struct target *target, struct image *image, while ((run_address + run_size - 1 < c->base + c->size - 1) && (section_last + 1 < image->num_sections)) { - if (image->sections[section_last + 1].base_address < (run_address + run_size)) + if (sections[section_last + 1]->base_address < (run_address + run_size)) { LOG_DEBUG("section %d out of order " "(surprising, but supported)", @@ -598,11 +630,11 @@ int flash_write_unlock(struct target *target, struct image *image, /* if we have multiple sections within our image, * flash programming could fail due to alignment issues * attempt to rebuild a consecutive buffer for the flash loader */ - pad_bytes = (image->sections[section_last + 1].base_address) - (run_address + run_size); + pad_bytes = (sections[section_last + 1]->base_address) - (run_address + run_size); if ((run_address + run_size + pad_bytes) > (c->base + c->size)) break; padding[section_last] = pad_bytes; - run_size += image->sections[++section_last].size; + run_size += sections[++section_last]->size; run_size += pad_bytes; if (pad_bytes > 0) @@ -651,15 +683,21 @@ int flash_write_unlock(struct target *target, struct image *image, size_t size_read; size_read = run_size - buffer_size; - if (size_read > image->sections[section].size - section_offset) - size_read = image->sections[section].size - section_offset; + if (size_read > sections[section]->size - section_offset) + size_read = sections[section]->size - section_offset; - if ((retval = image_read_section(image, section, section_offset, + /* KLUDGE! + * + * #¤%#"%¤% we have to figure out the section # from the sorted + * list of pointers to sections to invoke image_read_section()... + */ + int t_section_num = (sections[section] - image->sections) / sizeof(struct imageection); + + if ((retval = image_read_section(image, t_section_num, section_offset, size_read, buffer + buffer_size, &size_read)) != ERROR_OK || size_read == 0) { free(buffer); - free(padding); - return retval; + goto done; } /* see if we need to pad the section */ @@ -669,7 +707,7 @@ int flash_write_unlock(struct target *target, struct image *image, buffer_size += size_read; section_offset += size_read; - if (section_offset >= image->sections[section].size) + if (section_offset >= sections[section]->size) { section++; section_offset = 0; @@ -702,14 +740,17 @@ int flash_write_unlock(struct target *target, struct image *image, if (retval != ERROR_OK) { - free(padding); - return retval; /* abort operation */ + /* abort operation */ + goto done; } if (written != NULL) *written += run_size; /* add run size to total written counter */ } + +done: + free(sections); free(padding); return retval; commit 78248f1df67d1b4feefd8ac4e459acd7599d6af2 Author: Ãyvind Harboe <oyv...@zy...> Date: Thu Apr 29 03:49:32 2010 +0200 flash: write_image will now pad erase to nearest sector this is done for unlocking and it is a simple omission that it wasn't done for sectors. The unnerving thing is that nobody has complained about this until now.... Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/src/flash/nor/core.c b/src/flash/nor/core.c index b8dda96..1ff4193 100644 --- a/src/flash/nor/core.c +++ b/src/flash/nor/core.c @@ -1,6 +1,6 @@ /*************************************************************************** * Copyright (C) 2005 by Dominic Rath <Dom...@gm...> * - * Copyright (C) 2007,2008 Ãyvind Harboe <oyv...@zy...> * + * Copyright (C) 2007-2010 Ãyvind Harboe <oyv...@zy...> * * Copyright (C) 2008 by Spencer Oliver <sp...@sp...> * * Copyright (C) 2009 Zachary T Welch <zw...@su...> * * * @@ -519,12 +519,6 @@ int flash_write_unlock(struct target *target, struct image *image, struct flash_bank *c; int *padding; - /* REVISIT do_pad should perhaps just be another parameter. - * GDB wouldn't ever need it, since it erases separately. - * But "flash write_image" commands might want that option. - */ - bool do_pad = false; - section = 0; section_offset = 0; @@ -694,7 +688,7 @@ int flash_write_unlock(struct target *target, struct image *image, { /* calculate and erase sectors */ retval = flash_erase_address_range(target, - do_pad, run_address, run_size); + true, run_address, run_size); } } ----------------------------------------------------------------------- Summary of changes: src/flash/nor/core.c | 79 ++++++++++++++++++++++++++++++++++++-------------- tcl/board/zy1000.cfg | 3 +- 2 files changed, 59 insertions(+), 23 deletions(-) hooks/post-receive -- Main OpenOCD repository |