diff --git a/nebula/manager.py b/nebula/manager.py index d3251e65..4a2984de 100644 --- a/nebula/manager.py +++ b/nebula/manager.py @@ -281,7 +281,7 @@ def recover_board( # noqa:C901 devicetree_loc=devtreepath, extlinux_loc=extlinux_path, scr_loc=scr_path, - preloader_loc=preloader_path + preloader_loc=preloader_path, ) # if devtreepath: # self.usbsdmux.update_devicetree_for_mux(devtreepath) @@ -424,7 +424,7 @@ def board_reboot_uart_net_pdu( devtreepath, extlinux_path=None, scr_path=None, - preloader_path=None + preloader_path=None, ): """Manager when UART, PDU, and Network are available""" self._check_files_exist( @@ -434,7 +434,7 @@ def board_reboot_uart_net_pdu( devtreepath, extlinux_path, scr_path, - preloader_path + preloader_path, ) try: # Flush UART @@ -546,7 +546,7 @@ def board_reboot_sdmux_pdu( preloader_path=None, ): """Manager when sdcardmux, pdu is available""" - + try: # Flush UART self.monitor[0]._read_until_stop() # Flush @@ -730,17 +730,17 @@ def _find_boot_files(self, folder): targets = { "bit": ["system_top.bit"], - "bootbin": ["BOOT.BIN","soc_system.rbf"], - "kernel": ["uImage","Image","zImage"], - "dt": ["devicetree.dtb","system.dtb","socfpga.dtb"], + "bootbin": ["BOOT.BIN", "soc_system.rbf"], + "kernel": ["uImage", "Image", "zImage"], + "dt": ["devicetree.dtb", "system.dtb", "socfpga.dtb"], "ext": ["extlinux.conf"], "scr": ["u-boot.scr"], - "preloader" : ["u-boot-with-spl.sfp"], + "preloader": ["u-boot-with-spl.sfp"], "uboot": [ "u-boot_zynq.elf", "u-boot_adi_zynqmp_adrv9009_zu11eg_adrv2crr_fmc.elf", - "u-boot_xilinx_zynqmp_zcu102_revA.elf" - ] + "u-boot_xilinx_zynqmp_zcu102_revA.elf", + ], } required = ["bootbin", "dt", "kernel"] found_files = {} @@ -749,7 +749,7 @@ def _find_boot_files(self, folder): if pattern in files: found_files.update({filetype: os.path.join(folder, pattern)}) continue - if not filetype in found_files.keys(): + if filetype not in found_files.keys(): if filetype in required: raise Exception(f"{filetype} - {pattern} not found") else: @@ -766,7 +766,6 @@ def _find_boot_files(self, folder): found_files["uboot"], ) - def board_reboot_auto_folder( self, folder, sdcard=False, design_name=None, recover=False, jtag_mode=False ): @@ -795,8 +794,16 @@ def board_reboot_auto_folder( else: log.info("SD-Card/microblaze based device selected") - (bit, bootbin, kernel, dt, ext, scr, preloader, uboot) = \ - self._find_boot_files(folder) + ( + bit, + bootbin, + kernel, + dt, + ext, + scr, + preloader, + uboot, + ) = self._find_boot_files(folder) if jtag_mode: self.board_reboot_jtag_uart( @@ -851,7 +858,7 @@ def board_reboot_auto( devtreepath=devtreepath, extlinux_path=extlinux_path, scr_path=scr_path, - preloader_path=preloader_path + preloader_path=preloader_path, ) else: self.board_reboot_uart_net_pdu( @@ -861,7 +868,7 @@ def board_reboot_auto( devtreepath=devtreepath, extlinux_path=extlinux_path, scr_path=scr_path, - preloader_path=preloader_path + preloader_path=preloader_path, ) def shutdown_powerdown_board(self): diff --git a/nebula/network.py b/nebula/network.py index a8e4beb7..02e6028f 100644 --- a/nebula/network.py +++ b/nebula/network.py @@ -243,7 +243,9 @@ def update_boot_partition( if preloader_path: preloader_file = os.path.basename(preloader_path) self.copy_file_to_remote(preloader_path, "/tmp/sdcard/") - self.run_ssh_command(f"dd if=/tmp/sdcard/{preloader_file} of=/dev/mmcblk0p3 bs=512 && sync") + self.run_ssh_command( + f"dd if=/tmp/sdcard/{preloader_file} of=/dev/mmcblk0p3 bs=512 && sync" + ) self.run_ssh_command("sudo reboot", ignore_exceptions=True) def update_boot_partition_existing_files(self, subfolder=None): diff --git a/nebula/usbmux.py b/nebula/usbmux.py index 1bf5c2b1..a10ee0fb 100644 --- a/nebula/usbmux.py +++ b/nebula/usbmux.py @@ -213,7 +213,7 @@ def update_boot_files_from_external( devicetree_loc (str): The path to the devicetree file devicetree_overlay_loc (str): The path to the devicetree overlay file devicetree_overlay_config (str): The devicetree overlay configuration to be written on /boot/config.txt - extlinux_loc (str): The path to the Extlinux configuratoin file (Intel boards). + extlinux_loc (str): The path to the Extlinux configuration file (Intel boards). scr_loc (str): The path to the .scr file (Intel boards). preloader_loc (str): The path to the preloader file (.sfp) (Intel boards). """ @@ -230,15 +230,15 @@ def update_boot_files_from_external( continue bootfile_name = os.path.basename(bootfile_loc) if not os.path.isfile(bootfile_loc): - raise Exception("File not found: " + loc) + raise Exception("File not found: " + bootfile_loc) if field == "devicetree_overlay_loc": - outfile = os.path.join( - "/tmp", folder, "overlays", bootfile_name - ) + outfile = os.path.join("/tmp", folder, "overlays", bootfile_name) elif field == "preloader_loc": log.info(f"Writing {bootfile_loc} to /dev/{preloader_p} ") - os.system(f'dd if={bootfile_loc} of="/dev/{preloader_p}" bs=512 status=progress') + os.system( + f'dd if={bootfile_loc} of="/dev/{preloader_p}" bs=512 status=progress' + ) continue elif field == "extlinux_loc": os.system(f"mkdir -p /tmp/{folder}/extlinux") @@ -297,7 +297,7 @@ def update_boot_files_from_sdcard_itself( bootbin_loc (str): The path to the boot.bin file on the SD card. kernel_loc (str): The path to the kernel file on the SD card. devicetree_loc (str): The path to the devicetree file on the SD card. - extlinux_loc (str): The path to the Extlinux configuratoin file on the SD card (Intel boards). + extlinux_loc (str): The path to the Extlinux configuration file on the SD card (Intel boards). scr_loc (str): The path to the .scr file on the SD card (Intel boards). preloader_loc (str): The path to the preloader file (.sfp) on the SD card (Intel boards). """ @@ -307,7 +307,7 @@ def update_boot_files_from_sdcard_itself( preloader_p = f"{self._target_sdcard}3" try: - for field,bootfile_loc in args.items(): + for field, bootfile_loc in args.items(): if field in ["self"]: continue bootfile_loc = os.path.join("/tmp/", folder, bootfile_loc) @@ -325,7 +325,9 @@ def update_boot_files_from_sdcard_itself( + "\n".join(options) ) if field == "preloader_loc": - os.system(f'dd if={bootfile_loc} of="/dev/{preloader_p}" bs=512 status=progress') + os.system( + f'dd if={bootfile_loc} of="/dev/{preloader_p}" bs=512 status=progress' + ) continue bootfile_name = os.path.basename(bootfile_loc) diff --git a/tests/conftest.py b/tests/conftest.py index 72278999..9ca31561 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,6 +1,5 @@ import pytest -from nebula import pdu -from nebula import usbmux +from nebula import pdu, usbmux def pytest_addoption(parser): @@ -45,6 +44,7 @@ def power_on_dut(param): p.power_up_board() yield + @pytest.fixture() def sdmux_dutmode(param): u = usbmux( @@ -54,6 +54,7 @@ def sdmux_dutmode(param): u.set_mux_mode(mode="dut") yield + @pytest.fixture() def sdmux_hostmode(param): u = usbmux( @@ -63,6 +64,7 @@ def sdmux_hostmode(param): u.set_mux_mode(mode="host") yield + @pytest.fixture() def sdmux_offmode(param): u = usbmux( diff --git a/tests/nebula_config/nebula-manager-usbmux.yml b/tests/nebula_config/nebula-manager-usbmux.yml index 921b957d..e8cc1177 100644 --- a/tests/nebula_config/nebula-manager-usbmux.yml +++ b/tests/nebula_config/nebula-manager-usbmux.yml @@ -184,4 +184,4 @@ socfpga_cyclone5_de10_nano_cn0540: - logfilename: socfpga_cyclone5_de10_nano_cn0540.log - uboot_done_string: => usbmux-config: - - target_mux: id-000000001396 \ No newline at end of file + - target_mux: id-000000001396 diff --git a/tests/test_cli.py b/tests/test_cli.py index a901e009..846cb83d 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -85,9 +85,13 @@ def test_show_log(): @pytest.mark.hardware @pytest.mark.parametrize( - "config",[ - ("eval-cn0508-rpiz", os.path.join(os.path.dirname(__file__), "nebula_config", "nebula-rpi.yaml")), - ] + "config", + [ + ( + "eval-cn0508-rpiz", + os.path.join(os.path.dirname(__file__), "nebula_config", "nebula-rpi.yaml"), + ), + ], ) def test_usbmux_backup_update_bootfiles(power_off_dut, config): test_dir = os.path.dirname(__file__) @@ -138,13 +142,14 @@ def test_usbmux_backup_update_bootfiles(power_off_dut, config): @pytest.mark.hardware @pytest.mark.parametrize( - "config",[ + "config", + [ ( "eval-cn0508-rpiz", os.path.join(os.path.dirname(__file__), "nebula_config", "nebula-rpi.yaml"), - "5.15.92-v7+" + "5.15.92-v7+", ), - ] + ], ) def test_usbmux_backup_update_modules(power_off_dut, config): test_dir = os.path.dirname(__file__) diff --git a/tests/test_manager.py b/tests/test_manager.py index af2adf43..535e7d63 100644 --- a/tests/test_manager.py +++ b/tests/test_manager.py @@ -6,60 +6,111 @@ from nebula import helper, manager param_default = [ - pytest.param({ + pytest.param( + { "board": "zynq-zc706-adv7511-ad9361-fmcomms5", - "config": os.path.join(os.path.dirname(__file__), "nebula_config", "nebula-manager.yml") - }, id="sdg-nuc-02"), - pytest.param({ + "config": os.path.join( + os.path.dirname(__file__), "nebula_config", "nebula-manager.yml" + ), + }, + id="sdg-nuc-02", + ), + pytest.param( + { "board": "zynqmp-adrv9009-zu11eg-revb-adrv2crr-fmc-revb", - "config": os.path.join(os.path.dirname(__file__), "nebula_config", "nebula-manager.yml") - }, id="sdg-nuc-02"), - pytest.param({ + "config": os.path.join( + os.path.dirname(__file__), "nebula_config", "nebula-manager.yml" + ), + }, + id="sdg-nuc-02", + ), + pytest.param( + { "board": "zynqmp-zcu102-rev10-adrv9002-vcmos", - "config": os.path.join(os.path.dirname(__file__), "nebula_config", "nebula-manager.yml") - }, id="sdg-nuc-02"), - ] + "config": os.path.join( + os.path.dirname(__file__), "nebula_config", "nebula-manager.yml" + ), + }, + id="sdg-nuc-02", + ), +] param_usbmux = [ - pytest.param({ + pytest.param( + { "board": "zynq-zc706-adv7511-ad9361-fmcomms5", - "config": os.path.join(os.path.dirname(__file__), "nebula_config", "nebula-manager-usbmux.yml"), - }, id="sdg-nuc-02"), - pytest.param({ + "config": os.path.join( + os.path.dirname(__file__), "nebula_config", "nebula-manager-usbmux.yml" + ), + }, + id="sdg-nuc-02", + ), + pytest.param( + { "board": "zynqmp-adrv9009-zu11eg-revb-adrv2crr-fmc-revb", - "config": os.path.join(os.path.dirname(__file__), "nebula_config", "nebula-manager-usbmux.yml"), - }, id="sdg-nuc-02"), - pytest.param({ + "config": os.path.join( + os.path.dirname(__file__), "nebula_config", "nebula-manager-usbmux.yml" + ), + }, + id="sdg-nuc-02", + ), + pytest.param( + { "board": "zynqmp-zcu102-rev10-adrv9002-vcmos", - "config": os.path.join(os.path.dirname(__file__), "nebula_config", "nebula-manager-usbmux.yml"), - }, id="sdg-nuc-02"), - pytest.param({ + "config": os.path.join( + os.path.dirname(__file__), "nebula_config", "nebula-manager-usbmux.yml" + ), + }, + id="sdg-nuc-02", + ), + pytest.param( + { "board": "socfpga_cyclone5_de10_nano_cn0540", - "config": os.path.join(os.path.dirname(__file__), "nebula_config", "nebula-manager-usbmux.yml"), - }, id="sdg-nuc-03"), - ] + "config": os.path.join( + os.path.dirname(__file__), "nebula_config", "nebula-manager-usbmux.yml" + ), + }, + id="sdg-nuc-03", + ), +] param_jtag = [ - pytest.param({ + pytest.param( + { "board": "zynq-zc706-adv7511-ad9361-fmcomms5", - "config": os.path.join(os.path.dirname(__file__), "nebula_config", "nebula-manager-jtag.yml") - }, id="sdg-nuc-02"), - pytest.param({ + "config": os.path.join( + os.path.dirname(__file__), "nebula_config", "nebula-manager-jtag.yml" + ), + }, + id="sdg-nuc-02", + ), + pytest.param( + { "board": "zynqmp-adrv9009-zu11eg-revb-adrv2crr-fmc-revb", - "config": os.path.join(os.path.dirname(__file__), "nebula_config", "nebula-manager-jtag.yml") - }, id="sdg-nuc-02"), - pytest.param({ + "config": os.path.join( + os.path.dirname(__file__), "nebula_config", "nebula-manager-jtag.yml" + ), + }, + id="sdg-nuc-02", + ), + pytest.param( + { "board": "zynqmp-zcu102-rev10-adrv9002-vcmos", - "config": os.path.join(os.path.dirname(__file__), "nebula_config", "nebula-manager-jtag.yml") - }, id="sdg-nuc-02"), - ] + "config": os.path.join( + os.path.dirname(__file__), "nebula_config", "nebula-manager-jtag.yml" + ), + }, + id="sdg-nuc-02", + ), +] + @pytest.mark.hardware @pytest.mark.parametrize( "param", param_usbmux, ) -def test_board_reboot_uart_net_pdu(power_off_dut, sdmux_dutmode, power_on_dut, param): +def test_board_reboot_uart_net_pdu(power_off_dut, sdmux_dutmode, power_on_dut, param): # Get necessary boot files board = param["board"] @@ -82,28 +133,30 @@ def test_board_reboot_uart_net_pdu(power_off_dut, sdmux_dutmode, power_on_dut, elif "socfpga_cyclone5" in board: files = { "bootbinpath": "soc_system.rbf", - "uimagepath" : "zImage", + "uimagepath": "zImage", "devtreepath": "socfpga.dtb", "extlinux_path": "extlinux.conf", "scr_path": "u-boot.scr", - "preloader_path": "u-boot-with-spl.sfp" + "preloader_path": "u-boot-with-spl.sfp", } boot_files = { "system_top_bit_path": None, "bootbinpath": None, "uimagepath": None, - "devtreepath" : None, + "devtreepath": None, "extlinux_path": None, "scr_path": None, - "preloader_path": None + "preloader_path": None, } root = os.path.dirname(os.path.realpath(__file__)) for boot_file_path in boot_files.keys(): if boot_file_path in files.keys(): - boot_files[boot_file_path] = f"{root}/bootfiles/{board}/" + files[boot_file_path] + boot_files[boot_file_path] = ( + f"{root}/bootfiles/{board}/" + files[boot_file_path] + ) assert os.path.isfile(boot_files[boot_file_path]) m = manager(configfilename=config, board_name=board) @@ -117,7 +170,7 @@ def test_board_reboot_uart_net_pdu(power_off_dut, sdmux_dutmode, power_on_dut, "param", param_usbmux, ) -def test_board_reboot_sdmux_pdu(power_off_dut, sdmux_dutmode, power_on_dut, param): +def test_board_reboot_sdmux_pdu(power_off_dut, sdmux_dutmode, power_on_dut, param): # Get necessary boot files board = param["board"] @@ -140,30 +193,32 @@ def test_board_reboot_sdmux_pdu(power_off_dut, sdmux_dutmode, power_on_dut, par elif "socfpga_cyclone5" in board: files = { "bootbinpath": "soc_system.rbf", - "uimagepath" : "zImage", + "uimagepath": "zImage", "devtreepath": "socfpga.dtb", "extlinux_path": "extlinux.conf", "scr_path": "u-boot.scr", - "preloader_path": "u-boot-with-spl.sfp" + "preloader_path": "u-boot-with-spl.sfp", } boot_files = { "system_top_bit_path": None, "bootbinpath": None, "uimagepath": None, - "devtreepath" : None, - "devtree_overlay_path" : None, - "devtree_overlay_config_path" : None, + "devtreepath": None, + "devtree_overlay_path": None, + "devtree_overlay_config_path": None, "extlinux_path": None, "scr_path": None, - "preloader_path": None + "preloader_path": None, } root = os.path.dirname(os.path.realpath(__file__)) for boot_file_path in boot_files.keys(): if boot_file_path in files.keys(): - boot_files[boot_file_path] = f"{root}/bootfiles/{board}/" + files[boot_file_path] + boot_files[boot_file_path] = ( + f"{root}/bootfiles/{board}/" + files[boot_file_path] + ) assert os.path.isfile(boot_files[boot_file_path]) m = manager(configfilename=config, board_name=board) @@ -194,35 +249,41 @@ def test_board_reboot_auto_usbsdmux(power_off_dut, sdmux_dutmode, power_on_dut, files = param["files"] else: if "zynqmp" in board: - files.update({ - "bootbinpath": "BOOT.BIN", - "uimagepath": "Image", - "devtreepath": "system.dtb", - }) + files.update( + { + "bootbinpath": "BOOT.BIN", + "uimagepath": "Image", + "devtreepath": "system.dtb", + } + ) elif "socfpga_cyclone5" in board: - files.update({ - "bootbinpath": "soc_system.rbf", - "uimagepath" : "zImage", - "devtreepath": "socfpga.dtb", - "extlinux_path": "extlinux.conf", - "scr_path": "u-boot.scr", - "preloader_path": "u-boot-with-spl.sfp", - "fsblpath": None, - "ubootpath": None, - }) + files.update( + { + "bootbinpath": "soc_system.rbf", + "uimagepath": "zImage", + "devtreepath": "socfpga.dtb", + "extlinux_path": "extlinux.conf", + "scr_path": "u-boot.scr", + "preloader_path": "u-boot-with-spl.sfp", + "fsblpath": None, + "ubootpath": None, + } + ) if "zc706" in board: - files.update({"ubootpath" : "u-boot_zynq_zc706.elf"}) + files.update({"ubootpath": "u-boot_zynq_zc706.elf"}) elif "zu11eg" in board: - files.update({"ubootpath" : "u-boot_adi_zynqmp_adrv9009_zu11eg_adrv2crr_fmc.elf"}) + files.update( + {"ubootpath": "u-boot_adi_zynqmp_adrv9009_zu11eg_adrv2crr_fmc.elf"} + ) elif "zcu102" in board: - files.update({"ubootpath" : "u-boot_xilinx_zynqmp_zcu102_revA.elf"}) + files.update({"ubootpath": "u-boot_xilinx_zynqmp_zcu102_revA.elf"}) boot_files = { "system_top_bit_path": None, "bootbinpath": None, "uimagepath": None, - "devtreepath" : None, + "devtreepath": None, "extlinux_path": None, "scr_path": None, "preloader_path": None, @@ -233,16 +294,16 @@ def test_board_reboot_auto_usbsdmux(power_off_dut, sdmux_dutmode, power_on_dut, for boot_file_path in boot_files.keys(): if boot_file_path in files.keys(): if files[boot_file_path]: - boot_files[boot_file_path] = f"{root}/bootfiles/{board}/" + files[boot_file_path] + boot_files[boot_file_path] = ( + f"{root}/bootfiles/{board}/" + files[boot_file_path] + ) assert os.path.isfile(boot_files[boot_file_path]) m = manager(configfilename=config, board_name=board) m.net.check_board_booted() # load files vi board_reboot_auto() - m.board_reboot_auto( - **boot_files - ) + m.board_reboot_auto(**boot_files) @pytest.mark.hardware @@ -250,7 +311,9 @@ def test_board_reboot_auto_usbsdmux(power_off_dut, sdmux_dutmode, power_on_dut, "param", param_usbmux, ) -def test_board_reboot_auto_folder_usbsdmux(power_off_dut, sdmux_dutmode, power_on_dut, param): +def test_board_reboot_auto_folder_usbsdmux( + power_off_dut, sdmux_dutmode, power_on_dut, param +): # Get necessary boot files board = param["board"] @@ -266,6 +329,7 @@ def test_board_reboot_auto_folder_usbsdmux(power_off_dut, sdmux_dutmode, power_o design_name=board, ) + @pytest.mark.hardware @pytest.mark.parametrize( "param", @@ -288,35 +352,41 @@ def test_recover_board_functional(power_off_dut, sdmux_dutmode, power_on_dut, pa files = param["files"] else: if "zynqmp" in board: - files.update({ - "bootbinpath": "BOOT.BIN", - "uimagepath": "Image", - "devtreepath": "system.dtb", - }) + files.update( + { + "bootbinpath": "BOOT.BIN", + "uimagepath": "Image", + "devtreepath": "system.dtb", + } + ) elif "socfpga_cyclone5" in board: - files.update({ - "bootbinpath": "soc_system.rbf", - "uimagepath" : "zImage", - "devtreepath": "socfpga.dtb", - "extlinux_path": "extlinux.conf", - "scr_path": "u-boot.scr", - "preloader_path": "u-boot-with-spl.sfp", - "fsblpath": None, - "ubootpath": None, - }) + files.update( + { + "bootbinpath": "soc_system.rbf", + "uimagepath": "zImage", + "devtreepath": "socfpga.dtb", + "extlinux_path": "extlinux.conf", + "scr_path": "u-boot.scr", + "preloader_path": "u-boot-with-spl.sfp", + "fsblpath": None, + "ubootpath": None, + } + ) if "zc706" in board: - files.update({"ubootpath" : "u-boot_zynq_zc706.elf"}) + files.update({"ubootpath": "u-boot_zynq_zc706.elf"}) elif "zu11eg" in board: - files.update({"ubootpath" : "u-boot_adi_zynqmp_adrv9009_zu11eg_adrv2crr_fmc.elf"}) + files.update( + {"ubootpath": "u-boot_adi_zynqmp_adrv9009_zu11eg_adrv2crr_fmc.elf"} + ) elif "zcu102" in board: - files.update({"ubootpath" : "u-boot_xilinx_zynqmp_zcu102_revA.elf"}) + files.update({"ubootpath": "u-boot_xilinx_zynqmp_zcu102_revA.elf"}) boot_files = { "system_top_bit_path": None, "bootbinpath": None, "uimagepath": None, - "devtreepath" : None, + "devtreepath": None, "extlinux_path": None, "scr_path": None, "preloader_path": None, @@ -329,16 +399,16 @@ def test_recover_board_functional(power_off_dut, sdmux_dutmode, power_on_dut, pa for boot_file_path in boot_files.keys(): if boot_file_path in files.keys(): if files[boot_file_path]: - boot_files[boot_file_path] = f"{root}/bootfiles/{board}/" + files[boot_file_path] + boot_files[boot_file_path] = ( + f"{root}/bootfiles/{board}/" + files[boot_file_path] + ) assert os.path.isfile(boot_files[boot_file_path]) m = manager(configfilename=config, board_name=board) m.net.check_board_booted() # recover via usb-sd-mux - m.recover_board( - **boot_files - ) + m.recover_board(**boot_files) @pytest.mark.hardware @@ -363,35 +433,41 @@ def test_recover_board_usbsdmux(power_off_dut, sdmux_dutmode, power_on_dut, para files = param["files"] else: if "zynqmp" in board: - files.update({ - "bootbinpath": "BOOT.BIN", - "uimagepath": "Image", - "devtreepath": "system.dtb", - }) + files.update( + { + "bootbinpath": "BOOT.BIN", + "uimagepath": "Image", + "devtreepath": "system.dtb", + } + ) elif "socfpga_cyclone5" in board: - files.update({ - "bootbinpath": "soc_system.rbf", - "uimagepath" : "zImage", - "devtreepath": "socfpga.dtb", - "extlinux_path": "extlinux.conf", - "scr_path": "u-boot.scr", - "preloader_path": "u-boot-with-spl.sfp", - "fsblpath": None, - "ubootpath": None, - }) + files.update( + { + "bootbinpath": "soc_system.rbf", + "uimagepath": "zImage", + "devtreepath": "socfpga.dtb", + "extlinux_path": "extlinux.conf", + "scr_path": "u-boot.scr", + "preloader_path": "u-boot-with-spl.sfp", + "fsblpath": None, + "ubootpath": None, + } + ) if "zc706" in board: - files.update({"ubootpath" : "u-boot_zynq_zc706.elf"}) + files.update({"ubootpath": "u-boot_zynq_zc706.elf"}) elif "zu11eg" in board: - files.update({"ubootpath" : "u-boot_adi_zynqmp_adrv9009_zu11eg_adrv2crr_fmc.elf"}) + files.update( + {"ubootpath": "u-boot_adi_zynqmp_adrv9009_zu11eg_adrv2crr_fmc.elf"} + ) elif "zcu102" in board: - files.update({"ubootpath" : "u-boot_xilinx_zynqmp_zcu102_revA.elf"}) + files.update({"ubootpath": "u-boot_xilinx_zynqmp_zcu102_revA.elf"}) boot_files = { "system_top_bit_path": None, "bootbinpath": None, "uimagepath": None, - "devtreepath" : None, + "devtreepath": None, "extlinux_path": None, "scr_path": None, "preloader_path": None, @@ -404,7 +480,9 @@ def test_recover_board_usbsdmux(power_off_dut, sdmux_dutmode, power_on_dut, para for boot_file_path in boot_files.keys(): if boot_file_path in files.keys(): if files[boot_file_path]: - boot_files[boot_file_path] = f"{root}/bootfiles/{board}/" + files[boot_file_path] + boot_files[boot_file_path] = ( + f"{root}/bootfiles/{board}/" + files[boot_file_path] + ) assert os.path.isfile(boot_files[boot_file_path]) m = manager(configfilename=config, board_name=board) @@ -415,9 +493,7 @@ def test_recover_board_usbsdmux(power_off_dut, sdmux_dutmode, power_on_dut, para m.power.power_cycle_board() # recover via usb-sd-mux - m.recover_board( - **boot_files - ) + m.recover_board(**boot_files) @pytest.mark.hardware @@ -547,5 +623,6 @@ def test_recover_board_jtag(power_on_dut, param): ubootpath, ) + if __name__ == "__main__": test_board_reboot_uart_net_pdu() diff --git a/tests/test_usbsdmux.py b/tests/test_usbsdmux.py index 4549ea4b..7c2092c2 100644 --- a/tests/test_usbsdmux.py +++ b/tests/test_usbsdmux.py @@ -7,13 +7,16 @@ @pytest.mark.hardware @pytest.mark.parametrize( - "param",[ + "param", + [ { - "board":"eval-cn0508-rpiz", - "config": os.path.join(os.path.dirname(__file__), "nebula_config", "nebula-rpi.yaml"), - "target_mux": "id-000000001204", + "board": "eval-cn0508-rpiz", + "config": os.path.join( + os.path.dirname(__file__), "nebula_config", "nebula-rpi.yaml" + ), + "target_mux": "id-000000001204", }, - ] + ], ) def test_find_mux_device(param): sd = usbmux( @@ -26,16 +29,21 @@ def test_find_mux_device(param): @pytest.mark.hardware @pytest.mark.parametrize( - "param",[ + "param", + [ { "board": "eval-cn0508-rpiz", - "config": os.path.join(os.path.dirname(__file__), "nebula_config", "nebula-rpi.yaml"), + "config": os.path.join( + os.path.dirname(__file__), "nebula_config", "nebula-rpi.yaml" + ), }, { "board": "socfpga_cyclone5_de10_nano_cn0540", - "config": os.path.join(os.path.dirname(__file__), "nebula_config", "nebula-manager-usbmux.yml"), - } - ] + "config": os.path.join( + os.path.dirname(__file__), "nebula_config", "nebula-manager-usbmux.yml" + ), + }, + ], ) def test_find_muxed_sdcard(power_off_dut, param): sd = usbmux( @@ -48,22 +56,26 @@ def test_find_muxed_sdcard(power_off_dut, param): @pytest.mark.hardware @pytest.mark.parametrize( - "param",[ + "param", + [ { - "board":"socfpga_cyclone5_de10_nano_cn0540", - "config": os.path.join(os.path.dirname(__file__),"nebula_config","nebula-manager-usbmux.yml"), + "board": "socfpga_cyclone5_de10_nano_cn0540", + "config": os.path.join( + os.path.dirname(__file__), "nebula_config", "nebula-manager-usbmux.yml" + ), "files": [ - os.path.join("socfpga_cyclone5_de10_nano_cn0540","soc_system.rbf"), - os.path.join("socfpga_cyclone5_common","zImage"), - os.path.join("socfpga_cyclone5_de10_nano_cn0540","socfpga.dtb"), - os.path.join("socfpga_cyclone5_de10_nano_cn0540","extlinux.conf"), - os.path.join("socfpga_cyclone5_de10_nano_cn0540","u-boot.scr"), - os.path.join("socfpga_cyclone5_de10_nano_cn0540","u-boot-with-spl.sfp"), - ] - + os.path.join("socfpga_cyclone5_de10_nano_cn0540", "soc_system.rbf"), + os.path.join("socfpga_cyclone5_common", "zImage"), + os.path.join("socfpga_cyclone5_de10_nano_cn0540", "socfpga.dtb"), + os.path.join("socfpga_cyclone5_de10_nano_cn0540", "extlinux.conf"), + os.path.join("socfpga_cyclone5_de10_nano_cn0540", "u-boot.scr"), + os.path.join( + "socfpga_cyclone5_de10_nano_cn0540", "u-boot-with-spl.sfp" + ), + ], }, - ] -) + ], +) def test_backup_files_to_external(power_off_dut, param): sd = usbmux( board_name=param["board"], @@ -76,27 +88,41 @@ def test_backup_files_to_external(power_off_dut, param): partition="boot", destination="backup", target=param["files"], - subfolder=param["board"] + subfolder=param["board"], ) finally: sd.set_mux_mode("off") + @pytest.mark.hardware @pytest.mark.parametrize( - "param",[ + "param", + [ { - "board":"socfpga_cyclone5_de10_nano_cn0540", - "config": os.path.join(os.path.dirname(__file__),"nebula_config","nebula-manager-usbmux.yml"), + "board": "socfpga_cyclone5_de10_nano_cn0540", + "config": os.path.join( + os.path.dirname(__file__), "nebula_config", "nebula-manager-usbmux.yml" + ), "files": { - "bootbin_loc": os.path.join("socfpga_cyclone5_de10_nano_cn0540","soc_system.rbf"), - "kernel_loc": os.path.join("socfpga_cyclone5_common","zImage"), - "devicetree_loc": os.path.join("socfpga_cyclone5_de10_nano_cn0540","socfpga.dtb"), - "extlinux_loc": os.path.join("socfpga_cyclone5_de10_nano_cn0540","extlinux.conf"), - "scr_loc": os.path.join("socfpga_cyclone5_de10_nano_cn0540","u-boot.scr"), - "preloader_loc": os.path.join("socfpga_cyclone5_de10_nano_cn0540","u-boot-with-spl.sfp"), - } + "bootbin_loc": os.path.join( + "socfpga_cyclone5_de10_nano_cn0540", "soc_system.rbf" + ), + "kernel_loc": os.path.join("socfpga_cyclone5_common", "zImage"), + "devicetree_loc": os.path.join( + "socfpga_cyclone5_de10_nano_cn0540", "socfpga.dtb" + ), + "extlinux_loc": os.path.join( + "socfpga_cyclone5_de10_nano_cn0540", "extlinux.conf" + ), + "scr_loc": os.path.join( + "socfpga_cyclone5_de10_nano_cn0540", "u-boot.scr" + ), + "preloader_loc": os.path.join( + "socfpga_cyclone5_de10_nano_cn0540", "u-boot-with-spl.sfp" + ), + }, }, - ] + ], ) def test_update_boot_files_from_sdcard_itself(power_off_dut, param): sd = usbmux( @@ -106,26 +132,28 @@ def test_update_boot_files_from_sdcard_itself(power_off_dut, param): try: sd.find_muxed_sdcard() assert sd._target_sdcard - sd.update_boot_files_from_sdcard_itself( - **param["files"] - ) + sd.update_boot_files_from_sdcard_itself(**param["files"]) finally: sd.set_mux_mode("off") + @pytest.mark.hardware @pytest.mark.parametrize( - "param",[ + "param", + [ { - "board" : "eval-cn0508-rpiz", - "config": os.path.join(os.path.dirname(__file__), "nebula_config", "nebula-rpi.yaml"), - "files":{ + "board": "eval-cn0508-rpiz", + "config": os.path.join( + os.path.dirname(__file__), "nebula_config", "nebula-rpi.yaml" + ), + "files": { "kernel_loc": os.path.join("kernel7.img"), "devicetree_loc": os.path.join("bcm2710-rpi-3-b-plus.dtb"), - "devicetree_overlay_loc" : os.path.join("overlays","rpi-cn0508.dtbo"), - "devicetree_overlay_config_loc" : os.path.join("config.txt"), + "devicetree_overlay_loc": os.path.join("overlays", "rpi-cn0508.dtbo"), + "devicetree_overlay_config_loc": os.path.join("config.txt"), }, - "modules" : "5.15.92-v7+", - "config_param" : [ + "modules": "5.15.92-v7+", + "config_param": [ "dtoverlay=rpi-cn0508", "dtparam=rotate=270", "dtparam=speed=64000000", @@ -139,21 +167,33 @@ def test_update_boot_files_from_sdcard_itself(power_off_dut, param): "dtparam=gpiopull=up", "dtparam=act_led_gpio=13", "dtparam=act_led_trigger=heartbeat", - ] + ], }, { - "board":"socfpga_cyclone5_de10_nano_cn0540", - "config": os.path.join(os.path.dirname(__file__),"nebula_config","nebula-manager-usbmux.yml"), + "board": "socfpga_cyclone5_de10_nano_cn0540", + "config": os.path.join( + os.path.dirname(__file__), "nebula_config", "nebula-manager-usbmux.yml" + ), "files": { - "bootbin_loc": os.path.join("socfpga_cyclone5_de10_nano_cn0540","soc_system.rbf"), - "kernel_loc": os.path.join("socfpga_cyclone5_common","zImage"), - "devicetree_loc": os.path.join("socfpga_cyclone5_de10_nano_cn0540","socfpga.dtb"), - "extlinux_loc": os.path.join("socfpga_cyclone5_de10_nano_cn0540","extlinux.conf"), - "scr_loc": os.path.join("socfpga_cyclone5_de10_nano_cn0540","u-boot.scr"), - "preloader_loc": os.path.join("socfpga_cyclone5_de10_nano_cn0540","u-boot-with-spl.sfp"), - } + "bootbin_loc": os.path.join( + "socfpga_cyclone5_de10_nano_cn0540", "soc_system.rbf" + ), + "kernel_loc": os.path.join("socfpga_cyclone5_common", "zImage"), + "devicetree_loc": os.path.join( + "socfpga_cyclone5_de10_nano_cn0540", "socfpga.dtb" + ), + "extlinux_loc": os.path.join( + "socfpga_cyclone5_de10_nano_cn0540", "extlinux.conf" + ), + "scr_loc": os.path.join( + "socfpga_cyclone5_de10_nano_cn0540", "u-boot.scr" + ), + "preloader_loc": os.path.join( + "socfpga_cyclone5_de10_nano_cn0540", "u-boot-with-spl.sfp" + ), + }, }, - ] + ], ) def test_backup_update_boot_files_external(power_off_dut, param): sd = usbmux( @@ -166,13 +206,15 @@ def test_backup_update_boot_files_external(power_off_dut, param): if os.path.exists(destination): shutil.rmtree(destination) folder_b = sd.backup_files_to_external( - target=[ file for file in param["files"].values()], + target=[file for file in param["files"].values()], destination=destination, subfolder=subfolder, ) assert subfolder == folder_b - for target_file in [ file for file in param["files"].values()]: - assert os.path.isfile(os.path.join(destination, folder_b, os.path.basename(target_file))) + for target_file in [file for file in param["files"].values()]: + assert os.path.isfile( + os.path.join(destination, folder_b, os.path.basename(target_file)) + ) if "config_param" in param: with open(os.path.join(destination, folder_b, "config.txt"), "a") as f: @@ -183,18 +225,18 @@ def test_backup_update_boot_files_external(power_off_dut, param): target_files = dict() for _file, _loc in param["files"].items(): - target_files.update({_file : os.path.join(destination, folder_b, os.path.basename(_loc))}) + target_files.update( + {_file: os.path.join(destination, folder_b, os.path.basename(_loc))} + ) - sd.update_boot_files_from_external( - **target_files - ) + sd.update_boot_files_from_external(**target_files) if "modules" in param and param["modules"]: folder_r = sd.backup_files_to_external( partition="root", target=[os.path.join("lib", "modules", param["modules"])], destination=destination, - subfolder=subfolder + subfolder=subfolder, ) assert subfolder == folder_r assert os.path.isdir(os.path.join(destination, folder_r, param["modules"]))