This is an automated email from Gerrit.

Tomas Vanek ([email protected]) just uploaded a new patch set to Gerrit, which you 
can find at http://openocd.zylin.com/2993

-- gerrit

commit 5940f3bbc24c3b81c31728e4c563a53592e55cf5
Author: Tomas Vanek <[email protected]>
Date:   Fri Oct 2 11:00:07 2015 +0200

    Kinetis: invalidate flash cache after erase/write
    
    Cached old flash contents broke verify readback on Kx devices.
    
    Change-Id: I0effaf358f451b473f0d9c762a133ffd21bc64b4
    Signed-off-by: Tomas Vanek <[email protected]>

diff --git a/src/flash/nor/kinetis.c b/src/flash/nor/kinetis.c
index afcf988..5f8fee1 100644
--- a/src/flash/nor/kinetis.c
+++ b/src/flash/nor/kinetis.c
@@ -81,6 +81,8 @@
 
 /* Addressess */
 #define FLEXRAM                0x14000000
+
+#define FMC_PFB01CR    0x4001f004
 #define FTFx_FSTAT     0x40020000
 #define FTFx_FCNFG     0x40020001
 #define FTFx_FCCOB3    0x40020004
@@ -214,6 +216,7 @@ struct kinetis_flash_bank {
                FS_PROGRAM_SECTOR = 1,
                FS_PROGRAM_LONGWORD = 2,
                FS_PROGRAM_PHRASE = 4, /* Unsupported */
+               FS_INVALIDATE_CACHE = 8,
        } flash_support;
 };
 
@@ -824,6 +827,19 @@ static int kinetis_ftfx_command(struct target *target, 
uint8_t fcmd, uint32_t fa
 }
 
 
+static void kinetis_invalidate_flash_cache(struct flash_bank *bank)
+{
+       struct kinetis_flash_bank *kinfo = bank->driver_priv;
+       uint8_t pfb01cr_byte2 = 0xf0;
+
+       if (!(kinfo->flash_support & FS_INVALIDATE_CACHE))
+               return;
+
+       target_write_memory(bank->target, FMC_PFB01CR + 2, 1, 1, 
&pfb01cr_byte2);
+       return;
+}
+
+
 static int kinetis_erase(struct flash_bank *bank, int first, int last)
 {
        int result, i;
@@ -856,6 +872,8 @@ static int kinetis_erase(struct flash_bank *bank, int 
first, int last)
                bank->sectors[i].is_erased = 1;
        }
 
