File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
src/portable/raspberrypi/rp2040 Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -51,10 +51,14 @@ critical_section_t rp2usb_lock;
5151//--------------------------------------------------------------------+
5252// Implementation
5353//--------------------------------------------------------------------+
54- // Provide own byte by byte memcpy as not all copies are aligned
54+ // Provide own byte by byte memcpy as not all copies are aligned.
55+ // Use volatile to prevent compiler from widening to 16/32-bit accesses
56+ // which cause hard fault on RP2350 when dst/src point to USB DPRAM.
5557static void unaligned_memcpy (uint8_t * dst , const uint8_t * src , size_t n ) {
58+ volatile uint8_t * vdst = dst ;
59+ const volatile uint8_t * vsrc = src ;
5660 while (n -- ) {
57- * dst ++ = * src ++ ;
61+ * vdst ++ = * vsrc ++ ;
5862 }
5963}
6064
You can’t perform that action at this time.
0 commit comments