From 704affb49a106bd3a9de7e4ffc39145c19e8a551 Mon Sep 17 00:00:00 2001
From: Jan David Mol <mol@astron.nl>
Date: Mon, 4 Sep 2023 17:22:11 +0200
Subject: [PATCH] Wait for both images to boot, not just user

---
 .../devices/sdp/firmware.py                   | 20 +++++++++----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/tangostationcontrol/tangostationcontrol/devices/sdp/firmware.py b/tangostationcontrol/tangostationcontrol/devices/sdp/firmware.py
index 80ecd178b..85874d37d 100644
--- a/tangostationcontrol/tangostationcontrol/devices/sdp/firmware.py
+++ b/tangostationcontrol/tangostationcontrol/devices/sdp/firmware.py
@@ -262,31 +262,29 @@ class SDPFirmware(OPCUADevice):
     # overloaded functions
     # --------
 
-    def _power_hardware_on(self):
-        """Boot the SDP Firmware user image"""
+    def _boot_to_image(self, image_nr):
         # FPGAs that are actually reachable and we care about
         wait_for = ~(
             self.read_attribute("TR_fpga_communication_error_R")
         ) & self.read_attribute("TR_fpga_mask_R")
 
         # Order the correct firmare to be loaded
-        self.proxy.FPGA_boot_image_RW = [1] * N_pn
+        self.proxy.FPGA_boot_image_RW = [image_nr] * N_pn
 
         # Wait for the firmware to be loaded (ignoring masked out elements)
         self.wait_attribute(
             "FPGA_boot_image_R", lambda attr: ((attr == 1) | ~wait_for).all(), 60
         )
 
+    def _power_hardware_on(self):
+        """Boot the SDP Firmware user image"""
+
+        self._boot_to_image(0)
+
     def _power_hardware_off(self):
         """Use the SDP Firmware factory image"""
-        # Save actual mask values
-        TR_fpga_mask = self.proxy.TR_fpga_mask_RW
-        # Set the mask to all Trues
-        self.proxy.TR_fpga_mask_RW = [True] * N_pn
-        # Boot the boot image firmware
-        self.proxy.FPGA_boot_image_RW = [0] * N_pn
-        # Restore the mask
-        self.proxy.TR_fpga_mask_RW = TR_fpga_mask
+
+        self._boot_to_image(1)
 
     # --------
     # Commands
-- 
GitLab