mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-26 09:28:13 +00:00
core/bootloader: update protobuf definitions
This commit is contained in:
parent
fdcb64ac24
commit
8dacad0782
@ -85,7 +85,6 @@ SOURCE_BOOTLOADER = [
|
||||
'embed/bootloader/main.c',
|
||||
'embed/bootloader/messages.c',
|
||||
'embed/bootloader/protob/messages.pb.c',
|
||||
'embed/bootloader/protob/types.pb.c',
|
||||
]
|
||||
|
||||
SOURCE_TREZORHAL = [
|
||||
|
@ -1,7 +1,7 @@
|
||||
all: messages.pb.c types.pb.c
|
||||
all: messages.pb.c
|
||||
|
||||
%.pb.c: %.pb %.options
|
||||
nanopb_generator $< -T
|
||||
nanopb_generator $< -T -D . -s "mangle_names:M_FLATTEN"
|
||||
|
||||
%.pb: %.proto
|
||||
protoc -I/usr/include -I. $< -o $@
|
||||
|
@ -41,3 +41,5 @@ PB_BIND(FirmwareUpload, FirmwareUpload, AUTO)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
#ifndef PB_MESSAGES_PB_H_INCLUDED
|
||||
#define PB_MESSAGES_PB_H_INCLUDED
|
||||
#include <pb.h>
|
||||
#include "types.pb.h"
|
||||
|
||||
#if PB_PROTO_HEADER_VERSION != 40
|
||||
#error Regenerate this file with the current version of nanopb generator.
|
||||
@ -29,6 +28,17 @@ typedef enum _MessageType {
|
||||
MessageType_MessageType_GetFeatures = 55
|
||||
} MessageType;
|
||||
|
||||
typedef enum _FailureType {
|
||||
FailureType_Failure_UnexpectedMessage = 1,
|
||||
FailureType_Failure_DataError = 3,
|
||||
FailureType_Failure_ActionCancelled = 4,
|
||||
FailureType_Failure_ProcessError = 9
|
||||
} FailureType;
|
||||
|
||||
typedef enum _ButtonRequestType {
|
||||
ButtonRequestType_ButtonRequest_Other = 1
|
||||
} ButtonRequestType;
|
||||
|
||||
/* Struct definitions */
|
||||
typedef struct _ButtonAck {
|
||||
char dummy_field;
|
||||
@ -115,12 +125,6 @@ typedef struct _FirmwareUpload {
|
||||
typedef struct _Ping {
|
||||
bool has_message;
|
||||
char message[256];
|
||||
bool has_button_protection;
|
||||
bool button_protection;
|
||||
bool has_pin_protection;
|
||||
bool pin_protection;
|
||||
bool has_passphrase_protection;
|
||||
bool passphrase_protection;
|
||||
} Ping;
|
||||
|
||||
typedef struct _Success {
|
||||
@ -134,12 +138,20 @@ typedef struct _Success {
|
||||
#define _MessageType_MAX MessageType_MessageType_GetFeatures
|
||||
#define _MessageType_ARRAYSIZE ((MessageType)(MessageType_MessageType_GetFeatures+1))
|
||||
|
||||
#define _FailureType_MIN FailureType_Failure_UnexpectedMessage
|
||||
#define _FailureType_MAX FailureType_Failure_ProcessError
|
||||
#define _FailureType_ARRAYSIZE ((FailureType)(FailureType_Failure_ProcessError+1))
|
||||
|
||||
#define _ButtonRequestType_MIN ButtonRequestType_ButtonRequest_Other
|
||||
#define _ButtonRequestType_MAX ButtonRequestType_ButtonRequest_Other
|
||||
#define _ButtonRequestType_ARRAYSIZE ((ButtonRequestType)(ButtonRequestType_ButtonRequest_Other+1))
|
||||
|
||||
|
||||
/* Initializer values for message structs */
|
||||
#define Initialize_init_default {0}
|
||||
#define GetFeatures_init_default {0}
|
||||
#define Features_init_default {false, "", false, 0, false, 0, false, 0, false, 0, false, "", false, "", false, "", false, 0, false, {0, {0}}, false, 0, false, "", false, 0, false, 0, false, 0, false, "", false, {0, {0}}}
|
||||
#define Ping_init_default {false, "", false, 0, false, 0, false, 0}
|
||||
#define Ping_init_default {false, ""}
|
||||
#define Success_init_default {false, ""}
|
||||
#define Failure_init_default {false, _FailureType_MIN, false, ""}
|
||||
#define ButtonRequest_init_default {false, _ButtonRequestType_MIN}
|
||||
@ -150,7 +162,7 @@ typedef struct _Success {
|
||||
#define Initialize_init_zero {0}
|
||||
#define GetFeatures_init_zero {0}
|
||||
#define Features_init_zero {false, "", false, 0, false, 0, false, 0, false, 0, false, "", false, "", false, "", false, 0, false, {0, {0}}, false, 0, false, "", false, 0, false, 0, false, 0, false, "", false, {0, {0}}}
|
||||
#define Ping_init_zero {false, "", false, 0, false, 0, false, 0}
|
||||
#define Ping_init_zero {false, ""}
|
||||
#define Success_init_zero {false, ""}
|
||||
#define Failure_init_zero {false, _FailureType_MIN, false, ""}
|
||||
#define ButtonRequest_init_zero {false, _ButtonRequestType_MIN}
|
||||
@ -186,9 +198,6 @@ typedef struct _Success {
|
||||
#define FirmwareUpload_payload_tag 1
|
||||
#define FirmwareUpload_hash_tag 2
|
||||
#define Ping_message_tag 1
|
||||
#define Ping_button_protection_tag 2
|
||||
#define Ping_pin_protection_tag 3
|
||||
#define Ping_passphrase_protection_tag 4
|
||||
#define Success_message_tag 1
|
||||
|
||||
/* Struct field encoding specification for nanopb */
|
||||
@ -224,10 +233,7 @@ X(a, STATIC, OPTIONAL, BYTES, fw_vendor_keys, 26)
|
||||
#define Features_DEFAULT NULL
|
||||
|
||||
#define Ping_FIELDLIST(X, a) \
|
||||
X(a, STATIC, OPTIONAL, STRING, message, 1) \
|
||||
X(a, STATIC, OPTIONAL, BOOL, button_protection, 2) \
|
||||
X(a, STATIC, OPTIONAL, BOOL, pin_protection, 3) \
|
||||
X(a, STATIC, OPTIONAL, BOOL, passphrase_protection, 4)
|
||||
X(a, STATIC, OPTIONAL, STRING, message, 1)
|
||||
#define Ping_CALLBACK NULL
|
||||
#define Ping_DEFAULT NULL
|
||||
|
||||
@ -237,13 +243,13 @@ X(a, STATIC, OPTIONAL, STRING, message, 1)
|
||||
#define Success_DEFAULT NULL
|
||||
|
||||
#define Failure_FIELDLIST(X, a) \
|
||||
X(a, STATIC, OPTIONAL, ENUM, code, 1) \
|
||||
X(a, STATIC, OPTIONAL, UENUM, code, 1) \
|
||||
X(a, STATIC, OPTIONAL, STRING, message, 2)
|
||||
#define Failure_CALLBACK NULL
|
||||
#define Failure_DEFAULT NULL
|
||||
|
||||
#define ButtonRequest_FIELDLIST(X, a) \
|
||||
X(a, STATIC, OPTIONAL, ENUM, code, 1)
|
||||
X(a, STATIC, OPTIONAL, UENUM, code, 1)
|
||||
#define ButtonRequest_CALLBACK NULL
|
||||
#define ButtonRequest_DEFAULT NULL
|
||||
|
||||
@ -298,10 +304,10 @@ extern const pb_msgdesc_t FirmwareUpload_msg;
|
||||
#define Initialize_size 0
|
||||
#define GetFeatures_size 0
|
||||
#define Features_size 493
|
||||
#define Ping_size 264
|
||||
#define Ping_size 258
|
||||
#define Success_size 258
|
||||
#define Failure_size 269
|
||||
#define ButtonRequest_size 11
|
||||
#define Failure_size 260
|
||||
#define ButtonRequest_size 2
|
||||
#define ButtonAck_size 0
|
||||
#define FirmwareErase_size 6
|
||||
#define FirmwareRequest_size 12
|
||||
|
@ -1,6 +1,5 @@
|
||||
syntax = "proto2";
|
||||
|
||||
import "types.proto";
|
||||
|
||||
/**
|
||||
* Mapping between Trezor wire identifier (uint) and a protobuf message
|
||||
@ -21,6 +20,7 @@ enum MessageType {
|
||||
|
||||
/**
|
||||
* Request: Reset device to default state and ask for device details
|
||||
* @start
|
||||
* @next Features
|
||||
*/
|
||||
message Initialize {
|
||||
@ -28,6 +28,7 @@ message Initialize {
|
||||
|
||||
/**
|
||||
* Request: Ask for device details (no device reset)
|
||||
* @start
|
||||
* @next Features
|
||||
*/
|
||||
message GetFeatures {
|
||||
@ -35,8 +36,7 @@ message GetFeatures {
|
||||
|
||||
/**
|
||||
* Response: Reports various information about the device
|
||||
* @prev Initialize
|
||||
* @prev GetFeatures
|
||||
* @end
|
||||
*/
|
||||
message Features {
|
||||
optional string vendor = 1; // name of the manufacturer, e.g. "trezor.io"
|
||||
@ -45,19 +45,11 @@ message Features {
|
||||
optional uint32 patch_version = 4; // patch version of the firmware/bootloader, e.g. 0
|
||||
optional bool bootloader_mode = 5; // is device in bootloader mode?
|
||||
optional string device_id = 6; // device's unique identifier
|
||||
// optional bool pin_protection = 7; // is device protected by PIN?
|
||||
// optional bool passphrase_protection = 8; // is node/mnemonic encrypted using passphrase?
|
||||
optional string language = 9; // device language
|
||||
optional string label = 10; // device description label
|
||||
optional bool initialized = 12; // does device contain seed?
|
||||
optional bytes revision = 13; // SCM revision of firmware
|
||||
// optional bytes bootloader_hash = 14; // hash of the bootloader
|
||||
// optional bool imported = 15; // was storage imported from an external source?
|
||||
// optional bool pin_cached = 16; // is PIN already cached in session?
|
||||
// optional bool passphrase_cached = 17; // is passphrase already cached in session?
|
||||
optional bool firmware_present = 18; // is valid firmware loaded?
|
||||
// optional bool needs_backup = 19; // does storage need backup? (equals to Storage.needs_backup)
|
||||
// optional uint32 flags = 20; // device flags (equals to Storage.flags)
|
||||
optional string model = 21; // device hardware model
|
||||
optional uint32 fw_major = 22; // reported firmware version if in bootloader mode
|
||||
optional uint32 fw_minor = 23; // reported firmware version if in bootloader mode
|
||||
@ -68,17 +60,16 @@ message Features {
|
||||
|
||||
/**
|
||||
* Request: Test if the device is alive, device sends back the message in Success response
|
||||
* @start
|
||||
* @next Success
|
||||
*/
|
||||
message Ping {
|
||||
optional string message = 1; // message to send back in Success message
|
||||
optional bool button_protection = 2; // ask for button press
|
||||
optional bool pin_protection = 3; // ask for PIN if set in device
|
||||
optional bool passphrase_protection = 4; // ask for passphrase if set in device
|
||||
}
|
||||
|
||||
/**
|
||||
* Response: Success of the previous request
|
||||
* @end
|
||||
*/
|
||||
message Success {
|
||||
optional string message = 1; // human readable description of action or request-specific payload
|
||||
@ -86,33 +77,45 @@ message Success {
|
||||
|
||||
/**
|
||||
* Response: Failure of the previous request
|
||||
* @end
|
||||
*/
|
||||
message Failure {
|
||||
optional FailureType code = 1; // computer-readable definition of the error state
|
||||
optional string message = 2; // human-readable message of the error state
|
||||
enum FailureType {
|
||||
Failure_UnexpectedMessage = 1;
|
||||
Failure_DataError = 3;
|
||||
Failure_ActionCancelled = 4;
|
||||
Failure_ProcessError = 9;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Response: Device is waiting for HW button press.
|
||||
* @auxstart
|
||||
* @next ButtonAck
|
||||
* @next Cancel
|
||||
*/
|
||||
message ButtonRequest {
|
||||
optional ButtonRequestType code = 1;
|
||||
/**
|
||||
* Type of button request
|
||||
*/
|
||||
enum ButtonRequestType {
|
||||
ButtonRequest_Other = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request: Computer agrees to wait for HW button press
|
||||
* @prev ButtonRequest
|
||||
* @auxend
|
||||
*/
|
||||
message ButtonAck {
|
||||
}
|
||||
|
||||
/**
|
||||
* Request: Ask device to erase its firmware (so it can be replaced via FirmwareUpload)
|
||||
* @next Success
|
||||
* @start
|
||||
* @next FirmwareRequest
|
||||
* @next Failure
|
||||
*/
|
||||
message FirmwareErase {
|
||||
optional uint32 length = 1; // length of new firmware
|
||||
@ -129,10 +132,11 @@ message FirmwareRequest {
|
||||
|
||||
/**
|
||||
* Request: Send firmware in binary form to the device
|
||||
* @next FirmwareRequest
|
||||
* @next Success
|
||||
* @next Failure
|
||||
*/
|
||||
message FirmwareUpload {
|
||||
message FirmwareUpload {
|
||||
required bytes payload = 1; // firmware to be loaded into device
|
||||
optional bytes hash = 2; // hash of the payload
|
||||
}
|
||||
|
@ -1,11 +0,0 @@
|
||||
/* Automatically generated nanopb constant definitions */
|
||||
/* Generated by nanopb-0.4.1 */
|
||||
|
||||
#include "types.pb.h"
|
||||
#if PB_PROTO_HEADER_VERSION != 40
|
||||
#error Regenerate this file with the current version of nanopb generator.
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
@ -1,42 +0,0 @@
|
||||
/* Automatically generated nanopb header */
|
||||
/* Generated by nanopb-0.4.1 */
|
||||
|
||||
#ifndef PB_TYPES_PB_H_INCLUDED
|
||||
#define PB_TYPES_PB_H_INCLUDED
|
||||
#include <pb.h>
|
||||
|
||||
#if PB_PROTO_HEADER_VERSION != 40
|
||||
#error Regenerate this file with the current version of nanopb generator.
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Enum definitions */
|
||||
typedef enum _FailureType {
|
||||
FailureType_Failure_UnexpectedMessage = 1,
|
||||
FailureType_Failure_ActionCancelled = 4,
|
||||
FailureType_Failure_DataError = 3,
|
||||
FailureType_Failure_ProcessError = 9
|
||||
} FailureType;
|
||||
|
||||
typedef enum _ButtonRequestType {
|
||||
ButtonRequestType_ButtonRequest_Other = 1
|
||||
} ButtonRequestType;
|
||||
|
||||
/* Helper constants for enums */
|
||||
#define _FailureType_MIN FailureType_Failure_UnexpectedMessage
|
||||
#define _FailureType_MAX FailureType_Failure_ProcessError
|
||||
#define _FailureType_ARRAYSIZE ((FailureType)(FailureType_Failure_ProcessError+1))
|
||||
|
||||
#define _ButtonRequestType_MIN ButtonRequestType_ButtonRequest_Other
|
||||
#define _ButtonRequestType_MAX ButtonRequestType_ButtonRequest_Other
|
||||
#define _ButtonRequestType_ARRAYSIZE ((ButtonRequestType)(ButtonRequestType_ButtonRequest_Other+1))
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,20 +0,0 @@
|
||||
syntax = "proto2";
|
||||
|
||||
/**
|
||||
* Type of failures returned by Failure message
|
||||
* @used_in Failure
|
||||
*/
|
||||
enum FailureType {
|
||||
Failure_UnexpectedMessage = 1;
|
||||
Failure_ActionCancelled = 4;
|
||||
Failure_DataError = 3;
|
||||
Failure_ProcessError = 9;
|
||||
}
|
||||
|
||||
/**
|
||||
* Type of button request
|
||||
* @used_in ButtonRequest
|
||||
*/
|
||||
enum ButtonRequestType {
|
||||
ButtonRequest_Other = 1;
|
||||
}
|
@ -18,7 +18,7 @@ PYTHON ?= python
|
||||
@printf " NANOPB $@\n"
|
||||
$(Q)nanopb_generator $< \
|
||||
-L '#include "%s"' \
|
||||
-T \
|
||||
-T -D . \
|
||||
-s "mangle_names:M_FLATTEN"
|
||||
@grep " CALLBACK, " $@ && echo "CALLBACK field found" && rm $@ && exit 1 || :
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user