diff --git a/osfv_cli/osfv_cli/models/MSI PRO Z790-P WIFI DDR5.yml b/osfv_cli/osfv_cli/models/MSI PRO Z790-P WIFI DDR5.yml index 1b87041..76ceea9 100644 --- a/osfv_cli/osfv_cli/models/MSI PRO Z790-P WIFI DDR5.yml +++ b/osfv_cli/osfv_cli/models/MSI PRO Z790-P WIFI DDR5.yml @@ -3,7 +3,7 @@ flash_chip: voltage: "1.8V" programmer: - name: rte + name: rte_1_1 pwr_ctrl: sonoff: true diff --git a/osfv_cli/osfv_cli/models/VP6650.yml b/osfv_cli/osfv_cli/models/VP6650.yml new file mode 100644 index 0000000..5046385 --- /dev/null +++ b/osfv_cli/osfv_cli/models/VP6650.yml @@ -0,0 +1,14 @@ +--- +flash_chip: + model: "MX25L12833F/MX25L12835F/MX25L12845E/MX25L12865E/MX25L12873F" + voltage: "3.3V" + +programmer: + name: rte_1_1 + +pwr_ctrl: + sonoff: true + relay: false + init_on: true + +reset_cmos: true diff --git a/osfv_cli/osfv_cli/models/VP6670.yml b/osfv_cli/osfv_cli/models/VP6670.yml new file mode 100644 index 0000000..5046385 --- /dev/null +++ b/osfv_cli/osfv_cli/models/VP6670.yml @@ -0,0 +1,14 @@ +--- +flash_chip: + model: "MX25L12833F/MX25L12835F/MX25L12845E/MX25L12865E/MX25L12873F" + voltage: "3.3V" + +programmer: + name: rte_1_1 + +pwr_ctrl: + sonoff: true + relay: false + init_on: true + +reset_cmos: true diff --git a/osfv_cli/osfv_cli/rte.py b/osfv_cli/osfv_cli/rte.py index 9c267ec..f628008 100644 --- a/osfv_cli/osfv_cli/rte.py +++ b/osfv_cli/osfv_cli/rte.py @@ -182,6 +182,13 @@ def pwr_ctrl_off(self): raise Exception("Failed to power control OFF") time.sleep(2) + def discharge_psu(self): + """ + Push power button 5 times in the loop to make sure the charge from PSU is dissipated + """ + for _ in range(5): + self.power_off(3) + def pwr_ctrl_before_flash(self, programmer): # 1. sonoff/relay ON # 2. sleep 5 @@ -189,15 +196,14 @@ def pwr_ctrl_before_flash(self, programmer): # not (like FW4C). if self.dut_data["pwr_ctrl"]["init_on"] is True: self.pwr_ctrl_on() - time.sleep(1) + time.sleep(5) self.power_off(6) + time.sleep(10) else: - self.pwr_ctrl_off() # 3. RTE POFF # 4. sleep 3 - # Run 5 times in the loop to make sure to charge from PSU is dissipated - for _ in range(5): - self.power_off(3) + self.pwr_ctrl_off() + self.discharge_psu() if programmer == "rte_1_1": # 5. SPI ON @@ -205,10 +211,11 @@ def pwr_ctrl_before_flash(self, programmer): self.spi_enable() time.sleep(3) - if self.dut_data["pwr_ctrl"]["init_on"] is False: + if self.dut_data["pwr_ctrl"]["init_on"] is True: # 7. sonoff/relay OFF # 8. sleep 2 self.pwr_ctrl_off() + self.discharge_psu() def pwr_ctrl_after_flash(self, programmer): if programmer == "rte_1_1": diff --git a/osfv_cli/osfv_cli/rte_robot.py b/osfv_cli/osfv_cli/rte_robot.py new file mode 100644 index 0000000..2584c6e --- /dev/null +++ b/osfv_cli/osfv_cli/rte_robot.py @@ -0,0 +1,27 @@ +import robot.api.logger +from rte import RTE +from snipeit_api import SnipeIT + + +class RobotRTE: + def __init__(self, rte_ip): + snipeit_api = SnipeIT() + asset_id = snipeit_api.get_asset_id_by_rte_ip(rte_ip) + status, dut_model_name = snipeit_api.get_asset_model_name(asset_id) + if status: + robot.api.logger.info(f"DUT model retrieved from snipeit: {dut_model_name}") + else: + raise AssertionError( + f"Failed to retrieve model name from Snipe-IT. Check again arguments, or try providing model manually." + ) + self.rte = RTE(rte_ip, dut_model_name, snipeit_api) + + def flash_read(self, fw_file): + robot.api.logger.info(f"Reading from flash...") + self.rte.flash_read(fw_file) + robot.api.logger.info(f"Read flash content saved to {fw_file}") + + def flash_write(self, fw_file): + robot.api.logger.info(f"Writing {fw_file} to flash...") + self.rte.flash_write(fw_file) + robot.api.logger.info(f"Flash written") diff --git a/osfv_cli/osfv_cli/sonoff_api.py b/osfv_cli/osfv_cli/sonoff_api.py index 9769d1b..30f49e6 100644 --- a/osfv_cli/osfv_cli/sonoff_api.py +++ b/osfv_cli/osfv_cli/sonoff_api.py @@ -21,14 +21,14 @@ def _post_request(self, endpoint): return response.status_code def turn_on(self): - endpoint = "/cm?cmnd=Power%20On" + endpoint = "/switch/sonoff_s20_relay/turn_on" return self._post_request(endpoint) def turn_off(self): - endpoint = "/cm?cmnd=Power%20Off" + endpoint = "/switch/sonoff_s20_relay/turn_off" return self._post_request(endpoint) def get_state(self): - endpoint = "/cm?cmnd=Power" + endpoint = "/switch/sonoff_s20_relay" response = self._get_request(endpoint) - return response.get("POWER") + return response.get("state")