jtag: linuxgpiod: drop extra parenthesis
[openocd.git] / src / flash / nor / stm32h7x.c
index d3f17b2b199aab0bbde460b0450c060c89836fd2..c02fae992cbedc6e300f8572c05a2d86507fca3f 100644 (file)
@@ -1,18 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
 /***************************************************************************
  *   Copyright (C) 2017 by STMicroelectronics                              *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   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, see <http://www.gnu.org/licenses/>. *
  ***************************************************************************/
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -531,6 +520,7 @@ static int stm32x_protect(struct flash_bank *bank, int set, unsigned int first,
                unsigned int last)
 {
        struct target *target = bank->target;
+       struct stm32h7x_flash_bank *stm32x_info = bank->driver_priv;
        uint32_t protection;
 
        if (target->state != TARGET_HALTED) {
@@ -553,7 +543,7 @@ static int stm32x_protect(struct flash_bank *bank, int set, unsigned int first,
        }
 
        /* apply WRPSN mask */
-       protection &= 0xff;
+       protection &= stm32x_info->part_info->wps_mask;
 
        LOG_DEBUG("stm32x_protect, option_bytes written WPSN 0x%" PRIx32, protection);
 
@@ -759,7 +749,6 @@ static int stm32x_read_id_code(struct flash_bank *bank, uint32_t *id)
 static int stm32x_probe(struct flash_bank *bank)
 {
        struct target *target = bank->target;
-       struct cortex_m_common *cortex_m = target_to_cm(target);
        struct stm32h7x_flash_bank *stm32x_info = bank->driver_priv;
        uint16_t flash_size_in_kb;
        uint32_t device_id;
@@ -767,6 +756,11 @@ static int stm32x_probe(struct flash_bank *bank)
        stm32x_info->probed = false;
        stm32x_info->part_info = NULL;
 
+       if (!target_was_examined(target)) {
+               LOG_ERROR("Target not examined yet");
+               return ERROR_TARGET_NOT_EXAMINED;
+       }
+
        int retval = stm32x_read_id_code(bank, &stm32x_info->idcode);
        if (retval != ERROR_OK)
                return retval;
@@ -800,7 +794,8 @@ static int stm32x_probe(struct flash_bank *bank)
        /* get flash size from target */
        /* STM32H74x/H75x, the second core (Cortex-M4) cannot read the flash size */
        retval = ERROR_FAIL;
-       if (device_id == DEVID_STM32H74_H75XX && cortex_m->core_info->partno == CORTEX_M4_PARTNO)
+       if (device_id == DEVID_STM32H74_H75XX
+                       && cortex_m_get_impl_part(target) == CORTEX_M4_PARTNO)
                LOG_WARNING("%s cannot read the flash size register", target_name(target));
        else
                retval = target_read_u16(target, stm32x_info->part_info->fsize_addr, &flash_size_in_kb);
@@ -1085,10 +1080,8 @@ flash_lock:
 
 COMMAND_HANDLER(stm32x_handle_mass_erase_command)
 {
-       if (CMD_ARGC < 1) {
-               command_print(CMD, "stm32h7x mass_erase <bank>");
+       if (CMD_ARGC != 1)
                return ERROR_COMMAND_SYNTAX_ERROR;
-       }
 
        struct flash_bank *bank;
        int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
@@ -1106,10 +1099,8 @@ COMMAND_HANDLER(stm32x_handle_mass_erase_command)
 
 COMMAND_HANDLER(stm32x_handle_option_read_command)
 {
-       if (CMD_ARGC < 2) {
-               command_print(CMD, "stm32h7x option_read <bank> <option_reg offset>");
+       if (CMD_ARGC != 2)
                return ERROR_COMMAND_SYNTAX_ERROR;
-       }
 
        struct flash_bank *bank;
        int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
@@ -1131,10 +1122,8 @@ COMMAND_HANDLER(stm32x_handle_option_read_command)
 
 COMMAND_HANDLER(stm32x_handle_option_write_command)
 {
-       if (CMD_ARGC < 3) {
-               command_print(CMD, "stm32h7x option_write <bank> <option_reg offset> <value> [mask]");
+       if (CMD_ARGC != 3 && CMD_ARGC != 4)
                return ERROR_COMMAND_SYNTAX_ERROR;
-       }
 
        struct flash_bank *bank;
        int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);

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)