aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/flash/nor/aduc702x.c14
-rw-r--r--src/flash/nor/aducm360.c16
-rw-r--r--src/flash/nor/avrf.c16
-rw-r--r--src/flash/nor/cc26xx.c13
-rw-r--r--src/flash/nor/cc3220sf.c13
-rw-r--r--src/flash/nor/cfi.c5
-rw-r--r--src/flash/nor/core.c5
-rw-r--r--src/flash/nor/driver.h4
-rw-r--r--src/flash/nor/faux.c13
-rw-r--r--src/flash/nor/fm4.c6
-rw-r--r--src/flash/nor/jtagspi.c11
-rw-r--r--src/flash/nor/lpc2000.c14
-rw-r--r--src/flash/nor/lpc288x.c1
-rw-r--r--src/flash/nor/lpc2900.c20
-rw-r--r--src/flash/nor/mdr.c12
-rw-r--r--src/flash/nor/mrvlqspi.c8
-rw-r--r--src/flash/nor/msp432.c13
-rw-r--r--src/flash/nor/ocl.c12
-rw-r--r--src/flash/nor/psoc5lp.c22
-rw-r--r--src/flash/nor/stm32lx.c10
-rw-r--r--src/flash/nor/tcl.c16
21 files changed, 31 insertions, 213 deletions
diff --git a/src/flash/nor/aduc702x.c b/src/flash/nor/aduc702x.c
index 34cc362..824112b 100644
--- a/src/flash/nor/aduc702x.c
+++ b/src/flash/nor/aduc702x.c
@@ -74,12 +74,6 @@ static int aduc702x_build_sector_list(struct flash_bank *bank)
return ERROR_OK;
}
-static int aduc702x_protect_check(struct flash_bank *bank)
-{
- printf("aduc702x_protect_check not implemented yet.\n");
- return ERROR_OK;
-}
-
static int aduc702x_erase(struct flash_bank *bank, int first, int last)
{
/* int res; */
@@ -130,12 +124,6 @@ static int aduc702x_erase(struct flash_bank *bank, int first, int last)
return ERROR_OK;
}
-static int aduc702x_protect(struct flash_bank *bank, int set, int first, int last)
-{
- printf("aduc702x_protect not implemented yet.\n");
- return ERROR_FLASH_OPERATION_FAILED;
-}
-
/* If this fn returns ERROR_TARGET_RESOURCE_NOT_AVAILABLE, then the caller can fall
* back to another mechanism that does not require onboard RAM
*
@@ -394,11 +382,9 @@ struct flash_driver aduc702x_flash = {
.name = "aduc702x",
.flash_bank_command = aduc702x_flash_bank_command,
.erase = aduc702x_erase,
- .protect = aduc702x_protect,
.write = aduc702x_write,
.read = default_flash_read,
.probe = aduc702x_probe,
.auto_probe = aduc702x_probe,
.erase_check = default_flash_blank_check,
- .protect_check = aduc702x_protect_check,
};
diff --git a/src/flash/nor/aducm360.c b/src/flash/nor/aducm360.c
index 8681a25..7663783 100644
--- a/src/flash/nor/aducm360.c
+++ b/src/flash/nor/aducm360.c
@@ -103,13 +103,6 @@ static int aducm360_build_sector_list(struct flash_bank *bank)
}
/* ----------------------------------------------------------------------- */
-static int aducm360_protect_check(struct flash_bank *bank)
-{
- LOG_WARNING("aducm360_protect_check not implemented.");
- return ERROR_OK;
-}
-
-/* ----------------------------------------------------------------------- */
static int aducm360_mass_erase(struct target *target)
{
uint32_t value;
@@ -195,13 +188,6 @@ static int aducm360_erase(struct flash_bank *bank, int first, int last)
}
/* ----------------------------------------------------------------------- */
-static int aducm360_protect(struct flash_bank *bank, int set, int first, int last)
-{
- LOG_ERROR("aducm360_protect not implemented.");
- return ERROR_FLASH_OPERATION_FAILED;
-}
-
-/* ----------------------------------------------------------------------- */
static int aducm360_write_block_sync(
struct flash_bank *bank,
const uint8_t *buffer,
@@ -572,11 +558,9 @@ struct flash_driver aducm360_flash = {
.name = "aducm360",
.flash_bank_command = aducm360_flash_bank_command,
.erase = aducm360_erase,
- .protect = aducm360_protect,
.write = aducm360_write,
.read = default_flash_read,
.probe = aducm360_probe,
.auto_probe = aducm360_probe,
.erase_check = default_flash_blank_check,
- .protect_check = aducm360_protect_check,
};
diff --git a/src/flash/nor/avrf.c b/src/flash/nor/avrf.c
index 65ac601..b88f6f6 100644
--- a/src/flash/nor/avrf.c
+++ b/src/flash/nor/avrf.c
@@ -233,12 +233,6 @@ static int avrf_erase(struct flash_bank *bank, int first, int last)
return avr_jtagprg_leaveprogmode(avr);
}
-static int avrf_protect(struct flash_bank *bank, int set, int first, int last)
-{
- LOG_INFO("%s", __func__);
- return ERROR_OK;
-}
-
static int avrf_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
{
struct target *target = bank->target;
@@ -338,7 +332,7 @@ static int avrf_probe(struct flash_bank *bank)
bank->sectors[i].offset = i * avr_info->flash_page_size;
bank->sectors[i].size = avr_info->flash_page_size;
bank->sectors[i].is_erased = -1;
- bank->sectors[i].is_protected = 1;
+ bank->sectors[i].is_protected = -1;
}
avrf_info->probed = 1;
@@ -360,12 +354,6 @@ static int avrf_auto_probe(struct flash_bank *bank)
return avrf_probe(bank);
}
-static int avrf_protect_check(struct flash_bank *bank)
-{
- LOG_INFO("%s", __func__);
- return ERROR_OK;
-}
-
static int avrf_info(struct flash_bank *bank, char *buf, int buf_size)
{
struct target *target = bank->target;
@@ -479,13 +467,11 @@ struct flash_driver avr_flash = {
.commands = avrf_command_handlers,
.flash_bank_command = avrf_flash_bank_command,
.erase = avrf_erase,
- .protect = avrf_protect,
.write = avrf_write,
.read = default_flash_read,
.probe = avrf_probe,
.auto_probe = avrf_auto_probe,
.erase_check = default_flash_blank_check,
- .protect_check = avrf_protect_check,
.info = avrf_info,
.free_driver_priv = default_flash_free_driver_priv,
};
diff --git a/src/flash/nor/cc26xx.c b/src/flash/nor/cc26xx.c
index e6e9e59..7b87441 100644
--- a/src/flash/nor/cc26xx.c
+++ b/src/flash/nor/cc26xx.c
@@ -312,12 +312,6 @@ static int cc26xx_erase(struct flash_bank *bank, int first, int last)
return retval;
}
-static int cc26xx_protect(struct flash_bank *bank, int set, int first,
- int last)
-{
- return ERROR_OK;
-}
-
static int cc26xx_write(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t count)
{
@@ -508,11 +502,6 @@ static int cc26xx_auto_probe(struct flash_bank *bank)
return retval;
}
-static int cc26xx_protect_check(struct flash_bank *bank)
-{
- return ERROR_OK;
-}
-
static int cc26xx_info(struct flash_bank *bank, char *buf, int buf_size)
{
struct cc26xx_bank *cc26xx_bank = bank->driver_priv;
@@ -555,13 +544,11 @@ struct flash_driver cc26xx_flash = {
.name = "cc26xx",
.flash_bank_command = cc26xx_flash_bank_command,
.erase = cc26xx_erase,
- .protect = cc26xx_protect,
.write = cc26xx_write,
.read = default_flash_read,
.probe = cc26xx_probe,
.auto_probe = cc26xx_auto_probe,
.erase_check = default_flash_blank_check,
- .protect_check = cc26xx_protect_check,
.info = cc26xx_info,
.free_driver_priv = default_flash_free_driver_priv,
};
diff --git a/src/flash/nor/cc3220sf.c b/src/flash/nor/cc3220sf.c
index af45743..5ccb428 100644
--- a/src/flash/nor/cc3220sf.c
+++ b/src/flash/nor/cc3220sf.c
@@ -173,12 +173,6 @@ static int cc3220sf_erase(struct flash_bank *bank, int first, int last)
return retval;
}
-static int cc3220sf_protect(struct flash_bank *bank, int set, int first,
- int last)
-{
- return ERROR_OK;
-}
-
static int cc3220sf_write(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t count)
{
@@ -496,11 +490,6 @@ static int cc3220sf_auto_probe(struct flash_bank *bank)
return retval;
}
-static int cc3220sf_protect_check(struct flash_bank *bank)
-{
- return ERROR_OK;
-}
-
static int cc3220sf_info(struct flash_bank *bank, char *buf, int buf_size)
{
int printed;
@@ -517,13 +506,11 @@ struct flash_driver cc3220sf_flash = {
.name = "cc3220sf",
.flash_bank_command = cc3220sf_flash_bank_command,
.erase = cc3220sf_erase,
- .protect = cc3220sf_protect,
.write = cc3220sf_write,
.read = default_flash_read,
.probe = cc3220sf_probe,
.auto_probe = cc3220sf_auto_probe,
.erase_check = default_flash_blank_check,
- .protect_check = cc3220sf_protect_check,
.info = cc3220sf_info,
.free_driver_priv = default_flash_free_driver_priv,
};
diff --git a/src/flash/nor/cfi.c b/src/flash/nor/cfi.c
index 0ae72d4..a2db50f 100644
--- a/src/flash/nor/cfi.c
+++ b/src/flash/nor/cfi.c
@@ -1098,11 +1098,6 @@ static int cfi_protect(struct flash_bank *bank, int set, int first, int last)
return ERROR_TARGET_NOT_HALTED;
}
- if ((first < 0) || (last < first) || (last >= bank->num_sectors)) {
- LOG_ERROR("Invalid sector range");
- return ERROR_FLASH_SECTOR_INVALID;
- }
-
if (cfi_info->qry[0] != 'Q')
return ERROR_FLASH_BANK_NOT_PROBED;
diff --git a/src/flash/nor/core.c b/src/flash/nor/core.c
index 4941281..0aaa7d2 100644
--- a/src/flash/nor/core.c
+++ b/src/flash/nor/core.c
@@ -68,6 +68,11 @@ int flash_driver_protect(struct flash_bank *bank, int set, int first, int last)
/* force "set" to 0/1 */
set = !!set;
+ if (bank->driver->protect == NULL) {
+ LOG_ERROR("Flash protection is not supported.");
+ return ERROR_FLASH_OPER_UNSUPPORTED;
+ }
+
/* DANGER!
*
* We must not use any cached information about protection state!!!!
diff --git a/src/flash/nor/driver.h b/src/flash/nor/driver.h
index e7b3234..ef69a0f 100644
--- a/src/flash/nor/driver.h
+++ b/src/flash/nor/driver.h
@@ -109,6 +109,8 @@ struct flash_driver {
/**
* Bank/sector protection routine (target-specific).
*
+ * If protection is not implemented, set method to NULL
+ *
* When called, the driver should enable/disable protection
* for MINIMUM the range covered by first..last sectors
* inclusive. Some chips have alignment requirements will
@@ -178,6 +180,8 @@ struct flash_driver {
* flash_sector_s::is_protected field for each of the flash
* bank's sectors.
*
+ * If protection is not implemented, set method to NULL
+ *
* @param bank - the bank to check
* @returns ERROR_OK if successful; otherwise, an error code.
*/
diff --git a/src/flash/nor/faux.c b/src/flash/nor/faux.c
index 46eda72..d68940f 100644
--- a/src/flash/nor/faux.c
+++ b/src/flash/nor/faux.c
@@ -85,12 +85,6 @@ static int faux_erase(struct flash_bank *bank, int first, int last)
return ERROR_OK;
}
-static int faux_protect(struct flash_bank *bank, int set, int first, int last)
-{
- LOG_USER("set protection sector %d to %d to %s", first, last, set ? "on" : "off");
- return ERROR_OK;
-}
-
static int faux_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
{
struct faux_flash_bank *info = bank->driver_priv;
@@ -98,11 +92,6 @@ static int faux_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t o
return ERROR_OK;
}
-static int faux_protect_check(struct flash_bank *bank)
-{
- return ERROR_OK;
-}
-
static int faux_info(struct flash_bank *bank, char *buf, int buf_size)
{
snprintf(buf, buf_size, "faux flash driver");
@@ -129,13 +118,11 @@ struct flash_driver faux_flash = {
.commands = faux_command_handlers,
.flash_bank_command = faux_flash_bank_command,
.erase = faux_erase,
- .protect = faux_protect,
.write = faux_write,
.read = default_flash_read,
.probe = faux_probe,
.auto_probe = faux_probe,
.erase_check = default_flash_blank_check,
- .protect_check = faux_protect_check,
.info = faux_info,
.free_driver_priv = default_flash_free_driver_priv,
};
diff --git a/src/flash/nor/fm4.c b/src/flash/nor/fm4.c
index f5eab9c..d4d0f76 100644
--- a/src/flash/nor/fm4.c
+++ b/src/flash/nor/fm4.c
@@ -537,11 +537,6 @@ static int fm4_auto_probe(struct flash_bank *bank)
return fm4_probe(bank);
}
-static int fm4_protect_check(struct flash_bank *bank)
-{
- return ERROR_OK;
-}
-
static int fm4_get_info_command(struct flash_bank *bank, char *buf, int buf_size)
{
struct fm4_flash_bank *fm4_bank = bank->driver_priv;
@@ -714,7 +709,6 @@ struct flash_driver fm4_flash = {
.info = fm4_get_info_command,
.probe = fm4_probe,
.auto_probe = fm4_auto_probe,
- .protect_check = fm4_protect_check,
.read = default_flash_read,
.erase = fm4_flash_erase,
.erase_check = default_flash_blank_check,
diff --git a/src/flash/nor/jtagspi.c b/src/flash/nor/jtagspi.c
index c28ad22..c5c565f 100644
--- a/src/flash/nor/jtagspi.c
+++ b/src/flash/nor/jtagspi.c
@@ -343,21 +343,11 @@ static int jtagspi_protect(struct flash_bank *bank, int set, int first, int last
{
int sector;
- if ((first < 0) || (last < first) || (last >= bank->num_sectors)) {
- LOG_ERROR("Flash sector invalid");
- return ERROR_FLASH_SECTOR_INVALID;
- }
-
for (sector = first; sector <= last; sector++)
bank->sectors[sector].is_protected = set;
return ERROR_OK;
}
-static int jtagspi_protect_check(struct flash_bank *bank)
-{
- return ERROR_OK;
-}
-
static int jtagspi_read(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
{
struct jtagspi_flash_bank *info = bank->driver_priv;
@@ -431,7 +421,6 @@ struct flash_driver jtagspi_flash = {
.probe = jtagspi_probe,
.auto_probe = jtagspi_probe,
.erase_check = default_flash_blank_check,
- .protect_check = jtagspi_protect_check,
.info = jtagspi_info,
.free_driver_priv = default_flash_free_driver_priv,
};
diff --git a/src/flash/nor/lpc2000.c b/src/flash/nor/lpc2000.c
index 8e15c31..77beac1 100644
--- a/src/flash/nor/lpc2000.c
+++ b/src/flash/nor/lpc2000.c
@@ -1018,12 +1018,6 @@ static int lpc2000_erase(struct flash_bank *bank, int first, int last)
return retval;
}
-static int lpc2000_protect(struct flash_bank *bank, int set, int first, int last)
-{
- /* can't protect/unprotect on the lpc2000 */
- return ERROR_OK;
-}
-
static int lpc2000_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
{
struct target *target = bank->target;
@@ -1501,12 +1495,6 @@ static int lpc2000_erase_check(struct flash_bank *bank)
return lpc2000_iap_blank_check(bank, 0, bank->num_sectors - 1);
}
-static int lpc2000_protect_check(struct flash_bank *bank)
-{
- /* sectors are always protected */
- return ERROR_OK;
-}
-
static int get_lpc2000_info(struct flash_bank *bank, char *buf, int buf_size)
{
struct lpc2000_flash_bank *lpc2000_info = bank->driver_priv;
@@ -1571,13 +1559,11 @@ struct flash_driver lpc2000_flash = {
.commands = lpc2000_command_handlers,
.flash_bank_command = lpc2000_flash_bank_command,
.erase = lpc2000_erase,
- .protect = lpc2000_protect,
.write = lpc2000_write,
.read = default_flash_read,
.probe = lpc2000_probe,
.auto_probe = lpc2000_probe,
.erase_check = lpc2000_erase_check,
- .protect_check = lpc2000_protect_check,
.info = get_lpc2000_info,
.free_driver_priv = default_flash_free_driver_priv,
};
diff --git a/src/flash/nor/lpc288x.c b/src/flash/nor/lpc288x.c
index 2472913..474e721 100644
--- a/src/flash/nor/lpc288x.c
+++ b/src/flash/nor/lpc288x.c
@@ -167,6 +167,7 @@ static int lpc288x_read_part_info(struct flash_bank *bank)
return ERROR_OK;
}
+/* TODO: Revisit! Is it impossible to read protection status? */
static int lpc288x_protect_check(struct flash_bank *bank)
{
return ERROR_OK;
diff --git a/src/flash/nor/lpc2900.c b/src/flash/nor/lpc2900.c
index 1c65933..022fb82 100644
--- a/src/flash/nor/lpc2900.c
+++ b/src/flash/nor/lpc2900.c
@@ -1035,18 +1035,13 @@ static int lpc2900_erase(struct flash_bank *bank, int first, int last)
return ERROR_OK;
}
-static int lpc2900_protect(struct flash_bank *bank, int set, int first, int last)
-{
- /* This command is not supported.
- * "Protection" in LPC2900 terms is handled transparently. Sectors will
- * automatically be unprotected as needed.
- * Instead we use the concept of sector security. A secured sector is shown
- * as "protected" in OpenOCD. Sector security is a permanent feature, and
- * cannot be disabled once activated.
- */
-
- return ERROR_OK;
-}
+/* lpc2900_protect command is not supported.
+* "Protection" in LPC2900 terms is handled transparently. Sectors will
+* automatically be unprotected as needed.
+* Instead we use the concept of sector security. A secured sector is shown
+* as "protected" in OpenOCD. Sector security is a permanent feature, and
+* cannot be disabled once activated.
+*/
/**
* Write data to flash.
@@ -1591,7 +1586,6 @@ struct flash_driver lpc2900_flash = {
.commands = lpc2900_command_handlers,
.flash_bank_command = lpc2900_flash_bank_command,
.erase = lpc2900_erase,
- .protect = lpc2900_protect,
.write = lpc2900_write,
.read = default_flash_read,
.probe = lpc2900_probe,
diff --git a/src/flash/nor/mdr.c b/src/flash/nor/mdr.c
index f3916de..c4a4458 100644
--- a/src/flash/nor/mdr.c
+++ b/src/flash/nor/mdr.c
@@ -86,11 +86,6 @@ FLASH_BANK_COMMAND_HANDLER(mdr_flash_bank_command)
return ERROR_OK;
}
-static int mdr_protect_check(struct flash_bank *bank)
-{
- return ERROR_OK;
-}
-
static int mdr_mass_erase(struct flash_bank *bank)
{
struct target *target = bank->target;
@@ -217,11 +212,6 @@ reset_pg_and_lock:
return retval;
}
-static int mdr_protect(struct flash_bank *bank, int set, int first, int last)
-{
- return ERROR_OK;
-}
-
static int mdr_write_block(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t count)
{
@@ -625,13 +615,11 @@ struct flash_driver mdr_flash = {
"<type>: 0 for main memory, 1 for info memory",
.flash_bank_command = mdr_flash_bank_command,
.erase = mdr_erase,
- .protect = mdr_protect,
.write = mdr_write,
.read = mdr_read,
.probe = mdr_probe,
.auto_probe = mdr_auto_probe,
.erase_check = default_flash_blank_check,
- .protect_check = mdr_protect_check,
.info = get_mdr_info,
.free_driver_priv = default_flash_free_driver_priv,
};
diff --git a/src/flash/nor/mrvlqspi.c b/src/flash/nor/mrvlqspi.c
index eda6cc1..132e5f3 100644
--- a/src/flash/nor/mrvlqspi.c
+++ b/src/flash/nor/mrvlqspi.c
@@ -899,12 +899,6 @@ static int mrvlqspi_flash_erase_check(struct flash_bank *bank)
return ERROR_OK;
}
-static int mrvlqspi_protect_check(struct flash_bank *bank)
-{
- /* Not implemented yet */
- return ERROR_OK;
-}
-
int mrvlqspi_get_info(struct flash_bank *bank, char *buf, int buf_size)
{
struct mrvlqspi_flash_bank *mrvlqspi_info = bank->driver_priv;
@@ -947,13 +941,11 @@ struct flash_driver mrvlqspi_flash = {
.name = "mrvlqspi",
.flash_bank_command = mrvlqspi_flash_bank_command,
.erase = mrvlqspi_flash_erase,
- .protect = NULL,
.write = mrvlqspi_flash_write,
.read = mrvlqspi_flash_read,
.probe = mrvlqspi_probe,
.auto_probe = mrvlqspi_auto_probe,
.erase_check = mrvlqspi_flash_erase_check,
- .protect_check = mrvlqspi_protect_check,
.info = mrvlqspi_get_info,
.free_driver_priv = default_flash_free_driver_priv,
};
diff --git a/src/flash/nor/msp432.c b/src/flash/nor/msp432.c
index 5caa052..e2e65d4 100644
--- a/src/flash/nor/msp432.c
+++ b/src/flash/nor/msp432.c
@@ -655,12 +655,6 @@ static int msp432_erase(struct flash_bank *bank, int first, int last)
return retval;
}
-static int msp432_protect(struct flash_bank *bank, int set, int first,
- int last)
-{
- return ERROR_OK;
-}
-
static int msp432_write(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t count)
{
@@ -985,11 +979,6 @@ static int msp432_auto_probe(struct flash_bank *bank)
return retval;
}
-static int msp432_protect_check(struct flash_bank *bank)
-{
- return ERROR_OK;
-}
-
static int msp432_info(struct flash_bank *bank, char *buf, int buf_size)
{
struct msp432_bank *msp432_bank = bank->driver_priv;
@@ -1091,13 +1080,11 @@ struct flash_driver msp432_flash = {
.commands = msp432_command_handlers,
.flash_bank_command = msp432_flash_bank_command,
.erase = msp432_erase,
- .protect = msp432_protect,
.write = msp432_write,
.read = default_flash_read,
.probe = msp432_probe,
.auto_probe = msp432_auto_probe,
.erase_check = default_flash_blank_check,
- .protect_check = msp432_protect_check,
.info = msp432_info,
.free_driver_priv = msp432_flash_free_driver_priv,
};
diff --git a/src/flash/nor/ocl.c b/src/flash/nor/ocl.c
index 895c4af..f8913c0 100644
--- a/src/flash/nor/ocl.c
+++ b/src/flash/nor/ocl.c
@@ -35,11 +35,6 @@ static int ocl_erase_check(struct flash_bank *bank)
return ERROR_OK;
}
-static int ocl_protect_check(struct flash_bank *bank)
-{
- return ERROR_OK;
-}
-
/* flash_bank ocl 0 0 0 0 <target#> */
FLASH_BANK_COMMAND_HANDLER(ocl_flash_bank_command)
{
@@ -111,11 +106,6 @@ static int ocl_erase(struct flash_bank *bank, int first, int last)
return ERROR_OK;
}
-static int ocl_protect(struct flash_bank *bank, int set, int first, int last)
-{
- return ERROR_OK;
-}
-
static int ocl_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
{
struct ocl_priv *ocl = bank->driver_priv;
@@ -333,12 +323,10 @@ struct flash_driver ocl_flash = {
.name = "ocl",
.flash_bank_command = ocl_flash_bank_command,
.erase = ocl_erase,
- .protect = ocl_protect,
.write = ocl_write,
.read = default_flash_read,
.probe = ocl_probe,
.erase_check = ocl_erase_check,
- .protect_check = ocl_protect_check,
.auto_probe = ocl_auto_probe,
.free_driver_priv = default_flash_free_driver_priv,
};
diff --git a/src/flash/nor/psoc5lp.c b/src/flash/nor/psoc5lp.c
index b88abbb..d8e1c15 100644
--- a/src/flash/nor/psoc5lp.c
+++ b/src/flash/nor/psoc5lp.c
@@ -753,16 +753,6 @@ static int psoc5lp_nvl_write(struct flash_bank *bank,
return ERROR_OK;
}
-static int psoc5lp_nvl_protect_check(struct flash_bank *bank)
-{
- int i;
-
- for (i = 0; i < bank->num_sectors; i++)
- bank->sectors[i].is_protected = -1;
-
- return ERROR_OK;
-}
-
static int psoc5lp_nvl_get_info_command(struct flash_bank *bank,
char *buf, int buf_size)
{
@@ -855,7 +845,6 @@ struct flash_driver psoc5lp_nvl_flash = {
.info = psoc5lp_nvl_get_info_command,
.probe = psoc5lp_nvl_probe,
.auto_probe = psoc5lp_nvl_auto_probe,
- .protect_check = psoc5lp_nvl_protect_check,
.read = psoc5lp_nvl_read,
.erase = psoc5lp_nvl_erase,
.erase_check = psoc5lp_nvl_erase_check,
@@ -945,16 +934,6 @@ static int psoc5lp_eeprom_write(struct flash_bank *bank,
return ERROR_OK;
}
-static int psoc5lp_eeprom_protect_check(struct flash_bank *bank)
-{
- int i;
-
- for (i = 0; i < bank->num_sectors; i++)
- bank->sectors[i].is_protected = -1;
-
- return ERROR_OK;
-}
-
static int psoc5lp_eeprom_get_info_command(struct flash_bank *bank, char *buf, int buf_size)
{
struct psoc5lp_eeprom_flash_bank *psoc_eeprom_bank = bank->driver_priv;
@@ -1064,7 +1043,6 @@ struct flash_driver psoc5lp_eeprom_flash = {
.info = psoc5lp_eeprom_get_info_command,
.probe = psoc5lp_eeprom_probe,
.auto_probe = psoc5lp_eeprom_auto_probe,
- .protect_check = psoc5lp_eeprom_protect_check,
.read = default_flash_read,
.erase = psoc5lp_eeprom_erase,
.erase_check = default_flash_blank_check,
diff --git a/src/flash/nor/stm32lx.c b/src/flash/nor/stm32lx.c
index 3251df3..1be950f 100644
--- a/src/flash/nor/stm32lx.c
+++ b/src/flash/nor/stm32lx.c
@@ -424,13 +424,6 @@ static int stm32lx_erase(struct flash_bank *bank, int first, int last)
return ERROR_OK;
}
-static int stm32lx_protect(struct flash_bank *bank, int set, int first,
- int last)
-{
- LOG_WARNING("protection of the STM32L flash is not implemented");
- return ERROR_OK;
-}
-
static int stm32lx_write_half_pages(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t count)
{
@@ -862,7 +855,7 @@ static int stm32lx_probe(struct flash_bank *bank)
bank->sectors[i].offset = i * FLASH_SECTOR_SIZE;
bank->sectors[i].size = FLASH_SECTOR_SIZE;
bank->sectors[i].is_erased = -1;
- bank->sectors[i].is_protected = 1;
+ bank->sectors[i].is_protected = -1;
}
stm32lx_info->probed = 1;
@@ -955,7 +948,6 @@ struct flash_driver stm32lx_flash = {
.commands = stm32lx_command_handlers,
.flash_bank_command = stm32lx_flash_bank_command,
.erase = stm32lx_erase,
- .protect = stm32lx_protect,
.write = stm32lx_write,
.read = default_flash_read,
.probe = stm32lx_probe,
diff --git a/src/flash/nor/tcl.c b/src/flash/nor/tcl.c
index 95ca819..f056e07 100644
--- a/src/flash/nor/tcl.c
+++ b/src/flash/nor/tcl.c
@@ -98,10 +98,18 @@ COMMAND_HANDLER(handle_flash_info_command)
if (retval != ERROR_OK)
return retval;
- /* We must query the hardware to avoid printing stale information! */
- retval = p->driver->protect_check(p);
- if (retval != ERROR_OK)
- return retval;
+ /* If the driver does not implement protection, we show the default
+ * state of is_protected array - usually protection state unknown */
+ if (p->driver->protect_check == NULL) {
+ retval = ERROR_FLASH_OPER_UNSUPPORTED;
+ } else {
+ /* We must query the hardware to avoid printing stale information! */
+ retval = p->driver->protect_check(p);
+ if (retval != ERROR_OK && retval != ERROR_FLASH_OPER_UNSUPPORTED)
+ return retval;
+ }
+ if (retval == ERROR_FLASH_OPER_UNSUPPORTED)
+ LOG_WARNING("Flash protection check is not implemented.");
command_print(CMD_CTX,
"#%d : %s at 0x%8.8" PRIx32 ", size 0x%8.8" PRIx32