I am currently evaluating embOS from SEGGER running on Cortex M4F. It has 128 kilobytes of internal RAM, and 2 megabytes of external RAM, so I know I have plenty of memory.
My program uses some dynamic allocations (yes, I am aware that is not recommended on embedded systems).
When starting my task, I am trying to call malloc/OS_malloc
, where the OS_malloc
is the thread-safe version provided from embOS. In both cases, malloc
failed and returned NULL pointer.
When doing the same malloc/OS_malloc
before the OS starts, it works correctly:
**//Malloc here does not fail**
OS_IncDI(); /* Initially disable interrupts */
**//Malloc here does not fail**
OS_InitKern(); /* Initialize OS */
**//Malloc here does fail !!**
OS_InitHW(); /* Initialize Hardware for OS */
OS_CREATETASK(&TCBHP, "My Task", HPTask, 50, StackHP); //**<--And off course malloc failes inside teh task also**
OS_Start();
I went and tried using uCOS from MICRIUM, and I see the same behavior. Any ideas why this happens?