summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2026-04-03 16:54:36 +0700
committerGitHub <[email protected]>2026-04-03 16:54:36 +0700
commit625244854e4b4eeba01ef959ebfe1aa7d62d47e4 (patch)
tree21d079eb835b1f00efe6d61e4bdac6fca8036400
parentc790ac4071ba6ebf9f09020bd52e88416efecaa1 (diff)
parent9515ba8e795a582f4e62955b8d4398066e2acbb1 (diff)
Merge pull request #3585 from hathach/fix/rp2350-unaligned-memcpy
rp2040: fix RP2350 hard fault in unaligned_memcpy to USB DPRAM
-rw-r--r--src/portable/raspberrypi/rp2040/rp2040_usb.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/portable/raspberrypi/rp2040/rp2040_usb.c b/src/portable/raspberrypi/rp2040/rp2040_usb.c
index 1b13934d3..83ac48ec2 100644
--- a/src/portable/raspberrypi/rp2040/rp2040_usb.c
+++ b/src/portable/raspberrypi/rp2040/rp2040_usb.c
@@ -51,10 +51,14 @@ critical_section_t rp2usb_lock;
//--------------------------------------------------------------------+
// Implementation
//--------------------------------------------------------------------+
-// Provide own byte by byte memcpy as not all copies are aligned
+// Provide own byte by byte memcpy as not all copies are aligned.
+// Use volatile to prevent compiler from widening to 16/32-bit accesses
+// which cause hard fault on RP2350 when dst/src point to USB DPRAM.
static void unaligned_memcpy(uint8_t *dst, const uint8_t *src, size_t n) {
+ volatile uint8_t *vdst = dst;
+ const volatile uint8_t *vsrc = src;
while (n--) {
- *dst++ = *src++;
+ *vdst++ = *vsrc++;
}
}