Skip to content

Commit

Permalink
Merge pull request #25 from Dasharo/protectli-vp66X0
Browse files Browse the repository at this point in the history
Protectli vp66 x0
  • Loading branch information
macpijan authored Apr 2, 2024
2 parents 4135d9f + a949b95 commit b6604c4
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 11 deletions.
2 changes: 1 addition & 1 deletion osfv_cli/osfv_cli/models/MSI PRO Z790-P WIFI DDR5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ flash_chip:
voltage: "1.8V"

programmer:
name: rte
name: rte_1_1

pwr_ctrl:
sonoff: true
Expand Down
14 changes: 14 additions & 0 deletions osfv_cli/osfv_cli/models/VP6650.yml
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions osfv_cli/osfv_cli/models/VP6670.yml
Original file line number Diff line number Diff line change
@@ -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
19 changes: 13 additions & 6 deletions osfv_cli/osfv_cli/rte.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,33 +182,40 @@ 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
# Some flash scripts started with power platform ON, but some others
# 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
# 6. sleep 2
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":
Expand Down
27 changes: 27 additions & 0 deletions osfv_cli/osfv_cli/rte_robot.py
Original file line number Diff line number Diff line change
@@ -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")
8 changes: 4 additions & 4 deletions osfv_cli/osfv_cli/sonoff_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit b6604c4

Please sign in to comment.