def monitor(action, ctx, args, print_filter): """ Run idf_monitor.py to watch build output """ if args.port is None: args.port = _get_default_serial_port() desc_path = os.path.join(args.build_dir, "project_description.json") if not os.path.exists(desc_path): ensure_build_directory(args, ctx.info_name) with open(desc_path, "r") as f: project_desc = json.load(f) elf_file = os.path.join(args.build_dir, project_desc["app_elf"]) if not os.path.exists(elf_file): raise FatalError("ELF file '%s' not found. You need to build & flash the project before running 'monitor', " "and the binary on the device must match the one in the build directory exactly. " "Try '%s flash monitor'." % (elf_file, ctx.info_name)) idf_monitor = os.path.join(os.environ["IDF_PATH"], "tools/idf_monitor.py") monitor_args = [PYTHON, idf_monitor] if args.port is not None: monitor_args += ["-p", args.port] monitor_args += ["-b", project_desc["monitor_baud"]] monitor_args += ["--toolchain-prefix", project_desc["monitor_toolprefix"]] if print_filter is not None: monitor_args += ["--print_filter", print_filter] monitor_args += [elf_file] idf_py = [PYTHON] + _get_commandline_options(ctx) # commands to re-run idf.py monitor_args += ["-m", " ".join("'%s'" % a for a in idf_py)] if "MSYSTEM" in os.environ: monitor_args = ["winpty"] + monitor_args run_tool("idf_monitor", monitor_args, args.project_dir)
def monitor(action, ctx, args, print_filter, monitor_baud, encrypted, timestamps, timestamp_format): """ Run idf_monitor.py to watch build output """ desc_path = os.path.join(args.build_dir, 'project_description.json') if not os.path.exists(desc_path): ensure_build_directory(args, ctx.info_name) with open(desc_path, 'r') as f: project_desc = json.load(f) elf_file = os.path.join(args.build_dir, project_desc['app_elf']) if not os.path.exists(elf_file): raise FatalError("ELF file '%s' not found. You need to build & flash the project before running 'monitor', " 'and the binary on the device must match the one in the build directory exactly. ' "Try '%s flash monitor'." % (elf_file, ctx.info_name), ctx) idf_monitor = os.path.join(os.environ['IDF_PATH'], 'tools/idf_monitor.py') monitor_args = [PYTHON, idf_monitor] esp_port = args.port or _get_default_serial_port(args) monitor_args += ['-p', esp_port] if not monitor_baud: monitor_baud = os.getenv('IDF_MONITOR_BAUD') or os.getenv('MONITORBAUD') or project_desc['monitor_baud'] monitor_args += ['-b', monitor_baud] monitor_args += ['--toolchain-prefix', project_desc['monitor_toolprefix']] coredump_decode = get_sdkconfig_value(project_desc['config_file'], 'CONFIG_ESP_COREDUMP_DECODE') if coredump_decode is not None: monitor_args += ['--decode-coredumps', coredump_decode] target_arch_riscv = get_sdkconfig_value(project_desc['config_file'], 'CONFIG_IDF_TARGET_ARCH_RISCV') monitor_args += ['--target', project_desc['target']] revision = project_desc.get('rev') if revision: monitor_args += ['--revision', revision] if target_arch_riscv: monitor_args += ['--decode-panic', 'backtrace'] if print_filter is not None: monitor_args += ['--print_filter', print_filter] monitor_args += [elf_file] if encrypted: monitor_args += ['--encrypted'] if timestamps: monitor_args += ['--timestamps'] if timestamp_format: monitor_args += ['--timestamp-format', timestamp_format] idf_py = [PYTHON] + _get_commandline_options(ctx) # commands to re-run idf.py monitor_args += ['-m', ' '.join("'%s'" % a for a in idf_py)] if 'MSYSTEM' in os.environ: monitor_args = ['winpty'] + monitor_args run_tool('idf_monitor', monitor_args, args.project_dir)
def run_target(target_name, args): generator_cmd = GENERATORS[args.generator]["command"] if args.verbose: generator_cmd += [GENERATORS[args.generator]["verbose_flag"]] run_tool(generator_cmd[0], generator_cmd + [target_name], args.build_dir)
def monitor(action, ctx, args, print_filter, monitor_baud, encrypted): """ Run idf_monitor.py to watch build output """ if args.port is None: args.port = _get_default_serial_port() desc_path = os.path.join(args.build_dir, "project_description.json") if not os.path.exists(desc_path): ensure_build_directory(args, ctx.info_name) with open(desc_path, "r") as f: project_desc = json.load(f) elf_file = os.path.join(args.build_dir, project_desc["app_elf"]) if not os.path.exists(elf_file): raise FatalError( "ELF file '%s' not found. You need to build & flash the project before running 'monitor', " "and the binary on the device must match the one in the build directory exactly. " "Try '%s flash monitor'." % (elf_file, ctx.info_name), ctx) idf_monitor = os.path.join(os.environ["IDF_PATH"], "tools/idf_monitor.py") monitor_args = [PYTHON, idf_monitor] if args.port is not None: monitor_args += ["-p", args.port] if not monitor_baud: if os.getenv("IDF_MONITOR_BAUD"): monitor_baud = os.getenv("IDF_MONITOR_BAUD", None) elif os.getenv("MONITORBAUD"): monitor_baud = os.getenv("MONITORBAUD", None) else: monitor_baud = project_desc["monitor_baud"] monitor_args += ["-b", monitor_baud] monitor_args += [ "--toolchain-prefix", project_desc["monitor_toolprefix"] ] coredump_decode = get_sdkconfig_value(project_desc["config_file"], "CONFIG_ESP32_CORE_DUMP_DECODE") if coredump_decode is not None: monitor_args += ["--decode-coredumps", coredump_decode] if print_filter is not None: monitor_args += ["--print_filter", print_filter] monitor_args += [elf_file] if encrypted: monitor_args += ['--encrypted'] idf_py = [PYTHON] + _get_commandline_options( ctx) # commands to re-run idf.py monitor_args += ["-m", " ".join("'%s'" % a for a in idf_py)] if "MSYSTEM" in os.environ: monitor_args = ["winpty"] + monitor_args run_tool("idf_monitor", monitor_args, args.project_dir)
def build_target(target_name, ctx, args): """ Execute the target build system to build target 'target_name' Calls ensure_build_directory() which will run cmake to generate a build directory (with the specified generator) as needed. """ ensure_build_directory(args, ctx.info_name) generator_cmd = GENERATOR_CMDS[args.generator] if args.verbose: generator_cmd += [GENERATOR_VERBOSE[args.generator]] run_tool(generator_cmd[0], generator_cmd + [target_name], args.build_dir)
def flash(action, ctx, args): """ Run esptool to flash the entire project, from an argfile generated by the build system """ flasher_args_path = { # action -> name of flasher args file generated by build system "bootloader-flash": "flash_bootloader_args", "partition_table-flash": "flash_partition_table_args", "app-flash": "flash_app_args", "flash": "flash_project_args", "encrypted-app-flash": "flash_encrypted_app_args", "encrypted-flash": "flash_encrypted_project_args", }[action] esptool_args = _get_esptool_args(args) esptool_args += ["write_flash", "@" + flasher_args_path] run_tool("esptool.py", esptool_args, args.build_dir)
def monitor(action, ctx, args, print_filter, monitor_baud, encrypted, timestamps, timestamp_format): """ Run idf_monitor.py to watch build output """ project_desc = _get_project_desc(ctx, args) elf_file = os.path.join(args.build_dir, project_desc['app_elf']) idf_monitor = os.path.join(os.environ['IDF_PATH'], 'tools/idf_monitor.py') monitor_args = [PYTHON, idf_monitor] if project_desc['target'] != 'linux': esp_port = args.port or _get_default_serial_port(args) monitor_args += ['-p', esp_port] if not monitor_baud: monitor_baud = os.getenv('IDF_MONITOR_BAUD') or os.getenv( 'MONITORBAUD') or project_desc['monitor_baud'] monitor_args += ['-b', monitor_baud] monitor_args += [ '--toolchain-prefix', project_desc['monitor_toolprefix'] ] coredump_decode = get_sdkconfig_value(project_desc['config_file'], 'CONFIG_ESP_COREDUMP_DECODE') if coredump_decode is not None: monitor_args += ['--decode-coredumps', coredump_decode] target_arch_riscv = get_sdkconfig_value( project_desc['config_file'], 'CONFIG_IDF_TARGET_ARCH_RISCV') monitor_args += ['--target', project_desc['target']] revision = project_desc.get('rev') if revision: monitor_args += ['--revision', revision] if target_arch_riscv: monitor_args += ['--decode-panic', 'backtrace'] if print_filter is not None: monitor_args += ['--print_filter', print_filter] if elf_file: monitor_args += [elf_file] if encrypted: monitor_args += ['--encrypted'] if timestamps: monitor_args += ['--timestamps'] if timestamp_format: monitor_args += ['--timestamp-format', timestamp_format] idf_py = [PYTHON] + _get_commandline_options( ctx) # commands to re-run idf.py monitor_args += ['-m', ' '.join("'%s'" % a for a in idf_py)] run_tool('idf_monitor', monitor_args, args.project_dir)
def erase_flash(action, ctx, args): ensure_build_directory(args, ctx.info_name) esptool_args = _get_esptool_args(args) esptool_args += ['erase_flash'] run_tool('esptool.py', esptool_args, args.build_dir)
def erase_flash(action, ctx, args): esptool_args = _get_esptool_args(args) esptool_args += ["erase_flash"] run_tool("esptool.py", esptool_args, args.build_dir)
def monitor(action, ctx, args, print_filter, monitor_baud, encrypted, timestamps, timestamp_format): """ Run idf_monitor.py to watch build output """ project_desc = _get_project_desc(ctx, args) elf_file = os.path.join(args.build_dir, project_desc['app_elf']) idf_monitor = os.path.join(os.environ['IDF_PATH'], 'tools/idf_monitor.py') monitor_args = [PYTHON, idf_monitor] if project_desc['target'] != 'linux': esp_port = args.port or _get_default_serial_port(args) monitor_args += ['-p', esp_port] baud = monitor_baud or os.getenv('IDF_MONITOR_BAUD') or os.getenv( 'MONITORBAUD') if baud is None: # Baud hasn't been changed locally (by local baud argument nor by environment variables) # # Use the global baud rate if it has been changed by the command line. # Use project_desc['monitor_baud'] as the last option. global_baud_defined = ctx._parameter_source[ 'baud'] == click.core.ParameterSource.COMMANDLINE baud = args.baud if global_baud_defined else project_desc[ 'monitor_baud'] monitor_args += ['-b', baud] monitor_args += [ '--toolchain-prefix', project_desc['monitor_toolprefix'] ] coredump_decode = get_sdkconfig_value(project_desc['config_file'], 'CONFIG_ESP_COREDUMP_DECODE') if coredump_decode is not None: monitor_args += ['--decode-coredumps', coredump_decode] target_arch_riscv = get_sdkconfig_value( project_desc['config_file'], 'CONFIG_IDF_TARGET_ARCH_RISCV') monitor_args += ['--target', project_desc['target']] revision = project_desc.get('rev') if revision: monitor_args += ['--revision', revision] if target_arch_riscv: monitor_args += ['--decode-panic', 'backtrace'] if print_filter is not None: monitor_args += ['--print_filter', print_filter] if elf_file: monitor_args += [elf_file] if encrypted: monitor_args += ['--encrypted'] if timestamps: monitor_args += ['--timestamps'] if timestamp_format: monitor_args += ['--timestamp-format', timestamp_format] idf_py = [PYTHON] + _get_commandline_options( ctx) # commands to re-run idf.py monitor_args += ['-m', ' '.join("'%s'" % a for a in idf_py)] run_tool('idf_monitor', monitor_args, args.project_dir)