diff --git a/core/embed/bootloader/protob/messages.options b/core/embed/bootloader/protob/messages.options index 90ae4abff9..8630df2adb 100644 --- a/core/embed/bootloader/protob/messages.options +++ b/core/embed/bootloader/protob/messages.options @@ -3,7 +3,6 @@ Features.device_id max_size:25 Features.language max_size:17 Features.label max_size:33 Features.revision max_size:20 -Features.bootloader_hash max_size:32 Features.model max_size:17 Features.fw_vendor max_size:256 Features.fw_vendor_keys max_size:32 diff --git a/core/embed/bootloader/protob/messages.pb.c b/core/embed/bootloader/protob/messages.pb.c index 295fe2dbc5..63076e9ccb 100644 --- a/core/embed/bootloader/protob/messages.pb.c +++ b/core/embed/bootloader/protob/messages.pb.c @@ -1,95 +1,43 @@ /* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.3.9.4 */ +/* Generated by nanopb-0.4.1 */ #include "messages.pb.h" - -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 +#if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif +PB_BIND(Initialize, Initialize, AUTO) -const pb_field_t Initialize_fields[1] = { - PB_LAST_FIELD -}; +PB_BIND(GetFeatures, GetFeatures, AUTO) -const pb_field_t GetFeatures_fields[1] = { - PB_LAST_FIELD -}; -const pb_field_t Features_fields[18] = { - PB_FIELD( 1, STRING , OPTIONAL, STATIC , FIRST, Features, vendor, vendor, 0), - PB_FIELD( 2, UINT32 , OPTIONAL, STATIC , OTHER, Features, major_version, vendor, 0), - PB_FIELD( 3, UINT32 , OPTIONAL, STATIC , OTHER, Features, minor_version, major_version, 0), - PB_FIELD( 4, UINT32 , OPTIONAL, STATIC , OTHER, Features, patch_version, minor_version, 0), - PB_FIELD( 5, BOOL , OPTIONAL, STATIC , OTHER, Features, bootloader_mode, patch_version, 0), - PB_FIELD( 6, STRING , OPTIONAL, STATIC , OTHER, Features, device_id, bootloader_mode, 0), - PB_FIELD( 9, STRING , OPTIONAL, STATIC , OTHER, Features, language, device_id, 0), - PB_FIELD( 10, STRING , OPTIONAL, STATIC , OTHER, Features, label, language, 0), - PB_FIELD( 12, BOOL , OPTIONAL, STATIC , OTHER, Features, initialized, label, 0), - PB_FIELD( 13, BYTES , OPTIONAL, STATIC , OTHER, Features, revision, initialized, 0), - PB_FIELD( 18, BOOL , OPTIONAL, STATIC , OTHER, Features, firmware_present, revision, 0), - PB_FIELD( 21, STRING , OPTIONAL, STATIC , OTHER, Features, model, firmware_present, 0), - PB_FIELD( 22, UINT32 , OPTIONAL, STATIC , OTHER, Features, fw_major, model, 0), - PB_FIELD( 23, UINT32 , OPTIONAL, STATIC , OTHER, Features, fw_minor, fw_major, 0), - PB_FIELD( 24, UINT32 , OPTIONAL, STATIC , OTHER, Features, fw_patch, fw_minor, 0), - PB_FIELD( 25, STRING , OPTIONAL, STATIC , OTHER, Features, fw_vendor, fw_patch, 0), - PB_FIELD( 26, BYTES , OPTIONAL, STATIC , OTHER, Features, fw_vendor_keys, fw_vendor, 0), - PB_LAST_FIELD -}; +PB_BIND(Features, Features, 2) -const pb_field_t Ping_fields[5] = { - PB_FIELD( 1, STRING , OPTIONAL, STATIC , FIRST, Ping, message, message, 0), - PB_FIELD( 2, BOOL , OPTIONAL, STATIC , OTHER, Ping, button_protection, message, 0), - PB_FIELD( 3, BOOL , OPTIONAL, STATIC , OTHER, Ping, pin_protection, button_protection, 0), - PB_FIELD( 4, BOOL , OPTIONAL, STATIC , OTHER, Ping, passphrase_protection, pin_protection, 0), - PB_LAST_FIELD -}; -const pb_field_t Success_fields[2] = { - PB_FIELD( 1, STRING , OPTIONAL, STATIC , FIRST, Success, message, message, 0), - PB_LAST_FIELD -}; +PB_BIND(Ping, Ping, 2) -const pb_field_t Failure_fields[3] = { - PB_FIELD( 1, ENUM , OPTIONAL, STATIC , FIRST, Failure, code, code, 0), - PB_FIELD( 2, STRING , OPTIONAL, STATIC , OTHER, Failure, message, code, 0), - PB_LAST_FIELD -}; -const pb_field_t ButtonRequest_fields[2] = { - PB_FIELD( 1, ENUM , OPTIONAL, STATIC , FIRST, ButtonRequest, code, code, 0), - PB_LAST_FIELD -}; +PB_BIND(Success, Success, 2) -const pb_field_t ButtonAck_fields[1] = { - PB_LAST_FIELD -}; -const pb_field_t FirmwareErase_fields[2] = { - PB_FIELD( 1, UINT32 , OPTIONAL, STATIC , FIRST, FirmwareErase, length, length, 0), - PB_LAST_FIELD -}; +PB_BIND(Failure, Failure, 2) -const pb_field_t FirmwareRequest_fields[3] = { - PB_FIELD( 1, UINT32 , OPTIONAL, STATIC , FIRST, FirmwareRequest, offset, offset, 0), - PB_FIELD( 2, UINT32 , OPTIONAL, STATIC , OTHER, FirmwareRequest, length, offset, 0), - PB_LAST_FIELD -}; -const pb_field_t FirmwareUpload_fields[3] = { - PB_FIELD( 1, BYTES , REQUIRED, CALLBACK, FIRST, FirmwareUpload, payload, payload, 0), - PB_FIELD( 2, BYTES , OPTIONAL, STATIC , OTHER, FirmwareUpload, hash, payload, 0), - PB_LAST_FIELD -}; +PB_BIND(ButtonRequest, ButtonRequest, AUTO) + + +PB_BIND(ButtonAck, ButtonAck, AUTO) + + +PB_BIND(FirmwareErase, FirmwareErase, AUTO) + + +PB_BIND(FirmwareRequest, FirmwareRequest, AUTO) + + +PB_BIND(FirmwareUpload, FirmwareUpload, AUTO) -/* Check that field information fits in pb_field_t */ -#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) -#error Field descriptor for Failure.message is too large. Define PB_FIELD_16BIT to fix this. -#endif - -/* @@protoc_insertion_point(eof) */ diff --git a/core/embed/bootloader/protob/messages.pb.h b/core/embed/bootloader/protob/messages.pb.h index 8ebc696733..a06349064a 100644 --- a/core/embed/bootloader/protob/messages.pb.h +++ b/core/embed/bootloader/protob/messages.pb.h @@ -1,14 +1,12 @@ /* Automatically generated nanopb header */ -/* Generated by nanopb-0.3.9.4 */ +/* Generated by nanopb-0.4.1 */ #ifndef PB_MESSAGES_PB_H_INCLUDED #define PB_MESSAGES_PB_H_INCLUDED #include - #include "types.pb.h" -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 +#if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif @@ -30,30 +28,23 @@ typedef enum _MessageType { MessageType_MessageType_ButtonAck = 27, MessageType_MessageType_GetFeatures = 55 } MessageType; -#define _MessageType_MIN MessageType_MessageType_Initialize -#define _MessageType_MAX MessageType_MessageType_GetFeatures -#define _MessageType_ARRAYSIZE ((MessageType)(MessageType_MessageType_GetFeatures+1)) /* Struct definitions */ typedef struct _ButtonAck { char dummy_field; -/* @@protoc_insertion_point(struct:ButtonAck) */ } ButtonAck; typedef struct _GetFeatures { char dummy_field; -/* @@protoc_insertion_point(struct:GetFeatures) */ } GetFeatures; typedef struct _Initialize { char dummy_field; -/* @@protoc_insertion_point(struct:Initialize) */ } Initialize; typedef struct _ButtonRequest { bool has_code; ButtonRequestType code; -/* @@protoc_insertion_point(struct:ButtonRequest) */ } ButtonRequest; typedef struct _Failure { @@ -61,7 +52,6 @@ typedef struct _Failure { FailureType code; bool has_message; char message[256]; -/* @@protoc_insertion_point(struct:Failure) */ } Failure; typedef PB_BYTES_ARRAY_T(20) Features_revision_t; @@ -101,13 +91,11 @@ typedef struct _Features { char fw_vendor[256]; bool has_fw_vendor_keys; Features_fw_vendor_keys_t fw_vendor_keys; -/* @@protoc_insertion_point(struct:Features) */ } Features; typedef struct _FirmwareErase { bool has_length; uint32_t length; -/* @@protoc_insertion_point(struct:FirmwareErase) */ } FirmwareErase; typedef struct _FirmwareRequest { @@ -115,7 +103,6 @@ typedef struct _FirmwareRequest { uint32_t offset; bool has_length; uint32_t length; -/* @@protoc_insertion_point(struct:FirmwareRequest) */ } FirmwareRequest; typedef PB_BYTES_ARRAY_T(32) FirmwareUpload_hash_t; @@ -123,7 +110,6 @@ typedef struct _FirmwareUpload { pb_callback_t payload; bool has_hash; FirmwareUpload_hash_t hash; -/* @@protoc_insertion_point(struct:FirmwareUpload) */ } FirmwareUpload; typedef struct _Ping { @@ -135,16 +121,19 @@ typedef struct _Ping { bool pin_protection; bool has_passphrase_protection; bool passphrase_protection; -/* @@protoc_insertion_point(struct:Ping) */ } Ping; typedef struct _Success { bool has_message; char message[256]; -/* @@protoc_insertion_point(struct:Success) */ } Success; -/* Default values for struct fields */ + +/* Helper constants for enums */ +#define _MessageType_MIN MessageType_MessageType_Initialize +#define _MessageType_MAX MessageType_MessageType_GetFeatures +#define _MessageType_ARRAYSIZE ((MessageType)(MessageType_MessageType_GetFeatures+1)) + /* Initializer values for message structs */ #define Initialize_init_default {0} @@ -203,42 +192,123 @@ typedef struct _Success { #define Success_message_tag 1 /* Struct field encoding specification for nanopb */ -extern const pb_field_t Initialize_fields[1]; -extern const pb_field_t GetFeatures_fields[1]; -extern const pb_field_t Features_fields[18]; -extern const pb_field_t Ping_fields[5]; -extern const pb_field_t Success_fields[2]; -extern const pb_field_t Failure_fields[3]; -extern const pb_field_t ButtonRequest_fields[2]; -extern const pb_field_t ButtonAck_fields[1]; -extern const pb_field_t FirmwareErase_fields[2]; -extern const pb_field_t FirmwareRequest_fields[3]; -extern const pb_field_t FirmwareUpload_fields[3]; +#define Initialize_FIELDLIST(X, a) \ + +#define Initialize_CALLBACK NULL +#define Initialize_DEFAULT NULL + +#define GetFeatures_FIELDLIST(X, a) \ + +#define GetFeatures_CALLBACK NULL +#define GetFeatures_DEFAULT NULL + +#define Features_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, STRING, vendor, 1) \ +X(a, STATIC, OPTIONAL, UINT32, major_version, 2) \ +X(a, STATIC, OPTIONAL, UINT32, minor_version, 3) \ +X(a, STATIC, OPTIONAL, UINT32, patch_version, 4) \ +X(a, STATIC, OPTIONAL, BOOL, bootloader_mode, 5) \ +X(a, STATIC, OPTIONAL, STRING, device_id, 6) \ +X(a, STATIC, OPTIONAL, STRING, language, 9) \ +X(a, STATIC, OPTIONAL, STRING, label, 10) \ +X(a, STATIC, OPTIONAL, BOOL, initialized, 12) \ +X(a, STATIC, OPTIONAL, BYTES, revision, 13) \ +X(a, STATIC, OPTIONAL, BOOL, firmware_present, 18) \ +X(a, STATIC, OPTIONAL, STRING, model, 21) \ +X(a, STATIC, OPTIONAL, UINT32, fw_major, 22) \ +X(a, STATIC, OPTIONAL, UINT32, fw_minor, 23) \ +X(a, STATIC, OPTIONAL, UINT32, fw_patch, 24) \ +X(a, STATIC, OPTIONAL, STRING, fw_vendor, 25) \ +X(a, STATIC, OPTIONAL, BYTES, fw_vendor_keys, 26) +#define Features_CALLBACK NULL +#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) +#define Ping_CALLBACK NULL +#define Ping_DEFAULT NULL + +#define Success_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, STRING, message, 1) +#define Success_CALLBACK NULL +#define Success_DEFAULT NULL + +#define Failure_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, ENUM, 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) +#define ButtonRequest_CALLBACK NULL +#define ButtonRequest_DEFAULT NULL + +#define ButtonAck_FIELDLIST(X, a) \ + +#define ButtonAck_CALLBACK NULL +#define ButtonAck_DEFAULT NULL + +#define FirmwareErase_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, UINT32, length, 1) +#define FirmwareErase_CALLBACK NULL +#define FirmwareErase_DEFAULT NULL + +#define FirmwareRequest_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, UINT32, offset, 1) \ +X(a, STATIC, OPTIONAL, UINT32, length, 2) +#define FirmwareRequest_CALLBACK NULL +#define FirmwareRequest_DEFAULT NULL + +#define FirmwareUpload_FIELDLIST(X, a) \ +X(a, CALLBACK, REQUIRED, BYTES, payload, 1) \ +X(a, STATIC, OPTIONAL, BYTES, hash, 2) +#define FirmwareUpload_CALLBACK pb_default_field_callback +#define FirmwareUpload_DEFAULT NULL + +extern const pb_msgdesc_t Initialize_msg; +extern const pb_msgdesc_t GetFeatures_msg; +extern const pb_msgdesc_t Features_msg; +extern const pb_msgdesc_t Ping_msg; +extern const pb_msgdesc_t Success_msg; +extern const pb_msgdesc_t Failure_msg; +extern const pb_msgdesc_t ButtonRequest_msg; +extern const pb_msgdesc_t ButtonAck_msg; +extern const pb_msgdesc_t FirmwareErase_msg; +extern const pb_msgdesc_t FirmwareRequest_msg; +extern const pb_msgdesc_t FirmwareUpload_msg; + +/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ +#define Initialize_fields &Initialize_msg +#define GetFeatures_fields &GetFeatures_msg +#define Features_fields &Features_msg +#define Ping_fields &Ping_msg +#define Success_fields &Success_msg +#define Failure_fields &Failure_msg +#define ButtonRequest_fields &ButtonRequest_msg +#define ButtonAck_fields &ButtonAck_msg +#define FirmwareErase_fields &FirmwareErase_msg +#define FirmwareRequest_fields &FirmwareRequest_msg +#define FirmwareUpload_fields &FirmwareUpload_msg /* Maximum encoded size of messages (where known) */ #define Initialize_size 0 #define GetFeatures_size 0 -#define Features_size 499 -#define Ping_size 265 -#define Success_size 259 -#define Failure_size 270 +#define Features_size 493 +#define Ping_size 264 +#define Success_size 258 +#define Failure_size 269 #define ButtonRequest_size 11 #define ButtonAck_size 0 #define FirmwareErase_size 6 #define FirmwareRequest_size 12 /* FirmwareUpload_size depends on runtime parameters */ -/* Message IDs (where set with "msgid" option) */ -#ifdef PB_MSGID - -#define MESSAGES_MESSAGES \ - - -#endif - #ifdef __cplusplus } /* extern "C" */ #endif -/* @@protoc_insertion_point(eof) */ #endif diff --git a/core/embed/bootloader/protob/messages.proto b/core/embed/bootloader/protob/messages.proto index 3bbc356e22..ff0ac993ad 100644 --- a/core/embed/bootloader/protob/messages.proto +++ b/core/embed/bootloader/protob/messages.proto @@ -1,3 +1,5 @@ +syntax = "proto2"; + import "types.proto"; /** diff --git a/core/embed/bootloader/protob/types.pb.c b/core/embed/bootloader/protob/types.pb.c index dee641e327..651020e110 100644 --- a/core/embed/bootloader/protob/types.pb.c +++ b/core/embed/bootloader/protob/types.pb.c @@ -1,16 +1,11 @@ /* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.4.0-dev */ +/* Generated by nanopb-0.4.1 */ #include "types.pb.h" - -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 +#if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif - - -/* @@protoc_insertion_point(eof) */ diff --git a/core/embed/bootloader/protob/types.pb.h b/core/embed/bootloader/protob/types.pb.h index 579782dbc3..4930b31815 100644 --- a/core/embed/bootloader/protob/types.pb.h +++ b/core/embed/bootloader/protob/types.pb.h @@ -1,12 +1,11 @@ /* Automatically generated nanopb header */ -/* Generated by nanopb-0.4.0-dev */ +/* Generated by nanopb-0.4.1 */ #ifndef PB_TYPES_PB_H_INCLUDED #define PB_TYPES_PB_H_INCLUDED #include -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 +#if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif @@ -17,42 +16,27 @@ extern "C" { /* Enum definitions */ typedef enum _FailureType { FailureType_Failure_UnexpectedMessage = 1, - FailureType_Failure_ButtonExpected = 2, - FailureType_Failure_DataError = 3, FailureType_Failure_ActionCancelled = 4, - FailureType_Failure_PinExpected = 5, - FailureType_Failure_PinCancelled = 6, - FailureType_Failure_PinInvalid = 7, - FailureType_Failure_InvalidSignature = 8, - FailureType_Failure_ProcessError = 9, - FailureType_Failure_NotEnoughFunds = 10, - FailureType_Failure_NotInitialized = 11, - FailureType_Failure_FirmwareError = 99 + FailureType_Failure_DataError = 3, + FailureType_Failure_ProcessError = 9 } FailureType; -#define _FailureType_MIN FailureType_Failure_UnexpectedMessage -#define _FailureType_MAX FailureType_Failure_FirmwareError -#define _FailureType_ARRAYSIZE ((FailureType)(FailureType_Failure_FirmwareError+1)) typedef enum _ButtonRequestType { - ButtonRequestType_ButtonRequest_Other = 1, - ButtonRequestType_ButtonRequest_FeeOverThreshold = 2, - ButtonRequestType_ButtonRequest_ConfirmOutput = 3, - ButtonRequestType_ButtonRequest_ResetDevice = 4, - ButtonRequestType_ButtonRequest_ConfirmWord = 5, - ButtonRequestType_ButtonRequest_WipeDevice = 6, - ButtonRequestType_ButtonRequest_ProtectCall = 7, - ButtonRequestType_ButtonRequest_SignTx = 8, - ButtonRequestType_ButtonRequest_FirmwareCheck = 9, - ButtonRequestType_ButtonRequest_Address = 10, - ButtonRequestType_ButtonRequest_PublicKey = 11 + 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_PublicKey -#define _ButtonRequestType_ARRAYSIZE ((ButtonRequestType)(ButtonRequestType_ButtonRequest_PublicKey+1)) +#define _ButtonRequestType_MAX ButtonRequestType_ButtonRequest_Other +#define _ButtonRequestType_ARRAYSIZE ((ButtonRequestType)(ButtonRequestType_ButtonRequest_Other+1)) + #ifdef __cplusplus } /* extern "C" */ #endif -/* @@protoc_insertion_point(eof) */ #endif diff --git a/core/embed/bootloader/protob/types.proto b/core/embed/bootloader/protob/types.proto index c8ffdc12ba..d44a47ab1a 100644 --- a/core/embed/bootloader/protob/types.proto +++ b/core/embed/bootloader/protob/types.proto @@ -1,20 +1,14 @@ +syntax = "proto2"; + /** * Type of failures returned by Failure message * @used_in Failure */ enum FailureType { Failure_UnexpectedMessage = 1; - Failure_ButtonExpected = 2; - Failure_DataError = 3; Failure_ActionCancelled = 4; - Failure_PinExpected = 5; - Failure_PinCancelled = 6; - Failure_PinInvalid = 7; - Failure_InvalidSignature = 8; + Failure_DataError = 3; Failure_ProcessError = 9; - Failure_NotEnoughFunds = 10; - Failure_NotInitialized = 11; - Failure_FirmwareError = 99; } /** @@ -23,14 +17,4 @@ enum FailureType { */ enum ButtonRequestType { ButtonRequest_Other = 1; - ButtonRequest_FeeOverThreshold = 2; - ButtonRequest_ConfirmOutput = 3; - ButtonRequest_ResetDevice = 4; - ButtonRequest_ConfirmWord = 5; - ButtonRequest_WipeDevice = 6; - ButtonRequest_ProtectCall = 7; - ButtonRequest_SignTx = 8; - ButtonRequest_FirmwareCheck = 9; - ButtonRequest_Address = 10; - ButtonRequest_PublicKey = 11; }