コード例 #1
0
def main(argv):
    if argv:
        sys.exit('Test takes no args!')
    updater = hammerd_api.FirmwareUpdater(common.BASE_VENDOR_ID,
                                          common.BASE_PRODUCT_ID,
                                          common.BASE_USB_PATH)
    # Load EC image.
    with open(common.OLDER_IMAGE, 'rb') as f:
        ec_image = f.read()
    updater.LoadEcImage(ec_image)

    common.disable_hammerd()
    init_before_updaterw(updater)
    common.reset_stay_ro(updater)
    unlock_rw(updater)
    print('Updating to OLDER_IMAGE fw from RO')
    transfer_rw(updater, common.OLDER_IMAGE)
    common.sim_disconnect_connect(updater)

    common.disable_hammerd()
    init_before_updaterw(updater)
    common.reset_stay_ro(updater)
    unlock_rw(updater)
    print('Updating to NEWER_IMAGE from RO')
    transfer_rw(updater, common.NEWER_IMAGE)
    common.sim_disconnect_connect(updater)
コード例 #2
0
def update_invalid_rb(updater, image, image_desc):
    init_before_updaterw(updater)
    common.reset_stay_ro(updater)
    unlock_rw(updater)
    print(image_desc)
    transfer_rw(updater, image)
    assert updater.CurrentSection() == 0, 'RW has lower RB version!'
コード例 #3
0
def main(argv):
    if argv:
        sys.exit('Test takes no args!')
    updater = hammerd_api.FirmwareUpdater(common.BASE_VENDOR_ID,
                                          common.BASE_PRODUCT_ID,
                                          common.BASE_USB_PATH)
    # Load EC image.
    with open(common.RB_INITIAL, 'rb') as f:
        ec_image = f.read()
    updater.LoadEcImage(ec_image)

    common.disable_hammerd()

    # Make sure rollback is updated to current RW image (rb1)
    common.connect_usb(updater)
    inc_rollback(updater, 1)

    # Update to invalid RW with RB < current RB
    image_desc = 'Update to invalid RW with RB < current RB'
    update_invalid_rb(updater, common.RB_LOWER, image_desc)

    # Restore to valid RB
    image_desc = 'Restoring to valid RB_1 from RO'
    restore_valid_rb(updater, common.RB_INITIAL, image_desc)

    # Update to valid RW with RB > current RB
    image_desc = 'Update to valid RW with RB > current RB'
    init_before_updaterw(updater)
    common.reset_stay_ro(updater)
    unlock_rw(updater)
    restore_valid_rb(updater, common.RB_HIGHER, image_desc)

    # RB should now = RB_HIGHER
    common.connect_usb(updater)
    inc_rollback(updater, 9)
コード例 #4
0
def unlock_rw(updater):
    # Check if RW is locked and unlock if needed
    wp = get_wp_status(updater)
    print('WP status:  %s' % str(wp))
    if wp:
        print('Need to unlock RW')
        updater.UnlockRW()
        common.reset_stay_ro(updater)
コード例 #5
0
def unlock_rw(updater):
  # Check if RW is locked and unlock if needed
  wp_rw = get_wp_status(updater)
  print('WP status:  %s' %str(wp_rw))
  if wp_rw:
    print('Need to unlock RW')
    unlocked = updater.UnlockRW()
    assert unlocked == 1, 'Failed to unlock RW'
    common.reset_stay_ro(updater)
コード例 #6
0
def unlock_rw(updater):
    # Check if RW is locked and unlock if needed
    wp_rw = (get_flash_protection(updater)
             & common.EC_FLASH_PROTECT_RW_NOW) > 0
    print('WP status:  %s' % str(wp_rw))
    if wp_rw:
        print('Need to unlock RW')
        unlocked = updater.UnlockRW()
        assert unlocked == 1, 'Failed to unlock RW'
        common.reset_stay_ro(updater)
コード例 #7
0
def update_invalid_rw(updater, image, image_desc):
    init_before_updaterw(updater)
    common.reset_stay_ro(updater)
    unlock_rw(updater)
    print(image_desc)
    transfer_rw(updater, image)
    updater.SendSubcommand(hammerd_api.UpdateExtraCommand.JumpToRW)
    updater.CloseUsb()
    # If successful (it should not be), jump to RW resets the base.
    common.connect_usb(updater)
    updater.SendFirstPdu()
    updater.SendDone()
    print('Current section-invalid RW update: %s' % updater.CurrentSection())
    assert updater.CurrentSection() == 0, 'Running section should be 0 (RO)'