- update jtag_speed setting when changing it during runtime with a FT2232 based interface
authordrath <drath@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Thu, 16 Aug 2007 13:12:48 +0000 (13:12 +0000)
committerdrath <drath@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Thu, 16 Aug 2007 13:12:48 +0000 (13:12 +0000)
- use 'etm trigger_percent' setting when programming ETB trigger count
- fixed some small bugs in ETM trace analysis
- fixed minor bug in flash writing (thanks to Pavel Chromy)

git-svn-id: svn://svn.berlios.de/openocd/trunk@197 b42882b7-edfa-0310-969c-e2dbd0fdcd60

src/flash/flash.c
src/jtag/ft2232.c
src/openocd.c
src/target/etb.c
src/target/etm.c
src/target/etm.h

index 19d5c3c5870a7b1b5c65d71747ee46a4bdcd0954..9ca5f157be9aa1449aa8f1c66d2e2cd2e4dc58c4 100644 (file)
@@ -797,10 +797,13 @@ int flash_write(target_t *target, image_t *image, u32 *written, char **error_str
                while ((run_address + run_size < c->base + c->size)
                                && (section_last + 1 < image->num_sections))
                {
-                       if (image->sections[section_last + 1].base_address > (run_address + run_size))
-                               break;
                        if (image->sections[section_last + 1].base_address < (run_address + run_size))
+                       {
                                WARNING("section %d out of order", section_last + 1);
+                               break;
+                       }
+                       if (image->sections[section_last + 1].base_address != (run_address + run_size))
+                               break;
                        run_size += image->sections[++section_last].size;
                }
 
@@ -836,8 +839,8 @@ int flash_write(target_t *target, image_t *image, u32 *written, char **error_str
                                if (retval != ERROR_OK)
                                        snprintf(*error_str, FLASH_MAX_ERROR_STR, "error reading from image: %s", image->error_str);
                                else
-                                       
                                        snprintf(*error_str, FLASH_MAX_ERROR_STR, "error reading from image");
+                               
                                return ERROR_IMAGE_TEMPORARILY_UNAVAILABLE;
                        }
 
index 339e77daeed822728bfa1ddbb1822c044d411223..b1acee58b25a78ca4a01a7ab0d25b9e32f135494 100644 (file)
@@ -256,6 +256,8 @@ int ft2232_speed(int speed)
                ERROR("couldn't set FT2232 TCK speed");
                return retval;
        }
+
+       jtag_speed = speed;
        
        return ERROR_OK;
 }
