- more fixes to high density stm32x flash driver
[openocd.git] / src / flash / str9xpec.c
index b1bb3e93c1195d2ef57f9755bc592865e57dc1d9..f508e0bf8d96006a69385b573b9296b895176913 100644 (file)
@@ -2,6 +2,9 @@
  *   Copyright (C) 2005 by Dominic Rath                                    *
  *   Dominic.Rath@gmx.de                                                   *
  *                                                                         *
+ *   Copyright (C) 2008 by Spencer Oliver                                  *
+ *   spen@spen-soft.co.uk                                                  *
+ *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
  *   the Free Software Foundation; either version 2 of the License, or     *
 #include <unistd.h>
 #include <getopt.h>
 
-str9xpec_mem_layout_t mem_layout_str9pec[] = {
-       {0x00000000, 0x10000, 0},
-       {0x00010000, 0x10000, 1},
-       {0x00020000, 0x10000, 2},
-       {0x00030000, 0x10000, 3},
-       {0x00040000, 0x10000, 4},
-       {0x00050000, 0x10000, 5},
-       {0x00060000, 0x10000, 6},
-       {0x00070000, 0x10000, 7},
-       {0x00080000, 0x02000, 32},
-       {0x00082000, 0x02000, 33},
-       {0x00084000, 0x02000, 34},
-       {0x00086000, 0x02000, 35}
-};
-
 int str9xpec_register_commands(struct command_context_s *cmd_ctx);
 int str9xpec_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank);
 int str9xpec_erase(struct flash_bank_s *bank, int first, int last);
@@ -279,8 +267,11 @@ int str9xpec_build_block_list(struct flash_bank_s *bank)
        str9xpec_flash_controller_t *str9xpec_info = bank->driver_priv;
        
        int i;
-       int num_sectors = 0, b0_sectors = 0;
-               
+       int num_sectors;
+       int b0_sectors = 0, b1_sectors = 0;
+       u32 offset = 0;
+       int b1_size = 0x2000;
+       
        switch (bank->size)
        {
                case (256 * 1024):
@@ -289,14 +280,25 @@ int str9xpec_build_block_list(struct flash_bank_s *bank)
                case (512 * 1024):
                        b0_sectors = 8;
                        break;
+               case (1024 * 1024):
+                       b0_sectors = 16;
+                       break;
+               case (2048 * 1024):
+                       b0_sectors = 32;
+                       break;
+               case (128 * 1024):
+                       b1_size = 0x4000;
+                       b1_sectors = 8;
+                       break;
+               case (32 * 1024):
+                       b1_sectors = 4;
+                       break;
                default:
                        LOG_ERROR("BUG: unknown bank->size encountered");
                        exit(-1);
        }
        
-       /* include bank 1 sectors */
-       num_sectors = b0_sectors + 4;
-       bank->size += (32 * 1024);
+       num_sectors = b0_sectors + b1_sectors;
        
        bank->num_sectors = num_sectors;
        bank->sectors = malloc(sizeof(flash_sector_t) * num_sectors);
@@ -306,22 +308,24 @@ int str9xpec_build_block_list(struct flash_bank_s *bank)
        
        for (i = 0; i < b0_sectors; i++)
        {
-               bank->sectors[num_sectors].offset = mem_layout_str9pec[i].sector_start;
-               bank->sectors[num_sectors].size = mem_layout_str9pec[i].sector_size;
+               bank->sectors[num_sectors].offset = offset;
+               bank->sectors[num_sectors].size = 0x10000;
+               offset += bank->sectors[i].size;
                bank->sectors[num_sectors].is_erased = -1;
                bank->sectors[num_sectors].is_protected = 1;
-               str9xpec_info->sector_bits[num_sectors++] = mem_layout_str9pec[i].sector_bit;
+               str9xpec_info->sector_bits[num_sectors++] = i;
        }
-       
-       for (i = 8; i < 12; i++)
+
+       for (i = 0; i < b1_sectors; i++)
        {
-               bank->sectors[num_sectors].offset = mem_layout_str9pec[i].sector_start;
-               bank->sectors[num_sectors].size = mem_layout_str9pec[i].sector_size;
+               bank->sectors[num_sectors].offset = offset;
+               bank->sectors[num_sectors].size = b1_size;
+               offset += bank->sectors[i].size;
                bank->sectors[num_sectors].is_erased = -1;
                bank->sectors[num_sectors].is_protected = 1;
-               str9xpec_info->sector_bits[num_sectors++] = mem_layout_str9pec[i].sector_bit;
+               str9xpec_info->sector_bits[num_sectors++] = i + 32;
        }
-       
+               
        return ERROR_OK;
 }
 
@@ -343,12 +347,6 @@ int str9xpec_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, ch
        str9xpec_info = malloc(sizeof(str9xpec_flash_controller_t));
        bank->driver_priv = str9xpec_info;
        
-       if (bank->base != 0x00000000)
-       {
-               LOG_WARNING("overriding flash base address for STR91x device with 0x00000000");
-               bank->base = 0x00000000;
-       }
-
        /* find out jtag position of flash controller
         * it is always after the arm966 core */
        

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)