target: add examine-fail event 89/4289/9
authorTomas Vanek <vanekt@fbl.cz>
Sat, 4 Nov 2017 08:47:02 +0000 (09:47 +0100)
committerAntonio Borneo <borneo.antonio@gmail.com>
Thu, 12 Mar 2020 09:43:55 +0000 (09:43 +0000)
A configuration script may want to check the reason why examine fails
e.g. device has security lock engaged.

tcl/target/kx.cfg and klx.cfg is modified to use the new event
for testing of the security lock of Kinetis MCU

Change-Id: Id1d3a79d24e84b513f4ea35586cd2ab0437ff9b3
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4289
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
doc/openocd.texi
src/target/startup.tcl
src/target/target.c
src/target/target.h
tcl/target/klx.cfg
tcl/target/kx.cfg

index 454ae06753298e17848b29a4d36fcf07033411ff..711171a3431ad9f9ca048095c322382adde641f7 100644 (file)
@@ -4820,6 +4820,8 @@ The following target events are defined:
 @* Before target examine is called.
 @item @b{examine-end}
 @* After target examine is called with no errors.
+@item @b{examine-fail}
+@* After target examine fails.
 @item @b{gdb-attach}
 @* When GDB connects. Issued before any GDB communication with the target
 starts. GDB expects the target is halted during attachment.
@@ -5991,7 +5993,8 @@ Used in kinetis 'fcf_source protection' mode only.
 @end deffn
 
 @deffn Command {kinetis mdm check_security}
-Checks status of device security lock. Used internally in examine-end event.
+Checks status of device security lock. Used internally in examine-end
+and examine-fail event.
 @end deffn
 
 @deffn Command {kinetis mdm halt}
index cf844e1f64c3734a0f5b76978688c52048e52b1b..976cd2af5edacdf84748e63e4f91200fe4618d4b 100644 (file)
@@ -66,7 +66,9 @@ proc ocd_process_reset_inner { MODE } {
                if {![using_jtag] || [jtag tapisenabled [$t cget -chain-position]]} {
                        $t invoke-event examine-start
                        set err [catch "$t arp_examine allow-defer"]
-                       if { $err == 0 } {
+                       if { $err } {
+                               $t invoke-event examine-fail
+                       } else {
                                $t invoke-event examine-end
                        }
                }
index 1ba4e09878ee35fa4ccccde0740be292944c07f6..61ed9662d16e756fd23d629ac259b01c6c3aa280 100644 (file)
@@ -219,6 +219,7 @@ static const Jim_Nvp nvp_target_event[] = {
        { .value = TARGET_EVENT_RESET_END,           .name = "reset-end" },
 
        { .value = TARGET_EVENT_EXAMINE_START, .name = "examine-start" },
+       { .value = TARGET_EVENT_EXAMINE_FAIL, .name = "examine-fail" },
        { .value = TARGET_EVENT_EXAMINE_END, .name = "examine-end" },
 
        { .value = TARGET_EVENT_DEBUG_HALTED, .name = "debug-halted" },
@@ -708,13 +709,17 @@ static int default_check_reset(struct target *target)
        return ERROR_OK;
 }
 
+/* Equvivalent Tcl code arp_examine_one is in src/target/startup.tcl
+ * Keep in sync */
 int target_examine_one(struct target *target)
 {
        target_call_event_callbacks(target, TARGET_EVENT_EXAMINE_START);
 
        int retval = target->type->examine(target);
-       if (retval != ERROR_OK)
+       if (retval != ERROR_OK) {
+               target_call_event_callbacks(target, TARGET_EVENT_EXAMINE_FAIL);
                return retval;
+       }
 
        target_call_event_callbacks(target, TARGET_EVENT_EXAMINE_END);
 
index 81fd9d23dc5c1e387c4876e75fbc4b9683c268a1..b954ec22d2877f4228c37ec2343dff3b2bb4fce1 100644 (file)
@@ -275,6 +275,7 @@ enum target_event {
        TARGET_EVENT_DEBUG_RESUMED, /* target resumed to execute on behalf of the debugger */
 
        TARGET_EVENT_EXAMINE_START,
+       TARGET_EVENT_EXAMINE_FAIL,
        TARGET_EVENT_EXAMINE_END,
 
        TARGET_EVENT_GDB_ATTACH,
index 36b6ed5962cca1a5a441c6a4f3255e656db15d2f..84f6535e35ed7ae7484ddf03f31af245bb11aad7 100644 (file)
@@ -56,9 +56,9 @@ if {[using_hla]} {
    echo " it without mass erase. Don't set write protection on the first block."
    echo "!!!!!!!!!!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!!!!!!!"
    echo ""
-} {
-   # Detect secured MCU or boot lock-up in RESET/WDOG loop
-   $_CHIPNAME.cpu configure -event examine-start {
+} else {
+   # Detect secured MCU
+   $_TARGETNAME configure -event examine-fail {
       kinetis mdm check_security
    }
 
index 0ff5b0c5344348d226681ed7016935a3fdd24ef0..1dd5d316c77d35d97534b451ab28ed8252024c31 100644 (file)
@@ -58,9 +58,13 @@ if {[using_hla]} {
    echo " it without mass erase. Don't set write protection on the first block."
    echo "!!!!!!!!!!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!!!!!!!"
    echo ""
-} {
+} else {
    # Detect secured MCU or boot lock-up in RESET/WDOG loop
-   $_CHIPNAME.cpu configure -event examine-start {
+   $_TARGETNAME configure -event examine-fail {
+      kinetis mdm check_security
+   }
+   # During RESET/WDOG loop the target is sometimes falsely examined
+   $_TARGETNAME configure -event examine-end {
       kinetis mdm check_security
    }
 

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)