Hi,
I have no "nrf_crypto_allocator.h" in Components. Can anyone help me where to find this file?
Hi,
I have no "nrf_crypto_allocator.h" in Components. Can anyone help me where to find this file?
Hi Raza,
I'm no expert on this matter, but based on the information I found in this page: https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.0.0%2Fgroup__nrf__crypto__config.html
It seems that you might have set
#define NRF_CRYPTO_ALLOCATOR
to
1 (User macros)
According to the description, this requires you to add your own header file that declares the functions NRF_CRYPTO_ALLOC, NRF_CRYPTO_FREE, and NRF_CRYPTO_ALLOC_ON_STACK
So you'll have to either do that, or choose another option for NRF_CRYPTO_ALLOCATOR.
Best regards,
Raoul Pathak
HI Raaul,
Thanks alot for your reply.
so there is no header in SDK that declares those functions? and what other option can i use for this that uses already present headers in the SDK.
Best,
Raza Abbas
That's correct, that option is there specifically for you to add your own "user" allocator functions. The other options are detailed in the documentation page I linked you.
Just look for the Macro Definition Documentation for #define NRF_CRYPTO_ALLOCATOR
There are options to allocate to stack memory, to heap memory with malloc, or to use nrf_malloc to let it be handled by the SDK Memory Manager
Best regards,
Raoul
Hi Raoul,
can you elaborate more, because i am looking at the code of my precious college and i am new to nordic chips. it would be a great help. thanks in advance
Hi, sure
The cryptographic functions need some memory to operate with. This memory can be "allocated" to the crypto functions in various ways - statically to the stack, or dynamically, to heap memory. This is not specific to Nordic chips, you could read more about it here: https://www.geeksforgeeks.org/difference-between-static-and-dynamic-memory-allocation-in-c/
Dynamic (heap) memory allocation uses some algorithm to find free memory and reserve it for your function. For some advanced users, it might be desirable to use a custom algorithm or mechanism to allocate memory. For those users, NRF_CRYPTO_ALLOCATOR can be set to 1 (User Macros). If this option is selected, the user has to provide their own functions for allocating memory, declared through nrf_crypto_allocator.h.
But, as stated by my colleague in a similar case, option 1 (and therefore the header file) is usually not needed:/nrf_crypto_allocator.h: No such file or directory
Please try setting NRF_CRYPTO_ALLOCATOR to 0, to use the default allocator.
Or, if your previous colleague really found need to use a custom allocator, you will have to find out why they made this decision, and if it's still relevant, you should implement the functions NRF_CRYPTO_ALLOC, NRF_CRYPTO_FREE, and NRF_CRYPTO_ALLOC_ON_STACK according to that need.
I hope this clarifies things.
Best regards,
Raoul