load_and_start_firmware(bli, firmware_base) # Testing the device input('\n'.join(['1. Make sure that LED indicators are blinking', '2. Test button operation', '3. Press ENTER'])) # Installing signature with closing(bootloader.BootloaderInterface(args.iface)) as bli: info("Now we're going to sign the device") input('\n'.join(['1. Set PIO0_3 low, PIO0_1 low (J4 closed, J3 open)', '2. Reset the device (e.g. cycle power)', '3. Press ENTER'])) with CLIWaitCursor(): info('Reading unique ID...') unique_id = bli.read_unique_id() set_device_info(PRODUCT_NAME, unique_id) info('Requesting signature for unique ID %s', ' '.join(['%02x' % x for x in unique_id])) gensign_response = api.generate_signature(unique_id, PRODUCT_NAME) info('Signature has been generated successfully [%s], patching the firmware...', ['existing', 'NEW'][gensign_response.new]) firmware_with_signature = firmware_base.ljust(SIGNATURE_OFFSET, b'\xFF') + gensign_response.signature load_and_start_firmware(bli, firmware_with_signature) run(api, process_one_device)
'2. Test button operation', '3. Press ENTER' ])) # Installing signature with closing(bootloader.BootloaderInterface(args.iface)) as bli: info("Now we're going to sign the device") input('\n'.join([ '1. Set PIO0_3 low, PIO0_1 low (J4 closed, J3 open)', '2. Reset the device (e.g. cycle power)', '3. Press ENTER' ])) with CLIWaitCursor(): info('Reading unique ID...') unique_id = bli.read_unique_id() set_device_info(PRODUCT_NAME, unique_id) info('Requesting signature for unique ID %s', ' '.join(['%02x' % x for x in unique_id])) gensign_response = api.generate_signature(unique_id, PRODUCT_NAME) info( 'Signature has been generated successfully [%s], patching the firmware...', ['existing', 'NEW'][gensign_response.new]) firmware_with_signature = firmware_base.ljust( SIGNATURE_OFFSET, b'\xFF') + gensign_response.signature load_and_start_firmware(bli, firmware_with_signature) run(api, process_one_device)
try: # Using first command to get rid of any garbage lingering in the buffers cli.write_line_and_read_output_lines_until_timeout('systime') except Exception: pass # Getting the signature info('Requesting signature for unique ID %s', binascii.hexlify(unique_id).decode()) gensign_response = licensing_api.generate_signature(unique_id, PRODUCT_NAME) if gensign_response.new: info('New signature has been generated') else: info('This particular device has been signed earlier, reusing existing signature') base64_signature = b64encode(gensign_response.signature).decode() logger.info('Generated signature in Base64: %s', base64_signature) # Installing the signature; this may fail if the device has been signed earlier - the failure will be ignored out = cli.write_line_and_read_output_lines_until_timeout('zubax_id %s', base64_signature) logger.debug('Signature installation response (may fail, which is OK): %r', out) # Reading the signature back and verifying it installed_signature = read_zubax_id(cli)['hw_signature'] logger.info('Installed signature in Base64: %s', installed_signature) enforce(b64decode(installed_signature) == gensign_response.signature, 'Written signature does not match the generated signature') info('Signature has been installed and verified') run(licensing_api, process_one_device)
with CLIWaitCursor(): load_and_start_firmware(bli, firmware_base) # Testing the device input('\n'.join(['1. Make sure that LED indicators are blinking', '2. Test button operation', '3. Press ENTER'])) # Installing signature with closing(bootloader.BootloaderInterface(args.iface)) as bli: info("Now we're going to sign the device") input('\n'.join(['1. Set PIO0_3 low, PIO0_1 low (J4 closed, J3 open)', '2. Reset the device (e.g. cycle power)', '3. Press ENTER'])) with CLIWaitCursor(): info('Reading unique ID...') unique_id = bli.read_unique_id() info('Requesting signature for unique ID %s', ' '.join(['%02x' % x for x in unique_id])) gensign_response = api.generate_signature(unique_id, PRODUCT_NAME) info('Signature has been generated successfully [%s], patching the firmware...', ['existing', 'NEW'][gensign_response.new]) firmware_with_signature = firmware_base.ljust(SIGNATURE_OFFSET, b'\xFF') + gensign_response.signature load_and_start_firmware(bli, firmware_with_signature) run(process_one_device)