soc/tools/remove/comm_uart: limit write bursts to 8 32bits words
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Mon, 30 May 2016 14:16:05 +0000 (16:16 +0200)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Mon, 30 May 2016 14:16:05 +0000 (16:16 +0200)
litex/soc/tools/remote/comm_uart.py

index 10fa37e8db4d792632bfe87f2c830b1a33ff0208..b6a8f1c6ec8100c82f3e46772efc1bd5dd994cb0 100644 (file)
@@ -55,9 +55,14 @@ class CommUART:
     def write(self, addr, data):
         data = data if isinstance(data, list) else [data]
         length = len(data)
-        self._write([self.msg_type["write"], length])
-        self._write(list((addr//4).to_bytes(4, byteorder="big")))
-        for i, value in enumerate(data):
-            self._write(list(value.to_bytes(4, byteorder="big")))
-            if self.debug:
-                print("write {:08x} @ {:08x}".format(value, addr + 4*i))
+        offset = 0
+        while length:
+            size = min(length, 8)
+            self._write([self.msg_type["write"], size])
+            self._write(list(((addr+offset)//4).to_bytes(4, byteorder="big")))
+            for i, value in enumerate(data[offset:offset+size]):
+                self._write(list(value.to_bytes(4, byteorder="big")))
+                if self.debug:
+                    print("write {:08x} @ {:08x}".format(value, addr + offset, 4*i))
+            offset += size
+            length -= size