Skip to content
This repository was archived by the owner on Dec 18, 2025. It is now read-only.

Fix: Issue of SCB_DisableDCache(),SCB_InvalidateDCache(),SCB_CleanDCache() functions when compiling with -O0#1350

Open
devcoons wants to merge 3 commits into
ARM-software:developfrom
devcoons:develop
Open

Fix: Issue of SCB_DisableDCache(),SCB_InvalidateDCache(),SCB_CleanDCache() functions when compiling with -O0#1350
devcoons wants to merge 3 commits into
ARM-software:developfrom
devcoons:develop

Conversation

@devcoons

Copy link
Copy Markdown

The variables 'ccsidr', 'sets' and 'ways' needs to be defined as 'register uint32_t' to avoid issues when using the -O0 flag.

These variables are used in the 'do/while' which invalidates/cleans the cache, however, by using -O0 flag (On STM32H7),
the compiler does not exclude them from the cache, so the system invalidates/cleans also them and the result is to end-up in an infinite loop.

…DCache(), SCB_CleanDCache() functions when compiling with -O0
@grasci-arm

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@JonatanAntoni

JonatanAntoni commented Oct 25, 2021

Copy link
Copy Markdown
Member

@grasci-arm test this please

@flit

flit commented Oct 25, 2021

Copy link
Copy Markdown
Contributor

Relying on the register keyword is not a solid solution. It is considered only a hint that compilers are allowed to interpret as they like. The only thing is guarantees from the C language specification is automatic duration, no linkage, and the variable's address cannot be taken (the latter being the only difference from an auto variable).

The only reliable solution is to rewrite these cache maintenance routines using inline assembly.

@JonatanAntoni JonatanAntoni added the CI Consider this for a CI build. label Oct 26, 2021
@Masmiseim36

Copy link
Copy Markdown
Contributor

This topic was already discussed in #620. I think there is a better solution then adding the register keyword which is obsolete with C++17. Compare #1426

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

CI Consider this for a CI build. CORE review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants