This is an automated email from Gerrit.

Hsiangkai Wang ([email protected]) just uploaded a new patch set to Gerrit, 
which you can find at http://openocd.zylin.com/1327

-- gerrit

commit aab6ca7131318e979934e4f0f412a25fa3b073ea
Author: Hsiangkai <[email protected]>
Date:   Thu Apr 11 10:59:40 2013 +0800

    aice: add aice command "aice count_to_check_dbger <count>"
    
    Let user control the count to check $DBGER. The default count
    to check $DBGER is 30.
    
    Change-Id: I6d89eb481562efced23e42c07ee7ce42a91ae050
    Signed-off-by: Hsiangkai <[email protected]>

diff --git a/src/jtag/aice/aice_interface.c b/src/jtag/aice/aice_interface.c
index 1539f10..b4f79e5 100644
--- a/src/jtag/aice/aice_interface.c
+++ b/src/jtag/aice/aice_interface.c
@@ -117,6 +117,7 @@ static int aice_init(void)
        }
 
        aice.port->api->set_retry_times(aice.retry_times);
+       aice.port->api->set_count_to_check_dbger(aice.count_to_check_dbger);
 
        LOG_INFO("AICE JTAG Interface ready");
 
@@ -309,6 +310,18 @@ COMMAND_HANDLER(aice_handle_aice_retry_times_command)
        return ERROR_OK;
 }
 
+COMMAND_HANDLER(aice_handle_aice_count_to_check_dbger_command)
+{
+       LOG_DEBUG("aice_handle_aice_count_to_check_dbger_command");
+
+       if (CMD_ARGC == 1)
+               COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], 
aice.count_to_check_dbger);
+       else
+               LOG_ERROR("expected exactly one argument to aice 
count_to_check_dbger <count_of_checking>");
+
+       return ERROR_OK;
+}
+
 COMMAND_HANDLER(aice_handle_aice_custom_srst_script_command)
 {
        LOG_DEBUG("aice_handle_aice_custom_srst_script_command");
@@ -397,6 +410,13 @@ static const struct command_registration 
aice_subcommand_handlers[] = {
                .usage = "aice retry_times num_of_retry",
        },
        {
+               .name = "count_to_check_dbger",
+               .handler = &aice_handle_aice_count_to_check_dbger_command,
+               .mode = COMMAND_CONFIG,
+               .help = "set retry times as checking $DBGER status",
+               .usage = "aice count_to_check_dbger count_of_checking",
+       },
+       {
                .name = "custom_srst_script",
                .handler = &aice_handle_aice_custom_srst_script_command,
                .mode = COMMAND_CONFIG,
diff --git a/src/jtag/aice/aice_port.h b/src/jtag/aice/aice_port.h
index 2e72870..dfa6fe5 100644
--- a/src/jtag/aice/aice_port.h
+++ b/src/jtag/aice/aice_port.h
@@ -74,6 +74,7 @@ enum aice_api_s {
        AICE_SET_CUSTOM_SRST_SCRIPT,
        AICE_SET_CUSTOM_TRST_SCRIPT,
        AICE_SET_CUSTOM_RESTART_SCRIPT,
+       AICE_SET_COUNT_TO_CHECK_DBGER,
 };
 
 enum aice_error_s {
@@ -111,6 +112,8 @@ struct aice_port_s {
        const struct aice_port *port;
        /** */
        uint32_t retry_times;
+       /** */
+       uint32_t count_to_check_dbger;
 };
 
 /** */
@@ -198,6 +201,9 @@ struct aice_port_api_s {
 
        /** */
        int (*set_custom_restart_script)(const char *script);
+
+       /** */
+       int (*set_count_to_check_dbger)(uint32_t count_to_check);
 };
 
 #define AICE_PORT_UNKNOWN      0
diff --git a/src/jtag/aice/aice_usb.c b/src/jtag/aice/aice_usb.c
index 6999757..cb496e4 100644
--- a/src/jtag/aice/aice_usb.c
+++ b/src/jtag/aice/aice_usb.c
@@ -1264,6 +1264,7 @@ static bool cache_init;
 static char *custom_srst_script;
 static char *custom_trst_script;
 static char *custom_restart_script;
+static uint32_t aice_count_to_check_dbger = 30;
 
 static int aice_read_reg(uint32_t num, uint32_t *val);
 static int aice_write_reg(uint32_t num, uint32_t val);
@@ -1299,6 +1300,35 @@ static int check_suppressed_exception(uint32_t 
dbger_value)
        return ERROR_OK;
 }
 
+static int aice_check_dbger(uint32_t expect_status)
+{
+       uint32_t i = 0;
+       uint32_t value_dbger;
+
+       while (1) {
+               aice_read_misc(current_target_id, NDS_EDM_MISC_DBGER, 
&value_dbger);
+
+               if ((value_dbger & expect_status) == expect_status) {
+                       if (ERROR_OK != check_suppressed_exception(value_dbger))
+                               return ERROR_FAIL;
+                       return ERROR_OK;
+               }
+
+               long long then = 0;
+               if (i == aice_count_to_check_dbger)
+                       then = timeval_ms();
+               if (i >= aice_count_to_check_dbger) {
+                       if ((timeval_ms() - then) > 1000) {
+                               LOG_ERROR("Timeout (1000ms) waiting for $DBGER 
status being 0x%08x", expect_status);
+                               return ERROR_FAIL;
+                       }
+               }
+               i++;
+       }
+
+       return ERROR_FAIL;
+}
+
 static int aice_execute_dim(uint32_t *insts, uint8_t n_inst)
 {
        /** fill DIM */
@@ -1314,18 +1344,11 @@ static int aice_execute_dim(uint32_t *insts, uint8_t 
n_inst)
                return ERROR_FAIL;
 
        /** read DBGER.DPED */
-       uint32_t dbger_value;
-       if (aice_read_misc(current_target_id, NDS_EDM_MISC_DBGER, &dbger_value) 
!= ERROR_OK)
-               return ERROR_FAIL;
-
-       if ((dbger_value & NDS_DBGER_DPED) != NDS_DBGER_DPED) {
-               LOG_ERROR("DIM execution is not done");
+       if (aice_check_dbger(NDS_DBGER_DPED) != ERROR_OK) {
+               LOG_ERROR("ERROR! DIM execution is not done");
                return ERROR_FAIL;
        }
 
-       if (ERROR_OK != check_suppressed_exception(dbger_value))
-               return ERROR_FAIL;
-
        return ERROR_OK;
 }
 
@@ -1998,23 +2021,9 @@ static int aice_usb_halt(void)
                aice_write_misc(current_target_id, NDS_EDM_MISC_EDM_CMDR, 0);
        }
 
-       int i = 0;
-       while (1) {
-               aice_read_misc(current_target_id, NDS_EDM_MISC_DBGER, &dbger);
-
-               if (dbger & NDS_DBGER_DEX)
-                       break;
-
-               long long then = 0;
-               if (i == 30)
-                       then = timeval_ms();
-               if (i >= 30) {
-                       if ((timeval_ms() - then) > 1000) {
-                               LOG_ERROR("Timeout (1000ms) waiting for halt to 
complete");
-                               return ERROR_FAIL;
-                       }
-               }
-               i++;
+       if (aice_check_dbger(NDS_DBGER_DEX) != ERROR_OK) {
+               LOG_ERROR("ERROR! Cannot hold core through DBGI.");
+               return ERROR_FAIL;
        }
 
        if (debug_under_dex_on) {
@@ -2188,11 +2197,7 @@ static int aice_issue_reset_hold(void)
                        return ERROR_FAIL;
        }
 
-       uint32_t dbger_value;
-       if (aice_read_misc(current_target_id, NDS_EDM_MISC_DBGER, &dbger_value) 
!= ERROR_OK)
-               return ERROR_FAIL;
-
-       if ((NDS_DBGER_CRST | NDS_DBGER_DEX) == (dbger_value & (NDS_DBGER_CRST 
| NDS_DBGER_DEX))) {
+       if (aice_check_dbger(NDS_DBGER_CRST | NDS_DBGER_DEX) == ERROR_OK) {
                aice_backup_tmp_registers();
                core_state = AICE_TARGET_HALTED;
 
@@ -2211,10 +2216,7 @@ static int aice_issue_reset_hold(void)
                                return ERROR_FAIL;
                }
 
-               if (aice_read_misc(current_target_id, NDS_EDM_MISC_DBGER, 
&dbger_value) != ERROR_OK)
-                       return ERROR_FAIL;
-
-               if ((NDS_DBGER_CRST | NDS_DBGER_DEX) == (dbger_value & 
(NDS_DBGER_CRST | NDS_DBGER_DEX))) {
+               if (aice_check_dbger(NDS_DBGER_CRST | NDS_DBGER_DEX) == 
ERROR_OK) {
                        aice_backup_tmp_registers();
                        core_state = AICE_TARGET_HALTED;
 
@@ -2268,7 +2270,7 @@ static int aice_usb_run(void)
                return ERROR_FAIL;
 
        if ((dbger_value & NDS_DBGER_DEX) != NDS_DBGER_DEX) {
-               LOG_INFO("The debug target unexpectedly exited the debug mode");
+               LOG_WARNING("WARNING! Target exited debug mode unexpectedly.");
                return ERROR_FAIL;
        }
 
@@ -3144,19 +3146,11 @@ static int aice_usb_execute(uint32_t *instructions, 
uint32_t instruction_num)
                if (aice_execute(current_target_id) != ERROR_OK)
                        return ERROR_FAIL;
 
-               /** read DBGER.DPED */
-               uint32_t dbger_value;
-               if (aice_read_misc(current_target_id, NDS_EDM_MISC_DBGER,
-                                       &dbger_value) != ERROR_OK)
-                       return ERROR_FAIL;
-
-               if ((dbger_value & NDS_DBGER_DPED) != NDS_DBGER_DPED) {
-                       LOG_ERROR("DIM execution is not done");
+               /** check DBGER.DPED */
+               if (aice_check_dbger(NDS_DBGER_DPED) != ERROR_OK) {
+                       LOG_ERROR("ERROR! DIM execution is not done.");
                        return ERROR_FAIL;
                }
-
-               if (ERROR_OK != check_suppressed_exception(dbger_value))
-                       return ERROR_FAIL;
        }
 
        return ERROR_OK;
@@ -3183,6 +3177,13 @@ static int aice_usb_set_custom_restart_script(const char 
*script)
        return ERROR_OK;
 }
 
+static int aice_usb_set_count_to_check_dbger(uint32_t count_to_check)
+{
+       aice_count_to_check_dbger = count_to_check;
+
+       return ERROR_OK;
+}
+
 /** */
 struct aice_port_api_s aice_usb_api = {
        /** */
@@ -3249,4 +3250,6 @@ struct aice_port_api_s aice_usb_api = {
        .set_custom_trst_script = aice_usb_set_custom_trst_script,
        /** */
        .set_custom_restart_script = aice_usb_set_custom_restart_script,
+       /** */
+       .set_count_to_check_dbger = aice_usb_set_count_to_check_dbger,
 };

-- 

------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to