clear dispaly after usb failure - do not hang on Receiving...
This commit is contained in:
parent
66e4cf130f
commit
ae9806f702
@ -17,7 +17,8 @@ This lists the new changes that have not yet been published in a normal release.
|
||||
- cannot view or change the CCC spending policy once set, policy violations are not explained
|
||||
- existing multisig wallets can be used by importing the spending-policy-controlled key
|
||||
|
||||
- Enhancement: Add `Bitcoin Safe` option to `Export Wallet`
|
||||
- Enhancement: Add `Bitcoin Safe` option to `Export Wallet`
|
||||
- Bugfix: Hanging progress bar `Receiving...` after USB failure
|
||||
|
||||
|
||||
# Mk4 Specific Changes
|
||||
|
||||
@ -169,6 +169,7 @@ class USBHandler:
|
||||
msg_len = 0
|
||||
|
||||
while 1:
|
||||
success = False
|
||||
yield core._io_queue.queue_read(self.blockable)
|
||||
|
||||
try:
|
||||
@ -212,14 +213,12 @@ class USBHandler:
|
||||
# this saves memory over a simple slice (confirmed)
|
||||
args = memoryview(self.msg)[4:msg_len]
|
||||
resp = await self.handle(self.msg[0:4], args)
|
||||
msg_len = 0
|
||||
success = True
|
||||
except CCBusyError:
|
||||
# auth UX is doing something else
|
||||
resp = b'busy'
|
||||
msg_len = 0
|
||||
except HSMDenied:
|
||||
resp = b'err_Not allowed in HSM mode'
|
||||
msg_len = 0
|
||||
except HSMCMDDisabled:
|
||||
# do NOT change below error msg as other applications depend on it
|
||||
resp = b'err_HSM commands disabled'
|
||||
@ -227,16 +226,14 @@ class USBHandler:
|
||||
except (ValueError, AssertionError) as exc:
|
||||
# some limited invalid args feedback
|
||||
#print("USB request caused assert: ", end='')
|
||||
#sys.print_exception(exc)
|
||||
# sys.print_exception(exc)
|
||||
msg = str(exc)
|
||||
if not msg:
|
||||
msg = 'Assertion ' + problem_file_line(exc)
|
||||
resp = b'err_' + msg.encode()[0:80]
|
||||
msg_len = 0
|
||||
except MemoryError:
|
||||
# prefer to catch at higher layers, but sometimes can't
|
||||
resp = b'err_Out of RAM'
|
||||
msg_len = 0
|
||||
except FramingError as exc:
|
||||
raise exc
|
||||
except Exception as exc:
|
||||
@ -245,9 +242,15 @@ class USBHandler:
|
||||
print("USB request caused this: ", end='')
|
||||
sys.print_exception(exc)
|
||||
resp = b'err_Confused ' + problem_file_line(exc)
|
||||
msg_len = 0
|
||||
|
||||
# aways send a reply if they get this far
|
||||
if not success:
|
||||
# do not let the progress screen hang on "Receiving..."
|
||||
from ux import restore_menu
|
||||
restore_menu()
|
||||
|
||||
msg_len = 0
|
||||
|
||||
# always send a reply if they get this far
|
||||
await self.send_response(resp)
|
||||
|
||||
except FramingError as exc:
|
||||
|
||||
@ -172,7 +172,6 @@ def ux_poll_key():
|
||||
|
||||
return ch
|
||||
|
||||
|
||||
async def ux_show_story(msg, title=None, escape=None, sensitive=False,
|
||||
strict_escape=False, hint_icons=None):
|
||||
# show a big long string, and wait for XY to continue
|
||||
|
||||
@ -14,7 +14,7 @@ assert packed_len == FW_HEADER_SIZE
|
||||
def parse_hdr(hdr):
|
||||
return Header(**dict(zip(FWH_PY_VALUES.split(), struct.unpack(FWH_PY_FORMAT, hdr))))
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def upload_file(dev):
|
||||
def doit(data, pkt_len=2048):
|
||||
for pos in range(0, len(data), pkt_len):
|
||||
@ -91,28 +91,19 @@ def upgrade_by_sd(open_microsd, cap_story, pick_menu_item, goto_home, press_sele
|
||||
|
||||
@pytest.mark.parametrize('mode', ['compat', 'incompat'])
|
||||
@pytest.mark.parametrize('transport', ['sd', 'usb'])
|
||||
def test_hacky_upgrade(mode, cap_story, transport, dev, sim_exec, make_firmware, upload_file, sim_eval, upgrade_by_sd):
|
||||
|
||||
# manually: run this test on all Mark1 thru 3 simulators
|
||||
hw_label = eval(sim_eval('version.hw_label'))
|
||||
assert hw_label[0:2] in ['mk', 'q1']
|
||||
try:
|
||||
mkn = int(hw_label[2])
|
||||
except IndexError:
|
||||
mkn = "q1" # q1
|
||||
|
||||
print(f"Simulator is {hw_label}")
|
||||
def test_hacky_upgrade(mode, cap_story, transport, dev, sim_exec, make_firmware, upload_file,
|
||||
upgrade_by_sd, press_cancel, is_q1):
|
||||
|
||||
if mode == 'compat':
|
||||
data = make_firmware(mkn)
|
||||
data = make_firmware("q1" if is_q1 else 4)
|
||||
elif mode == 'incompat':
|
||||
with pytest.raises(RuntimeError) as err:
|
||||
if mkn == "q1":
|
||||
mkn = 4
|
||||
|
||||
make_firmware(mkn-1)
|
||||
assert "too big for our USB upgrades" in str(err)
|
||||
return
|
||||
if is_q1:
|
||||
data = make_firmware(4)
|
||||
else:
|
||||
with pytest.raises(RuntimeError) as err:
|
||||
make_firmware(3)
|
||||
assert "too big for our USB upgrades" in str(err)
|
||||
return
|
||||
|
||||
hdr = data[FW_HEADER_OFFSET:FW_HEADER_OFFSET+FW_HEADER_SIZE]
|
||||
|
||||
@ -139,6 +130,7 @@ def test_hacky_upgrade(mode, cap_story, transport, dev, sim_exec, make_firmware,
|
||||
|
||||
_, story = cap_story()
|
||||
assert "Install this new firmware?" in story
|
||||
press_cancel()
|
||||
# check data was uploaded verbatim (VERY SLOW)
|
||||
# for pos in range(0, cooked.firmware_length + 128, 128):
|
||||
# to_eval = f'from sflash import SF;SF.array[{pos}:{pos+128}]'
|
||||
@ -148,6 +140,6 @@ def test_hacky_upgrade(mode, cap_story, transport, dev, sim_exec, make_firmware,
|
||||
# assert a == hdr, f"wrong @ {pos}"
|
||||
# else:
|
||||
# assert a == data[pos:pos+128], repr(pos)
|
||||
|
||||
|
||||
|
||||
# EOF
|
||||
|
||||
Loading…
Reference in New Issue
Block a user