mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #4849 from ARMmbed/nanomesh_memory
Allow using of malloc() for reserving the Nanostack's heap.pull/4935/head
commit
5321a75fd3
|
@ -34,6 +34,7 @@ An example of the configuration file:
|
|||
| Parameter name | Value | Description |
|
||||
| --------------- | ------------- | ----------- |
|
||||
| heap-size | number [0-0xfffe] | Nanostack's internal heap size |
|
||||
| use-malloc-for-heap | `false` or `true` | Use `malloc()` for reserving the internal heap. Default: `false` |
|
||||
|
||||
### Thread related configuration parameters
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
"name": "mbed-mesh-api",
|
||||
"config": {
|
||||
"heap-size": 32500,
|
||||
"use-malloc-for-heap": false,
|
||||
"6lowpan-nd-channel-mask": "(1<<12)",
|
||||
"6lowpan-nd-channel-page": 0,
|
||||
"6lowpan-nd-channel": 12,
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "eventOS_scheduler.h"
|
||||
#include "eventOS_event.h"
|
||||
#include "net_interface.h"
|
||||
|
@ -22,13 +23,18 @@
|
|||
#include "platform/arm_hal_timer.h"
|
||||
#include "ns_hal_init.h"
|
||||
#include "include/mesh_system.h"
|
||||
#include "mbed_assert.h"
|
||||
// For tracing we need to define flag, have include and define group
|
||||
#define HAVE_DEBUG 1
|
||||
#include "ns_trace.h"
|
||||
#define TRACE_GROUP "m6-mesh-system"
|
||||
|
||||
/* Heap for NanoStack */
|
||||
#if !MBED_CONF_MBED_MESH_API_USE_MALLOC_FOR_HEAP
|
||||
static uint8_t app_stack_heap[MBED_CONF_MBED_MESH_API_HEAP_SIZE + 1];
|
||||
#else
|
||||
static uint8_t *app_stack_heap;
|
||||
#endif
|
||||
static bool mesh_initialized = false;
|
||||
|
||||
/*
|
||||
|
@ -55,6 +61,10 @@ static void mesh_system_heap_error_handler(heap_fail_t event)
|
|||
void mesh_system_init(void)
|
||||
{
|
||||
if (mesh_initialized == false) {
|
||||
#if MBED_CONF_MBED_MESH_API_USE_MALLOC_FOR_HEAP
|
||||
app_stack_heap = malloc(MBED_CONF_MBED_MESH_API_HEAP_SIZE+1);
|
||||
MBED_ASSERT(app_stack_heap);
|
||||
#endif
|
||||
ns_hal_init(app_stack_heap, MBED_CONF_MBED_MESH_API_HEAP_SIZE,
|
||||
mesh_system_heap_error_handler, NULL);
|
||||
eventOS_scheduler_mutex_wait();
|
||||
|
|
Loading…
Reference in New Issue