aboutsummaryrefslogtreecommitdiff
path: root/src/flash
diff options
context:
space:
mode:
authorTomas Vanek <vanekt@fbl.cz>2017-07-13 21:35:22 +0200
committerPaul Fertser <fercerpav@gmail.com>2017-07-24 13:11:06 +0100
commit02bc718d1a49dd04bffa446f1dadd6b86d0d107c (patch)
treec8f9d00bad312b3563c05733086dc891929640df /src/flash
parentdbd0d90af9ba12934eabd68d82aac9d7eb7e1e6a (diff)
downloadriscv-openocd-02bc718d1a49dd04bffa446f1dadd6b86d0d107c.zip
riscv-openocd-02bc718d1a49dd04bffa446f1dadd6b86d0d107c.tar.gz
riscv-openocd-02bc718d1a49dd04bffa446f1dadd6b86d0d107c.tar.bz2
flash Kinetis: fix probe for FlexNVM partitioned as EEPROM backup
If a MCU has FlexNVM partitioned as EEPROM backup only (no data flash), kinetis_probe_chip() detects zero fcfg2_maxaddr1 and adjusts flash banks count to 1, what is obviously wrong. The change limits the test to devices without FlexNVM. Computation of program flash/FlexNVM blocks is now more robust. Missing case 0x07 is added to switch (fcfg1_depart) Change-Id: I0bd6030a0fe1ab62aeb0223bbdf2aee1505bf6a0 Reported-by: simon.haines@scalardata.com Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/4180 Tested-by: jenkins Reviewed-by: Simon Haines <simon.haines@scalardata.com> Reviewed-by: Paul Fertser <fercerpav@gmail.com>
Diffstat (limited to 'src/flash')
-rw-r--r--src/flash/nor/kinetis.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/flash/nor/kinetis.c b/src/flash/nor/kinetis.c
index f57579d..4ef4385 100644
--- a/src/flash/nor/kinetis.c
+++ b/src/flash/nor/kinetis.c
@@ -2387,7 +2387,9 @@ static int kinetis_probe_chip(struct kinetis_chip *k_chip)
if (num_blocks == 0)
num_blocks = k_chip->fcfg2_maxaddr1_shifted ? 2 : 1;
- else if (k_chip->fcfg2_maxaddr1_shifted == 0 && num_blocks >= 2) {
+ else if (k_chip->fcfg2_maxaddr1_shifted == 0 && num_blocks >= 2 && fcfg2_pflsh) {
+ /* fcfg2_maxaddr1 may be zero due to partitioning whole NVM as EEPROM backup
+ * Do not adjust block count in this case! */
num_blocks = 1;
LOG_WARNING("MAXADDR1 is zero, number of flash banks adjusted to 1");
} else if (k_chip->fcfg2_maxaddr1_shifted != 0 && num_blocks == 1) {
@@ -2444,6 +2446,7 @@ static int kinetis_probe_chip(struct kinetis_chip *k_chip)
case 0x06:
k_chip->dflash_size = k_chip->nvm_size - (4096 << fcfg1_depart);
break;
+ case 0x07:
case 0x08:
k_chip->dflash_size = 0;
break;
@@ -2502,8 +2505,13 @@ static int kinetis_probe_chip(struct kinetis_chip *k_chip)
/* Program section size is equal to sector size by default */
}
- k_chip->num_pflash_blocks = num_blocks / (2 - fcfg2_pflsh);
- k_chip->num_nvm_blocks = num_blocks - k_chip->num_pflash_blocks;
+ if (fcfg2_pflsh) {
+ k_chip->num_pflash_blocks = num_blocks;
+ k_chip->num_nvm_blocks = 0;
+ } else {
+ k_chip->num_pflash_blocks = (num_blocks + 1) / 2;
+ k_chip->num_nvm_blocks = num_blocks - k_chip->num_pflash_blocks;
+ }
if (use_nvm_marking) {
nvm_marking[0] = k_chip->num_nvm_blocks ? 'X' : 'N';