Hi
I am running MQX on the Vybrid Tower board (target twrvg65gs10_a5) from internal SRAM using IAR as the compiler.
On calling the functions _mem_alloc(size) or _mem_alloc_system(size) NULL is returned and the task error code is set to LWMEM_POOL_INVALID.
I am unsure why this is, as the system pool should surely be valid?
From reading the docs, it appears these are aliased to using lwmem functions instead, so do I need to call _lwmem_set_default_pool() ?
Steps I have taken:
Currently MQX_USED_UNCACHED_MEM is set to 1 (default) and MQX_USE_LWMEM_ALLOCATOR is set to 0.
Apologies if this is in the manual somewhere, but I can't quite see it.
Message was edited by: Christopher Hemingway added- Trace through mem_alloc
Solved! Go to Solution.
Fixed
Turns out enabling lightweight memory through:
#define MQX_USE_LWMEM_ALLOCATOR 1
in user_config.h
Was needed so that _lwmem_init_internal() was called correctly.
I previously had LWMEM set to 0, but this appears to have not completely disabled it, and so _mem_init_internal() was being called by MQX at startup instead of _lwmem_init_internal(), although _mem_alloc() was being aliased by MQX to _lwmem_alloc().
Changing the value to 1 and recompiling fixed the errors, and memory now allocates fine.
Fixed
Turns out enabling lightweight memory through:
#define MQX_USE_LWMEM_ALLOCATOR 1
in user_config.h
Was needed so that _lwmem_init_internal() was called correctly.
I previously had LWMEM set to 0, but this appears to have not completely disabled it, and so _mem_init_internal() was being called by MQX at startup instead of _lwmem_init_internal(), although _mem_alloc() was being aliased by MQX to _lwmem_alloc().
Changing the value to 1 and recompiling fixed the errors, and memory now allocates fine.