Skip to content

Fix STM32 USB PMA access at O3#67

Open
ataffanel wants to merge 1 commit into
masterfrom
ataffanel/o3-usb-pma-fix
Open

Fix STM32 USB PMA access at O3#67
ataffanel wants to merge 1 commit into
masterfrom
ataffanel/o3-usb-pma-fix

Conversation

@ataffanel

Copy link
Copy Markdown
Member

The STM32 USB packet memory area must be accessed as volatile 16-bit words. With the current GCC at -O3, the old plain uint16_t pointer lets the compiler combine descriptor writes into 32-bit stores, corrupting CDC descriptors during enumeration.

Use volatile halfword PMA accesses and copy odd-length transfers byte-safely so descriptor buffers are not read or written past their requested lengths. Keep the default optimized build while allowing diagnostics with OPT overrides.

The STM32 USB packet memory area must be accessed as volatile 16-bit words. With the current GCC at -O3, the old plain uint16_t pointer lets the compiler combine descriptor writes into 32-bit stores, corrupting CDC descriptors during enumeration.

Use volatile halfword PMA accesses and copy odd-length transfers byte-safely so descriptor buffers are not read or written past their requested lengths. Keep the default optimized build while allowing diagnostics with OPT overrides.
@ataffanel ataffanel requested a review from tobbeanton June 4, 2026 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant