- reworked presto.c to allow use of either FTD2XX or libftdi (libftdi not functional...
[openocd.git] / src / flash / at91sam7.c
index fdc1c51adefbc8791d2fdd467ce754269ce521e3..b4b347586ed9e91a4ff11a6ef9cf8671bea9a8b2 100644 (file)
@@ -326,7 +326,15 @@ int at91sam7_read_part_info(struct flash_bank_s *bank)
        at91sam7_info->cidr_version = cidr&0x001F;
        bank->size = NVPSIZ[at91sam7_info->cidr_nvpsiz];
        at91sam7_info->target_name = "Unknown";
-       
+
+       /* Support just for bulk erase of the whole device */
+       bank->num_sectors = 1;
+       bank->sectors = malloc(sizeof(flash_sector_t));
+       bank->sectors[0].offset = 0;
+       bank->sectors[0].size = bank->size;
+       bank->sectors[0].is_erased = -1;
+       bank->sectors[0].is_protected = -1;
+
        DEBUG("nvptyp: 0x%3.3x, arch: 0x%4.4x", at91sam7_info->cidr_nvptyp, at91sam7_info->cidr_arch );
 
        /* Read main and master clock freqency register */
@@ -565,22 +573,27 @@ int at91sam7_erase(struct flash_bank_s *bank, int first, int last)
                return ERROR_FLASH_OPERATION_FAILED;
        }       
        
-       if ((first < 0) || (last < first) || (last >= at91sam7_info->num_lockbits))
+       if ((first < 0) || (last < first) || (last >= bank->num_sectors))
        {
-               return ERROR_FLASH_SECTOR_INVALID;
+               if ((first == 0) && (last == (at91sam7_info->num_lockbits-1)))
+               {
+                       WARNING("Sector numbers based on lockbit count, probably a deprecated script");
+                       last = bank->num_sectors-1;
+               }
+               else return ERROR_FLASH_SECTOR_INVALID;
        }
 
-       /* Configure the flash controller timing */
-       at91sam7_read_clock_info(bank); 
-       at91sam7_set_flash_mode(bank,FMR_TIMING_FLASH);
-
-       if ((first == 0) && (last == (at91sam7_info->num_lockbits-1)))
+       if ((first != 0) || (last != (bank->num_sectors-1)))
        {
-               return at91sam7_flash_command(bank, EA, 0);
+               WARNING("Can only erase the whole flash area, pages are autoerased on write");
+               return ERROR_FLASH_OPERATION_FAILED;
        }
 
-       WARNING("Can only erase the whole flash area, pages are autoerased on write");
-       return ERROR_FLASH_OPERATION_FAILED;
+       /* Configure the flash controller timing */
+       at91sam7_read_clock_info(bank); 
+       at91sam7_set_flash_mode(bank,FMR_TIMING_FLASH);
+
+       return at91sam7_flash_command(bank, EA, 0);
 }
 
 int at91sam7_protect(struct flash_bank_s *bank, int set, int first, int last)

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)