chrome_ti50: update rolledback check

firmware_GSCPinweaverUpdate rolls back to a DT image that doesn't have
the "Rollback detected" print. Check the rollback count to verify
rollback on Ti50 DT devices.

BUG=none
TEST=run firmware_GSCPinweaverUpdate on skyrim

Change-Id: I1ac60606024199c8ed4f94144a300503cb7a7a26
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/6643511
Reviewed-by: Jett Rink <[email protected]>
Commit-Queue: Jett Rink <[email protected]>
Tested-by: Mary Ruthven <[email protected]>
Auto-Submit: Mary Ruthven <[email protected]>
diff --git a/server/cros/servo/chrome_cr50.py b/server/cros/servo/chrome_cr50.py
index 9c29d8f..7deeced 100644
--- a/server/cros/servo/chrome_cr50.py
+++ b/server/cros/servo/chrome_cr50.py
@@ -363,6 +363,10 @@
     TPM_INIT_MAX = 120000
     TIME_SINCE_DS_RE = ' = (.*) s'
     TIME_SINCE_COLD_RESET_RE = 'since cold_reset: ([0-9]*) s'
+    # Cr50 always printed "Rollback detected" in the sysinfo output
+    ALWAYS_HAD_ROLLBACK_PRINT = True
+    # Cr50 will rollback after 7 resets
+    ROLLBACK_THRESHOLD = 7
 
     def __init__(self, servo, faft_config):
         """Initializes a ChromeCr50 object.
diff --git a/server/cros/servo/chrome_ti50.py b/server/cros/servo/chrome_ti50.py
index cf4dfb4..3bf4cc8 100644
--- a/server/cros/servo/chrome_ti50.py
+++ b/server/cros/servo/chrome_ti50.py
@@ -27,7 +27,10 @@
     START_STR = ['ti50_common']
     BID_RE = r'Board ID: (\S{8}):?(|\S{8}), flags: (\S{8})\s'
     CCD_PW_DENIED = 'failed: ParamCount'
-
+    # Ti50 DT images didn't always print "Rollback detected" in the sysinfo
+    # output. Fallback to checking rollback count.
+    ALWAYS_HAD_ROLLBACK_PRINT = False
+    ROLLBACK_THRESHOLD = 5
     # Ti50 only supports v2
     AP_RO_VERSIONS = [2]
     # ===============================================================
@@ -291,3 +294,10 @@
     def clear_system_reset_enforcement(self):
         """Try to clear system reset enforcement"""
         self.send_command('ap_ro_verify erase')
+
+    def rolledback(self):
+        """Returns true if ti50 rolled back"""
+        rolledback = super(ChromeTi50, self).rolledback()
+        if self.ALWAYS_HAD_ROLLBACK_PRINT:
+            return rolledback
+        return self.get_reset_count() > self.ROLLBACK_THRESHOLD
diff --git a/server/cros/servo/chrome_ti50_nt.py b/server/cros/servo/chrome_ti50_nt.py
index eb5d83a..2ffe32e 100644
--- a/server/cros/servo/chrome_ti50_nt.py
+++ b/server/cros/servo/chrome_ti50_nt.py
@@ -72,3 +72,4 @@
     # Ti50 FW is installed in 2 locations
     DUT_PROD_PATHS = [DUT_PROD]
     DUT_PREPVT_PATHS = [DUT_PREPVT]
+    ALWAYS_HAD_ROLLBACK_PRINT = True