tools: add vtrust parsing to binctl

This commit is contained in:
Pavol Rusnak 2018-01-28 11:24:50 +01:00
parent 1b712a0446
commit 7bbcd99d53
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
1 changed files with 12 additions and 1 deletions

View File

@ -18,7 +18,18 @@ def format_sigmask(sigmask):
def format_vtrust(vtrust):
bits = [str(b) if vtrust & (1 << b) == 0 else '.' for b in range(16)]
return '%d = [%s]' % (vtrust, ' '.join(bits))
# see docs/bootloader.md for vtrust constants
desc = ''
wait = (vtrust & 0x000F) ^ 0x000F
if wait > 0:
desc = 'WAIT_%d' % wait
if vtrust & 0x0010 == 0:
desc += ' RED'
if vtrust & 0x0020 == 0:
desc += ' CLICK'
if vtrust & 0x0040 == 0:
desc += ' STRING'
return '%d = [%s] = [%s]' % (vtrust, ' '.join(bits), desc)
# bootloader/firmware headers specification: https://github.com/trezor/trezor-core/blob/master/docs/bootloader.md