DANGER: committed work-in-progress to handle examination of jtag devices without...
[openocd.git] / src / jtag / jtag.c
index 04b3892d23fc2d296d6f8007241ba29a347b944f..d5158126c9160bc9eac4638e1a4b416940f3442a 100644 (file)
@@ -401,7 +401,7 @@ void* cmd_queue_alloc(size_t size)
        return t + offset;
 }
 
-void cmd_queue_free()
+void cmd_queue_free(void)
 {
        cmd_queue_page_t *page = cmd_queue_pages;
 
@@ -416,7 +416,7 @@ void cmd_queue_free()
        cmd_queue_pages = NULL;
 }
 
-static void jtag_prelude1()
+static void jtag_prelude1(void)
 {
        if (jtag_trst == 1)
        {
@@ -1311,12 +1311,12 @@ int jtag_reset_callback(enum jtag_event event, void *priv)
 
 void jtag_sleep(u32 us)
 {
-       usleep(us);
+       alive_sleep(us/1000);
 }
 
 /* Try to examine chain layout according to IEEE 1149.1 ยง12
  */
-int jtag_examine_chain()
+int jtag_examine_chain(void)
 {
        jtag_device_t *device = jtag_devices;
        scan_field_t field;
@@ -1364,9 +1364,8 @@ int jtag_examine_chain()
                if ((idcode & 1) == 0)
                {
                        /* LSB must not be 0, this indicates a device in bypass */
-                       device_count++;
-                       
-                       LOG_WARNING("Device was in bypass after TRST/TMS reset");
+                       LOG_WARNING("Device does not have IDCODE");
+                       idcode=0;
                        
                        bit_count += 1;
                }
@@ -1403,13 +1402,6 @@ int jtag_examine_chain()
                                break;
                        }
                        
-                       if (device)
-                       {
-                               device->idcode = idcode;
-                               device = device->next;
-                       }
-                       device_count++;
-                       
                        manufacturer = (idcode & 0xffe) >> 1;
                        part = (idcode & 0xffff000) >> 12;
                        version = (idcode & 0xf0000000) >> 28;
@@ -1419,6 +1411,12 @@ int jtag_examine_chain()
                        
                        bit_count += 32;
                }
+               if (device)
+               {
+                       device->idcode = idcode;
+                       device = device->next;
+               }
+               device_count++;
        }
        
        /* see if number of discovered devices matches configuration */
@@ -1433,7 +1431,7 @@ int jtag_examine_chain()
        return ERROR_OK;
 }
 
-int jtag_validate_chain()
+int jtag_validate_chain(void)
 {
        jtag_device_t *device = jtag_devices;
        int total_ir_length = 0;
@@ -1588,10 +1586,10 @@ static int jtag_init_inner(struct command_context_s *cmd_ctx)
                
                if (validate_tries > 5)
                {
-                       LOG_ERROR("Could not validate JTAG chain, exit");
+                       LOG_ERROR("Could not validate JTAG chain");
                        return ERROR_JTAG_INVALID_INTERFACE;
                }
-               usleep(10000);
+               alive_sleep(10);
        }
        
        return ERROR_OK;
@@ -1662,6 +1660,7 @@ static int default_khz(int khz, int *jtag_speed)
 
 static int default_speed_div(int speed, int *khz)
 {
+       LOG_ERROR("Translation from jtag_speed to khz not implemented");
        return ERROR_FAIL;      
 }
 
@@ -1897,7 +1896,7 @@ int handle_jtag_speed_command(struct command_context_s *cmd_ctx, char *cmd, char
        {
        } else
        {
-               retval=ERROR_COMMAND_SYNTAX_ERROR;
+               return ERROR_COMMAND_SYNTAX_ERROR;
        }
        command_print(cmd_ctx, "jtag_speed: %d", jtag_speed);
        
@@ -1934,8 +1933,15 @@ int handle_jtag_khz_command(struct command_context_s *cmd_ctx, char *cmd, char *
        {
        } else
        {
-               retval=ERROR_COMMAND_SYNTAX_ERROR;
+               return ERROR_COMMAND_SYNTAX_ERROR;
+       }
+
+       if (jtag!=NULL) 
+       {
+               if ((retval=jtag->speed_div(jtag_speed, &speed_khz))!=ERROR_OK)
+                       return retval;
        }
+       
        command_print(cmd_ctx, "jtag_khz: %d", speed_khz);
        return retval;
 

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)