Set empty usage field for commands that do not need parameters
[openocd.git] / src / flash / nor / tms470.c
index 86858a84ed9ffea3a9e11869b8eec827ec9b477e..195d1ae1f2c07a547ef21980fe2825228975ec7d 100644 (file)
@@ -13,9 +13,7 @@
  *   GNU General Public License for more details.                          *
  *                                                                         *
  *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.           *
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
  ***************************************************************************/
 
 #ifdef HAVE_CONFIG_H
@@ -153,6 +151,7 @@ static int tms470_read_part_info(struct flash_bank *bank)
        if (bank->sectors) {
                free(bank->sectors);
                bank->sectors = NULL;
+               bank->num_sectors = 0;
        }
 
        /*
@@ -166,7 +165,8 @@ static int tms470_read_part_info(struct flash_bank *bank)
                        part_name = "TMS470R1A256";
 
                        if (bank->base >= 0x00040000) {
-                               LOG_ERROR("No %s flash bank contains base address 0x%08" PRIx32 ".",
+                               LOG_ERROR("No %s flash bank contains base address "
+                                               TARGET_ADDR_FMT ".",
                                                part_name,
                                                bank->base);
                                return ERROR_FLASH_OPERATION_FAILED;
@@ -205,7 +205,7 @@ static int tms470_read_part_info(struct flash_bank *bank)
                                (void)memcpy(bank->sectors, TMS470R1A288_BANK1_SECTORS,
                                                sizeof(TMS470R1A288_BANK1_SECTORS));
                        } else {
-                               LOG_ERROR("No %s flash bank contains base address 0x%08" PRIx32 ".",
+                               LOG_ERROR("No %s flash bank contains base address " TARGET_ADDR_FMT ".",
                                                part_name, bank->base);
                                return ERROR_FLASH_OPERATION_FAILED;
                        }
@@ -245,7 +245,7 @@ static int tms470_read_part_info(struct flash_bank *bank)
                                (void)memcpy(bank->sectors, TMS470R1A384_BANK2_SECTORS,
                                                sizeof(TMS470R1A384_BANK2_SECTORS));
                        } else {
-                               LOG_ERROR("No %s flash bank contains base address 0x%08" PRIx32 ".",
+                               LOG_ERROR("No %s flash bank contains base address " TARGET_ADDR_FMT ".",
                                                part_name, bank->base);
                                return ERROR_FLASH_OPERATION_FAILED;
                        }
@@ -756,9 +756,6 @@ static int tms470_erase_sector(struct flash_bank *bank, int sector)
        target_write_u32(target, 0xFFFFFFDC, glbctrl);
        LOG_DEBUG("set glbctrl = 0x%08" PRIx32 "", glbctrl);
 
-       if (result == ERROR_OK)
-               bank->sectors[sector].is_erased = 1;
-
        return result;
 }
 
@@ -904,8 +901,8 @@ static int tms470_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t
 
        tms470_read_part_info(bank);
 
-       LOG_INFO("Writing %" PRId32 " bytes starting at 0x%08" PRIx32 "", count, bank->base +
-               offset);
+       LOG_INFO("Writing %" PRId32 " bytes starting at " TARGET_ADDR_FMT,
+                       count, bank->base + offset);
 
        /* set GLBCTRL.4  */
        target_read_u32(target, 0xFFFFFFDC, &glbctrl);
@@ -1046,27 +1043,17 @@ static int tms470_erase_check(struct flash_bank *bank)
         * an attempt to reduce the JTAG overhead.
         */
        for (sector = 0; sector < bank->num_sectors; sector++) {
-               if (bank->sectors[sector].is_erased != 1) {
-                       uint32_t i, addr = bank->base + bank->sectors[sector].offset;
-
-                       LOG_INFO("checking flash bank %d sector %d", tms470_info->ordinal, sector);
-
-                       target_read_buffer(target, addr, bank->sectors[sector].size, buffer);
-
-                       bank->sectors[sector].is_erased = 1;
-                       for (i = 0; i < bank->sectors[sector].size; i++) {
-                               if (buffer[i] != 0xff) {
-                                       LOG_WARNING("tms470 bank %d, sector %d, not erased.",
-                                               tms470_info->ordinal,
-                                               sector);
-                                       LOG_WARNING(
-                                               "at location 0x%08" PRIx32 ": flash data is 0x%02x.",
-                                               addr + i,
-                                               buffer[i]);
-
-                                       bank->sectors[sector].is_erased = 0;
-                                       break;
-                               }
+               uint32_t i, addr = bank->base + bank->sectors[sector].offset;
+
+               LOG_INFO("checking flash bank %d sector %d", tms470_info->ordinal, sector);
+
+               target_read_buffer(target, addr, bank->sectors[sector].size, buffer);
+
+               bank->sectors[sector].is_erased = 1;
+               for (i = 0; i < bank->sectors[sector].size; i++) {
+                       if (buffer[i] != 0xff) {
+                               bank->sectors[sector].is_erased = 0;
+                               break;
                        }
                }
                if (bank->sectors[sector].is_erased != 1) {
@@ -1175,7 +1162,7 @@ FLASH_BANK_COMMAND_HANDLER(tms470_flash_bank_command)
        return ERROR_OK;
 }
 
-struct flash_driver tms470_flash = {
+const struct flash_driver tms470_flash = {
        .name = "tms470",
        .commands = tms470_command_handlers,
        .flash_bank_command = tms470_flash_bank_command,
@@ -1188,4 +1175,5 @@ struct flash_driver tms470_flash = {
        .erase_check = tms470_erase_check,
        .protect_check = tms470_protect_check,
        .info = get_tms470_info,
+       .free_driver_priv = default_flash_free_driver_priv,
 };

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)