From 8aa77da2b1e028ad3b05bbd7f244c56da73c07dc Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Tue, 27 Oct 2009 23:32:10 +0000 Subject: [PATCH] - bugfix: wrong number of available flash blocks Committed on the Free edition of March Hare Software CVSNT Server. Upgrade to CVS Suite for more features and support: http://march-hare.com/cvsnt/ git-svn-id: http://moon:8086/svn/vhdl/trunk@543 cc03376c-175c-47c8-b038-4cd826a8556b --- lib/CPUs/MIPS/bsp/examples/cfiflash.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/CPUs/MIPS/bsp/examples/cfiflash.c b/lib/CPUs/MIPS/bsp/examples/cfiflash.c index 7ab15be..bbfbe43 100644 --- a/lib/CPUs/MIPS/bsp/examples/cfiflash.c +++ b/lib/CPUs/MIPS/bsp/examples/cfiflash.c @@ -91,7 +91,7 @@ UINT32 cfi_find(flash_t *pObj) for (i=0; i < size; i++) pObj->info.wbuf_size *= 2; - pObj->info.nblocks = pObj->info.num_flash * ((UINT32)(pF16[2*0x2E] << 8 | pF16[2*0x2D]) + 1); + pObj->info.nblocks = (UINT32)(pF16[2*0x2E] << 8 | pF16[2*0x2D]) + 1; pObj->info.blocksize = pObj->info.num_flash * ((UINT32)(pF16[2*0x30] << 8 | pF16[2*0x2F]) * 256); *pF = 0x00FF00FF; @@ -345,6 +345,9 @@ UINT32 flash_erase(flash_t *pObj, UINT32 offset, UINT32 size) int i; UINT32 offset_end, error; + if (size % 4) + size = 4*(size/4 + 1); + offset_end = offset + size; for (i=offset; i < offset_end; i += pObj->info.blocksize) @@ -366,6 +369,9 @@ UINT32 flash_erase(flash_t *pObj, UINT32 offset, UINT32 size) UINT32 flash_program(flash_t *pObj, UINT32 offset, UINT8 *pData, UINT32 size) { + if (size % 4) + size = 4*(size/4 + 1); + return cfi_program_multi(pObj, offset/4, (UINT32*)pData, size/4); }