This is an automated email from Gerrit. "Carlos Sanchez <carlossanc...@geotab.com>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8009
-- gerrit commit 02a48d6626f43decbc5d018d00c2911f498314e2 Author: Sven van Ashbrook <svenvanasbro...@geotab.com> Date: Fri Apr 29 11:22:41 2022 -0400 flash/nor/kinetis: Eliminate dependency on fcfg1 Prepare for introduction of S32K. Not every kinetis chip has the same FCFG1 layout. Eliminate kinetis.c's dependency on FCFG1 layout. Exception: nvm_partition command, as it is chip-specific. This is addressed in a later commit in the series. Change-Id: Ib9dac157c47027507fd395485d9b9deb485e4926 Signed-off-by: Sven van Ashbrook <svenvanasbro...@geotab.com> diff --git a/src/flash/nor/kinetis.c b/src/flash/nor/kinetis.c index 1fbfccac80..eece80f97d 100644 --- a/src/flash/nor/kinetis.c +++ b/src/flash/nor/kinetis.c @@ -256,7 +256,6 @@ struct kinetis_chip { struct target *target; bool probed; - uint32_t sim_fcfg1; uint32_t maxaddr0_shifted; uint32_t maxaddr1_shifted; @@ -268,6 +267,7 @@ struct kinetis_chip { uint32_t pflash_size; uint32_t nvm_base; uint32_t nvm_size; /* whole FlexNVM */ + uint32_t ee_size; uint32_t dflash_size; /* accessible rest of FlexNVM if EEPROM backup uses part of FlexNVM */ uint32_t progr_accel_ram; @@ -2071,10 +2071,9 @@ static int kinetis_probe_chip(struct kinetis_chip *k_chip) int result; uint8_t fcfg1_nvmsize, fcfg1_pfsize, fcfg1_eesize, fcfg1_depart; uint8_t fcfg2_pflsh; - uint32_t ee_size = 0; uint32_t pflash_size_k, nvm_size_k, dflash_size_k; uint32_t pflash_size_m; - uint32_t sim_sdid, sim_fcfg2; + uint32_t sim_sdid, sim_fcfg1, sim_fcfg2; unsigned num_blocks = 0; unsigned maxaddr_shift = 13; struct target *target = k_chip->target; @@ -2090,6 +2089,7 @@ static int kinetis_probe_chip(struct kinetis_chip *k_chip) k_chip->pflash_base = 0; k_chip->nvm_base = 0x10000000; k_chip->progr_accel_ram = FLEXRAM; + k_chip->ee_size = 0; name[0] = '\0'; @@ -2518,7 +2518,7 @@ static int kinetis_probe_chip(struct kinetis_chip *k_chip) return ERROR_FLASH_OPER_UNSUPPORTED; } - result = target_read_u32(target, k_chip->sim_base + SIM_FCFG1_OFFSET, &k_chip->sim_fcfg1); + result = target_read_u32(target, k_chip->sim_base + SIM_FCFG1_OFFSET, &sim_fcfg1); if (result != ERROR_OK) return result; @@ -2527,12 +2527,12 @@ static int kinetis_probe_chip(struct kinetis_chip *k_chip) return result; LOG_DEBUG("SDID: 0x%08" PRIX32 " FCFG1: 0x%08" PRIX32 " FCFG2: 0x%08" PRIX32, sim_sdid, - k_chip->sim_fcfg1, sim_fcfg2); + sim_fcfg1, sim_fcfg2); - fcfg1_nvmsize = (uint8_t)((k_chip->sim_fcfg1 >> 28) & 0x0f); - fcfg1_pfsize = (uint8_t)((k_chip->sim_fcfg1 >> 24) & 0x0f); - fcfg1_eesize = (uint8_t)((k_chip->sim_fcfg1 >> 16) & 0x0f); - fcfg1_depart = (uint8_t)((k_chip->sim_fcfg1 >> 8) & 0x0f); + fcfg1_nvmsize = (uint8_t)((sim_fcfg1 >> 28) & 0x0f); + fcfg1_pfsize = (uint8_t)((sim_fcfg1 >> 24) & 0x0f); + fcfg1_eesize = (uint8_t)((sim_fcfg1 >> 16) & 0x0f); + fcfg1_depart = (uint8_t)((sim_fcfg1 >> 8) & 0x0f); fcfg2_pflsh = (uint8_t)((sim_fcfg2 >> 23) & 0x01); k_chip->maxaddr0_shifted = ((sim_fcfg2 >> 24) & 0x7f) << maxaddr_shift; @@ -2583,10 +2583,10 @@ static int kinetis_probe_chip(struct kinetis_chip *k_chip) case 0x07: case 0x08: case 0x09: - ee_size = (16 << (10 - fcfg1_eesize)); + k_chip->ee_size = (16 << (10 - fcfg1_eesize)); break; default: - ee_size = 0; + k_chip->ee_size = 0; break; } @@ -2686,7 +2686,7 @@ static int kinetis_probe_chip(struct kinetis_chip *k_chip) nvm_size_k = k_chip->nvm_size / 1024; dflash_size_k = k_chip->dflash_size / 1024; LOG_INFO("%u FlexNVM banks: %" PRIu32 " KiB total, %" PRIu32 " KiB available as data flash, %" - PRIu32 " bytes FlexRAM", k_chip->num_nvm_blocks, nvm_size_k, dflash_size_k, ee_size); + PRIu32 " bytes FlexRAM", k_chip->num_nvm_blocks, nvm_size_k, dflash_size_k, k_chip->ee_size); } k_chip->probed = true; @@ -2908,9 +2908,8 @@ static int kinetis_blank_check(struct flash_bank *bank) uint8_t ftfx_fstat; if (use_block_cmd && k_bank->flash_class == FC_FLEX_NVM) { - uint8_t fcfg1_depart = (uint8_t)((k_chip->sim_fcfg1 >> 8) & 0x0f); /* block operation cannot be used on FlexNVM when EEPROM backup partition is set */ - if (fcfg1_depart != 0xf && fcfg1_depart != 0) + if (k_chip->ee_size) use_block_cmd = false; } --