From: Øyvind H. <go...@us...> - 2010-05-14 13:27:18
|
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 dcca0b7694d23dbee6f1554dfbc4bffc4bedb4f2 (commit) via 0eb7fb59a0afe9c82f1f3d3f88fb88e3f04d706a (commit) from 215a5f7442773693045613cff9e3ce3c7f7e9678 (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 dcca0b7694d23dbee6f1554dfbc4bffc4bedb4f2 Author: Jon Povey <jon...@ra...> Date: Thu May 13 18:31:42 2010 +0900 NAND: fix first and last handling in nand_build_bbt Last block was being skipped, fix by changing the loop test from "<" to "<=" First block argument was ignored, always started from block 0 (and counted the wrong blocks as bad if first was nonzero). Now we use it. Signed-off-by: Jon Povey <jon...@ra...> Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/src/flash/nand/core.c b/src/flash/nand/core.c index e763491..44b13ce 100644 --- a/src/flash/nand/core.c +++ b/src/flash/nand/core.c @@ -222,8 +222,9 @@ COMMAND_HELPER(nand_command_get_device, unsigned name_index, int nand_build_bbt(struct nand_device *nand, int first, int last) { - uint32_t page = 0x0; + uint32_t page; int i; + int pages_per_block = (nand->erase_size / nand->page_size); uint8_t oob[6]; if ((first < 0) || (first >= nand->num_blocks)) @@ -232,7 +233,8 @@ int nand_build_bbt(struct nand_device *nand, int first, int last) if ((last >= nand->num_blocks) || (last == -1)) last = nand->num_blocks - 1; - for (i = first; i < last; i++) + page = first * pages_per_block; + for (i = first; i <= last; i++) { nand_read_page(nand, page, NULL, 0, oob, 6); @@ -248,7 +250,7 @@ int nand_build_bbt(struct nand_device *nand, int first, int last) nand->blocks[i].is_bad = 0; } - page += (nand->erase_size / nand->page_size); + page += pages_per_block; } return ERROR_OK; commit 0eb7fb59a0afe9c82f1f3d3f88fb88e3f04d706a Author: Jon Povey <jon...@ra...> Date: Thu May 13 18:31:41 2010 +0900 NAND: fix off-by-one error in erase command argument range The last_block argument to nand_erase() is checked against nand->num_blocks, but the highest valid block number is (total - 1), the test for invalid should be ">=" rather than ">". Signed-off-by: Jon Povey <jon...@ra...> Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/src/flash/nand/core.c b/src/flash/nand/core.c index 9013812..e763491 100644 --- a/src/flash/nand/core.c +++ b/src/flash/nand/core.c @@ -528,7 +528,7 @@ int nand_erase(struct nand_device *nand, int first_block, int last_block) if (!nand->device) return ERROR_NAND_DEVICE_NOT_PROBED; - if ((first_block < 0) || (last_block > nand->num_blocks)) + if ((first_block < 0) || (last_block >= nand->num_blocks)) return ERROR_INVALID_ARGUMENTS; /* make sure we know if a block is bad before erasing it */ ----------------------------------------------------------------------- Summary of changes: src/flash/nand/core.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) hooks/post-receive -- Main OpenOCD repository |