From 1ae30bc64cbd8d34da8a54bc36de2e640e5d65bc Mon Sep 17 00:00:00 2001 From: Ciro Cattuto Date: Tue, 28 Dec 2021 21:54:45 +0100 Subject: [PATCH] Improved read() and write() behavior Re-read head and tail of RTT buffers on every call to read() or write(), to avoid issues when target restarts and resets RTT buffers' state between calls. --- examples/rtt/rtt.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/rtt/rtt.js b/examples/rtt/rtt.js index 4aaeccf..7950865 100644 --- a/examples/rtt/rtt.js +++ b/examples/rtt/rtt.js @@ -112,6 +112,7 @@ class RTT { async read (bufId) { var buf = this.bufUp[bufId]; + buf.RdOff = await this.processor.readMem32(buf.bufAddr + 16); buf.WrOff = await this.processor.readMem32(buf.bufAddr + 12); if (buf.WrOff > buf.RdOff) { @@ -136,6 +137,7 @@ class RTT { var buf = this.bufDown[bufId]; buf.RdOff = await this.processor.readMem32(buf.bufAddr + 16); + buf.WrOff = await this.processor.readMem32(buf.bufAddr + 12); if (buf.WrOff >= buf.RdOff) var num_avail = buf.SizeOfBuffer - (buf.WrOff - buf.RdOff);