diff options
author | Tomas Vanek <vanekt@fbl.cz> | 2018-01-06 12:10:12 +0100 |
---|---|---|
committer | Tomas Vanek <vanekt@fbl.cz> | 2018-03-03 09:40:34 +0000 |
commit | e8b2e62d45a7e62bc0d982f6d778d86accfee060 (patch) | |
tree | e1fa7f1a209eab12c7a655cb08635e51153d31ad /src | |
parent | bb9d9c60264a905926e0d15f84842858d0de80b7 (diff) |
flash/nor/psoc4: adjust flash size limited by wounding
All credit goes to Dmitry Grinberg
http://dmitry.gr/index.php?r=05.Projects&proj=24.%20PSoC4%20confidential
Change-Id: Iae8fd6f11a7f62e8ffe970473688f6fac5a0a261
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4324
Tested-by: jenkins
Diffstat (limited to 'src')
-rw-r--r-- | src/flash/nor/psoc4.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/flash/nor/psoc4.c b/src/flash/nor/psoc4.c index 1d861edc..d4ce1fb0 100644 --- a/src/flash/nor/psoc4.c +++ b/src/flash/nor/psoc4.c @@ -78,6 +78,8 @@ CYBL10x6x, CY8C4127_BL, CY8C4247_BL Programming Specifications Document No. 001-91508 Rev. *B September 22, 2014 + + http://dmitry.gr/index.php?r=05.Projects&proj=24.%20PSoC4%20confidential */ /* register locations */ @@ -717,6 +719,22 @@ cleanup: } +/* Due to Cypress's method of market segmentation some devices + * have accessible only 1/2, 1/4 or 1/8 of SPCIF described flash */ +static int psoc4_test_flash_wounding(struct target *target, uint32_t flash_size) +{ + int retval, i; + for (i = 3; i >= 1; i--) { + uint32_t addr = flash_size >> i; + uint32_t dummy; + retval = target_read_u32(target, addr, &dummy); + if (retval != ERROR_OK) + return i; + } + return 0; +} + + static int psoc4_probe(struct flash_bank *bank) { struct psoc4_flash_bank *psoc4_info = bank->driver_priv; @@ -798,6 +816,15 @@ static int psoc4_probe(struct flash_bank *bank) if (num_macros != (num_rows + PSOC4_ROWS_PER_MACRO - 1) / PSOC4_ROWS_PER_MACRO) LOG_WARNING("Number of macros does not correspond with flash size!"); + if (!psoc4_info->legacy_family) { + int wounding = psoc4_test_flash_wounding(target, num_rows * row_size); + if (wounding > 0) { + flash_size_in_kb = flash_size_in_kb >> wounding; + num_rows = num_rows >> wounding; + LOG_INFO("WOUNDING detected: accessible flash size %" PRIu32 " kbytes", flash_size_in_kb); + } + } + if (bank->sectors) { free(bank->sectors); } |