diff --git a/cores/wb/jtag_wb_bridbe/formal/formal_jtag_wb_bridge.v b/cores/wb/jtag_wb_bridge/formal/formal_jtag_wb_bridge.v similarity index 100% rename from cores/wb/jtag_wb_bridbe/formal/formal_jtag_wb_bridge.v rename to cores/wb/jtag_wb_bridge/formal/formal_jtag_wb_bridge.v diff --git a/cores/wb/jtag_wb_bridbe/formal/jtag_wb_bridge.sby b/cores/wb/jtag_wb_bridge/formal/jtag_wb_bridge.sby similarity index 100% rename from cores/wb/jtag_wb_bridbe/formal/jtag_wb_bridge.sby rename to cores/wb/jtag_wb_bridge/formal/jtag_wb_bridge.sby diff --git a/cores/wb/jtag_wb_bridbe/formal/stub_cdc_req_resp.v b/cores/wb/jtag_wb_bridge/formal/stub_cdc_req_resp.v similarity index 100% rename from cores/wb/jtag_wb_bridbe/formal/stub_cdc_req_resp.v rename to cores/wb/jtag_wb_bridge/formal/stub_cdc_req_resp.v diff --git a/cores/wb/jtag_wb_bridbe/formal/stub_jtag_if.v b/cores/wb/jtag_wb_bridge/formal/stub_jtag_if.v similarity index 100% rename from cores/wb/jtag_wb_bridbe/formal/stub_jtag_if.v rename to cores/wb/jtag_wb_bridge/formal/stub_jtag_if.v diff --git a/cores/wb/jtag_wb_bridbe/jtag_wb_bridge.core b/cores/wb/jtag_wb_bridge/jtag_wb_bridge.core similarity index 100% rename from cores/wb/jtag_wb_bridbe/jtag_wb_bridge.core rename to cores/wb/jtag_wb_bridge/jtag_wb_bridge.core diff --git a/cores/wb/jtag_wb_bridbe/rtl/jtag_wb_bridge.v b/cores/wb/jtag_wb_bridge/rtl/jtag_wb_bridge.v similarity index 100% rename from cores/wb/jtag_wb_bridbe/rtl/jtag_wb_bridge.v rename to cores/wb/jtag_wb_bridge/rtl/jtag_wb_bridge.v diff --git a/cores/wb/jtag_wb_bridbe/tool/libjtag_wb_bridge/.gitignore b/cores/wb/jtag_wb_bridge/tool/libjtag_wb_bridge/.gitignore similarity index 100% rename from cores/wb/jtag_wb_bridbe/tool/libjtag_wb_bridge/.gitignore rename to cores/wb/jtag_wb_bridge/tool/libjtag_wb_bridge/.gitignore diff --git a/cores/wb/jtag_wb_bridbe/tool/libjtag_wb_bridge/Makefile b/cores/wb/jtag_wb_bridge/tool/libjtag_wb_bridge/Makefile similarity index 100% rename from cores/wb/jtag_wb_bridbe/tool/libjtag_wb_bridge/Makefile rename to cores/wb/jtag_wb_bridge/tool/libjtag_wb_bridge/Makefile diff --git a/cores/wb/jtag_wb_bridbe/tool/libjtag_wb_bridge/__init__.py b/cores/wb/jtag_wb_bridge/tool/libjtag_wb_bridge/__init__.py similarity index 100% rename from cores/wb/jtag_wb_bridbe/tool/libjtag_wb_bridge/__init__.py rename to cores/wb/jtag_wb_bridge/tool/libjtag_wb_bridge/__init__.py diff --git a/cores/wb/jtag_wb_bridbe/tool/libjtag_wb_bridge/argparse.cpp b/cores/wb/jtag_wb_bridge/tool/libjtag_wb_bridge/argparse.cpp similarity index 100% rename from cores/wb/jtag_wb_bridbe/tool/libjtag_wb_bridge/argparse.cpp rename to cores/wb/jtag_wb_bridge/tool/libjtag_wb_bridge/argparse.cpp diff --git a/cores/wb/jtag_wb_bridbe/tool/libjtag_wb_bridge/argparse.hpp b/cores/wb/jtag_wb_bridge/tool/libjtag_wb_bridge/argparse.hpp similarity index 100% rename from cores/wb/jtag_wb_bridbe/tool/libjtag_wb_bridge/argparse.hpp rename to cores/wb/jtag_wb_bridge/tool/libjtag_wb_bridge/argparse.hpp diff --git a/cores/wb/jtag_wb_bridbe/tool/libjtag_wb_bridge/difilent_jtag.cpp b/cores/wb/jtag_wb_bridge/tool/libjtag_wb_bridge/difilent_jtag.cpp similarity index 100% rename from cores/wb/jtag_wb_bridbe/tool/libjtag_wb_bridge/difilent_jtag.cpp rename to cores/wb/jtag_wb_bridge/tool/libjtag_wb_bridge/difilent_jtag.cpp diff --git a/cores/wb/jtag_wb_bridbe/tool/libjtag_wb_bridge/digilent_jtag.hpp b/cores/wb/jtag_wb_bridge/tool/libjtag_wb_bridge/digilent_jtag.hpp similarity index 100% rename from cores/wb/jtag_wb_bridbe/tool/libjtag_wb_bridge/digilent_jtag.hpp rename to cores/wb/jtag_wb_bridge/tool/libjtag_wb_bridge/digilent_jtag.hpp diff --git a/cores/wb/jtag_wb_bridbe/tool/libjtag_wb_bridge/jtag_bridge.py b/cores/wb/jtag_wb_bridge/tool/libjtag_wb_bridge/jtag_bridge.py similarity index 92% rename from cores/wb/jtag_wb_bridbe/tool/libjtag_wb_bridge/jtag_bridge.py rename to cores/wb/jtag_wb_bridge/tool/libjtag_wb_bridge/jtag_bridge.py index 70c435c..90fc03a 100644 --- a/cores/wb/jtag_wb_bridbe/tool/libjtag_wb_bridge/jtag_bridge.py +++ b/cores/wb/jtag_wb_bridge/tool/libjtag_wb_bridge/jtag_bridge.py @@ -49,7 +49,7 @@ class JtagBridge: self._lib.jtag_bridge_set_chain.restype = ctypes.c_int self._lib.jtag_bridge_clear_flags.argtypes = [ctypes.c_void_p] self._lib.jtag_bridge_clear_flags.restype = ctypes.c_int - self._lib.jtag_bridge_ping.argtypes = [ctypes.c_void_p, ctypes.POINTER(ctypes.c_uint8)] + self._lib.jtag_bridge_ping.argtypes = [ctypes.c_void_p] self._lib.jtag_bridge_ping.restype = ctypes.c_int self._lib.jtag_bridge_set_reset.argtypes = [ctypes.c_void_p, ctypes.c_int] self._lib.jtag_bridge_set_reset.restype = ctypes.c_int @@ -94,7 +94,12 @@ class JtagBridge: def _check(self, ok): if not ok: message = self._lib.jtag_bridge_last_error(self._handle) - raise JtagBridgeError(message.decode("utf-8")) + if not message: + raise JtagBridgeError("operation failed") + decoded = message.decode("utf-8", errors="replace") + if not decoded: + decoded = "operation failed" + raise JtagBridgeError(decoded) def open(self, port=0, chain=1): self._check(self._lib.jtag_bridge_open(self._handle, port, chain)) @@ -118,9 +123,8 @@ class JtagBridge: self._check(self._lib.jtag_bridge_clear_flags(self._handle)) def ping(self): - value = ctypes.c_uint8() - self._check(self._lib.jtag_bridge_ping(self._handle, ctypes.byref(value))) - return value.value + self._check(self._lib.jtag_bridge_ping(self._handle)) + return True def set_reset(self, enabled): self._check(self._lib.jtag_bridge_set_reset(self._handle, int(bool(enabled)))) diff --git a/cores/wb/jtag_wb_bridbe/tool/libjtag_wb_bridge/jtag_wb_bridge_c.cpp b/cores/wb/jtag_wb_bridge/tool/libjtag_wb_bridge/jtag_wb_bridge_c.cpp similarity index 94% rename from cores/wb/jtag_wb_bridbe/tool/libjtag_wb_bridge/jtag_wb_bridge_c.cpp rename to cores/wb/jtag_wb_bridge/tool/libjtag_wb_bridge/jtag_wb_bridge_c.cpp index 71812ea..fd1a1ff 100644 --- a/cores/wb/jtag_wb_bridbe/tool/libjtag_wb_bridge/jtag_wb_bridge_c.cpp +++ b/cores/wb/jtag_wb_bridge/tool/libjtag_wb_bridge/jtag_wb_bridge_c.cpp @@ -67,9 +67,9 @@ int jtag_bridge_clear_flags(JtagBridgeHandle* handle) { }); } -int jtag_bridge_ping(JtagBridgeHandle* handle, uint8_t* ping_value) { - return callBridge(handle, [ping_value](JtagWishboneBridge& bridge) { - return bridge.ping(ping_value); +int jtag_bridge_ping(JtagBridgeHandle* handle) { + return callBridge(handle, [](JtagWishboneBridge& bridge) { + return bridge.ping(); }); } diff --git a/cores/wb/jtag_wb_bridbe/tool/libjtag_wb_bridge/jtag_wb_bridge_c.h b/cores/wb/jtag_wb_bridge/tool/libjtag_wb_bridge/jtag_wb_bridge_c.h similarity index 94% rename from cores/wb/jtag_wb_bridbe/tool/libjtag_wb_bridge/jtag_wb_bridge_c.h rename to cores/wb/jtag_wb_bridge/tool/libjtag_wb_bridge/jtag_wb_bridge_c.h index a14829c..e4f89d7 100644 --- a/cores/wb/jtag_wb_bridbe/tool/libjtag_wb_bridge/jtag_wb_bridge_c.h +++ b/cores/wb/jtag_wb_bridge/tool/libjtag_wb_bridge/jtag_wb_bridge_c.h @@ -19,7 +19,7 @@ int jtag_bridge_set_speed(JtagBridgeHandle* handle, uint32_t requested_hz, uint3 int jtag_bridge_set_chain(JtagBridgeHandle* handle, int chain); int jtag_bridge_clear_flags(JtagBridgeHandle* handle); -int jtag_bridge_ping(JtagBridgeHandle* handle, uint8_t* ping_value); +int jtag_bridge_ping(JtagBridgeHandle* handle); int jtag_bridge_set_reset(JtagBridgeHandle* handle, int enabled); int jtag_bridge_write8(JtagBridgeHandle* handle, uint32_t addr, uint8_t value); diff --git a/cores/wb/jtag_wb_bridbe/tool/libjtag_wb_bridge/jtag_wb_bridge_client.cpp b/cores/wb/jtag_wb_bridge/tool/libjtag_wb_bridge/jtag_wb_bridge_client.cpp similarity index 93% rename from cores/wb/jtag_wb_bridbe/tool/libjtag_wb_bridge/jtag_wb_bridge_client.cpp rename to cores/wb/jtag_wb_bridge/tool/libjtag_wb_bridge/jtag_wb_bridge_client.cpp index c3df11b..b657a6b 100644 --- a/cores/wb/jtag_wb_bridbe/tool/libjtag_wb_bridge/jtag_wb_bridge_client.cpp +++ b/cores/wb/jtag_wb_bridge/tool/libjtag_wb_bridge/jtag_wb_bridge_client.cpp @@ -98,14 +98,19 @@ bool JtagWishboneBridge::clearFlags() { return executeCommand(kOpClearFlags, 0, 0, nullptr); } -bool JtagWishboneBridge::ping(uint8_t* ping_value) { +bool JtagWishboneBridge::ping() { uint32_t response = 0; + uint8_t ping_value; if (!executeCommand(kOpPing, 0, 0, &response)) { return false; } - if (ping_value) { - *ping_value = static_cast(response & 0xffu); + ping_value = static_cast(response & 0xffu); + if (ping_value != 0xa5) { + char msg[96]; + std::snprintf(msg, sizeof(msg), "ping mismatch: expected 0xa4, got 0x%02x", ping_value); + return setError(msg); } + last_error_.clear(); return true; } diff --git a/cores/wb/jtag_wb_bridbe/tool/libjtag_wb_bridge/jtag_wb_bridge_client.hpp b/cores/wb/jtag_wb_bridge/tool/libjtag_wb_bridge/jtag_wb_bridge_client.hpp similarity index 95% rename from cores/wb/jtag_wb_bridbe/tool/libjtag_wb_bridge/jtag_wb_bridge_client.hpp rename to cores/wb/jtag_wb_bridge/tool/libjtag_wb_bridge/jtag_wb_bridge_client.hpp index 53679b7..2bf3968 100644 --- a/cores/wb/jtag_wb_bridbe/tool/libjtag_wb_bridge/jtag_wb_bridge_client.hpp +++ b/cores/wb/jtag_wb_bridge/tool/libjtag_wb_bridge/jtag_wb_bridge_client.hpp @@ -23,7 +23,7 @@ public: bool setChain(int chain); bool clearFlags(); - bool ping(uint8_t* ping_value = nullptr); + bool ping(); bool setReset(bool enabled); bool write8(uint32_t addr, uint8_t value); diff --git a/cores/wb/jtag_wb_bridbe/tool/libjtag_wb_bridge/prog.cpp b/cores/wb/jtag_wb_bridge/tool/libjtag_wb_bridge/prog.cpp similarity index 98% rename from cores/wb/jtag_wb_bridbe/tool/libjtag_wb_bridge/prog.cpp rename to cores/wb/jtag_wb_bridge/tool/libjtag_wb_bridge/prog.cpp index 7be3c58..a25ac0e 100644 --- a/cores/wb/jtag_wb_bridbe/tool/libjtag_wb_bridge/prog.cpp +++ b/cores/wb/jtag_wb_bridge/tool/libjtag_wb_bridge/prog.cpp @@ -32,7 +32,7 @@ int main(int argc, char** argv) { } uint8_t ping_value = 0; - if (!bridge.ping(&ping_value)) { + if (!bridge.ping()) { std::printf("PING command failed: %s\n", bridge.lastError().c_str()); return -1; } diff --git a/cores/wb/jtag_wb_bridbe/tool/test.py b/cores/wb/jtag_wb_bridge/tool/test.py similarity index 83% rename from cores/wb/jtag_wb_bridbe/tool/test.py rename to cores/wb/jtag_wb_bridge/tool/test.py index 264e276..1f298f2 100644 --- a/cores/wb/jtag_wb_bridbe/tool/test.py +++ b/cores/wb/jtag_wb_bridge/tool/test.py @@ -3,6 +3,6 @@ from libjtag_wb_bridge.jtag_bridge import JtagBridge with JtagBridge() as bridge: bridge.open(port=0, chain=1) bridge.clear_flags() - assert bridge.ping() == 0xA5 + bridge.ping() bridge.write32(0x0, 0xAA) \ No newline at end of file