def build_trub_records(file_name, slot_assignments=None, os_info=None, sensor_graph=None, app_info=None, use_safeupdate=False): """Build a trub script based on the records received for each slot. slot_assignments should be a list of tuples in the following form: ("slot X" or "controller", firmware_image_name, record_type, args) The output of this autobuild action will be a trub script in build/output/<file_name> that assigns the given firmware to each slot in the order specified in the slot_assignments list. Args: file_name (str): The name of the output file that we should create. This file name should end in .trub slot_assignments (list of (str, str, str, list)): The tuple contains (slot name, firmware file, record type, args) os_info (tuple(int, str)): A tuple of OS version tag and X.Y version number that will be set as part of the OTA script if included. Optional. sensor_graph (str): Name of sgf file. Optional. app_info (tuple(int, str)): A tuple of App version tag and X.Y version number that will be set as part of the OTA script if included. Optional. use_safeupdate (bool): Enables safe firmware update """ resolver = ProductResolver.Create() env = Environment(tools=[]) files = [] records = [] if slot_assignments is not None: slots = [_parse_slot_assignment(x) for x in slot_assignments] files = [ ensure_image_is_hex( resolver.find_unique("firmware_image", x[1]).full_path) for x in slot_assignments ] env['SLOTS'] = slots else: env['SLOTS'] = None env['USE_SAFEUPDATE'] = use_safeupdate env['OS_INFO'] = os_info env['APP_INFO'] = app_info env['UPDATE_SENSORGRAPH'] = False if sensor_graph is not None: files.append(sensor_graph) env['UPDATE_SENSORGRAPH'] = True env.Command([os.path.join('build', 'output', file_name)], files, action=Action(_build_records_action, "Building TRUB script at $TARGET"))
def autobuild_bootstrap_file(file_name, image_list): """Combine multiple firmware images into a single bootstrap hex file. The files listed in image_list must be products of either this tile or any dependency tile and should correspond exactly with the base name listed on the products section of the module_settings.json file of the corresponding tile. They must be listed as firmware_image type products. This function keeps a global map of all of the intermediate files that it has had to create so that we don't try to build them multiple times. Args: file_name(str): Full name of the output bootstrap hex file. image_list(list of str): List of files that will be combined into a single hex file that will be used to flash a chip. """ family = utilities.get_family('module_settings.json') target = family.platform_independent_target() resolver = ProductResolver.Create() env = Environment(tools=[]) output_dir = target.build_dirs()['output'] build_dir = target.build_dirs()['build'] build_output_name = os.path.join(build_dir, file_name) full_output_name = os.path.join(output_dir, file_name) processed_input_images = [] for image_name in image_list: image_info = resolver.find_unique('firmware_image', image_name) image_path = image_info.full_path hex_path = arm.ensure_image_is_hex(image_path) processed_input_images.append(hex_path) env.Command( build_output_name, processed_input_images, action=Action( arm.merge_hex_executables, "Merging %d hex files into $TARGET" % len(processed_input_images))) env.Command(full_output_name, build_output_name, Copy("$TARGET", "$SOURCE"))