faft: Implement a FAFT test for Ctrl-U developer boot USB

This test requires a USB disk plugged-in, which contains a Chrome OS test
image (built by "build_image test"). On runtime, this test first switches
DUT to developer mode. When dev_boot_usb=0, pressing Ctrl-U on developer
screen should not boot the USB disk. When dev_boot_usb=1, pressing Ctrl-U
should boot the USB disk.

Several helpful methods are added to FAFT infrastructure, like:
  FAFTClient:
    - get_dev_boot_usb: Get dev_boot_usb value
    - set_dev_boot_usb: Set dev_boot_usb value
    - is_removable_device_boot: Check the current boot device is removable
  FAFTSequence:
    - dev_boot_usb_checker: Check the current boot is from a developer USB

BUG=chromium-os:35255
TEST=run_remote_tests.sh --board daisy --remote dut firmware_DevBootUSB

Change-Id: I717a0c2bdc086031ad721ba915668416bd5a7256
Reviewed-on: https://gerrit.chromium.org/gerrit/35553
Reviewed-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Mike Truty <truty@chromium.org>
Commit-Ready: Tom Wai-Hong Tam <waihong@chromium.org>
Tested-by: Tom Wai-Hong Tam <waihong@chromium.org>
diff --git a/server/cros/faftsequence.py b/server/cros/faftsequence.py
index e225d51..b5fa5b1 100644
--- a/server/cros/faftsequence.py
+++ b/server/cros/faftsequence.py
@@ -87,6 +87,8 @@
     FIRMWARE_SCREEN_DELAY = 10
     # Delay between passing firmware screen and text mode warning screen.
     TEXT_SCREEN_DELAY = 20
+    # Delay for waiting beep done.
+    BEEP_DELAY = 1
     # Delay of loading the USB kernel.
     USB_LOAD_DELAY = 10
     # Delay between USB plug-out and plug-in.
@@ -180,8 +182,9 @@
             'reboot_action': (self.sync_and_warm_reboot),
             'firmware_action': (None)
         })
-        self.clear_set_gbb_flags(vboot.GBB_FLAG_FORCE_DEV_SWITCH_ON |
-                                 vboot.GBB_FLAG_DEV_SCREEN_SHORT_DELAY,
+        self.clear_set_gbb_flags(vboot.GBB_FLAG_DEV_SCREEN_SHORT_DELAY |
+                                 vboot.GBB_FLAG_FORCE_DEV_SWITCH_ON |
+                                 vboot.GBB_FLAG_FORCE_DEV_BOOT_USB,
                                  vboot.GBB_FLAG_ENTER_TRIGGERS_TONORM)
         if self._install_image_path:
             self.install_test_image(self._install_image_path,
@@ -551,6 +554,20 @@
                 self.crossystem_checker(crossystem_dict))
 
 
+    def dev_boot_usb_checker(self, dev_boot_usb=True):
+        """Check the current boot is from a developer USB (Ctrl-U trigger).
+
+        Args:
+          dev_boot_usb: True to expect an USB boot;
+                        False to expect an internal device boot.
+
+        Returns:
+          True if the currect boot device matched; otherwise, False.
+        """
+        return (self.crossystem_checker({'mainfw_type': 'developer'})
+                and self.faft_client.is_removable_device_boot() == dev_boot_usb)
+
+
     def root_part_checker(self, expected_part):
         """Check the partition number of the root device matched.