Skip to content

Commit

Permalink
tools: fix update script for early firmwares with less version-info
Browse files Browse the repository at this point in the history
Fix update script for firmwares which predate 'BOARD_TYPE', 'JADE_STATE'
and 'JADE_NETWORKS' version-info reply fields.
  • Loading branch information
JamieDriver committed Oct 10, 2023
1 parent 76ae7e4 commit c86e1a8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions update_jade_fw.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ def _delta_appropriate(fw):
# Download compressed firmware file from Firmware Server using 'requests'
def download_file(verinfo, release):
# Workout hw_target subdir
hw_target = {'JADE': 'jade', 'JADE_V1.1': 'jade1.1'}.get(verinfo['BOARD_TYPE'])
build_type = {'SB': '', 'DEV': 'dev'}.get(verinfo['JADE_FEATURES'])
board_type = verinfo.get("BOARD_TYPE")
features = verinfo.get("JADE_FEATURES")
hw_target = {'JADE': 'jade', 'JADE_V1.1': 'jade1.1'}.get(board_type if board_type else 'JADE')
build_type = {'SB': '', 'DEV': 'dev'}.get(features)
if hw_target is None or build_type is None:
logger.error(f'Unsupported hardware: {verinfo["BOARD_TYPE"]} / {verinfo["JADE_FEATURES"]}')
logger.error(f'Unsupported hardware: {board_type} / {features}')
return None, None, None, None
hw_target += build_type

Expand Down Expand Up @@ -150,7 +152,7 @@ def ota(jade, verinfo, fwcompressed, fwlength, fwhash, patchlen=None):
chunksize = int(verinfo['JADE_OTA_MAX_CHUNK'])
assert chunksize > 0

if verinfo['JADE_STATE'] not in ['READY', 'UNINIT']:
if verinfo.get('JADE_STATE') not in ['READY', 'UNINIT']:
# The network to use is deduced from the version-info
print('Please ensure Jade is unlocked')
network = 'testnet' if verinfo.get('JADE_NETWORKS') == 'TEST' else 'mainnet'
Expand Down

0 comments on commit c86e1a8

Please sign in to comment.