This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/TMS570LC4357: big arrays / out of memory error

Part Number: TMS570LC4357

Tool/software: Code Composer Studio

Hello,

The program I have is as follow:

#include <stdio.h>
#include <stdint.h>
#include <string.h>

#define MLEN 59;

int main(void)
{

    //unsigned char sk[CRYPTO_SECRETKEYBYTES];
    volatile unsigned char pk[1600];
    volatile unsigned char sm[1600];

    unsigned long smlen = 85;
    unsigned long mlen = 54;
    unsigned char mo[5];
    //unsigned char mo[MLEN+CRYPTO_BYTES]="";

     //randombytes(mi, MLEN);

    //crypto_sign_keypair(pk, sk);
    //crypto_sign(sm, &smlen, mi, 59, sk);

    int valid = crypto_sign_open(mo, &mlen, sm, smlen, pk);

  return 0;
}

It runs out of the memory, Registr DFSR indicates an out-of-range address. 

How can I fix this?

Best,

Soundes.

  • My guess is you are running out of stack.  All those arrays are on the stack.  And perhaps the function crypto_sign_open uses lots of stack too.

    Thanks and regards,

    -George

  • Hi georg,
    the stack is 0x99999999 for my program.
    I still have the same problem!
    Do you think that creation of tables with malloc/calloc would solve the problem?
    best,
    Soundes.
  • I presume you have not literally allocated 0x99999999 bytes for the stack.  That's just your way of saying you have allocated a lot of space for the stack, and the problem still occurs.

    Soundes Marzougui said:
    It runs out of the memory, Registr DFSR indicates an out-of-range address. 

    I am not familiar with the DFSR register, and what it represents.  I'll turn this thread over to device experts who can help you debug this problem.

    Thanks and regards,

    -George

  • Hello Soundes,

    Can you try a larger stack size as George suggested?
  • Hello QJ,
    I tried 0x00030000 as a stack. and the stack usage showed that I my program needs only 10400Bytes. But everytime I allocate a bag table it turns to a non-valid memory range!
    Bets,
    Soundes.
  • Hello Soundes,

    Please change the stack size in sys_core.asm:

    userSp .word 0x08000000+0x00001000
    svcSp .word 0x08000000+0x00001000+0x00000100
    fiqSp .word 0x08000000+0x00001000+0x00000100+0x00000100
    irqSp .word 0x08000000+0x00001000+0x00000100+0x00000100+0x00000100
    abortSp .word 0x08000000+0x00001000+0x00000100+0x00000100+0x00000100+0x00000100
    undefSp .word 0x08000000+0x00001000+0x00000100+0x00000100+0x00000100+0x00000100+0x00000100

    If your code executes in user mode, please increase the 2nd number in all the lines (0x00001000). If your code runs in SVC mode, please increase the 3rd number in the lines (0x00000100).

    The stack memory size defined in cmd file should be larger than the stack size (user+svc+fiq+irq+abort+underdef).
  • Thank you a lot!!

    It solved finally my problem.