This is an automated email from Gerrit.

Paul Fertser (fercer...@gmail.com) just uploaded a new patch set to Gerrit, 
which you can find at http://openocd.zylin.com/2694

-- gerrit

commit 4f03aff1ed0a9840e3fd8c2126337770fdbee9cc
Author: Paul Fertser <fercer...@gmail.com>
Date:   Sat Apr 4 11:08:15 2015 +0300

    flash/nor/mdr: add docs, remove memory leak on probe()
    
    This adds the mandatory Info documentation for the driver as well as
    the usage field.
    
    As a clean up, this also includes freeing of the allocated memory
    which results in a memory leak if probe is invoked multiple times.
    
    Valgrind-tested.
    
    Reported by Dmitry Shpak.
    
    Change-Id: I2b1d9b9e8b069c6665b11d880b40ce19a1b26ce6
    Signed-off-by: Paul Fertser <fercer...@gmail.com>

diff --git a/doc/openocd.texi b/doc/openocd.texi
index 4bec637..121218d 100644
--- a/doc/openocd.texi
+++ b/doc/openocd.texi
@@ -5854,6 +5854,31 @@ hardcoded in the OpenOCD sources.
 @end deffn
 @end deffn
 
+@deffn {Flash Driver} mdr
+This drivers handles the integrated NOR flash on Milandr Cortex-M
+based controllers. A known limitation is that the Info memory can't be
+read or verified as it's not memory mapped.
+
+@example
+flash bank <name> mdr <base> <size> 0 0 <target#> @var{type} @var{page_count} 
@var{sec_count}
+@end example
+
+@itemize @bullet
+@item @var{type} - 0 for main memory, 1 for info memory
+@item @var{page_count} - total number of pages
+@item @var{sec_count} - number of sector per page count
+@end itemize
+
+Example usage:
+@example
+if @{ [info exists IMEMORY] && [string equal $IMEMORY true] @} @{
+   flash bank $@{_CHIPNAME@}_info.flash mdr 0x00000000 0x01000 0 0 
$_TARGETNAME 1 1 4
+@} else @{
+   flash bank $_CHIPNAME.flash mdr 0x00000000 0x20000 0 0 $_TARGETNAME 0 32 4
+@}
+@end example
+@end deffn
+
 @section mFlash
 
 @subsection mFlash Configuration
diff --git a/src/flash/nor/mdr.c b/src/flash/nor/mdr.c
index ed76aab..98e013a 100644
--- a/src/flash/nor/mdr.c
+++ b/src/flash/nor/mdr.c
@@ -482,6 +482,11 @@ static int mdr_probe(struct flash_bank *bank)
        page_count = mdr_info->page_count;
        page_size = bank->size / page_count;
 
+       if (bank->sectors) {
+               free(bank->sectors);
+               bank->sectors = NULL;
+       }
+
        bank->num_sectors = page_count;
        bank->sectors = malloc(sizeof(struct flash_sector) * page_count);
 
@@ -516,6 +521,8 @@ static int get_mdr_info(struct flash_bank *bank, char *buf, 
int buf_size)
 
 struct flash_driver mdr_flash = {
        .name = "mdr",
+       .usage = "flash bank <name> mdr <base> <size> 0 0 <target#> <type> 
<page_count> <sec_count>\n"
+       "<type>: 0 for main memory, 1 for info memory",
        .flash_bank_command = mdr_flash_bank_command,
        .erase = mdr_erase,
        .protect = mdr_protect,

-- 

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
OpenOCD-devel mailing list
OpenOCD-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to