diff --git a/doc/manager_recovery.pu b/doc/manager_recovery.pu index a12b946a..f86b0d37 100644 --- a/doc/manager_recovery.pu +++ b/doc/manager_recovery.pu @@ -11,17 +11,17 @@ if (Is Linux is accessible?) then (yes) #palegreen: Home sweet home; kill else (no) - + if (usbsdmux enabled) then (yes) partition #yellow "SD Card Mux"{ : power down board using PDU __power.power_down_board()__; if (SD card mode) then (yes) - : update boot files + : update boot files from within sdcard via usb-sd-mux; else (no) - : update boot files + : update boot files from external sources via usb-sd-mux; endif diff --git a/nebula/errors.py b/nebula/errors.py index 6318db9f..82dd008b 100644 --- a/nebula/errors.py +++ b/nebula/errors.py @@ -34,6 +34,7 @@ class LinuxNotReached(Error): pass + class UbootNotReached(Error): """U-boot menu not reachable""" diff --git a/nebula/jtag.py b/nebula/jtag.py index 1ec92cdd..c2e6c664 100644 --- a/nebula/jtag.py +++ b/nebula/jtag.py @@ -115,7 +115,7 @@ def target_set_str(self, target_name): + "}} ; " ) - def boot_to_uboot(self, fsblpath="fsbl.elf" ,ubootpath="u-boot.elf"): + def boot_to_uboot(self, fsblpath="fsbl.elf", ubootpath="u-boot.elf"): """From JTAG reset board and load up FSBL and uboot This should be followed by uboot interaction to stop it""" assert os.path.isfile(fsblpath) @@ -143,7 +143,11 @@ def boot_to_uboot(self, fsblpath="fsbl.elf" ,ubootpath="u-boot.elf"): cmd += "after 1000; " cmd += "puts {Loading U-BOOT}; " - cmd += "if {[catch {dow " + ubootpath + "} result]} {puts {Error loading FSBL... u-boot is probably loaded}; }; " + cmd += ( + "if {[catch {dow " + + ubootpath + + "} result]} {puts {Error loading FSBL... u-boot is probably loaded}; }; " + ) cmd += "con; " self.run_xsdb(cmd) diff --git a/nebula/manager.py b/nebula/manager.py index 884340f8..4f2bbe8b 100644 --- a/nebula/manager.py +++ b/nebula/manager.py @@ -25,7 +25,7 @@ class manager: """Board Manager""" - def __init__( + def __init__( # noqa:C901 self, monitor_type="uart", configfilename=None, @@ -112,7 +112,9 @@ def __init__( self.tftp = False if "usbmux-config" in configs: - self.usbsdmux = usbmux(yamlfilename=self.configfilename, board_name=board_name) + self.usbsdmux = usbmux( + yamlfilename=self.configfilename, board_name=board_name + ) else: self.usbsdmux = None @@ -201,15 +203,15 @@ def network_check(self): raise ne.SSHNotFunctionalAfterBootFileUpdate @_release_thread_lock - def recover_board( - self, + def recover_board( # noqa:C901 + self, system_top_bit_path, bootbinpath, uimagepath, devtreepath, fsblpath=None, ubootpath=None, - sdcard=False + sdcard=False, ): """Recover boards with UART, PDU, JTAG, USB-SD-Mux and Network if available""" self._check_files_exist( @@ -263,7 +265,7 @@ def recover_board( self.usbsdmux.update_boot_files_from_external( bootbin_loc=bootbinpath, kernel_loc=uimagepath, - devicetree_loc=devtreepath + devicetree_loc=devtreepath, ) # if devtreepath: # self.usbsdmux.update_devicetree_for_mux(devtreepath) @@ -305,7 +307,8 @@ def recover_board( devtree_filename=devtreepath, ) results = self.monitor[0]._read_until_done_multi( - done_strings=["Starting kernel", "root@analog"], max_time=100 + done_strings=["Starting kernel", "root@analog"], + max_time=100, ) if len(results) == 1: @@ -332,7 +335,7 @@ def recover_board( devtreepath, fsblpath, ubootpath, - sdcard + sdcard, ) log.info("Linux fully recovered") else: @@ -348,7 +351,7 @@ def board_reboot_jtag_uart( devtreepath, fsblpath=None, ubootpath=None, - sdcard=False + sdcard=False, ): """Reset board and load fsbl, uboot, bitstream, and kernel over JTAG. Then over UART boot @@ -362,7 +365,7 @@ def board_reboot_jtag_uart( log.info("u-boot accessible after JTAG reset") else: log.info("u-boot not reachable, manually loading u-boot over JTAG") - self.jtag.boot_to_uboot(fsblpath,ubootpath) + self.jtag.boot_to_uboot(fsblpath, ubootpath) log.info("Taking over UART control") if not self.monitor[0]._enter_uboot_menu_from_power_cycle(): raise ne.UbootNotReached @@ -538,7 +541,7 @@ def board_reboot_sdmux_pdu( self.usbsdmux.update_boot_files_from_external( bootbin_loc=bootbinpath, kernel_loc=uimagepath, - devicetree_loc=devtreepath + devicetree_loc=devtreepath, ) # if devtreepath: # self.usbsdmux.update_devicetree_for_mux(devtreepath) @@ -753,10 +756,16 @@ def board_reboot_auto_folder( ) def board_reboot_auto( - self, system_top_bit_path, bootbinpath, uimagepath, devtreepath, sdcard=False, recover=False + self, + system_top_bit_path, + bootbinpath, + uimagepath, + devtreepath, + sdcard=False, + recover=False, ): """Automatically select loading mechanism - based on current class setup""" + based on current class setup""" if recover: self.recover_board( system_top_bit_path=system_top_bit_path, diff --git a/tests/conftest.py b/tests/conftest.py index f0aa3138..ca351a88 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -34,6 +34,7 @@ def power_off_dut(config, board): p.power_down_board() yield + @pytest.fixture() def power_on_dut(config, board): p = pdu( diff --git a/tests/nebula_config/nebula-manager-usbmux.yml b/tests/nebula_config/nebula-manager-usbmux.yml index 97d12573..8832d443 100644 --- a/tests/nebula_config/nebula-manager-usbmux.yml +++ b/tests/nebula_config/nebula-manager-usbmux.yml @@ -138,4 +138,4 @@ zynqmp-zcu102-rev10-adrv9002-vcmos: - baudrate: 115200 - logfilename: zynqmp-zcu102-rev10-adrv9002-vcmos.log usbmux-config: - - target_mux: id-000000001358 \ No newline at end of file + - target_mux: id-000000001358 diff --git a/tests/test_manager.py b/tests/test_manager.py index 608b86ef..bf213bf5 100644 --- a/tests/test_manager.py +++ b/tests/test_manager.py @@ -3,8 +3,8 @@ import time import pytest -from nebula import manager -from nebula import helper +from nebula import helper, manager + # @pytest.mark.skip(reason="Not fully implemented") # @pytest.mark.dependency() @@ -31,17 +31,23 @@ def test_board_reboot_uart_net_pdu(): devtreepath=devtree_filename, ) + @pytest.mark.hardware @pytest.mark.parametrize( "config", - [os.path.join(os.path.dirname(__file__), "nebula_config", "nebula-manager-usbmux.yml")], + [ + os.path.join( + os.path.dirname(__file__), "nebula_config", "nebula-manager-usbmux.yml" + ) + ], ) @pytest.mark.parametrize( - "board", [ + "board", + [ "zynq-zc706-adv7511-ad9361-fmcomms5", "zynqmp-adrv9009-zu11eg-revb-adrv2crr-fmc-revb", - "zynqmp-zcu102-rev10-adrv9002-vcmos" - ] + "zynqmp-zcu102-rev10-adrv9002-vcmos", + ], ) def test_board_reboot_sdmux_pdu(power_on_dut, config, board): @@ -54,7 +60,7 @@ def test_board_reboot_sdmux_pdu(power_on_dut, config, board): if "zynqmp" in board: uimage = "Image" - devtree= "system.dtb" + devtree = "system.dtb" system_top_bit_path = f"{root}/bootfiles/{board}/" + system_top_bit bootbinpath = f"{root}/bootfiles/{board}/" + bootbin @@ -69,24 +75,25 @@ def test_board_reboot_sdmux_pdu(power_on_dut, config, board): m = manager(configfilename=config, board_name=board) m.net.check_board_booted() - m.board_reboot_sdmux_pdu( - system_top_bit_path, - bootbinpath, - uimagepath, - devtreepath - ) + m.board_reboot_sdmux_pdu(system_top_bit_path, bootbinpath, uimagepath, devtreepath) + @pytest.mark.hardware @pytest.mark.parametrize( "config", - [os.path.join(os.path.dirname(__file__), "nebula_config", "nebula-manager-usbmux.yml")], + [ + os.path.join( + os.path.dirname(__file__), "nebula_config", "nebula-manager-usbmux.yml" + ) + ], ) @pytest.mark.parametrize( - "board", [ + "board", + [ "zynq-zc706-adv7511-ad9361-fmcomms5", "zynqmp-adrv9009-zu11eg-revb-adrv2crr-fmc-revb", - "zynqmp-zcu102-rev10-adrv9002-vcmos" - ] + "zynqmp-zcu102-rev10-adrv9002-vcmos", + ], ) def test_recover_board_functional(power_on_dut, config, board): @@ -108,7 +115,7 @@ def test_recover_board_functional(power_on_dut, config, board): if "zynqmp" in board: uimage = "Image" - devtree= "system.dtb" + devtree = "system.dtb" system_top_bit_path = f"{root}/bootfiles/{board}/" + system_top_bit bootbinpath = f"{root}/bootfiles/{board}/" + bootbin @@ -124,31 +131,31 @@ def test_recover_board_functional(power_on_dut, config, board): assert os.path.isfile(fsblpath) assert os.path.isfile(ubootpath) - m = manager(configfilename=config, board_name=board) m.net.check_board_booted() # recover via usb-sd-mux m.recover_board( - system_top_bit_path, - bootbinpath, - uimagepath, - devtreepath, - fsblpath, - ubootpath + system_top_bit_path, bootbinpath, uimagepath, devtreepath, fsblpath, ubootpath ) + @pytest.mark.hardware @pytest.mark.parametrize( "config", - [os.path.join(os.path.dirname(__file__), "nebula_config", "nebula-manager-usbmux.yml")], + [ + os.path.join( + os.path.dirname(__file__), "nebula_config", "nebula-manager-usbmux.yml" + ) + ], ) @pytest.mark.parametrize( - "board", [ + "board", + [ "zynq-zc706-adv7511-ad9361-fmcomms5", "zynqmp-adrv9009-zu11eg-revb-adrv2crr-fmc-revb", - "zynqmp-zcu102-rev10-adrv9002-vcmos" - ] + "zynqmp-zcu102-rev10-adrv9002-vcmos", + ], ) def test_recover_board_usbsdmux(power_on_dut, config, board): @@ -170,7 +177,7 @@ def test_recover_board_usbsdmux(power_on_dut, config, board): if "zynqmp" in board: uimage = "Image" - devtree= "system.dtb" + devtree = "system.dtb" system_top_bit_path = f"{root}/bootfiles/{board}/" + system_top_bit bootbinpath = f"{root}/bootfiles/{board}/" + bootbin @@ -186,7 +193,6 @@ def test_recover_board_usbsdmux(power_on_dut, config, board): assert os.path.isfile(fsblpath) assert os.path.isfile(ubootpath) - m = manager(configfilename=config, board_name=board) m.net.check_board_booted() @@ -196,25 +202,22 @@ def test_recover_board_usbsdmux(power_on_dut, config, board): # recover via usb-sd-mux m.recover_board( - system_top_bit_path, - bootbinpath, - uimagepath, - devtreepath, - fsblpath, - ubootpath + system_top_bit_path, bootbinpath, uimagepath, devtreepath, fsblpath, ubootpath ) + @pytest.mark.hardware @pytest.mark.parametrize( "config", [os.path.join(os.path.dirname(__file__), "nebula_config", "nebula-manager.yml")], ) @pytest.mark.parametrize( - "board", [ + "board", + [ "zynq-zc706-adv7511-ad9361-fmcomms5", "zynqmp-adrv9009-zu11eg-revb-adrv2crr-fmc-revb", - "zynqmp-zcu102-rev10-adrv9002-vcmos" - ] + "zynqmp-zcu102-rev10-adrv9002-vcmos", + ], ) def test_recover_board_uart(power_on_dut, config, board): @@ -236,7 +239,7 @@ def test_recover_board_uart(power_on_dut, config, board): if "zynqmp" in board: uimage = "Image" - devtree= "system.dtb" + devtree = "system.dtb" system_top_bit_path = f"{root}/bootfiles/{board}/" + system_top_bit bootbinpath = f"{root}/bootfiles/{board}/" + bootbin @@ -270,18 +273,24 @@ def test_recover_board_uart(power_on_dut, config, board): ubootpath, ) + # @pytest.mark.skip(reason="Not fully implemented") @pytest.mark.hardware @pytest.mark.parametrize( "config", - [os.path.join(os.path.dirname(__file__), "nebula_config", "nebula-manager-jtag.yml")], + [ + os.path.join( + os.path.dirname(__file__), "nebula_config", "nebula-manager-jtag.yml" + ) + ], ) @pytest.mark.parametrize( - "board", [ + "board", + [ "zynq-zc706-adv7511-ad9361-fmcomms5", "zynqmp-adrv9009-zu11eg-revb-adrv2crr-fmc-revb", - "zynqmp-zcu102-rev10-adrv9002-vcmos" - ] + "zynqmp-zcu102-rev10-adrv9002-vcmos", + ], ) def test_recover_board_jtag(power_on_dut, config, board): @@ -303,7 +312,7 @@ def test_recover_board_jtag(power_on_dut, config, board): if "zynqmp" in board: uimage = "Image" - devtree= "system.dtb" + devtree = "system.dtb" system_top_bit_path = f"{root}/bootfiles/{board}/" + system_top_bit bootbinpath = f"{root}/bootfiles/{board}/" + bootbin @@ -338,5 +347,6 @@ def test_recover_board_jtag(power_on_dut, config, board): ubootpath, ) + if __name__ == "__main__": test_board_reboot_uart_net_pdu()