Greetings,
I have problem with malloc function in fimware. I need to use it to follow guidelines of API for some peripheral sensor but on call it throws FaultISR. I modified linker .lds file to expand heap but error persist. Where to look for a clue?
This is my :lds file and part of startup file. Chip is TM4C123AE6PM.
MEMORY
{
FLASH (RX) : ORIGIN = 0x00000000, LENGTH = 0x00040000
SRAM (WX) : ORIGIN = 0x20000000, LENGTH = 0x00008000
}
REGION_ALIAS("REGION_TEXT", FLASH);
REGION_ALIAS("REGION_BSS", SRAM);
REGION_ALIAS("REGION_DATA", SRAM);
REGION_ALIAS("REGION_STACK", SRAM);
REGION_ALIAS("REGION_HEAP", SRAM);
REGION_ALIAS("REGION_ARM_EXIDX",FLASH);
REGION_ALIAS("REGION_ARM_EXTAB",FLASH);
SECTIONS
{
/* --- USER CONFIG --- */
_heap_size = 0x3000; /* 12 KB heap malloc(4096) is safe */
_stack_size = 0x2000; /* 8 KB stack safe for most apps */
/* --- Vector Table --- */
.intvecs (0x00000000) : {
KEEP(*(.intvecs))
} > REGION_TEXT
/* --- Code --- */
.text : {
*(.text*)
*(.rodata*)
KEEP(*(.init))
KEEP(*(.fini))
. = ALIGN(4);
} > REGION_TEXT
/* --- Initialized Data --- */
.data : {
__data_load__ = LOADADDR(.data); /* Flash address of .data */
__data_start__ = .; /* RAM start */
*(.data*)
. = ALIGN(4);
__data_end__ = .; /* RAM end */
} > REGION_DATA AT > REGION_TEXT
.bss : {
__bss_start__ = .;
*(.bss*)
*(COMMON)
. = ALIGN(4);
__bss_end__ = .;
} > REGION_BSS
/* --- HEAP --- */
.heap : {
__heap_start__ = .;
. = . + _heap_size; /* <-- reserves 12 KB in SRAM */
__HeapLimit = .; /* <-- end of the heap region */
end = __heap_start__;
_end = end; /* <-- start of heap (for legacy) */
__end = end;
} > REGION_HEAP
.stack : {
_stack_top = ORIGIN(SRAM) + LENGTH(SRAM);
_estack = _stack_top;
__stack = _stack_top;
_stack_bottom = _stack_top - _stack_size;
} > REGION_STACK
ASSERT(__HeapLimit <= _stack_bottom, "Heap overlaps stack!")
}
extern uint32_t _estack;
//*****************************************************************************
//
// External declarations for the interrupt handlers used by the application.
//
//*****************************************************************************
// To be added by user
//*****************************************************************************
//
// The vector table. Note that the proper constructs must be placed on this to
// ensure that it ends up at physical address 0x0000.0000 or at the start of
// the program if located at a start address other than 0.
//
//*****************************************************************************
__attribute__((section(".intvecs")))
void (* const g_pfnVectors[])(void) = {
(void (*)(void))&_estack,
// The initial stack pointer
ResetISR,
...