1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 07:28:10 +00:00

fix(legacy): support Success and Failure for debuglink

This commit is contained in:
matejcik 2022-02-10 11:19:59 +01:00 committed by matejcik
parent 825ccd9df5
commit 310b6c5217
2 changed files with 8 additions and 9 deletions

View File

@ -79,8 +79,8 @@ enum MessageType {
// Management // Management
MessageType_Initialize = 0 [(bitcoin_only) = true, (wire_in) = true, (wire_tiny) = true]; MessageType_Initialize = 0 [(bitcoin_only) = true, (wire_in) = true, (wire_tiny) = true];
MessageType_Ping = 1 [(bitcoin_only) = true, (wire_in) = true]; MessageType_Ping = 1 [(bitcoin_only) = true, (wire_in) = true];
MessageType_Success = 2 [(bitcoin_only) = true, (wire_out) = true]; MessageType_Success = 2 [(bitcoin_only) = true, (wire_out) = true, (wire_debug_out) = true];
MessageType_Failure = 3 [(bitcoin_only) = true, (wire_out) = true]; MessageType_Failure = 3 [(bitcoin_only) = true, (wire_out) = true, (wire_debug_out) = true];
MessageType_ChangePin = 4 [(bitcoin_only) = true, (wire_in) = true]; MessageType_ChangePin = 4 [(bitcoin_only) = true, (wire_in) = true];
MessageType_WipeDevice = 5 [(bitcoin_only) = true, (wire_in) = true]; MessageType_WipeDevice = 5 [(bitcoin_only) = true, (wire_in) = true];
MessageType_GetEntropy = 9 [(bitcoin_only) = true, (wire_in) = true]; MessageType_GetEntropy = 9 [(bitcoin_only) = true, (wire_in) = true];

View File

@ -36,17 +36,16 @@ IFACE_DIR_PAIRS = {
SPECIAL_DEBUG_MESSAGES = {"MessageType_LoadDevice"} SPECIAL_DEBUG_MESSAGES = {"MessageType_LoadDevice"}
def get_wire_extension(message): def get_wire_extensions(message):
extensions = message.GetOptions().Extensions extensions = message.GetOptions().Extensions
return next(ext for ext in IFACE_DIR_PAIRS if extensions[ext]) return (ext for ext in IFACE_DIR_PAIRS if extensions[ext])
def handle_message(fh, fl, skipped, message): def handle_message(fh, fl, skipped, message, extension):
name = message.name name = message.name
short_name = name.split("MessageType_", 1).pop() short_name = name.split("MessageType_", 1).pop()
assert short_name != name assert short_name != name
extension = get_wire_extension(message)
interface, direction = IFACE_DIR_PAIRS[extension] interface, direction = IFACE_DIR_PAIRS[extension]
for s in skipped: for s in skipped:
@ -120,8 +119,8 @@ messages = defaultdict(list)
for message in MessageType.DESCRIPTOR.values: for message in MessageType.DESCRIPTOR.values:
if message.GetOptions().deprecated: if message.GetOptions().deprecated:
continue continue
extension = get_wire_extension(message) for extension in get_wire_extensions(message):
messages[extension].append(message) messages[extension].append(message)
for extension in (wire_in, wire_out, wire_debug_in, wire_debug_out): for extension in (wire_in, wire_out, wire_debug_in, wire_debug_out):
if extension == wire_debug_in: if extension == wire_debug_in:
@ -133,7 +132,7 @@ for extension in (wire_in, wire_out, wire_debug_in, wire_debug_out):
for message in messages[extension]: for message in messages[extension]:
if message.name in SPECIAL_DEBUG_MESSAGES: if message.name in SPECIAL_DEBUG_MESSAGES:
fh.write("#if DEBUG_LINK\n") fh.write("#if DEBUG_LINK\n")
handle_message(fh, fl, skipped, message) handle_message(fh, fl, skipped, message, extension)
if message.name in SPECIAL_DEBUG_MESSAGES: if message.name in SPECIAL_DEBUG_MESSAGES:
fh.write("#endif\n") fh.write("#endif\n")