ECC under FreeRTOS

winequarter wrote on Thursday, October 30, 2008:


Does anyone have experience with Elliptic Curve Crpytography running under FreeRTOS? I’m currently working with an AT91SAM7X256 (ARM7TDMI). I tried to do some encryption with the MIRACL library from There are no problems with “simple” operations with big numbers, e.g. the calculation of 50!. But when I try to execute an elliptic curve operation, everything stands still :frowning:
The encryption works without FreeRTOS.

So has anyone experienced with this topic. Of course, it is also possible to use some other library - I’m not tied up to MIRACL.



davedoors wrote on Thursday, October 30, 2008:

I dont know about ECC, but a few pointers to look at first.

Does the algorithm use a lot of stack?  Stack overflow is the most common problem.  FreeRTOS includes some utilities to detect stack overflow.

Does the algorithm do anything using global variables, or is it in any other way not re entrant?  If so then you will have to use guards if accessing the library from more than one task.

Does the algorithm attempt to perform any dynamic memory allocation using malloc? If so then you will need to ensure your linker script allocates a heap, or replace calls to malloc with pvPortMalloc().

winequarter wrote on Thursday, October 30, 2008:

Hi Dave!

Thanks a lot for your hints! I think, the library uses a lot of stack. I tried to dramatically reduce the memory-consumption of FreeRTOS and my program. I decreased the Heap-Size and disabled every unused part.
I tried to announce a StackOverflow with vApplicationStackOverflowHook but without success (there is no announcement). (configCHECK_FOR_STACK_OVERFLOW is set to 2).

The Lib has some switches which prevents it to allocate any vars. So everything is static and on the stack. It’s used in only one thread. So I think there should not be a problem with reentrance or global variables.

I’m on my wits’ end. What else can i do to analyze the problem?

edwards3 wrote on Thursday, October 30, 2008:

Did you increase the stack allocated to the task in the call to xTaskCreate?

winequarter wrote on Friday, October 31, 2008:

Of course, I did not ;(
But again, my program is not running. I think I have to try a bare-metal implementation for this problem. But I’ll keep at it and will try other things with FreeRTOS. I’m still impressed… :slight_smile: