From b12aaa4aa3d4c15d3575fde9441d60810b5bd9f7 Mon Sep 17 00:00:00 2001 From: Maciej Pijanowski Date: Mon, 10 Jun 2024 17:48:24 +0200 Subject: [PATCH] osfv_cli: introduce flash power state param Fixes: https://github.com/Dasharo/osfv-scripts/issues/37 Fixes: https://github.com/Dasharo/osfv-scripts/issues/15 Tested: * MSI Z690 DUT model retrieved from snipeit: MSI PRO Z690-A DDR4 Found Macronix flash chip "MX25U25635F" (32768 kB, SPI) on linux_spi. * Protectli V1410 DUT model retrieved from snipeit: V1410 Found Winbond flash chip "W25Q128.V" (16384 kB, SPI) on ch341a_spi. * Protectli VP6650 DUT model retrieved from snipeit: VP6650 Found Macronix flash chip "MX25L12833F/MX25L12835F/MX25L12845E/MX25L12865E/MX25L12873F" (16384 kB, SPI) on linux_spi. * PC Engines APU3 DUT model retrieved from snipeit: APU3 Found Winbond flash chip "W25Q64JV-.Q" (8192 kB, SPI) on linux_spi. * PC Engines APU4 DUT model retrieved from snipeit: APU4 Found Winbond flash chip "W25Q64JV-.Q" (8192 kB, SPI) on linux_spi. * Protecli VP46XX - none in lab currently fully connected Signed-off-by: Maciej Pijanowski --- osfv_cli/osfv_cli/models/APU2.yml | 2 +- osfv_cli/osfv_cli/models/APU3.yml | 2 +- osfv_cli/osfv_cli/models/APU4.yml | 2 +- osfv_cli/osfv_cli/models/APU5.yml | 2 +- osfv_cli/osfv_cli/models/APU6.yml | 2 +- osfv_cli/osfv_cli/models/APU7.yml | 2 +- osfv_cli/osfv_cli/models/EA-0113.yml | 2 +- osfv_cli/osfv_cli/models/FW4C.yml | 2 +- .../osfv_cli/models/MSI PRO Z690-A DDR4.yml | 2 +- .../osfv_cli/models/MSI PRO Z690-A DDR5.yml | 2 +- .../models/MSI PRO Z790-P WIFI DDR5.yml | 2 +- .../models/MinnowBoard Turbot B41.yml | 2 +- osfv_cli/osfv_cli/models/V1210.yml | 2 +- osfv_cli/osfv_cli/models/V1410.yml | 2 +- osfv_cli/osfv_cli/models/V1610.yml | 2 +- osfv_cli/osfv_cli/models/VP2410.yml | 2 +- osfv_cli/osfv_cli/models/VP2420.yml | 2 +- osfv_cli/osfv_cli/models/VP4630.yml | 2 +- osfv_cli/osfv_cli/models/VP4650.yml | 2 +- osfv_cli/osfv_cli/models/VP4670.yml | 2 +- osfv_cli/osfv_cli/models/VP6650.yml | 2 +- osfv_cli/osfv_cli/models/VP6670.yml | 2 +- osfv_cli/osfv_cli/rte.py | 50 +++++++++---------- 23 files changed, 46 insertions(+), 48 deletions(-) diff --git a/osfv_cli/osfv_cli/models/APU2.yml b/osfv_cli/osfv_cli/models/APU2.yml index 0c04c0a..c6f7a37 100644 --- a/osfv_cli/osfv_cli/models/APU2.yml +++ b/osfv_cli/osfv_cli/models/APU2.yml @@ -9,6 +9,6 @@ programmer: pwr_ctrl: sonoff: false relay: true - init_on: true + flashing_power_state: "G3" reset_cmos: true diff --git a/osfv_cli/osfv_cli/models/APU3.yml b/osfv_cli/osfv_cli/models/APU3.yml index 0c04c0a..c6f7a37 100644 --- a/osfv_cli/osfv_cli/models/APU3.yml +++ b/osfv_cli/osfv_cli/models/APU3.yml @@ -9,6 +9,6 @@ programmer: pwr_ctrl: sonoff: false relay: true - init_on: true + flashing_power_state: "G3" reset_cmos: true diff --git a/osfv_cli/osfv_cli/models/APU4.yml b/osfv_cli/osfv_cli/models/APU4.yml index 0c04c0a..c6f7a37 100644 --- a/osfv_cli/osfv_cli/models/APU4.yml +++ b/osfv_cli/osfv_cli/models/APU4.yml @@ -9,6 +9,6 @@ programmer: pwr_ctrl: sonoff: false relay: true - init_on: true + flashing_power_state: "G3" reset_cmos: true diff --git a/osfv_cli/osfv_cli/models/APU5.yml b/osfv_cli/osfv_cli/models/APU5.yml index 0c04c0a..c6f7a37 100644 --- a/osfv_cli/osfv_cli/models/APU5.yml +++ b/osfv_cli/osfv_cli/models/APU5.yml @@ -9,6 +9,6 @@ programmer: pwr_ctrl: sonoff: false relay: true - init_on: true + flashing_power_state: "G3" reset_cmos: true diff --git a/osfv_cli/osfv_cli/models/APU6.yml b/osfv_cli/osfv_cli/models/APU6.yml index 0c04c0a..c6f7a37 100644 --- a/osfv_cli/osfv_cli/models/APU6.yml +++ b/osfv_cli/osfv_cli/models/APU6.yml @@ -9,6 +9,6 @@ programmer: pwr_ctrl: sonoff: false relay: true - init_on: true + flashing_power_state: "G3" reset_cmos: true diff --git a/osfv_cli/osfv_cli/models/APU7.yml b/osfv_cli/osfv_cli/models/APU7.yml index 0c04c0a..c6f7a37 100644 --- a/osfv_cli/osfv_cli/models/APU7.yml +++ b/osfv_cli/osfv_cli/models/APU7.yml @@ -9,6 +9,6 @@ programmer: pwr_ctrl: sonoff: false relay: true - init_on: true + flashing_power_state: "G3" reset_cmos: true diff --git a/osfv_cli/osfv_cli/models/EA-0113.yml b/osfv_cli/osfv_cli/models/EA-0113.yml index c80f79d..5bf6cac 100644 --- a/osfv_cli/osfv_cli/models/EA-0113.yml +++ b/osfv_cli/osfv_cli/models/EA-0113.yml @@ -9,4 +9,4 @@ programmer: pwr_ctrl: sonoff: false relay: true - init_on: true + flashing_power_state: "G3" diff --git a/osfv_cli/osfv_cli/models/FW4C.yml b/osfv_cli/osfv_cli/models/FW4C.yml index aca2dea..b4683d5 100644 --- a/osfv_cli/osfv_cli/models/FW4C.yml +++ b/osfv_cli/osfv_cli/models/FW4C.yml @@ -11,7 +11,7 @@ pwr_ctrl: sonoff: false # whether power is controller via on-board RTE relay (required) relay: true - init_on: false + flashing_power_state: "OFF" # whether CMOS reset is required after flashing (optional - defaults to false) reset_cmos: true diff --git a/osfv_cli/osfv_cli/models/MSI PRO Z690-A DDR4.yml b/osfv_cli/osfv_cli/models/MSI PRO Z690-A DDR4.yml index 76ceea9..dbe6531 100644 --- a/osfv_cli/osfv_cli/models/MSI PRO Z690-A DDR4.yml +++ b/osfv_cli/osfv_cli/models/MSI PRO Z690-A DDR4.yml @@ -8,4 +8,4 @@ programmer: pwr_ctrl: sonoff: true relay: false - init_on: false + flashing_power_state: "OFF" diff --git a/osfv_cli/osfv_cli/models/MSI PRO Z690-A DDR5.yml b/osfv_cli/osfv_cli/models/MSI PRO Z690-A DDR5.yml index 76ceea9..dbe6531 100644 --- a/osfv_cli/osfv_cli/models/MSI PRO Z690-A DDR5.yml +++ b/osfv_cli/osfv_cli/models/MSI PRO Z690-A DDR5.yml @@ -8,4 +8,4 @@ programmer: pwr_ctrl: sonoff: true relay: false - init_on: false + flashing_power_state: "OFF" 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 76ceea9..dbe6531 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 @@ -8,4 +8,4 @@ programmer: pwr_ctrl: sonoff: true relay: false - init_on: false + flashing_power_state: "OFF" diff --git a/osfv_cli/osfv_cli/models/MinnowBoard Turbot B41.yml b/osfv_cli/osfv_cli/models/MinnowBoard Turbot B41.yml index f1e855c..f8b5549 100644 --- a/osfv_cli/osfv_cli/models/MinnowBoard Turbot B41.yml +++ b/osfv_cli/osfv_cli/models/MinnowBoard Turbot B41.yml @@ -9,6 +9,6 @@ programmer: pwr_ctrl: sonoff: false relay: true - init_on: false + flashing_power_state: "OFF" reset_cmos: false diff --git a/osfv_cli/osfv_cli/models/V1210.yml b/osfv_cli/osfv_cli/models/V1210.yml index eff5f3a..6d23e0d 100644 --- a/osfv_cli/osfv_cli/models/V1210.yml +++ b/osfv_cli/osfv_cli/models/V1210.yml @@ -10,7 +10,7 @@ pwr_ctrl: sonoff: false # whether power is controller via on-board RTE relay (required) relay: true - init_on: false + flashing_power_state: "OFF" # whether CMOS reset is required after flashing (optional - defaults to false) reset_cmos: true diff --git a/osfv_cli/osfv_cli/models/V1410.yml b/osfv_cli/osfv_cli/models/V1410.yml index eff5f3a..6d23e0d 100644 --- a/osfv_cli/osfv_cli/models/V1410.yml +++ b/osfv_cli/osfv_cli/models/V1410.yml @@ -10,7 +10,7 @@ pwr_ctrl: sonoff: false # whether power is controller via on-board RTE relay (required) relay: true - init_on: false + flashing_power_state: "OFF" # whether CMOS reset is required after flashing (optional - defaults to false) reset_cmos: true diff --git a/osfv_cli/osfv_cli/models/V1610.yml b/osfv_cli/osfv_cli/models/V1610.yml index eff5f3a..6d23e0d 100644 --- a/osfv_cli/osfv_cli/models/V1610.yml +++ b/osfv_cli/osfv_cli/models/V1610.yml @@ -10,7 +10,7 @@ pwr_ctrl: sonoff: false # whether power is controller via on-board RTE relay (required) relay: true - init_on: false + flashing_power_state: "OFF" # whether CMOS reset is required after flashing (optional - defaults to false) reset_cmos: true diff --git a/osfv_cli/osfv_cli/models/VP2410.yml b/osfv_cli/osfv_cli/models/VP2410.yml index 71df3e6..db4805d 100644 --- a/osfv_cli/osfv_cli/models/VP2410.yml +++ b/osfv_cli/osfv_cli/models/VP2410.yml @@ -14,7 +14,7 @@ pwr_ctrl: sonoff: false # whether power is controller via on-board RTE relay (required) relay: true - init_on: false + flashing_power_state: "OFF" # whether CMOS reset is required after flashing (optional - defaults to false) reset_cmos: true diff --git a/osfv_cli/osfv_cli/models/VP2420.yml b/osfv_cli/osfv_cli/models/VP2420.yml index be69853..e267a57 100644 --- a/osfv_cli/osfv_cli/models/VP2420.yml +++ b/osfv_cli/osfv_cli/models/VP2420.yml @@ -9,6 +9,6 @@ programmer: pwr_ctrl: sonoff: false relay: true - init_on: true + flashing_power_sate: "G3" reset_cmos: true diff --git a/osfv_cli/osfv_cli/models/VP4630.yml b/osfv_cli/osfv_cli/models/VP4630.yml index 96ea991..a140934 100644 --- a/osfv_cli/osfv_cli/models/VP4630.yml +++ b/osfv_cli/osfv_cli/models/VP4630.yml @@ -14,7 +14,7 @@ pwr_ctrl: sonoff: false # whether power is controller via on-board RTE relay (required) relay: true - init_on: true + flashing_power_state: "OFF" # whether CMOS reset is required after flashing (optional - defaults to false) reset_cmos: true diff --git a/osfv_cli/osfv_cli/models/VP4650.yml b/osfv_cli/osfv_cli/models/VP4650.yml index c5581f7..911b432 100644 --- a/osfv_cli/osfv_cli/models/VP4650.yml +++ b/osfv_cli/osfv_cli/models/VP4650.yml @@ -14,7 +14,7 @@ pwr_ctrl: sonoff: true # whether power is controller via on-board RTE relay (required) relay: false - init_on: true + flashing_power_state: "OFF" # whether CMOS reset is required after flashing (optional - defaults to false) reset_cmos: true diff --git a/osfv_cli/osfv_cli/models/VP4670.yml b/osfv_cli/osfv_cli/models/VP4670.yml index c5581f7..911b432 100644 --- a/osfv_cli/osfv_cli/models/VP4670.yml +++ b/osfv_cli/osfv_cli/models/VP4670.yml @@ -14,7 +14,7 @@ pwr_ctrl: sonoff: true # whether power is controller via on-board RTE relay (required) relay: false - init_on: true + flashing_power_state: "OFF" # whether CMOS reset is required after flashing (optional - defaults to false) reset_cmos: true diff --git a/osfv_cli/osfv_cli/models/VP6650.yml b/osfv_cli/osfv_cli/models/VP6650.yml index 5046385..e196a17 100644 --- a/osfv_cli/osfv_cli/models/VP6650.yml +++ b/osfv_cli/osfv_cli/models/VP6650.yml @@ -9,6 +9,6 @@ programmer: pwr_ctrl: sonoff: true relay: false - init_on: true + flashing_power_state: "OFF" reset_cmos: true diff --git a/osfv_cli/osfv_cli/models/VP6670.yml b/osfv_cli/osfv_cli/models/VP6670.yml index 5046385..e196a17 100644 --- a/osfv_cli/osfv_cli/models/VP6670.yml +++ b/osfv_cli/osfv_cli/models/VP6670.yml @@ -9,6 +9,6 @@ programmer: pwr_ctrl: sonoff: true relay: false - init_on: true + flashing_power_state: "OFF" reset_cmos: true diff --git a/osfv_cli/osfv_cli/rte.py b/osfv_cli/osfv_cli/rte.py index f628008..3015ac8 100644 --- a/osfv_cli/osfv_cli/rte.py +++ b/osfv_cli/osfv_cli/rte.py @@ -52,6 +52,7 @@ def load_model_data(self): voltage_validator = Any("1.8V", "3.3V") programmer_name_validator = Any("rte_1_1", "rte_1_0", "ch341a") + flashing_power_state_validator = Any("G3", "OFF") schema = Schema( { @@ -65,7 +66,7 @@ def load_model_data(self): Required("pwr_ctrl"): { Required("sonoff"): bool, Required("relay"): bool, - Required("init_on"): bool, + Required("flashing_power_state"): flashing_power_state_validator, }, Optional("reset_cmos", default=False): bool, } @@ -189,45 +190,42 @@ def discharge_psu(self): 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(5) - self.power_off(6) - time.sleep(10) - else: - # 3. RTE POFF - # 4. sleep 3 - self.pwr_ctrl_off() - self.discharge_psu() + def pwr_ctrl_before_flash(self, programmer, power_state): + + # Always start from the same state (PSU active) + self.pwr_ctrl_on() + time.sleep(5) + self.power_off(6) + time.sleep(10) + # Some platforms need to enable SPI lines at this point + # when PSU is active (e.g. VP6650). Otherwise the chip is not detected. + # So we must turn the PSU ON first in the middle of power cycle, + # even if we perform flashing with the PSU OFF. 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 True: - # 7. sonoff/relay OFF - # 8. sleep 2 + if power_state == "G3": + pass + elif power_state == "OFF": self.pwr_ctrl_off() self.discharge_psu() + else: + exit( + f"Power state: '{power_state}' is not supported. Please check model config." + ) def pwr_ctrl_after_flash(self, programmer): if programmer == "rte_1_1": - # 10. SPI OFF - # 11. sleep 2 self.spi_disable() time.sleep(2) def flash_cmd(self, args, read_file=None, write_file=None): - self.pwr_ctrl_before_flash(self.dut_data["programmer"]["name"]) - - # 9. flashrom + self.pwr_ctrl_before_flash( + self.dut_data["programmer"]["name"], + self.dut_data["pwr_ctrl"]["flashing_power_state"], + ) # Create SSH client ssh = paramiko.SSHClient()