From dd50a21b5926041a3bacea574dfc861e54e1f191 Mon Sep 17 00:00:00 2001 From: Martin Mueller Date: Tue, 3 Nov 2026 17:03:29 +0100 Subject: [PATCH] force writing of udp header aligned and in order, fixed xilinx ctb crash on p rx_hostname --- .../slsDetectorFunctionList.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c index 04d95fc0b..04b091032 100644 --- a/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c @@ -1502,8 +1502,9 @@ int configureMAC() { } #endif - // get struct memory - udp_header *udp = (udp_header *)(Arm_getUDPBaseAddress()); + // build udp header + udp_header header; + udp_header *udp = &header; memset(udp, 0, sizeof(udp_header)); // mac addresses @@ -1535,6 +1536,14 @@ int configureMAC() { calcChecksum(udp); + // force FPGA writes to be aligned and in order + volatile uint32_t *dst = (volatile uint32_t *)Arm_getUDPBaseAddress(); + uint32_t words[sizeof(udp_header) / sizeof(uint32_t)]; + memcpy(words, udp, sizeof(udp_header)); + for (size_t i = 0; i != sizeof(words) / sizeof(words[0]); ++i) { + dst[i] = words[i]; + } + return OK; }