flash/nor/mdr: add docs, remove memory leak on probe() 94/2694/2
authorPaul Fertser <fercerpav@gmail.com>
Sat, 4 Apr 2015 08:08:15 +0000 (11:08 +0300)
committerPaul Fertser <fercerpav@gmail.com>
Thu, 16 Apr 2015 19:29:06 +0000 (20:29 +0100)
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 <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2694
Tested-by: jenkins
Reviewed-by: Дмитрий Шпак <disona@yandex.ru>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
doc/openocd.texi
src/flash/nor/mdr.c

index 3573d6d87ff766456f7b14e41b724538a4dd571a..679d017b8082f6e518f861e2b25bb21fffb6ebe8 100644 (file)
@@ -5874,6 +5874,31 @@ flash bank $_FLASHNAME mrvlqspi 0x0 0 0 0 $_TARGETNAME 0x46010000
 
 @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
index ed76aab097cb78b0ee45bbfbefd187188eb71b1b..98e013aa355585b77d10dcac63f78eaf11fdaff1 100644 (file)
@@ -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,

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)