msp430x5xx: Add fix for possible bug in msp430-elf-gcc 9.3.0. #1481
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Describe the PR
Consider the following contrived MSP430 code and linker script:
As of
msp430-elf-gcc
version9.3.0
, this produces the following code (on any opt-level besides-O0
) that does two reads from volatile variableUSBVECINT
and then uses the second read for the remainder ofmain
:In a real
tinyusb
application, the second read ofUSBVECINT
will produce a garbage value that causes the application to infinitely loop in the catch-allwhile(true)
case of the MSP430 USB interrupt handler. This PR uses an inlineasm
statement to suppress the undesired optimization for affected compiler versions, while leaving older versions alone.9.2.0
works fine with the original code from my testing. I may revisit this PR with a better solution later if I can find one.Additional Context
Fixed Sample Code (applied to TinyUSB)
Compiler Version