Skip to content

Commit a6bbc16

Browse files
committed
protobuf: add reboot purpose
The user will be able to reboot into the bootloader for multiple reasons: - Upgrade device (default, backwards compatible) - Going to the startup settings, to change e.g. the setting to display the firmware hash at boot
1 parent 5cd2bb3 commit a6bbc16

File tree

6 files changed

+94
-3
lines changed

6 files changed

+94
-3
lines changed

messages/system.proto

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,9 @@ syntax = "proto3";
1616
package shiftcrypto.bitbox02;
1717

1818
message RebootRequest {
19-
19+
enum Purpose {
20+
UPGRADE = 0;
21+
SETTINGS = 1;
22+
}
23+
Purpose purpose = 1;
2024
}

py/bitbox02/bitbox02/bitbox02/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,6 @@
5454
btc,
5555
common,
5656
eth,
57+
system,
5758
)
5859
from .bootloader import Bootloader

py/bitbox02/bitbox02/bitbox02/bitbox02.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@
4444
from bitbox02.communication.generated import common_pb2 as common
4545
from bitbox02.communication.generated import keystore_pb2 as keystore
4646
from bitbox02.communication.generated import antiklepto_pb2 as antiklepto
47+
48+
# pylint: disable=unused-import
49+
# We export it in __init__.py
50+
from bitbox02.communication.generated import system_pb2 as system
4751
except ModuleNotFoundError:
4852
print("Run `make py` to generate the protobuf messages")
4953
sys.exit()

py/bitbox02/bitbox02/communication/generated/system_pb2.py

Lines changed: 34 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,54 @@
11
# @generated by generate_proto_mypy_stubs.py. Do not edit!
22
import sys
3+
from google.protobuf.descriptor import (
4+
EnumDescriptor as google___protobuf___descriptor___EnumDescriptor,
5+
)
6+
37
from google.protobuf.message import (
48
Message as google___protobuf___message___Message,
59
)
610

11+
from typing import (
12+
List as typing___List,
13+
Optional as typing___Optional,
14+
Tuple as typing___Tuple,
15+
cast as typing___cast,
16+
)
17+
18+
from typing_extensions import (
19+
Literal as typing_extensions___Literal,
20+
)
21+
722

823
class RebootRequest(google___protobuf___message___Message):
24+
class Purpose(int):
25+
DESCRIPTOR: google___protobuf___descriptor___EnumDescriptor = ...
26+
@classmethod
27+
def Name(cls, number: int) -> str: ...
28+
@classmethod
29+
def Value(cls, name: str) -> RebootRequest.Purpose: ...
30+
@classmethod
31+
def keys(cls) -> typing___List[str]: ...
32+
@classmethod
33+
def values(cls) -> typing___List[RebootRequest.Purpose]: ...
34+
@classmethod
35+
def items(cls) -> typing___List[typing___Tuple[str, RebootRequest.Purpose]]: ...
36+
UPGRADE = typing___cast(RebootRequest.Purpose, 0)
37+
SETTINGS = typing___cast(RebootRequest.Purpose, 1)
38+
UPGRADE = typing___cast(RebootRequest.Purpose, 0)
39+
SETTINGS = typing___cast(RebootRequest.Purpose, 1)
40+
41+
purpose = ... # type: RebootRequest.Purpose
942

1043
def __init__(self,
44+
*,
45+
purpose : typing___Optional[RebootRequest.Purpose] = None,
1146
) -> None: ...
1247
@classmethod
1348
def FromString(cls, s: bytes) -> RebootRequest: ...
1449
def MergeFrom(self, other_msg: google___protobuf___message___Message) -> None: ...
1550
def CopyFrom(self, other_msg: google___protobuf___message___Message) -> None: ...
51+
if sys.version_info >= (3,):
52+
def ClearField(self, field_name: typing_extensions___Literal[u"purpose"]) -> None: ...
53+
else:
54+
def ClearField(self, field_name: typing_extensions___Literal[u"purpose",b"purpose"]) -> None: ...

src/rust/bitbox02-rust/src/shiftcrypto.bitbox02.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,17 @@ pub struct RandomNumberRequest {
744744
}
745745
#[derive(Clone, PartialEq, ::prost::Message)]
746746
pub struct RebootRequest {
747+
#[prost(enumeration="reboot_request::Purpose", tag="1")]
748+
pub purpose: i32,
749+
}
750+
/// Nested message and enum types in `RebootRequest`.
751+
pub mod reboot_request {
752+
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
753+
#[repr(i32)]
754+
pub enum Purpose {
755+
Upgrade = 0,
756+
Settings = 1,
757+
}
747758
}
748759
/// Deprecated, last used in v1.0.0
749760
#[derive(Clone, PartialEq, ::prost::Message)]

0 commit comments

Comments
 (0)