-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix D-Cache invalidation at boot and during MPU setup on Cortex-M7 #35258
Fix D-Cache invalidation at boot and during MPU setup on Cortex-M7 #35258
Conversation
On reset we do not know what is the status of the D-Cache, nor its content. If it is disabled, do not try to clean it, as it might contains random data for random addresses, and this might just create a bus fault. Invalidating it is enough. If it is enabled, it means its content is not random. SCB_InvalidateDCache() will clean it, invalidate it and disable it. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
84d88ac
to
ae3170a
Compare
Will test this on SAM E70, hang on Confirmed, this makes the SAM E70 no crash, thanks @aurel32 for the fix |
It would be good to test it on an NXP chip. They use a different MPU. |
Agreed, will ask @MaureenHelm to try this out. @mnkp does this address the issue you are seeing on Atmel SAM? |
In case CONFIG_NOCACHE_MEMORY=y, the D-Cache need to be clean and invalidated before enabling the MPU to make sure no data from a __nocache__ region is present in the D-Cache. If the D-Cache is disabled, SCB_CleanInvalidateDCache() shall not be used as it might contains random data for random addresses, and this might just create a bus fault. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
ae3170a
to
6c46bc9
Compare
I think more testing is definitely welcome. Note however that at the end the issue is not linked with the MPU, but just related to the fact that the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested a few networking samples with mimxrt1060_evk
and not seeing any issues.
The i.MX RT family (CM7) has the standard Arm MPU. It's only the Kinetis family (CM4) that has the NXP MPU.
@FRASTM any updates on testing this? |
Why do we need to clean the d-cache in Just for me to understand the context:
|
Hi, Regards, |
Hi @CristXu, Thank you for your insight! 😃 Let me clarify a bit.
My question to @CristXu is
Another question for Zephyr community is
Don't take me wrong. I'm not against anything. I just want to know the protocol / requirements / expectations for booting. In fact, I think it's a good idea to have a region of memory for passing data. But in this case, the data is passed by the cache, not the OCRAM, AFAICS. |
Yes, i agree with you. the values need update to the OCRAM after configure this area as the non-cacheable area. But sorry, i do not have any idea of clean/flash the cache to OCRAM before booting zephyr. |
The pb of the #35220 is not fixed with this PR. The |
@FRASTM would it make sense for stm32f7 to define |
I do not really know what are the impacts of setting the CONFIG_INIT_ARCH_HW_AT_BOOT for the soc/stm32f7 family |
Note that on my side I was able to reproduce the issue from #35220 on a stm32f723e discovery board, and that patch was fixing the problem. That's actually how I produced that patch.
The PR is composed of two patches. One fixes the issue in The other one fixes the issue for Therefore there is no need to select this option for the STM32F7, instead we should understand why the fix doesn't work in your case. For me the bus fault happened in the |
This PR fixes issues introduced by d6b5023 and reported as #35089, #35107 and #35220.
It's not clear to me if we should check the status of the D-Cache, or if it is ensured to be disabled at reset, so I took the safe way.