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: Stack Usage

Part Number: TMS570LC4357


Tool/software: Code Composer Studio

Hello,

I want to run an encryption algorithm that needs 10kilo bytes of memory. 

For that I did changes in .cmd file 

MEMORY
{
/* USER CODE BEGIN (2) */
/* USER CODE END */
    VECTORS (X)  : origin=0x00000000 length=0x00000020
    FLASH0  (RX) : origin=0x00000020 length=0x001FFFE0
    FLASH1  (RX) : origin=0x00200000 length=0x00200000
    STACKS  (RW) : origin=0x08000000 length=0x00030000 //<= here are my canges I took from the RAM memory
    RAM     (RW) : origin=0x08030000 length=0x0007EB00 //<= here are my canges I took from the RAM memory

/* USER CODE BEGIN (3) */
/* USER CODE END */
}

and I changed the stack in CSS by going to Project-> Properties-> ARM linker -> basic options and I put stack size 167kB which means 0x00030000.

The problem I get is that during the execution the program is pointing to a non-valid memory address. (during allocation of some char * arrays of size 1000). 

I checked again the stack usage. 

Here is my question: If I did give the stack 167 kB, why in the stack usage it is taking just 10400 Bytes ?

How can I convince this fabulous stack that he can use 167 kB from the RAM!!

(kB = kilo bytes)

 

Best regards,

Sounde Marzougui.

  • Memory allocated dynamically at run time, by calling malloc (or related functions), does not come from the stack, but the heap.  Please search the ARM compiler manual for the sub-chapter titled Dynamic Memory Allocation.  

    Further, always check the result returned by malloc for NULL, which means the allocation failed.  It is typical to write a custom function similar to this ...

    void *malloc_with_check(size_t size)
    {
       void *ptr = malloc(size);
    
       if (ptr == NULL)
       {
           /* error recovery */
       }
    
       return ptr;
    }

    Thanks and regards,

    -George