questions about AT_NONCACHEABLE_SECTION_INIT() macro Hello, I have a few questions about AT_NONCACHEABLE_SECTION_INIT and its use in fsl_dcp.c This causes a variable to be placed in the “NonCacheable.init” section. The name of this section suggests an area that is not cached but is initialized. Presumably, the variable needs to be accessed by a master other than the core. Let's take the example evkmimxrt1020_dcp (for the RT1020-EVK) The linker script in this example places “NonCacheable.init” in .data (and thus in DTC), which is initialized but is not the designated non-cached area. This looks like it could be a problem! Let's also take a look at how AT_NONCACHEABLE_SECTION_INIT() is used in the DCP driver: The variable `s_dcpContextSwitchingBuffer` has not been initialized! So there are two scenarios: It is intentionally left uninitialized. In this case, however, the macro `AT_NONCACHEABLE_SECTION()` should be used instead of `AT_NONCACHEABLE_SECTION_INIT()`. It actually needed to be initialized. In this case, the problem is that it hasn't been initialized. best regards Max Re: questions about AT_NONCACHEABLE_SECTION_INIT() macro Hi @mastupristi ,
Thank you for your detailed analysis. We have reviewed both points you raised.
1. NonCacheable.init placed in DTCM — Not a cache coherency issue
Your observation is correct that the linker script places `NonCacheable.init` into `.data`, which resides in `SRAM_DTC` (DTCM).
However, this does not cause a cache coherency problem on RT1020. DTCM is tightly-coupled memory on Cortex-M7 — its access path bypasses the L1 D-Cache entirely by hardware design. Even though it is not placed in a separately named `NCACHE_REGION`, data in DTCM is inherently non-cacheable and safe for DMA-capable peripherals like DCP to access.
Please help check this AN: https://www.nxp.com/docs/en/application-note/AN12042.pdf
And If you modify the linker script to place this section in OCRAM or SDRAM, you must ensure the corresponding MPU region is configured as non-cacheable, or that the driver/application performs proper cache maintenance (clean/invalidate).
2. Macro usage — Correct observation, no functional impact
You are correct that `s_dcpContextSwitchingBuffer` uses `AT_NONCACHEABLE_SECTION_INIT()` without an explicit initializer. Per SDK convention, `AT_NONCACHEABLE_SECTION_INIT()` is intended for variables with non-zero initial values (`= {xx}`), while `AT_NONCACHEABLE_SECTION()` is for zero-initialized variables.
Since this variable has static storage duration, C guarantees zero-initialization regardless — there is no functional bug. The buffer does not depend on any specific initial value; the DCP hardware manages its contents at runtime.
That said, using `AT_NONCACHEABLE_SECTION()` would be more semantically appropriate and would save 208 bytes of Flash. We acknowledge this as a code quality improvement opportunity.
Best regards, Gavin
View full article