Example #1
0
def set_local_nic_ip_from_usbdev(
    c, address="auto", yamlfilename="/etc/default/nebula", board_name=None
):
    """ Set IP of virtual NIC created from DUT based on found MAC """
    try:
        import os

        if not os.name in ["nt", "posix"]:
            raise Exception("This command only works on Linux currently")
        u = nebula.uart(
            address=address, yamlfilename=yamlfilename, board_name=board_name
        )
        u.print_to_console = False
        ipaddr = u.get_ip_address()
        if not ipaddr:
            # Try again, sometimes there is junk in terminal
            ipaddr = u.get_ip_address()
        if not ipaddr:
            print("Board IP is not set, must be set first")
            return
        # Get local mac from board
        addr = u.get_local_mac_usbdev()
        addr = addr.replace(":", "")
        addr = addr.replace("\r", "")
        addr = addr.strip()
        # Get IP of virtual nic
        cmd = (
            "ip -4 addr l enx"
            + addr
            + "| grep -v 127 | awk '$1 == \"inet\" {print $2}' | awk -F'/' '{print $1}'"
        )
        out = c.run(cmd)
        local = out.stdout
        local = local.replace("\r", "").replace("\n", "").strip()
        # Compare against local
        ipaddrs = ipaddr.split(".")
        do_not_set = False
        if local:
            remotesub = ".".join(ipaddrs[:-1])
            locals = local.split(".")
            localsub = ".".join(locals[:-1])
            do_not_set = remotesub == localsub
            if do_not_set:
                ipaddrs = local

        if not do_not_set:
            # Create new address
            ipaddrs[-1] = str(int(ipaddrs[-1]) + 9)
            ipaddrs = ".".join(ipaddrs)
            cmd = "ifconfig enx" + addr + " " + ipaddrs
            c.run(cmd)

        print("Local IP Set:", ipaddrs, "Remote:", ipaddr)
        del u
    except Exception as ex:
        raise ex
Example #2
0
def test_adrv9361_fmc_get_to_uboot_menu():

    config = "/etc/default/nebula"
    config = "/etc/nebula/nebula-zynq-adrv9361-z7035-fmc.yaml"
    power = pdu(yamlfilename=config)
    u = uart(yamlfilename=config)

    # Go go go
    power.power_cycle_board()
    assert u._enter_uboot_menu_from_power_cycle()
Example #3
0
def get_ip(c, address="auto", yamlfilename="/etc/default/nebula", board_name=None):
    """ Get IP of DUT from UART connection """
    #     try:
    # YAML will override
    u = nebula.uart(address=address, yamlfilename=yamlfilename, board_name=board_name)
    u.print_to_console = False
    addr = u.get_ip_address()
    del u
    if addr:
        print(addr)
    else:
        raise Exception("Address not found")
Example #4
0
def set_dhcp(
    c, address="auto", nic="eth0", yamlfilename="/etc/default/nebula", board_name=None
):
    """ Set board to use DHCP for networking from UART connection """
    try:
        u = nebula.uart(
            address=address, yamlfilename=yamlfilename, board_name=board_name
        )
        u.print_to_console = False
        u.request_ip_dhcp()
        del u
    except Exception as ex:
        print(ex)
Example #5
0
def set_static_ip(
    c,
    ip,
    address="auto",
    nic="eth0",
    yamlfilename="/etc/default/nebula",
    board_name=None,
):
    """ Set Static IP address of board of DUT from UART connection """
    try:
        u = nebula.uart(
            address=address, yamlfilename=yamlfilename, board_name=board_name
        )
        u.print_to_console = False
        u.set_ip_static(ip, nic)
        del u
    except Exception as ex:
        print(ex)
Example #6
0
def get_mezzanine(
    c, address="auto", yamlfilename="/etc/default/nebula", board_name=None
):
    """ Get Mezzanine (FMC) name of DUT from UART connection """
    try:
        u = nebula.uart(
            address=address, yamlfilename=yamlfilename, board_name=board_name
        )
        u.print_to_console = False
        cmd = "find /sys/ -name eeprom | xargs fru-dump -b -i | grep Part Number"
        addr = u.get_uart_command_for_linux(cmd, "")
        if addr:
            if addr[-1] == "#":
                addr = addr[:-1]
            print(addr)
        else:
            print("Address not found")
        del u
    except Exception as ex:
        print(ex)
Example #7
0
def restart_board_uart(
    c, address="auto", yamlfilename="/etc/default/nebula", board_name=None
):
    """ Reboot DUT from UART connection assuming Linux is accessible"""
    try:
        u = nebula.uart(
            address=address, yamlfilename=yamlfilename, board_name=board_name
        )
        u.print_to_console = False
        cmd = "reboot"
        u.get_uart_command_for_linux(cmd, "")
        # if addr:
        #     if addr[-1] == "#":
        #         addr = addr[:-1]
        #     print(addr)
        # else:
        #     print("Address not found")
        del u
    except Exception as ex:
        print(ex)
Example #8
0
def update_boot_files_uart(
    c,
    system_top_bit_filename,
    uimagepath,
    devtreepath,
    address=None,
    yamlfilename="/etc/default/nebula",
    reboot=False,
    board_name=None,
):
    """ Update boot files through u-boot menu (Assuming board is running) """
    u = nebula.uart(address=address, yamlfilename=yamlfilename, board_name=board_name)
    u.print_to_console = False
    if reboot:
        u._write_data("reboot")
        time.sleep(4)
    u.update_boot_files_from_running(
        system_top_bit_filename=system_top_bit_filename,
        kernel_filename=uimagepath,
        devtree_filename=devtreepath,
    )
Example #9
0
def test_adrv9361_fmc_uboot_boot():
    # Get necessary boot files
    root = os.path.dirname(os.path.realpath(__file__))
    system_top_bit_filename = root + "/bootfiles/system_top.bit"
    devtree_filename = root + "/bootfiles/devicetree.dtb"
    kernel_filename = root + "/bootfiles/uImage"
    assert os.path.isfile(system_top_bit_filename)
    assert os.path.isfile(devtree_filename)
    assert os.path.isfile(kernel_filename)

    # Go go go
    config = "/etc/default/nebula"
    config = "/etc/nebula/nebula-zynq-adrv9361-z7035-fmc.yaml"
    u = uart(yamlfilename=config)
    u.print_to_console = True
    u.load_system_uart(system_top_bit_filename, devtree_filename,
                       kernel_filename)
    u.start_log()
    status = u._wait_for_boot_complete_linaro()
    u.stop_log()

    # Check board booted :)
    assert status
Example #10
0
def get_carriername(
    c, address="auto", yamlfilename="/etc/default/nebula", board_name=None
):
    """ Get Carrier (FPGA) name of DUT from UART connection """
    try:
        u = nebula.uart(
            address=address, yamlfilename=yamlfilename, board_name=board_name
        )
        u.print_to_console = False
        cmd = "cat /sys/firmware/devicetree/base/model"
        addr = u.get_uart_command_for_linux(cmd, "")
        if addr:
            if addr[-1] == "#":
                addr = addr[:-1]
            addr = addr.split("\x00")
            if "@" in addr[-1]:
                addr = addr[:-1]
            addr = "-".join(addr)
            print(addr)
        else:
            print("Address not found")
        del u
    except Exception as ex:
        print(ex)