Enabling FAFT on Parrot

This change contains the following fixes:
1) Fixing CTRL+D sequence. Before Servo would press D+CTRL.
2) Fixing hang when rec_mode is set to off while device is off.
3) workaround for bug 16231. Device does not boot after entering dev mode.
4) changing dev_screen timeout to accomodate slower devices.

BUG=chrome-os-partner:16829,chrome-os-partner:16231
TEST=control.faft_lv1, control.faft_lv2, control.faft_lv4 test suites pass

Change-Id: I1f35ecb6814fffb2dc14a934d2c964fa1d1f8c84
Reviewed-on: https://gerrit.chromium.org/gerrit/39724
Reviewed-by: Tom Wai-Hong Tam <waihong@chromium.org>
Reviewed-by: Jay Kim <yongjaek@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Gediminas Ramanauskas <gedis@chromium.org>
Tested-by: Gediminas Ramanauskas <gedis@chromium.org>
diff --git a/server/cros/faft_delay_constants.py b/server/cros/faft_delay_constants.py
index ff6b04d..8934221 100644
--- a/server/cros/faft_delay_constants.py
+++ b/server/cros/faft_delay_constants.py
@@ -67,3 +67,11 @@
 
         if platform == 'Snow':
             self.ec_boot_to_console = 0.4
+
+        if platform == 'Parrot':
+            # Parrot uses UART to switch to rec mode instead of gpio thus to
+            # clear rec_mode, devices needs to be sufficiently booted.
+            self.ec_boot_to_console = 4
+
+            # Parrot takes slightly longer to get to dev screen.
+            self.dev_screen = 8
diff --git a/server/cros/faftsequence.py b/server/cros/faftsequence.py
index fdfbe53..ee468a6 100644
--- a/server/cros/faftsequence.py
+++ b/server/cros/faftsequence.py
@@ -1027,6 +1027,12 @@
         self.wait_for_client_offline()
         self.wait_fw_screen_and_switch_keyboard_dev_mode(dev=True)
 
+        # TODO (crosbug.com/p/16231) remove this conditional completely if/when
+        # issue is resolved.
+        if self.client_attr.platform == 'Parrot':
+            self.wait_for_client_offline()
+            self.cold_reboot()
+
 
     def disable_keyboard_dev_mode(self):
         logging.info("Disabling keyboard controlled developer mode")
diff --git a/server/cros/servo.py b/server/cros/servo.py
index f6ee2de..7b1965d 100644
--- a/server/cros/servo.py
+++ b/server/cros/servo.py
@@ -261,13 +261,19 @@
         Note, key presses will remain on indefinitely. See
             _press_and_release_keys for release procedure.
         """
-        (m1_a1, m1_a0, m2_a1, m2_a0) = self.KEY_MATRIX[self._key_matrix][key]
+        (m1_a1, m1_a0, m2_a1, m2_a0) = self.KEY_MATRIX[self._key_matrix]['none']
         self.set_nocheck('kbd_m2_a0', m2_a0)
         self.set_nocheck('kbd_m2_a1', m2_a1)
         self.set_nocheck('kbd_m1_a0', m1_a0)
         self.set_nocheck('kbd_m1_a1', m1_a1)
         self.set_nocheck('kbd_en', 'on')
 
+        (m1_a1, m1_a0, m2_a1, m2_a0) = self.KEY_MATRIX[self._key_matrix][key]
+        self.set_nocheck('kbd_m2_a0', m2_a0)
+        self.set_nocheck('kbd_m2_a1', m2_a1)
+        self.set_nocheck('kbd_m1_a0', m1_a0)
+        self.set_nocheck('kbd_m1_a1', m1_a1)
+
 
     def _press_and_release_keys(self, key,
                                 press_secs=SERVO_KEY_PRESS_DELAY):