index 7e85c82b6cc723b7c8e7a465efaaa23ae16d5600..4965d52f31a5c2c8d231689872d9046f85d4f888 100644 (file)
@@ -18,7 +18,7 @@
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
-#define OPENOCD_VERSION "Open On-Chip Debugger (2007-08-14 12:00 CEST)"
+#define OPENOCD_VERSION "Open On-Chip Debugger (2007-08-16 15:00 CEST)"
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
index 81e20af01c23b86e7015f0cc5a655dfbb572a2d6..f145f3021b3834f02c063d1cdd547821514fea2f 100644 (file)
@@ -636,6 +636,7 @@ int etb_start_capture(etm_context_t *etm_ctx)
 {
        etb_t *etb = etm_ctx->capture_driver_priv;
        u32 etb_ctrl_value = 0x1;
+       u32 trigger_count;
 
        if ((etm_ctx->portmode & ETM_PORT_MODE_MASK) == ETM_PORT_DEMUXED)
        {
@@ -650,7 +651,9 @@ int etb_start_capture(etm_context_t *etm_ctx)
        if ((etm_ctx->portmode & ETM_PORT_MODE_MASK) == ETM_PORT_MUXED)
                return ERROR_ETM_PORTMODE_NOT_SUPPORTED;
        
-       etb_write_reg(&etb->reg_cache->reg_list[ETB_TRIGGER_COUNTER], 0x600);
+       trigger_count = (etb->ram_depth * etm_ctx->trigger_percent) / 100;
+       
+       etb_write_reg(&etb->reg_cache->reg_list[ETB_TRIGGER_COUNTER], trigger_count);
        etb_write_reg(&etb->reg_cache->reg_list[ETB_RAM_WRITE_POINTER], 0x0);
        etb_write_reg(&etb->reg_cache->reg_list[ETB_CTRL], etb_ctrl_value);
        jtag_execute_queue();
index cbe3db5932549798a9795b83f8f2aa49fd14d0bc..3f7bbbf13c1227aff1886002d7162896814c2245 100644 (file)
@@ -762,6 +762,7 @@ int etmv1_analyze_trace(etm_context_t *ctx, struct command_context_s *cmd_ctx)
                u32 old_index = ctx->pipe_index;
                u32 last_instruction = ctx->last_instruction;
                u32 cycles = 0;
+               int current_pc_ok = ctx->pc_ok;
                
                if (ctx->trace_data[ctx->pipe_index].flags & ETMV1_TRIGGER_CYCLE)
                {
@@ -836,6 +837,16 @@ int etmv1_analyze_trace(etm_context_t *ctx, struct command_context_s *cmd_ctx)
                                        break;
                                case 0x4:       /* periodic synchronization point */
                                        next_pc = ctx->last_branch;
+                                       /* if we had no valid PC prior to this synchronization point,
+                                        * we have to move on with the next trace cycle
+                                        */
+                                       if (!current_pc_ok)
+                                       {
+                                               command_print(cmd_ctx, "--- periodic synchronization point at 0x%8.8x ---", next_pc);
+                                               ctx->current_pc = next_pc;
+                                               ctx->pipe_index++;
+                                               continue;
+                                       }
                                        break;
                                default:        /* reserved */
                                        ERROR("BUG: branch reason code 0x%x is reserved", ctx->last_branch_reason);             
@@ -883,7 +894,9 @@ int etmv1_analyze_trace(etm_context_t *ctx, struct command_context_s *cmd_ctx)
                                }
                                else if (retval == ERROR_TRACE_INSTRUCTION_UNAVAILABLE)
                                {
-                                       /* TODO: handle incomplete images */
+                                       /* TODO: handle incomplete images 
+                                        * for now we just quit the analsysis*/
+                                       return retval;
                                }
                        }
                        
@@ -910,7 +923,7 @@ int etmv1_analyze_trace(etm_context_t *ctx, struct command_context_s *cmd_ctx)
                                
                                do {
                                        if ((retval = etmv1_next_packet(ctx, &packet, 0)) != 0)
-                                               return -1;
+                                               return ERROR_ETM_ANALYSIS_FAILED;
                                        ctx->last_ptr &= ~(0x7f << shift);
                                        ctx->last_ptr |= (packet & 0x7f) << shift;
                                        shift += 7;
@@ -936,7 +949,7 @@ int etmv1_analyze_trace(etm_context_t *ctx, struct command_context_s *cmd_ctx)
                                                {
                                                        u32 data;
                                                        if (etmv1_data(ctx, 4, &data) != 0)
-                                                               return -1;
+                                                               return ERROR_ETM_ANALYSIS_FAILED;
                                                        command_print(cmd_ctx, "data: 0x%8.8x", data);
                                                }
                                        }
@@ -945,7 +958,7 @@ int etmv1_analyze_trace(etm_context_t *ctx, struct command_context_s *cmd_ctx)
                                {
                                        u32 data;
                                        if (etmv1_data(ctx, arm_access_size(&instruction), &data) != 0)
-                                               return -1;
+                                               return ERROR_ETM_ANALYSIS_FAILED;
                                        command_print(cmd_ctx, "data: 0x%8.8x", data);
                                }
                        }
@@ -1771,6 +1784,7 @@ int handle_etm_analyze_command(struct command_context_s *cmd_ctx, char *cmd, cha
        armv4_5_common_t *armv4_5;
        arm7_9_common_t *arm7_9;
        etm_context_t *etm_ctx;
+       int retval;
 
        target = get_current_target(cmd_ctx);
        
@@ -1786,7 +1800,23 @@ int handle_etm_analyze_command(struct command_context_s *cmd_ctx, char *cmd, cha
                return ERROR_OK;
        }
        
-       etmv1_analyze_trace(etm_ctx, cmd_ctx);
+       if ((retval = etmv1_analyze_trace(etm_ctx, cmd_ctx)) != ERROR_OK)
+       {
+               switch(retval)
+               {
+                       case ERROR_ETM_ANALYSIS_FAILED:
+                               command_print(cmd_ctx, "further analysis failed (corrupted trace data or just end of data");
+                               break;
+                       case ERROR_TRACE_INSTRUCTION_UNAVAILABLE:
+                               command_print(cmd_ctx, "no instruction for current address available, analysis aborted");
+                               break;
+                       case ERROR_TRACE_IMAGE_UNAVAILABLE:
+                               command_print(cmd_ctx, "no image available for trace analysis");
+                               break;
+                       default:
+                               command_print(cmd_ctx, "unknown error: %i", retval);
+               }
+       }
        
        return ERROR_OK;
 }
index bcaf25132ce34a78bf9e2c2355bbc7cc25ce5530..bfa1252b761ca4284da449754785a326c1d0b73e 100644 (file)
@@ -209,5 +209,6 @@ extern etm_context_t* etm_create_context(etm_portmode_t portmode, char *capture_
 #define ERROR_ETM_INVALID_DRIVER       (-1300)\r
 #define ERROR_ETM_PORTMODE_NOT_SUPPORTED       (-1301)\r
 #define ERROR_ETM_CAPTURE_INIT_FAILED  (-1302)\r
+#define ERROR_ETM_ANALYSIS_FAILED      (-1303)\r
 \r
 #endif /* ETM_H */\r

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)