+       kinetis_invalidate_flash_cache(bank);
+
        if (first == 0) {
                LOG_WARNING
                        ("flash configuration field erased, please reset the 
device");
@@ -1053,6 +1071,7 @@ static int kinetis_write(struct flash_bank *bank, const 
uint8_t *buffer,
                return ERROR_FLASH_OPERATION_FAILED;
        }
 
+       kinetis_invalidate_flash_cache(bank);
        return ERROR_OK;
 }
 
@@ -1085,7 +1104,7 @@ static int kinetis_read_part_info(struct flash_bank *bank)
                        pflash_sector_size_bytes = 1<<10;
                        nvm_sector_size_bytes = 1<<10;
                        num_blocks = 2;
-                       kinfo->flash_support = FS_PROGRAM_LONGWORD | 
FS_PROGRAM_SECTOR;
+                       kinfo->flash_support = FS_PROGRAM_LONGWORD | 
FS_PROGRAM_SECTOR | FS_INVALIDATE_CACHE;
                        break;
                case KINETIS_K_SDID_K10_M72:
                case KINETIS_K_SDID_K20_M72:
@@ -1098,7 +1117,7 @@ static int kinetis_read_part_info(struct flash_bank *bank)
                        pflash_sector_size_bytes = 2<<10;
                        nvm_sector_size_bytes = 1<<10;
                        num_blocks = 2;
-                       kinfo->flash_support = FS_PROGRAM_LONGWORD | 
FS_PROGRAM_SECTOR;
+                       kinfo->flash_support = FS_PROGRAM_LONGWORD | 
FS_PROGRAM_SECTOR | FS_INVALIDATE_CACHE;
                        kinfo->max_flash_prog_size = 1<<10;
                        break;
                case KINETIS_K_SDID_K10_M100:
@@ -1114,7 +1133,7 @@ static int kinetis_read_part_info(struct flash_bank *bank)
                        pflash_sector_size_bytes = 2<<10;
                        nvm_sector_size_bytes = 2<<10;
                        num_blocks = 2;
-                       kinfo->flash_support = FS_PROGRAM_LONGWORD | 
FS_PROGRAM_SECTOR;
+                       kinfo->flash_support = FS_PROGRAM_LONGWORD | 
FS_PROGRAM_SECTOR | FS_INVALIDATE_CACHE;
                        break;
                case KINETIS_K_SDID_K21_M120:
                case KINETIS_K_SDID_K22_M120:
@@ -1123,7 +1142,7 @@ static int kinetis_read_part_info(struct flash_bank *bank)
                        kinfo->max_flash_prog_size = 1<<10;
                        nvm_sector_size_bytes = 4<<10;
                        num_blocks = 2;
-                       kinfo->flash_support = FS_PROGRAM_PHRASE | 
FS_PROGRAM_SECTOR;
+                       kinfo->flash_support = FS_PROGRAM_PHRASE | 
FS_PROGRAM_SECTOR | FS_INVALIDATE_CACHE;
                        break;
                case KINETIS_K_SDID_K10_M120:
                case KINETIS_K_SDID_K20_M120:
@@ -1133,7 +1152,7 @@ static int kinetis_read_part_info(struct flash_bank *bank)
                        pflash_sector_size_bytes = 4<<10;
                        nvm_sector_size_bytes = 4<<10;
                        num_blocks = 4;
-                       kinfo->flash_support = FS_PROGRAM_PHRASE | 
FS_PROGRAM_SECTOR;
+                       kinfo->flash_support = FS_PROGRAM_PHRASE | 
FS_PROGRAM_SECTOR | FS_INVALIDATE_CACHE;
                        break;
                default:
                        LOG_ERROR("Unsupported K-family FAMID");
@@ -1147,7 +1166,7 @@ static int kinetis_read_part_info(struct flash_bank *bank)
                                /* K02FN64, K02FN128: FTFA, 2kB sectors */
                                pflash_sector_size_bytes = 2<<10;
                                num_blocks = 1;
-                               kinfo->flash_support = FS_PROGRAM_LONGWORD;
+                               kinfo->flash_support = FS_PROGRAM_LONGWORD | 
FS_INVALIDATE_CACHE;
                                break;
 
                        case KINETIS_SDID_FAMILYID_K2X | 
KINETIS_SDID_SUBFAMID_KX2: {
@@ -1162,7 +1181,7 @@ static int kinetis_read_part_info(struct flash_bank *bank)
                                        /* MK24FN1M */
                                        pflash_sector_size_bytes = 4<<10;
                                        num_blocks = 2;
-                                       kinfo->flash_support = 
FS_PROGRAM_PHRASE | FS_PROGRAM_SECTOR;
+                                       kinfo->flash_support = 
FS_PROGRAM_PHRASE | FS_PROGRAM_SECTOR | FS_INVALIDATE_CACHE;
                                        kinfo->max_flash_prog_size = 1<<10;
                                        break;
                                }
@@ -1172,7 +1191,7 @@ static int kinetis_read_part_info(struct flash_bank *bank)
                                        /* K22 with new-style SDID - smaller 
pflash with FTFA, 2kB sectors */
                                        pflash_sector_size_bytes = 2<<10;
                                        /* autodetect 1 or 2 blocks */
-                                       kinfo->flash_support = 
FS_PROGRAM_LONGWORD;
+                                       kinfo->flash_support = 
FS_PROGRAM_LONGWORD | FS_INVALIDATE_CACHE;
                                        break;
                                }
                                LOG_ERROR("Unsupported Kinetis K22 DIEID");
@@ -1183,12 +1202,12 @@ static int kinetis_read_part_info(struct flash_bank 
*bank)
                                if ((kinfo->sim_sdid & 
(KINETIS_SDID_DIEID_MASK)) == KINETIS_SDID_DIEID_K24FN256) {
                                        /* K24FN256 - smaller pflash with FTFA 
*/
                                        num_blocks = 1;
-                                       kinfo->flash_support = 
FS_PROGRAM_LONGWORD;
+                                       kinfo->flash_support = 
FS_PROGRAM_LONGWORD | FS_INVALIDATE_CACHE;
                                        break;
                                }
                                /* K24FN1M without errata 7534 */
                                num_blocks = 2;
-                               kinfo->flash_support = FS_PROGRAM_PHRASE | 
FS_PROGRAM_SECTOR;
+                               kinfo->flash_support = FS_PROGRAM_PHRASE | 
FS_PROGRAM_SECTOR | FS_INVALIDATE_CACHE;
                                kinfo->max_flash_prog_size = 1<<10;
                                break;
 
@@ -1202,7 +1221,7 @@ static int kinetis_read_part_info(struct flash_bank *bank)
                                nvm_sector_size_bytes = 4<<10;
                                kinfo->max_flash_prog_size = 1<<10;
                                num_blocks = 2;
-                               kinfo->flash_support = FS_PROGRAM_PHRASE | 
FS_PROGRAM_SECTOR;
+                               kinfo->flash_support = FS_PROGRAM_PHRASE | 
FS_PROGRAM_SECTOR | FS_INVALIDATE_CACHE;
                                break;
 
                        case KINETIS_SDID_FAMILYID_K2X | 
KINETIS_SDID_SUBFAMID_KX6:
@@ -1213,7 +1232,7 @@ static int kinetis_read_part_info(struct flash_bank *bank)
                                nvm_sector_size_bytes = 4<<10;
                                kinfo->max_flash_prog_size = 1<<10;
                                num_blocks = 4;
-                               kinfo->flash_support = FS_PROGRAM_PHRASE | 
FS_PROGRAM_SECTOR;
+                               kinfo->flash_support = FS_PROGRAM_PHRASE | 
FS_PROGRAM_SECTOR | FS_INVALIDATE_CACHE;
                                break;
                        default:
                                LOG_ERROR("Unsupported Kinetis FAMILYID 
SUBFAMID");

-- 

------------------------------------------------------------------------------
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to