Пример #1
0
def gen_boot_bin(config) -> None:

    if has_key(config, "console"):
        console = config["console"]
    else:
        console = Xexpect(log)
        setattr(config, "console", console)

    remove(os.path.join(config["imagesDir"], config["binFile"]))
    if config["bifFile"]:
        copy_file(config["bifFile"], config["imagesDir"])

    console.runcmd(f"cd {config['imagesDir']}")

    bootgen_cmd = [
        config["bootgenCmd"],
        "-arch",
        config["platform"].lower(),
        config["bootgenExtraArgs"],
        "-log",
        "info",
        "-image",
        config["bifFile"],
        "-o",
        config["binFile"],
    ]
    cmd = " ".join(bootgen_cmd)
    console.runcmd(cmd, expected="Bootimage generated successfully")

    if is_file(os.path.join(config["imagesDir"], config["binFile"])):
        log.info("Bootable Image generate successful")
    else:
        err_msg = f"{config['binFile']} creation failed"
        log.error(err_msg)
        raise Exception(err_msg)
Пример #2
0
    def set_proc(self, proc: str) -> None:

        # Map proc instances with simple keys
        proc_dict = {
            "versal": "Versal *",
            "a72_0": "Cortex-A72*#0",
            "a72_1": "Cortex-A72*#1",
            "a53_0": "Cortex-A53*#0",
            "a53_1": "Cortex-A53*#1",
            "r5_0": "Cortex-R5*#0",
            "r5_1": "Cortex-R5*#1",
            "a9_0": "*Cortex-A9*#0",
            "MB_PSM": "MicroBlaze PSM",
            "MB_PPU": "MicroBlaze PPU",
            "MB": "MicroBlaze*#0",
        }

        cmd = "targets -set -nocase -filter {name =~ "
        if has_key(proc_dict, proc):
            cmd += f'"{proc_dict[proc]}"' + "}"
        else:
            cmd += f'"{proc}"' + "}"

        f_msgs = ["no targets found"]
        self.runcmd(cmd, expected_failures=f_msgs)
Пример #3
0
 def _load_bitstream(self):
     if has_key(self.config,
                "is_rfdc_board") and self.config["is_rfdc_board"]:
         Isolation_Data = {
             "0xFFD80118": "0x00800000",
             "0xFFD80120": "0x00800000"
         }
         Pl_logic_reset = {
             "0xFF0a002C": "0x80000000",
             "0xFF0A0344": "0x80000000",
             "0xFF0A0348": "0x80000000",
             "0xFF0A0054": "0x0",
         }
         macros = {"0xFF0A0054": "0x80000000"}
         validate_macros = {
             "0xFF0A0344": "0x80000000",
             "0xFF0A0348": "0x80000000"
         }
         self.load_bitstream(f"{self.images_dir}/system.bit")
         self.xsdbcon.write(Isolation_Data)
         self.xsdbcon.write(Pl_logic_reset)
         self._validate_address(validate_macros)
         sleep(5)
         self.xsdbcon.write(macros)
         sleep(5)
Пример #4
0
 def _configure(self):
     self.interface = self.config.get("board_interface")
     if self.interface == "host_target":
         # self.prompt = "(%|#|>|\\$|# )"
         self.hostname = socket.gethostname()
         if has_key(self.config,
                    "remote_host") and self.config["remote_host"]:
             self.hostname = self.config["remote_host"]
     else:
         raise Exception(
             f"ERROR: invalid serial interface {self.interface}")
Пример #5
0
def bifstring(bifstr: str, value: str, config) -> str:
    # Get the design name
    if has_key(config, "designs"):
        design = config["designs"].split("/")[-2]

    if re.search(r"ext=", value):
        bifstr += config[
            "designs"] + "outputs/" + f"{design}.{value.split('=')[1]}"
    elif re.search(r"rel=", value):
        bifstr += config["imagesDir"] + f"{value.split('=')[1]}"
    elif re.search(r"path=", value):
        config["tmpvalue"] = value.split("=")[1]
        bifstr += config["tmpvalue"]
    else:
        config["tmpvalue"] = value
        bifstr += config["tmpvalue"]
    return bifstr
Пример #6
0
def sd_boot(board, boot_device="SD"):
    board.serial.mode = True
    board.systest.reboot()
    if not board.xsdb:
        board.xsdb = Xsdb(board.config, hwserver=board.config["systest_host"])

    board.serial = Serial("systest", board.config, mode=True).driver
    if board.config["platform"] == "zynq":
        board.systest.runcmd("bootmode 'sd'")
        board.serial.mode = True
        board.systest.reset()
    elif board.config["platform"] == "zynqmp":
        if has_key(board.config, "bootmode_tcl"):
            board.xsdb.run_tcl(f"{board.config['bootmode_tcl']}")
        else:
            zynqmp_bootmode_sd(board, boot_device)

    elif board.config["platform"] == "versal":
        board.systest.runcmd("bootmode 'sd1_ls'")
