You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’ve encountered an issue with the current implementation of memset and memcpy in the standard library on the pico. When the SCB_CCR_UNALIGN_TRP flag is enabled to trap unaligned accesses, both functions may internally perform word-sized operations on unaligned addresses—even when operating on uint8_t arrays. This results in a UsageFault exception on CPUs that do not support unaligned accesses. While this is allowed by the C standard, it is problematic for platforms enforcing strict alignment. To ensure compatibility with systems that enable UNALIGN_TRP, these functions need to handle unaligned pointers correctly, for example, by using byte-wise operations when the pointer is not word-aligned.
I guess this must be on RP2350? Looking at the RP2350 datasheet says that CCR.UNALIGN_TRP is RW, but the RP2040 datasheet says that CCR.UNALIGN_TRP is RO and hardwired to 1. (With the latter being one of the unfortunate examples of where the Reset column in the auto-generated register tables doesn't know what the real reset value is. See also raspberrypi/pico-feedback#241 )
Uh oh!
There was an error while loading. Please reload this page.
I’ve encountered an issue with the current implementation of memset and memcpy in the standard library on the pico. When the SCB_CCR_UNALIGN_TRP flag is enabled to trap unaligned accesses, both functions may internally perform word-sized operations on unaligned addresses—even when operating on uint8_t arrays. This results in a UsageFault exception on CPUs that do not support unaligned accesses. While this is allowed by the C standard, it is problematic for platforms enforcing strict alignment. To ensure compatibility with systems that enable UNALIGN_TRP, these functions need to handle unaligned pointers correctly, for example, by using byte-wise operations when the pointer is not word-aligned.
example code.
The text was updated successfully, but these errors were encountered: