Beispiel #1
0
def pex_thread(pex_tty, pex_log):
    pex_serial = serial.Serial(pex_tty, 115200, timeout=3000000, bytesize=serial.EIGHTBITS,
                                parity=serial.PARITY_NONE, xonxoff=False, rtscts=False, dsrdtr=False)
    pex_expect = pexpect_serial.SerialSpawn(pex_serial, timeout=3000000, encoding='utf-8', codec_errors='ignore')
    pex_expect.logfile = pex_log

    pex_expect.expect("Unrecoverable failure")
    logger.warn("Process failed to run to completion")
Beispiel #2
0
def ap_thread(ap_tty, ap_log, runtime, processor):
    baud_rate = 115200

    ap_serial = serial.Serial(ap_tty, baud_rate, timeout=3000000, bytesize=serial.EIGHTBITS,
                               parity=serial.PARITY_NONE, xonxoff=False, rtscts=False, dsrdtr=False)
    ap_expect = pexpect_serial.SerialSpawn(ap_serial, timeout=3000000, encoding='utf-8', codec_errors='ignore')
    ap_expect.logfile = ap_log

    ap_expect.expect(isp_utils.terminateMessage(runtime))
Beispiel #3
0
def runPipe(exe_path, ap, pex_tty, pex_log, openocd_log_file,
            gdb_log_file, flash_init_image_path, gdb_port, no_log, arch):
    logger.debug("Connecting to {}".format(pex_tty))
    pex_serial = serial.Serial(pex_tty, 115200, timeout=3000000,
            bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, xonxoff=False, rtscts=False, dsrdtr=False)

    pex_expect = pexpect_serial.SerialSpawn(pex_serial, timeout=3000000, encoding='utf-8', codec_errors='ignore')
    pex_expect.logfile = pex_log
    
    logger.info("Sending flash init file {} to {}".format(flash_init_image_path, pex_tty))
    pex_serial.write(open(flash_init_image_path, "rb").read())
    logger.debug("Done writing init file")

    found = pex_expect.expect(["Entering idle loop.", "Entering infinite loop.", pexpect.EOF])
    if found > 0:
        pex_expect.close()
        return isp_utils.retVals.FAILURE
    pex_expect.close()

    pex = multiprocessing.Process(target=pex_thread, args=(pex_tty, pex_log))
    if not no_log:
        pex.start()

    logger.debug("Spawning openocd")
    openocd_proc = start_openocd(openocd_log_file)
    if not openocd_proc:
        return isp_utils.retVals.FAILURE

    logger.debug("Spawning gdb")
    gdb = multiprocessing.Process(target=gdb_thread, args=(exe_path, gdb_log_file, arch))

    if gdb_port == 0:
        gdb.start()

    if no_log:
        logger.info("Application is running. Press CTRL-C to exit")
        while True:
            pass

    logger.debug("waiting for pex and ap to finish")
    while pex.is_alive() and ap.is_alive():
        pass

    openocd_proc.terminate()
    gdb.terminate()

    ap.terminate()
    pex.terminate()

    return isp_utils.retVals.SUCCESS
def runPipe(exe_path, ap, pex_tty, pex_baud_rate, pex_log, run_dir,
            pex_kernel_path, no_log, iveia_tmp):
    logger.debug("Connecting PEX uart to {}, baud rate {}".format(
        pex_tty, pex_baud_rate))
    pex_serial = serial.Serial(pex_tty,
                               pex_baud_rate,
                               timeout=3000000,
                               bytesize=serial.EIGHTBITS,
                               parity=serial.PARITY_NONE,
                               xonxoff=False,
                               rtscts=False,
                               dsrdtr=False)

    pex_expect = pexpect_serial.SerialSpawn(pex_serial,
                                            timeout=3000000,
                                            encoding='utf-8',
                                            codec_errors='ignore')
    pex_expect.logfile = pex_log

    ap_tags_load_image = os.path.join(
        run_dir,
        os.path.basename(exe_path) + ".load_image")

    # before you copy the images to the iveia_tmp, make sure you clear that dir (e.g. remove all the
    # files in there possibly from other runs )
    #    cmd = ["/bin/rm -f",
    #           iveia_tmp + "/" + os.path.basename(exe_path),
    #           iveia_tmp + "/" + os.path.basename(pex_path),
    #           iveia_tmp + "/" + os.path.basename(exe_path) + ".load_image"]
    #    result1 = runIveiaCmd(cmd, pex_log, run_dir)

    load_pex_and_tag_files_args = [
        "scp", pex_kernel_path, ap_tags_load_image, exe_path,
        "root@atlas-ii-z8-hp:" + iveia_tmp
    ]

    result = subprocess.call(load_pex_and_tag_files_args,
                             stdout=pex_log,
                             stderr=subprocess.STDOUT,
                             cwd=run_dir)

    if result != 0:
        logger.error(
            "Failed to copy to iveia board the pex kernel and the ap_tag_info files ..."
        )
        logger.error("Used command : {} returned {}".format(
            load_pex_and_tag_files_args, result))
        return isp_utils.retVals.FAILURE

    isp_load_args = [
        "isp-loader", iveia_tmp + "/" + os.path.basename(exe_path),
        iveia_tmp + "/" + os.path.basename(pex_kernel_path),
        iveia_tmp + "/" + os.path.basename(exe_path) + ".load_image"
    ]

    logger.info(
        "Loading pex kernel and ap tags into the mem space of the PIPE and AP respectively and issuing reset"
    )
    result = runIveiaCmd(isp_load_args, pex_log, run_dir)

    if result != isp_utils.retVals.SUCCESS:
        return isp_utils.retVals.FAILURE

    # when the data is already in the memory, the PEX is interrupted (to process rule cache misses)
    # before it can print "Entering idle loop"
    found = pex_expect.expect(
        ["Releasing host core.", "Unrecoverable failure.", pexpect.EOF])
    if found > 0:
        pex_expect.close()
        return isp_utils.retVals.FAILURE
    pex_expect.close()

    pex = multiprocessing.Process(target=pex_thread,
                                  args=(pex_tty, pex_baud_rate, pex_log))
    if not no_log:
        pex.start()

    logger.debug("waiting for pex and ap to finish")
    while pex.is_alive() and ap.is_alive():
        pass

    ap.terminate()
    pex.terminate()

    return isp_utils.retVals.SUCCESS