1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-08-02 11:58:32 +00:00

fix(core): update sync protobuf messages in bootloader

This commit is contained in:
Pavol Rusnak 2021-02-09 16:10:23 +01:00 committed by matejcik
parent d475248ef1
commit f46380147f
4 changed files with 20 additions and 21 deletions

View File

@ -153,6 +153,8 @@ static secbool _send_msg(uint8_t iface_num, uint16_t msg_id,
} }
#define MSG_SEND_INIT(TYPE) TYPE msg_send = TYPE##_init_default #define MSG_SEND_INIT(TYPE) TYPE msg_send = TYPE##_init_default
#define MSG_SEND_ASSIGN_REQUIRED_VALUE(FIELD, VALUE) \
{ msg_send.FIELD = VALUE; }
#define MSG_SEND_ASSIGN_VALUE(FIELD, VALUE) \ #define MSG_SEND_ASSIGN_VALUE(FIELD, VALUE) \
{ \ { \
msg_send.has_##FIELD = true; \ msg_send.has_##FIELD = true; \
@ -281,9 +283,9 @@ static void send_msg_features(uint8_t iface_num,
const image_header *const hdr) { const image_header *const hdr) {
MSG_SEND_INIT(Features); MSG_SEND_INIT(Features);
MSG_SEND_ASSIGN_STRING(vendor, "trezor.io"); MSG_SEND_ASSIGN_STRING(vendor, "trezor.io");
MSG_SEND_ASSIGN_VALUE(major_version, VERSION_MAJOR); MSG_SEND_ASSIGN_REQUIRED_VALUE(major_version, VERSION_MAJOR);
MSG_SEND_ASSIGN_VALUE(minor_version, VERSION_MINOR); MSG_SEND_ASSIGN_REQUIRED_VALUE(minor_version, VERSION_MINOR);
MSG_SEND_ASSIGN_VALUE(patch_version, VERSION_PATCH); MSG_SEND_ASSIGN_REQUIRED_VALUE(patch_version, VERSION_PATCH);
MSG_SEND_ASSIGN_VALUE(bootloader_mode, true); MSG_SEND_ASSIGN_VALUE(bootloader_mode, true);
MSG_SEND_ASSIGN_STRING(model, "T"); MSG_SEND_ASSIGN_STRING(model, "T");
if (vhdr && hdr) { if (vhdr && hdr) {

View File

@ -1,5 +1,5 @@
/* Automatically generated nanopb constant definitions */ /* Automatically generated nanopb constant definitions */
/* Generated by nanopb-0.4.3 */ /* Generated by nanopb-0.4.4 */
#include "messages.pb.h" #include "messages.pb.h"
#if PB_PROTO_HEADER_VERSION != 40 #if PB_PROTO_HEADER_VERSION != 40

View File

@ -1,5 +1,5 @@
/* Automatically generated nanopb header */ /* Automatically generated nanopb header */
/* Generated by nanopb-0.4.3 */ /* Generated by nanopb-0.4.4 */
#ifndef PB_MESSAGES_PB_H_INCLUDED #ifndef PB_MESSAGES_PB_H_INCLUDED
#define PB_MESSAGES_PB_H_INCLUDED #define PB_MESSAGES_PB_H_INCLUDED
@ -65,11 +65,8 @@ typedef PB_BYTES_ARRAY_T(32) Features_fw_vendor_keys_t;
typedef struct _Features { typedef struct _Features {
bool has_vendor; bool has_vendor;
char vendor[33]; char vendor[33];
bool has_major_version;
uint32_t major_version; uint32_t major_version;
bool has_minor_version;
uint32_t minor_version; uint32_t minor_version;
bool has_patch_version;
uint32_t patch_version; uint32_t patch_version;
bool has_bootloader_mode; bool has_bootloader_mode;
bool bootloader_mode; bool bootloader_mode;
@ -150,7 +147,7 @@ extern "C" {
/* Initializer values for message structs */ /* Initializer values for message structs */
#define Initialize_init_default {0} #define Initialize_init_default {0}
#define GetFeatures_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 Features_init_default {false, "", 0, 0, 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, ""} #define Ping_init_default {false, ""}
#define Success_init_default {false, ""} #define Success_init_default {false, ""}
#define Failure_init_default {false, _FailureType_MIN, false, ""} #define Failure_init_default {false, _FailureType_MIN, false, ""}
@ -161,7 +158,7 @@ extern "C" {
#define FirmwareUpload_init_default {{{NULL}, NULL}, false, {0, {0}}} #define FirmwareUpload_init_default {{{NULL}, NULL}, false, {0, {0}}}
#define Initialize_init_zero {0} #define Initialize_init_zero {0}
#define GetFeatures_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 Features_init_zero {false, "", 0, 0, 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, ""} #define Ping_init_zero {false, ""}
#define Success_init_zero {false, ""} #define Success_init_zero {false, ""}
#define Failure_init_zero {false, _FailureType_MIN, false, ""} #define Failure_init_zero {false, _FailureType_MIN, false, ""}
@ -213,9 +210,9 @@ extern "C" {
#define Features_FIELDLIST(X, a) \ #define Features_FIELDLIST(X, a) \
X(a, STATIC, OPTIONAL, STRING, vendor, 1) \ X(a, STATIC, OPTIONAL, STRING, vendor, 1) \
X(a, STATIC, OPTIONAL, UINT32, major_version, 2) \ X(a, STATIC, REQUIRED, UINT32, major_version, 2) \
X(a, STATIC, OPTIONAL, UINT32, minor_version, 3) \ X(a, STATIC, REQUIRED, UINT32, minor_version, 3) \
X(a, STATIC, OPTIONAL, UINT32, patch_version, 4) \ X(a, STATIC, REQUIRED, UINT32, patch_version, 4) \
X(a, STATIC, OPTIONAL, BOOL, bootloader_mode, 5) \ X(a, STATIC, OPTIONAL, BOOL, bootloader_mode, 5) \
X(a, STATIC, OPTIONAL, STRING, device_id, 6) \ X(a, STATIC, OPTIONAL, STRING, device_id, 6) \
X(a, STATIC, OPTIONAL, STRING, language, 9) \ X(a, STATIC, OPTIONAL, STRING, language, 9) \
@ -235,12 +232,12 @@ X(a, STATIC, OPTIONAL, BYTES, fw_vendor_keys, 26)
#define Ping_FIELDLIST(X, a) \ #define Ping_FIELDLIST(X, a) \
X(a, STATIC, OPTIONAL, STRING, message, 1) X(a, STATIC, OPTIONAL, STRING, message, 1)
#define Ping_CALLBACK NULL #define Ping_CALLBACK NULL
#define Ping_DEFAULT NULL #define Ping_DEFAULT (const pb_byte_t*)"\x0a\x00\x00"
#define Success_FIELDLIST(X, a) \ #define Success_FIELDLIST(X, a) \
X(a, STATIC, OPTIONAL, STRING, message, 1) X(a, STATIC, OPTIONAL, STRING, message, 1)
#define Success_CALLBACK NULL #define Success_CALLBACK NULL
#define Success_DEFAULT NULL #define Success_DEFAULT (const pb_byte_t*)"\x0a\x00\x00"
#define Failure_FIELDLIST(X, a) \ #define Failure_FIELDLIST(X, a) \
X(a, STATIC, OPTIONAL, UENUM, code, 1) \ X(a, STATIC, OPTIONAL, UENUM, code, 1) \

View File

@ -40,9 +40,9 @@ message GetFeatures {
*/ */
message Features { message Features {
optional string vendor = 1; // name of the manufacturer, e.g. "trezor.io" optional string vendor = 1; // name of the manufacturer, e.g. "trezor.io"
optional uint32 major_version = 2; // major version of the firmware/bootloader, e.g. 1 required uint32 major_version = 2; // major version of the firmware/bootloader, e.g. 1
optional uint32 minor_version = 3; // minor version of the firmware/bootloader, e.g. 0 required uint32 minor_version = 3; // minor version of the firmware/bootloader, e.g. 0
optional uint32 patch_version = 4; // patch version of the firmware/bootloader, e.g. 0 required uint32 patch_version = 4; // patch version of the firmware/bootloader, e.g. 0
optional bool bootloader_mode = 5; // is device in bootloader mode? optional bool bootloader_mode = 5; // is device in bootloader mode?
optional string device_id = 6; // device's unique identifier optional string device_id = 6; // device's unique identifier
optional string language = 9; // device language optional string language = 9; // device language
@ -64,7 +64,7 @@ message Features {
* @next Success * @next Success
*/ */
message Ping { message Ping {
optional string message = 1; // message to send back in Success message optional string message = 1 [default=""]; // message to send back in Success message
} }
/** /**
@ -72,7 +72,7 @@ message Ping {
* @end * @end
*/ */
message Success { message Success {
optional string message = 1; // human readable description of action or request-specific payload optional string message = 1 [default=""]; // human readable description of action or request-specific payload
} }
/** /**
@ -136,7 +136,7 @@ message FirmwareRequest {
* @next Success * @next Success
* @next Failure * @next Failure
*/ */
message FirmwareUpload { message FirmwareUpload {
required bytes payload = 1; // firmware to be loaded into device required bytes payload = 1; // firmware to be loaded into device
optional bytes hash = 2; // hash of the payload optional bytes hash = 2; // hash of the payload
} }