This is an automated email from Gerrit.

Bohdan Tymkiv (b...@cypress.com) just uploaded a new patch set to Gerrit, which 
you can find at http://openocd.zylin.com/4785

-- gerrit

commit 5ca80dcf4772ba50048b9b1e70096b6ed74c9c88
Author: Bohdan Tymkiv <b...@cypress.com>
Date:   Wed Dec 5 11:57:26 2018 +0200

    flash/nor/core: Fix chunk size calculation in default_flash_mem_blank_check
    
    Slow version of blank check procedure reads target memory sector-by-sector
    using 1 KB chunks. Due to bug in chunk size calculation algorithm the actual
    size of the chunk is always 1 KB even if sector size is smaller.
    This causes out-of-boundary read of the last sector.
    
    Steps to reproduce:
    1) Use target with small sectors (e.g. psoc6 with 512-byte sectors)
    2) set WORKAREASIZE_CM0 0
    3) flash erase_check 1
    
    Running slow fallback erase check - add working memory
    Info : SWD DPIDR 0x6ba02477
    Error: Failed to read memory at 0x14008000
    unknown error when checking erase state of flash bank #1 at 0x14000000
        Bank is erased
    
    Change-Id: I03d0d5fb3a1950ae6aac425f5e24c7fd94b38325
    Signed-off-by: Bohdan Tymkiv <b...@cypress.com>

diff --git a/src/flash/nor/core.c b/src/flash/nor/core.c
index 0aaa7d2..c541afc 100644
--- a/src/flash/nor/core.c
+++ b/src/flash/nor/core.c
@@ -322,8 +322,8 @@ static int default_flash_mem_blank_check(struct flash_bank 
*bank)
                for (j = 0; j < bank->sectors[i].size; j += buffer_size) {
                        uint32_t chunk;
                        chunk = buffer_size;
-                       if (chunk > (j - bank->sectors[i].size))
-                               chunk = (j - bank->sectors[i].size);
+                       if (chunk > (bank->sectors[i].size - j))
+                               chunk = (bank->sectors[i].size - j);
 
                        retval = target_read_memory(target,
                                        bank->base + bank->sectors[i].offset + 
j,

-- 


_______________________________________________
OpenOCD-devel mailing list
OpenOCD-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to