AnsweredAssumed Answered

FRDM K64F + FreeRTOS + LwIP - Hard fault

Question asked by Tze Yang Liaw on Jul 15, 2015
Latest reply on Jul 17, 2015 by Richard Barry

Hello all,

 

Am looking for advice on an issue I am currently facing. Details:

 

Running FreeRTOS + LwIP on FRDMK64F, toolchain is KDS v3.0 and KSDK v1.2.0. Project was created using Processor Expert.

I'm observing that malloc() called from the LwIP code always seems to return NULL. Origin of this observation is because I am running into a hard fault when one of the LwIP sntp functions calls gmtime(). Based on the disassembly listing it seems a malloc() was called in gmtime() and I am suspecting a memory allocation issue.

 

Not quite certain what I may have got wrong in my setup. Am continuing to look into this but any ideas would be useful and much appreciated. Thanks!

 

Heap and stack setup details as follows for review:

 

FreeRTOS config:

/* Heap Memory */

#define configFRTOS_MEMORY_SCHEME                2

#define configTOTAL_HEAP_SIZE                    98304

#define configUSE_HEAP_SECTION_NAME              1

#define configHEAP_SECTION_NAME_STRING           ".m_data_2"

 

 

Linker:

HEAP_SIZE  = DEFINED(__heap_size__)  ? __heap_size__  : 0xA000;

STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x4000;

/* Specify the memory areas */

MEMORY {

  m_interrupts          (RX)  : ORIGIN = 0x00000000, LENGTH = 0x00000400

  m_flash_config        (RX)  : ORIGIN = 0x00000400, LENGTH = 0x00000010

  m_text                (RX)  : ORIGIN = 0x00000410, LENGTH = 0x000FFBF0

  m_data                (RW)  : ORIGIN = 0x1FFF0000, LENGTH = 0x00010000

  m_data_2              (RW)  : ORIGIN = 0x20000000, LENGTH = 0x00030000

}

Outcomes