RP2xxx USB driver - memcpy issue
There is strange issue in USB driver usb_start_tx function when @memcpy is used.
For Zig 0.14:
- RP2350 crashes when @memcpy is used but RP2040 is fine
- RP2040 crashes when
rom.memcpycode is used even before zig 0.14 update this was working fine -
std.mem.copyForwardsseems to work for both - but we probably should use it as just temporary solution
related PR: #432
It looks like this might be an issue with memory alignment. Please take a look here: https://github.com/raspberrypi/pico-sdk/issues/2216#issuecomment-2721525484 and also this comment:
"# beware commpiler memcpy cannot be used for unaligned copies in peripheral space"
in link
The issue might occur when copying memory between CPU space and peripheral space. TinyUSB had to implement a custom byte-by-byte memcpy implementation for the RP2040. The RP2350 should support unaligned memory access, but there might still be some edge cases, so it’s better to use a byte-by-byte implementation as well.
There are two scenarios where we are affected:
- When we use
@memcpydirectly in the USB driver (it was replaced bystd.mem.copyForwardsin some recent commits). - When we feed the endpoint FIFO (internally,
@memcpyis called for the provided slice)