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/2992
-- gerrit commit ddd83efc5ad608afc266918fa95b4b6bcc9e2f4d Author: Tomas Vanek <[email protected]> Date: Tue Sep 29 18:15:36 2015 +0200 Kinetis: improve flash detection using SIM_FCFG2 MAXADDR0 and MAXADDR1 Autodetect 1 or 2 flash blocks devices and recheck bank sizes. Change-Id: Ib3b68db9ec5356b8d5dc73c9f12053f7476bf474 Signed-off-by: Tomas Vanek <[email protected]> diff --git a/src/flash/nor/kinetis.c b/src/flash/nor/kinetis.c index 5e64247..afcf988 100644 --- a/src/flash/nor/kinetis.c +++ b/src/flash/nor/kinetis.c @@ -1061,7 +1061,7 @@ static int kinetis_read_part_info(struct flash_bank *bank) int result, i; uint32_t offset = 0; uint8_t fcfg1_nvmsize, fcfg1_pfsize, fcfg1_eesize, fcfg1_depart; - uint8_t fcfg2_pflsh; + uint8_t fcfg2_maxaddr0, fcfg2_pflsh, fcfg2_maxaddr1; uint32_t nvm_size = 0, pf_size = 0, df_size = 0, ee_size = 0; unsigned num_blocks = 0, num_pflash_blocks = 0, num_nvm_blocks = 0, first_nvm_bank = 0, pflash_sector_size_bytes = 0, nvm_sector_size_bytes = 0; @@ -1171,7 +1171,7 @@ static int kinetis_read_part_info(struct flash_bank *bank) || (kinfo->sim_sdid & (KINETIS_SDID_DIEID_MASK)) == KINETIS_SDID_DIEID_K22FN512) { /* K22 with new-style SDID - smaller pflash with FTFA, 2kB sectors */ pflash_sector_size_bytes = 2<<10; - num_blocks = 2; /* 1 or 2 blocks */ + /* autodetect 1 or 2 blocks */ kinfo->flash_support = FS_PROGRAM_LONGWORD; break; } @@ -1223,7 +1223,7 @@ static int kinetis_read_part_info(struct flash_bank *bank) /* KL-series */ pflash_sector_size_bytes = 1<<10; nvm_sector_size_bytes = 1<<10; - num_blocks = 1; + /* autodetect 1 or 2 blocks */ kinfo->flash_support = FS_PROGRAM_LONGWORD; break; default: @@ -1253,6 +1253,18 @@ static int kinetis_read_part_info(struct flash_bank *bank) fcfg1_depart = (uint8_t)((kinfo->sim_fcfg1 >> 8) & 0x0f); fcfg2_pflsh = (uint8_t)((kinfo->sim_fcfg2 >> 23) & 0x01); + fcfg2_maxaddr0 = (uint8_t)((kinfo->sim_fcfg2 >> 24) & 0x7f); + fcfg2_maxaddr1 = (uint8_t)((kinfo->sim_fcfg2 >> 16) & 0x7f); + + if (num_blocks == 0) + num_blocks = fcfg2_maxaddr1 ? 2 : 1; + else if (fcfg2_maxaddr1 == 0 && num_blocks >= 2) { + num_blocks = 1; + LOG_WARNING("MAXADDR1 is zero, number of flash banks adjusted to 1"); + } else if (fcfg2_maxaddr1 != 0 && num_blocks == 1) { + num_blocks = 2; + LOG_WARNING("MAXADDR1 is non zero, number of flash banks adjusted to 2"); + } /* when the PFLSH bit is set, there is no FlexNVM/FlexRAM */ if (!fcfg2_pflsh) { @@ -1406,6 +1418,20 @@ static int kinetis_read_part_info(struct flash_bank *bank) return ERROR_FLASH_BANK_INVALID; } + if (bank->bank_number == 0 && ((uint32_t)fcfg2_maxaddr0 << 13) != bank->size) + LOG_WARNING("MAXADDR0 0x%02" PRIx8 " check failed," + " please report to OpenOCD mailing list", fcfg2_maxaddr0); + if (fcfg2_pflsh) { + if (bank->bank_number == 1 && ((uint32_t)fcfg2_maxaddr1 << 13) != bank->size) + LOG_WARNING("MAXADDR1 0x%02" PRIx8 " check failed," + " please report to OpenOCD mailing list", fcfg2_maxaddr1); + } else { + if ((unsigned)bank->bank_number == first_nvm_bank + && ((uint32_t)fcfg2_maxaddr1 << 13) != df_size) + LOG_WARNING("FlexNVM MAXADDR1 0x%02" PRIx8 " check failed," + " please report to OpenOCD mailing list", fcfg2_maxaddr1); + } + if (bank->sectors) { free(bank->sectors); bank->sectors = NULL; -- ------------------------------------------------------------------------------ _______________________________________________ OpenOCD-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openocd-devel
