Can I use regular (stack) memory in fsl_dcp.c?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can I use regular (stack) memory in fsl_dcp.c?

430 Views
N-
Contributor I

Currently in the fsl_dsp.c a static variable is used from non-cacheable RAM:

```
AT_NONCACHEABLE_SECTION_INIT(static dcp_context_t s_dcpContextSwitchingBuffer);
```
It seems wasteful to reserve 208 bytes permanently to calculate a SHA once a week.
I could use the RAM for better purposes. So just a plain static buffer:
```
static dcp_context_t s_dcpContextSwitchingBuffer;
```

Now I did read the DCACHE invalidate application note but I am a little unsure how and when to implement this as the buffer is passed to the hardware via the DCP_Type->CONTEXT register.

I _think_ the following should do in dcp_hash_update_non_blocking():
```
DCACHE_CleanByRange((uint32_t)dcpPacket, sizeof(dcpPacket));
```

Anyone have any experience or done something similar with the DCP?

0 Kudos
Reply
5 Replies

359 Views
EdwinHz
NXP TechSupport
NXP TechSupport

Hi @N-,

Could you please share the part number that you are using, along with the SDK example you are looking into and SDK and IDE versions?

BR,
Edwin.

0 Kudos
Reply

342 Views
N-
Contributor I

iMXRT1024, SDK 2.14.0, manifest version 3.13.0, MCUExpresso 11.8.1
The DCP example with the CRC32,SHA and AES calls using the DCP hardware.

The fsl_dcp.c at line 94 creates a non-cacheable variable which I would like to convert so it can use regular memory (on the stack or heap) using invalidate and clean.

0 Kudos
Reply

314 Views
EdwinHz
NXP TechSupport
NXP TechSupport

Hi @N-,

Thanks for your clarifications. I must say that in this case, we highly encourage you to not change the fsl_dcp.c driver, as changing it might result in unexpected behavior of this module. I understand that you mention the 208 bytes could be better used elsewhere for other operations instead of a once-a-week SHA calculation, but in this case do consider it necessary for the proper functionality of your device.

I would also like to encourage you to update your MCUXpresso IDE and SDK to the latest versions.

BR,
Edwin.

0 Kudos
Reply

259 Views
N-
Contributor I

That is really unfortunate to hear.

Can you show me how to convert the SHA256 example so it uses invalidate can clean instead of a static non cached global variable?

0 Kudos
Reply

427 Views
N-
Contributor I

Obviously the DCACHE_CleanByRange should be done before the __DSB and __ISB

(Ran out of time to edit the message)

0 Kudos
Reply