flash/nor: consolidate flash protect/protect_check 65/4765/3
authorTomas Vanek <vanekt@fbl.cz>
Thu, 15 Nov 2018 11:19:25 +0000 (12:19 +0100)
committerTomas Vanek <vanekt@fbl.cz>
Mon, 26 Nov 2018 09:31:35 +0000 (09:31 +0000)
Make flash_driver methods protect() and protect_check()
optional.

Remove dummy definitions of these methods from the drivers
which do not implement protection handling.

Some drivers did not define protect method. It raised segfault
before this change and now it is handled properly.

Lot of drivers returned ERROR_OK from dummy protect()
- now flash_driver_protect() returns an error if not handled by the driver.

Change-Id: I2d4a0da316bf03c6379791b1b1c6198fbf22e66c
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4765
Tested-by: jenkins
Reviewed-by: Andreas Bolsch <hyphen0break@gmail.com>
Reviewed-by: Christopher Head <chead@zaber.com>
21 files changed:
src/flash/nor/aduc702x.c
src/flash/nor/aducm360.c
src/flash/nor/avrf.c
src/flash/nor/cc26xx.c
src/flash/nor/cc3220sf.c
src/flash/nor/cfi.c
src/flash/nor/core.c
src/flash/nor/driver.h
src/flash/nor/faux.c
src/flash/nor/fm4.c
src/flash/nor/jtagspi.c
src/flash/nor/lpc2000.c
src/flash/nor/lpc288x.c
src/flash/nor/lpc2900.c
src/flash/nor/mdr.c
src/flash/nor/mrvlqspi.c
src/flash/nor/msp432.c
src/flash/nor/ocl.c
src/flash/nor/psoc5lp.c
src/flash/nor/stm32lx.c
src/flash/nor/tcl.c

index 34cc362eba7444233a5ea3c3560264c67025eb92..824112b1bc44a57090f73923996a095918f224d6 100644 (file)
@@ -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,
 };
index 8681a25af45a44b51867e495da8725c48488ad98..7663783478f522472112ffac5529e973e3c392de 100644 (file)
@@ -102,13 +102,6 @@ static int aducm360_build_sector_list(struct flash_bank *bank)
        return ERROR_OK;
 }
 
-/* ----------------------------------------------------------------------- */
-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)
 {
@@ -194,13 +187,6 @@ static int aducm360_erase(struct flash_bank *bank, int first, int last)
        return res;
 }
 
-/* ----------------------------------------------------------------------- */
-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,
@@ -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,
 };
index 65ac6015f0a69443532df1f489081a9dc6aecd6c..b88f6f61c3995365543e661fd0f3b645c29c9fb6 100644 (file)
@@ -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,
 };
index e6e9e5999f822d8af4101e07606e91bb0bcbac2a..7b8744143365474e2b02afbf9da6f90930074fa9 100644 (file)
@@ -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,
 };
index af45743b92f63895019184ecba6e677813c844fd..5ccb428a89b8e9ebf7f6c059c5e502a088128f93 100644 (file)
@@ -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,
 };
index 0ae72d4a28be45756f8f122e8ea6d5552099577b..a2db50f3322fde08d958cded4fa499db99cf9520 100644 (file)
@@ -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;
 
index 49412816c3a2449bae3beba33e508e9d1b4b9571..0aaa7d26f0b5e58c9f09a7f12f592dfb745ce24a 100644 (file)
@@ -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!!!!
index e7b3234439d73f13ff39c7d7a54781ad487fd2d3..ef69a0f424f2d3e7c2ab979cd9bb60254e6ead13 100644 (file)
@@ -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.
         */
index 46eda722334c4201a2f22711d75a131e2f7c70b8..d68940fc6ea2dfe86052f9c703111e78d249efd4 100644 (file)
@@ -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,
 };
index f5eab9c5b39c39444f08de3956344213bd4e1b8b..d4d0f76b46c7c52ade8d15f7f0411aedb899f3af 100644 (file)
@@ -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,
index c28ad22f7a823b7cb6fb14a9ad74a5f6ec417291..c5c565f2a19301f8a602fea1166126ffb6a9d6b0 100644 (file)
@@ -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,
 };
index 8e15c3122dcf99d655134662ca6b1a3c2278ed2f..77beac1ca1630650dea8f05f9943392abfb2c65f 100644 (file)
@@ -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,
 };
index 24729138a0228a11b3096fcd81212a5e62928489..474e721eb81403346e5ed54e41ebdb387b5ec0f9 100644 (file)
@@ -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;
index 1c65933e21a8fdb44c865b34dfb091f911a4aeed..022fb82a3e7fe9a78ed6539faace287b327251eb 100644 (file)
@@ -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,
index f3916ded98fe9f4a5e02397fcb167cd0a2960b28..c4a4458f9e68b35ea129acedd3c5f3dd37ab43c6 100644 (file)
@@ -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,
 };
index eda6cc1ad2e079ed0c49bce380c9c80ccf605a40..132e5f36b3de7ac574c84a6cd4e817341bd4eb05 100644 (file)
@@ -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,
 };
index 5caa0520d5154a39b6f450e9b4e7f5cc54eec691..e2e65d4f0b480ed70d2dfb3e72e1b7e443bdbb7a 100644 (file)
@@ -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,
 };
index 895c4af219374f54f0636c201dd5290c88dc562c..f8913c09053fe0859855679cdb43781442e5fcfc 100644 (file)
@@ -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,
 };
index b88abbb4704f105d3476a2301f64b20404406ef4..d8e1c15682e4d8b510657f4b753988176b33d85d 100644 (file)
@@ -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,
index 3251df3fcfe6f44abacba341ff6875f02d724e54..1be950fe0bf7a8dbcea57c846f05dbe1a95c1ae8 100644 (file)
@@ -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,
index 95ca8192f79ebb22ca010756bffff8d6d56920cd..f056e07538eb8db3fb52a9c4ee79e770fa4ef604 100644 (file)
@@ -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

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)