target start_algorithm: Don't copy the IN mem_params fix uninitialised value.
[openocd.git] / src / target / stm8.c
index 262497b0d52ca727221230ebf378a014fd07fa2c..b62ff131de420702152a7856e68702dc18af88ff 100644 (file)
@@ -477,7 +477,8 @@ static int stm8_examine_debug_reason(struct target *target)
        uint8_t csr1, csr2;
 
        retval = stm8_read_dm_csrx(target, &csr1, &csr2);
-       LOG_DEBUG("csr1 = 0x%02X csr2 = 0x%02X", csr1, csr2);
+       if (retval == ERROR_OK)
+               LOG_DEBUG("csr1 = 0x%02X csr2 = 0x%02X", csr1, csr2);
 
        if ((target->debug_reason != DBG_REASON_DBGRQ)
                && (target->debug_reason != DBG_REASON_SINGLESTEP)) {
@@ -1188,6 +1189,11 @@ static int stm8_write_core_reg(struct target *target, unsigned int num)
        return ERROR_OK;
 }
 
+static const char *stm8_get_gdb_arch(struct target *target)
+{
+       return "stm8";
+}
+
 static int stm8_get_gdb_reg_list(struct target *target, struct reg **reg_list[],
                int *reg_list_size, enum target_register_class reg_class)
 {
@@ -1749,7 +1755,7 @@ static int stm8_examine(struct target *target)
 
 /** Checks whether a memory region is erased. */
 static int stm8_blank_check_memory(struct target *target,
-               target_addr_t address, uint32_t count, uint32_t *blank, uint8_t erased_value)
+               struct target_memory_check_block *blocks, int num_blocks, uint8_t erased_value)
 {
        struct working_area *erase_check_algorithm;
        struct reg_param reg_params[2];
@@ -1777,10 +1783,10 @@ static int stm8_blank_check_memory(struct target *target,
        stm8_info.common_magic = STM8_COMMON_MAGIC;
 
        init_mem_param(&mem_params[0], 0x0, 3, PARAM_OUT);
-       buf_set_u32(mem_params[0].value, 0, 24, address);
+       buf_set_u32(mem_params[0].value, 0, 24, blocks[0].address);
 
        init_mem_param(&mem_params[1], 0x3, 3, PARAM_OUT);
-       buf_set_u32(mem_params[1].value, 0, 24, count);
+       buf_set_u32(mem_params[1].value, 0, 24, blocks[0].size);
 
        init_reg_param(&reg_params[0], "a", 32, PARAM_IN_OUT);
        buf_set_u32(reg_params[0].value, 0, 32, erased_value);
@@ -1794,15 +1800,19 @@ static int stm8_blank_check_memory(struct target *target,
                        10000, &stm8_info);
 
        if (retval == ERROR_OK)
-               *blank = (*(reg_params[0].value) == 0xff);
+               blocks[0].result = (*(reg_params[0].value) == 0xff);
 
        destroy_mem_param(&mem_params[0]);
        destroy_mem_param(&mem_params[1]);
        destroy_reg_param(&reg_params[0]);
+       destroy_reg_param(&reg_params[1]);
 
        target_free_working_area(target, erase_check_algorithm);
 
-       return retval;
+       if (retval != ERROR_OK)
+               return retval;
+
+       return 1;       /* only one block has been checked */
 }
 
 static int stm8_checksum_memory(struct target *target, target_addr_t address,
@@ -1880,6 +1890,8 @@ static int stm8_run_algorithm(struct target *target, int num_mem_params,
        }
 
        for (int i = 0; i < num_mem_params; i++) {
+               if (mem_params[i].direction == PARAM_IN)
+                       continue;
                retval = target_write_buffer(target, mem_params[i].address,
                                mem_params[i].size, mem_params[i].value);
                if (retval != ERROR_OK)
@@ -1887,6 +1899,9 @@ static int stm8_run_algorithm(struct target *target, int num_mem_params,
        }
 
        for (int i = 0; i < num_reg_params; i++) {
+               if (reg_params[i].direction == PARAM_IN)
+                       continue;
+
                struct reg *reg = register_get_by_name(stm8->core_cache,
                                reg_params[i].reg_name, 0);
 
@@ -2195,6 +2210,7 @@ struct target_type stm8_target = {
        .assert_reset = stm8_reset_assert,
        .deassert_reset = stm8_reset_deassert,
 
+       .get_gdb_arch = stm8_get_gdb_arch,
        .get_gdb_reg_list = stm8_get_gdb_reg_list,
 
        .read_memory = stm8_read_memory,

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)