def generate(hex_file, family, application, application_version, application_version_string, bootloader_version, bl_settings_version, start_address, no_backup, backup_address): # Initial consistency checks if family is None: click.echo("Error: IC Family required.") return # The user can specify the application version with two different # formats. As an integer, e.g. 102130, or as a string # "10.21.30". Internally we convert to integer. if application_version_string: application_version_internal = convert_version_string_to_int(application_version_string) else: application_version_internal = application_version if application is not None: if not os.path.isfile(application): click.echo("Error: Application file not found.") return if application_version_internal is None: click.echo("Error: Application version required.") return if bootloader_version is None: click.echo("Error: Bootloader version required.") return if bl_settings_version is None: click.echo("Error: Bootloader DFU settings version required.") return if (no_backup is not None) and (backup_address is not None): click.echo("Error: Bootloader DFU settings backup page cannot be specified if backup is disabled.") return if no_backup is None: no_backup = False if no_backup == False: display_settings_backup_warning() if (start_address is not None) and (backup_address is None): click.echo("WARNING: Using default offset in order to calculate bootloader settings backup page") sett = BLDFUSettings() sett.generate(arch=family, app_file=application, app_ver=application_version_internal, bl_ver=bootloader_version, bl_sett_ver=bl_settings_version, custom_bl_sett_addr=start_address, no_backup=no_backup, backup_address=backup_address) sett.tohexfile(hex_file) click.echo("\nGenerated Bootloader DFU settings .hex file and stored it in: {}".format(hex_file)) click.echo("{0}".format(str(sett)))
def generate(hex_file, family, application, application_version, application_version_string, bootloader_version, bl_settings_version, start_address): # Initial consistency checks if family is None: click.echo("Error: IC Family required.") return # The user can specify the application version with two different # formats. As an integer, e.g. 102130, or as a string # "10.21.30". Internally we convert to integer. if application_version_string: application_version_internal = convert_version_string_to_int( application_version_string) else: application_version_internal = application_version if application is not None: if not os.path.isfile(application): click.echo("Error: Application file not found.") return if application_version_internal is None: click.echo("Error: Application version required.") return if bootloader_version is None: click.echo("Error: Bootloader version required.") return if bl_settings_version is None: click.echo("Error: Bootloader DFU settings version required.") return sett = BLDFUSettings() sett.generate(arch=family, app_file=application, app_ver=application_version_internal, bl_ver=bootloader_version, bl_sett_ver=bl_settings_version, custom_bl_sett_addr=start_address) sett.tohexfile(hex_file) click.echo( "\nGenerated Bootloader DFU settings .hex file and stored it in: {}". format(hex_file)) click.echo("{0}".format(str(sett)))
def generate(hex_file, family, application, application_version, application_version_string, bootloader_version, bl_settings_version): # Initial consistency checks if family is None: click.echo("Error: IC Family required.") return # The user can specify the application version with two different # formats. As an integer, e.g. 102130, or as a string # "10.21.30". Internally we convert to integer. if application_version_string: application_version_internal = convert_version_string_to_int(application_version_string) else: application_version_internal = application_version if application is not None: if not os.path.isfile(application): click.echo("Error: Application file not found.") return if application_version_internal is None: click.echo("Error: Application version required.") return if bootloader_version is None: click.echo("Error: Bootloader version required.") return if bl_settings_version is None: click.echo("Error: Bootloader DFU settings version required.") return sett = BLDFUSettings() sett.generate(arch=family, app_file=application, app_ver=application_version_internal, bl_ver=bootloader_version, bl_sett_ver=bl_settings_version) sett.tohexfile(hex_file) click.echo("\nGenerated Bootloader DFU settings .hex file and stored it in: {}".format(hex_file)) click.echo("{0}".format(str(sett)))
def generate(hex_file, family, application, application_version, bootloader_version, bl_settings_version): # Initial consistency checks if family is None: click.echo("Error: IC Family required.") return if application is not None: if not os.path.isfile(application): click.echo("Error: Application file not found.") return if application_version is None: click.echo("Error: Application version required.") return if bootloader_version is None: click.echo("Error: Bootloader version required.") return if bl_settings_version is None: click.echo("Error: Bootloader DFU settings version required.") return sett = BLDFUSettings() sett.generate(arch=family, app_file=application, app_ver=application_version, bl_ver=bootloader_version, bl_sett_ver=bl_settings_version) sett.tohexfile(hex_file) click.echo( "\nGenerated Bootloader DFU settings .hex file and stored it in: {}". format(hex_file)) click.echo("{0}".format(str(sett)))
def generate(hex_file, family, application, application_version, application_version_string, bootloader_version, bl_settings_version, start_address, no_backup, backup_address, app_boot_validation, sd_boot_validation, softdevice, key_file): # The user can specify the application version with two different # formats. As an integer, e.g. 102130, or as a string # "10.21.30". Internally we convert to integer. if application_version_string: application_version_internal = convert_version_string_to_int( application_version_string) if application_version: click.echo( 'Warning: When both application-version-string and application-version are provided, only the string will be used.' ) else: application_version_internal = application_version if application is not None: if not os.path.isfile(application): raise click.FileError(application, hint="Application file not found") if application_version_internal is None: raise click.UsageError( '--application-version or --application-version-string' ' required with application image.') if (no_backup is not None) and (backup_address is not None): raise click.BadParameter( "Bootloader DFU settings backup page cannot be specified if backup is disabled.", param_hint='backup_address') if no_backup is None: no_backup = False if no_backup is False: display_settings_backup_warning() if (start_address is not None) and (backup_address is None): click.echo( "WARNING: Using default offset in order to calculate bootloader settings backup page" ) if bl_settings_version == 1 and (app_boot_validation or sd_boot_validation): raise click.BadParameter( "Bootloader settings version 1 does not support boot validation.", param_hint='bl_settings_version') # load signing key (if needed) only once if 'VALIDATE_ECDSA_P256_SHA256' in (app_boot_validation, sd_boot_validation): if not os.path.isfile(key_file): raise click.UsageError( "Key file must be given when 'VALIDATE_ECDSA_P256_SHA256' boot validation is used" ) signer = Signing() default_key = signer.load_key(key_file) if default_key: display_sec_warning() else: signer = None if app_boot_validation and not application: raise click.UsageError( "--application hex file must be set when using --app_boot_validation" ) if sd_boot_validation and not softdevice: raise click.UsageError( "--softdevice hex file must be set when using --sd_boot_validation" ) # Default boot validation cases if app_boot_validation is None and application is not None and bl_settings_version == 2: app_boot_validation = DEFAULT_BOOT_VALIDATION if sd_boot_validation is None and softdevice is not None and bl_settings_version == 2: sd_boot_validation = DEFAULT_BOOT_VALIDATION sett = BLDFUSettings() sett.generate(arch=family, app_file=application, app_ver=application_version_internal, bl_ver=bootloader_version, bl_sett_ver=bl_settings_version, custom_bl_sett_addr=start_address, no_backup=no_backup, backup_address=backup_address, app_boot_validation_type=app_boot_validation, sd_boot_validation_type=sd_boot_validation, sd_file=softdevice, signer=signer) sett.tohexfile(hex_file) click.echo( "\nGenerated Bootloader DFU settings .hex file and stored it in: {}". format(hex_file)) click.echo("{0}".format(str(sett)))