target: reexamine after polling succeeds again
[openocd.git] / src / target / target.c
index 1557c72d97047f49ecee4374d2f6ae03ad9b9f5b..4d277c694b85412d0be46d1ee36f920cf0b22609 100644 (file)
@@ -853,7 +853,7 @@ done:
  */
 
 int target_run_flash_async_algorithm(struct target *target,
-               uint8_t *buffer, uint32_t count, int block_size,
+               const uint8_t *buffer, uint32_t count, int block_size,
                int num_mem_params, struct mem_param *mem_params,
                int num_reg_params, struct reg_param *reg_params,
                uint32_t buffer_start, uint32_t buffer_size,
@@ -1274,6 +1274,10 @@ COMMAND_HANDLER(handle_target_init_command)
        if (ERROR_OK != retval)
                return retval;
 
+       retval = command_run_line(CMD_CTX, "init_target_events");
+       if (ERROR_OK != retval)
+               return retval;
+
        retval = command_run_line(CMD_CTX, "init_board");
        if (ERROR_OK != retval)
                return retval;
@@ -2379,6 +2383,10 @@ static int handle_target(void *priv)
        for (struct target *target = all_targets;
                        is_jtag_poll_safe() && target;
                        target = target->next) {
+
+               if (!target_was_examined(target))
+                       continue;
+
                if (!target->tap->enabled)
                        continue;
 
@@ -2410,8 +2418,12 @@ static int handle_target(void *priv)
                                return retval;
                        }
                        /* Since we succeeded, we reset backoff count */
-                       if (target->backoff.times > 0)
-                               LOG_USER("Polling target %s succeeded again", target_name(target));
+                       if (target->backoff.times > 0) {
+                               LOG_USER("Polling target %s succeeded again, trying to reexamine", target_name(target));
+                               target_reset_examined(target);
+                               target_examine_one(target);
+                       }
+
                        target->backoff.times = 0;
                }
        }
@@ -3182,7 +3194,7 @@ static COMMAND_HELPER(handle_verify_image_command_internal, int verify)
                                if (diffs == 0)
                                        LOG_ERROR("checksum mismatch - attempting binary compare");
 
-                               data = (uint8_t *)malloc(buf_cnt);
+                               data = malloc(buf_cnt);
 
                                /* Can we use 32bit word accesses? */
                                int size = 1;
@@ -3614,29 +3626,30 @@ COMMAND_HANDLER(handle_profile_command)
 
        const uint32_t MAX_PROFILE_SAMPLE_NUM = 10000;
        uint32_t offset;
-       uint32_t num_of_sampels;
+       uint32_t num_of_samples;
        int retval = ERROR_OK;
+
+       COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], offset);
+
        uint32_t *samples = malloc(sizeof(uint32_t) * MAX_PROFILE_SAMPLE_NUM);
        if (samples == NULL) {
                LOG_ERROR("No memory to store samples.");
                return ERROR_FAIL;
        }
 
-       COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], offset);
-
        /**
         * Some cores let us sample the PC without the
         * annoying halt/resume step; for example, ARMv7 PCSR.
         * Provide a way to use that more efficient mechanism.
         */
        retval = target_profiling(target, samples, MAX_PROFILE_SAMPLE_NUM,
-                               &num_of_sampels, offset);
+                               &num_of_samples, offset);
        if (retval != ERROR_OK) {
                free(samples);
                return retval;
        }
 
-       assert(num_of_sampels <= MAX_PROFILE_SAMPLE_NUM);
+       assert(num_of_samples <= MAX_PROFILE_SAMPLE_NUM);
 
        retval = target_poll(target);
        if (retval != ERROR_OK) {
@@ -3666,7 +3679,7 @@ COMMAND_HANDLER(handle_profile_command)
                COMMAND_PARSE_NUMBER(u32, CMD_ARGV[3], end_address);
        }
 
-       write_gmon(samples, num_of_sampels, CMD_ARGV[1],
+       write_gmon(samples, num_of_samples, CMD_ARGV[1],
                        with_range, start_address, end_address);
        command_print(CMD_CTX, "Wrote %s", CMD_ARGV[1]);
 
@@ -5093,7 +5106,7 @@ static int target_create(Jim_GetOptInfo *goi)
        target->target_number = new_target_number();
 
        /* allocate memory for each unique target type */
-       target->type = (struct target_type *)calloc(1, sizeof(struct target_type));
+       target->type = calloc(1, sizeof(struct target_type));
 
        memcpy(target->type, target_types[x], sizeof(struct target_type));
 
@@ -5479,7 +5492,7 @@ COMMAND_HANDLER(handle_fast_load_image_command)
        image_size = 0x0;
        retval = ERROR_OK;
        fastload_num = image.num_sections;
-       fastload = (struct FastLoad *)malloc(sizeof(struct FastLoad)*image.num_sections);
+       fastload = malloc(sizeof(struct FastLoad)*image.num_sections);
        if (fastload == NULL) {
                command_print(CMD_CTX, "out of memory");
                image_close(&image);
@@ -5703,7 +5716,7 @@ COMMAND_HANDLER(handle_test_mem_access_command)
                                        read_buf[i] = read_ref[i];
                                }
                                command_print_sameline(CMD_CTX,
-                                               "Test read %d x %d @ %d to %saligned buffer: ", count,
+                                               "Test read %" PRIu32 " x %d @ %d to %saligned buffer: ", count,
                                                size, offset, host_offset ? "un" : "");
 
                                struct duration bench;
@@ -5775,7 +5788,7 @@ out:
                                for (size_t i = 0; i < host_bufsiz; i++)
                                        write_buf[i] = rand();
                                command_print_sameline(CMD_CTX,
-                                               "Test write %d x %d @ %d from %saligned buffer: ", count,
+                                               "Test write %" PRIu32 " x %d @ %d from %saligned buffer: ", count,
                                                size, offset, host_offset ? "un" : "");
 
                                retval = target_write_memory(target, wa->address, 1, num_bytes, test_pattern);

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)