| // Copyright 2019 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| library fuchsia.developer.ffx; |
| |
| // Covers the FFX Daemon Fastboot protocol. For information about how the fastboot |
| // protocol works, see: |
| // https://android.googlesource.com/platform/system/core/+/HEAD/fastboot/ |
| // for the most up-to-date information. |
| |
| /// The maximum size of a fastboot response is 256 bytes, minus |
| /// four bytes for the header defining the type of message. |
| const MAX_FASTBOOT_MESSAGE_SIZE uint32 = 252; |
| |
| type FastbootError = strict enum { |
| PROTOCOL_ERROR = 1; |
| COMMUNICATION_ERROR = 2; |
| REDISCOVERED_ERROR = 3; |
| @deprecated |
| TARGET_ERROR = 4; |
| @deprecated |
| NON_FASTBOOT_DEVICE = 5; |
| REBOOT_FAILED = 6; |
| }; |
| |
| /// Adding more specific reboot errors. These are not necessarily |
| /// Fastboot errors because the target can be in Fuchsia state or |
| /// Zedboot. Therefore, there is a separate error type for these. |
| type RebootError = strict enum { |
| // Timed out waiting for the target to reboot |
| TIMED_OUT = 1; |
| // Failed sending the reboot signal. |
| FAILED_TO_SEND_TARGET_REBOOT = 2; |
| // Did not receive event that the reboot signal was sent. |
| FAILED_TO_SEND_ON_REBOOT = 3; |
| // Failed when sending zedboot reboot signal. |
| ZEDBOOT_COMMUNICATION_ERROR = 4; |
| // No Zedboot address found. Fatal internal error. |
| NO_ZEDBOOT_ADDRESS = 5; |
| // Overnet target communication error. |
| TARGET_COMMUNICATION = 6; |
| // Error sending the Fastboot reboot signal. |
| FASTBOOT_ERROR = 7; |
| }; |
| |
| /// Callback event listener for upload progress. |
| protocol UploadProgressListener { |
| OnError(struct { |
| error string:MAX; |
| }); |
| OnStarted(struct { |
| size uint64; |
| }); |
| OnProgress(struct { |
| bytes_written uint64; |
| }); |
| OnFinished(); |
| }; |
| |
| /// Callback event listener for when the device reboots to the |
| /// bootloader. |
| protocol RebootListener { |
| OnReboot(); |
| }; |
| |
| |
| /// Callback event listener for listing all variables. |
| protocol VariableListener { |
| OnVariable(struct { |
| name string:64; |
| value string:64; |
| }); |
| }; |
| |
| |
| @discoverable |
| protocol Fastboot { |
| Prepare(resource struct { |
| listener client_end:RebootListener; |
| }) -> (struct {}) error RebootError; |
| GetVar(struct { |
| name string:64; |
| }) -> (struct { |
| value string:64; |
| }) error FastbootError; |
| GetAllVars(resource struct { |
| listener client_end:VariableListener; |
| }) -> (struct {}) error FastbootError; |
| Flash(resource struct { |
| partition_name string:64; |
| path string:256; |
| listener client_end:UploadProgressListener; |
| }) -> (struct {}) error FastbootError; |
| Erase(struct { |
| partition_name string:64; |
| }) -> (struct {}) error FastbootError; |
| Boot() -> (struct {}) error FastbootError; |
| Reboot() -> (struct {}) error FastbootError; |
| RebootBootloader(resource struct { |
| listener client_end:RebootListener; |
| }) -> (struct {}) error RebootError; |
| ContinueBoot() -> (struct {}) error FastbootError; |
| GetStaged(resource struct { |
| path string:256; |
| }) -> (struct {}) error FastbootError; |
| Stage(resource struct { |
| path string:256; |
| listener client_end:UploadProgressListener; |
| }) -> (struct {}) error FastbootError; |
| SetActive(struct { |
| slot string:64; |
| }) -> (struct {}) error FastbootError; |
| Oem(struct { |
| command string:64; |
| }) -> (struct {}) error FastbootError; |
| }; |
| |
| type FastbootTarget = table { |
| /// The fastboot serial number of the target. |
| 1: serial string:MAX_FASTBOOT_MESSAGE_SIZE; |
| }; |
| |
| @discoverable |
| protocol FastbootTargetStream { |
| /// Gets the next target from the protocol. Intended to be used as a hanging get |
| /// on the client side. |
| GetNext() -> (struct { |
| target FastbootTarget; |
| }); |
| }; |