cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 and calloc failure

Manu Abraham
Senior

Hi,

I am using a STMH743 running an LWIP example, added in mbedTLS to the mix.

Eventually, got into a certificate parse issue,

narrowing it down:

I found that calloc failed:

 (890) x509_crt_parse_der_core:

 (899) x509_crt_parse_der_core: mbedtls_calloc(), crt->raw.p=NULL, len:995

Tried searching a bit on calloc failure, came up with this link:

https://www.keil.com/support/docs/4094.htm

But that appears to match ( ? ) the startup file that I do have:

;*******************************************************************************
; User Stack and Heap initialization
;*******************************************************************************
                 IF      :DEF:__MICROLIB
                
                 EXPORT  __initial_sp
                 EXPORT  __heap_base
                 EXPORT  __heap_limit
                
                 ELSE
                
                 IMPORT  __use_two_region_memory
                 EXPORT  __user_initial_stackheap
                 
__user_initial_stackheap
 
                 LDR     R0, =  Heap_Mem
                 LDR     R1, =(Stack_Mem + Stack_Size)
                 LDR     R2, = (Heap_Mem +  Heap_Size)
                 LDR     R3, = Stack_Mem
                 BX      LR
 
                 ALIGN
 
                 ENDIF
 
                 END
 
;************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE*****

I am at a loss, how to go forward.

Can someone help ?

Thanks,

Manu

3 REPLIES 3
Manu Abraham
Senior

Replying to my own post ..

Played around with the Heap size,

This fixed the calloc() issue.

Sorry about the noise.

Thanks,

Manu

For others, stack and heap are defined in startup.s, the memory involved can be established via a scatter file

;*******************************************************************************
;
; Amount of memory (in bytes) allocated for Stack
; Tailor this value to your application needs
; <h> Stack Configuration
;   <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
 
Stack_Size      EQU     0x0800
 
                AREA    STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem       SPACE   Stack_Size
__initial_sp
 
 
; <h> Heap Configuration
;   <o>  Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
 
Heap_Size       EQU     0x2000
 
                AREA    HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem        SPACE   Heap_Size
__heap_limit
 
;***************************************************************************** 
  RW_RAM1 0x60000000 UNINIT 0x00040000  {  ; RW data
    *(HEAP)  ; external SRAM
  } 

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..

Thanks, Clive1

I have a faint memory, (you or someone else ?)

A mention about stack and heap requirements running a web server with and without TLS/SSL quite a while back ?

Could not find that discussion, anymore though.

Thanks,

Manu