Пример #7
0
def generate_bif(config, format_type: str) -> None:
    bif_path = os.path.join(config["workDir"], config["bifFile"])
    with open(bif_path, "w") as biffile:
        if format_type == "new":
            defdata = {
                "plm": ["type = bootloader", "path"],
                "pmccdo": ["type = pmcdata,load=0xF2000000", "path"],
                "cdo": ["type = cdo", "path"],
                "sys_dtb": ["load=0x1000", "path"],
                "linux_image": ["load=0x2000000", "path"],
                "uboot": ["", "path"],
                "puf": ["puf_file", "path"],
                "aie-elf": ["core = aie", "path"],
                "psm": ["core = psm", "psmElf"],
                "a72": ["core = a72-0", "path"],
                "r5": ["core = r5-0", "path"],
                "a72_1": ["core = a72-1", "path"],
                "r5_1": ["core = r5-1", "path"],
                "r5_lock": ["core = r5-lockstep", "path"],
            }
            subsys_data = {
                "pmc_subsys": "0x1c000001",
                "lpd_subsys": "0x4210002",
                "pl_cfi_subsys": "0x18700000",
                "aie_subsys": "0x421c005",
                "fpd_subsys": "0x420c003",
                "subsystem": "0x1c000000",
            }
            biffile.write("new_bif:\n{\n")
            id_code = "0x04ca8093"
            extended_id_code = "0x01"
            if has_key(config, "id_code"):
                id_code = config["id_code"]
            if has_key(config, "extended_id_code"):
                extended_id_code = config["extended_id_code"]
            if has_key(config, "bootheader"):
                biffile.write(config["bootheader"].format())
            biffile.write(
                f" id_code = {id_code}\n extended_id_code = {extended_id_code} \n id = 0x1\n"
            )
            id = 2
            headers, l_components = zip(*config.bif)
            for header, components in zip(headers, l_components):
                # config library returns list so cast back to namedtuple
                header = Header(*header)
                components = [
                    Component(*component) for component in components
                ]
                if header.header == "image":
                    subsystem_id = subsys_data[header.name]
                    biffile.write(
                        f" {header.header}\n {{\n  name = {header.name}\n  id = {subsystem_id}\n"
                    )
                    if header.args:
                        biffile.write(f"  {header.args}\n")
                    for component in components:
                        extra_args = bifstring("",
                                               "".join(component.params[:-1]),
                                               config)
                        image_path = bifstring("", component.params[-1],
                                               config)
                        str_component = create_partition(
                            id, defdata[component.name][0], extra_args,
                            image_path)
                        biffile.write(str_component)
                elif header.header == "metaheader":
                    for component in components:
                        extra_args = bifstring("",
                                               "".join(component.params[:-1]),
                                               config)
                        str_component = (f"\n  metaheader \n"
                                         f"  {{\n"
                                         f"    {extra_args}\n"
                                         f"  }}\n")
                        biffile.write(str_component)
                biffile.write(" }\n")
                id = id + 1
            biffile.write("}\n")
        elif format_type == "old":
            defdata = {
                "plm": ["bootloader", "path"],
                "pmccdo": ["pmcdata,load=0xF2000000", "path"],
                "cdo": ["partition_type=cdo", "path"],
                "aie-elf": ["destination_cpu=aie", "path"],
                "psm": ["destination_cpu=psm", "psmElf"],
                "a72": ["destination_cpu=a72-0", "path"],
                "r5": ["destination_cpu=r5-0", "path"],
            }
            if config["boot_header"]:
                biffile.write(f"{config['boot_header']}" ":\n{\n")
            else:
                biffile.write("all:\n{\n")
            for image in config["bif"]:
                comp = image[0]
                value = image[1]
                bifstr = "[{}] ".format(defdata[comp][0])
                bifstr = bifstring(bifstr, value, config)
                bifstr = "\t{}\n".format(bifstr)
                biffile.write(bifstr)
            biffile.write("}\n")

    if is_file(bif_path):
        copy_file(
            bif_path,
            os.path.join(config["imagesDir"], config["bifFile"]),
        )
        log.info("Bif Generated successfully")
    else:
        err_msg = "Bif generation failed"
        log.error(err_msg)
        raise Exception(err_msg)