## Heap Corrupted > Link Layer's heap is corrupted. ---- Link Layer's heap has an internal integrity checking mechanism: each memory block is guarded a few magic numbers. When these numbers are different from expectation, that block must be corrupted, so an assertion is raised. ### How to deal with it? * Are you using `ll_malloc` to allocate buffers from Link Layer's heap? Check if too many bytes are written into it. * Hunt for wild pointers. * Bisect or revert to elder revisions to locate the code causing the problem. * [Dump the memory](/user_guide/dive-into-sdk.html#memory-dump) and contact us for further support.
## Out of Memory > Controller fails to allocate memory. ---- Controller fails to allocate memory for Link Layer control procedures or internal messages. ### How to deal with it? Are you using `ll_malloc` to allocate too much memory? Please reduce the amount. Tips: Call `ll_get_heap_free_size` to check the free size of Link Layer's heap in bytes.
## Memory Corrupted > Variables for inter process communication is corrupted. ---- Variables for inter process communication within Controller is corrupted. Memory location of these variables: near the end of RAM range reserved for `platform.bin`. ### How to deal with it? * Hunt for wild pointers. * Bisect or revert to elder revisions to locate the code causing the problem. * [Dump the memory](/user_guide/dive-into-sdk.html#memory-dump) and contact us for further support.
## Memory Corrupted > Variables for multi-tasking is corrupted. ---- Variables for multi-tasking within Controller is corrupted. Memory location of these variables: near the end of RAM range reserved for `platform.bin`. ### How to deal with it? * Hunt for wild pointers. * Bisect or revert to elder revisions to locate the code causing the problem. * [Dump the memory](/user_guide/dive-into-sdk.html#memory-dump) and contact us for further support.
## Memory Corrupted > Variables for HCI is corrupted. ---- Variables for the internal Host-Controller Interface is corrupted. ### How to deal with it? * Hunt for wild pointers. * Bisect or revert to elder revisions to locate the code causing the problem. * [Dump the memory](/user_guide/dive-into-sdk.html#memory-dump) and contact us for further support.
## FreeRTOS Specific: Task Function Exited > A function that implements a task has exited. ---- A function that implements a task must not exit or attempt to return to its caller as there is nothing to return to. ### How to deal with it? If a task wants to exit it should instead call `vTaskDelete(NULL)`.
## FreeRTOS Specific: Unsafe API called in ISR > A function that is not interrupt safe is called in ISR. ---- This is not the interrupt safe version of the enter critical function and it is being called from an interrupt context. Only API functions that end in "FromISR" can be used in an interrupt. ### How to deal with it? * Call the corresponding function that end in "FromISR" instead; * Use `IS_IN_INTERRUPT()` to test if in an interrupt and call the correct API variant.
## FreeRTOS Usage Violation > Various FreeRTOS usage violations. ---- Examples: * Call `vPortExitCritical()` without `vPortEnterCritical()` * Interrupt priority higher than `configMAX_SYSCALL_INTERRUPT_PRIORITY`, and within the ISR, a "FromISR" function is called. ISR safe FreeRTOS API functions must *only* be called from interrupts that have been assigned a priority at or below `configMAX_SYSCALL_INTERRUPT_PRIORITY`, i.e. the value of priority is equal or larger than `configMAX_SYSCALL_INTERRUPT_PRIORITY`.
## Malformed HCI Command > Parameters too long ---- Parameters of an HCI command exceeds maximum length. Some HCI commands have a variable number of parameters with an upper limit. Take _LE Set Extended Scan Parameters_ as an example. It accepts at most two types of PHYs on primary advertising channels. The corresponding GAP API is `gap_set_ext_scan_para`, and if a value which is larger than 2 is passed as `config_num`, this assertion is triggered. ```c /** * ... * @param config_num configure number 2 at most. It indicates that host would configure how many kinds of PHY * ... */ uint8_t gap_set_ext_scan_para(const bd_addr_type_t own_addr_type, const scan_filter_policy_t filter, const uint8_t config_num, const scan_phy_config_t *configs); ``` ### How to deal with it? Check [_Programmers' Guide on BLE_](/application-notes/pg_ble_stack_cn/index.html), and do not pass invalid parameters to `gap_set_ext_scan_para`, `gap_ext_create_connection`, etc.
## Invalid Internal ACL Packets Length > Allocated ACL packets length is shorter than data ---- When sending ACL data (any L2CAP data or signalling), firstly, internal packets are allocated in link layer, then data is filled. When filling data, it is found that total length of internal packets is actually shorted than data. The **most likely cause** for this assertion is thread-safety violation on stack API, i.e. stack API is called from another thread (task). ### How to deal with it? Make sure that stack API thread-safety is not violated. Check out _Programmers' Guide on BLE_ for more details. Tip: * Use _Afx Tool_ to check it automatically; or, * Manually search for such conditions in _Static Call Graph_ generated by Keil.
## Out of Memory > Failed to allocate memory from one of internal heaps ---- Event `PLATFORM_CB_EVT_HEAP_OOM` is emitted when allocation on heap fails (heap out of memory). Parameter `(void *data)` is casted from an integer identifying which item is OOM. | #Id | Heap-like Items | |:------:|:--------------------- | | 0 | FreeRTOS's heap | | 1 | Link Layer's heap | | 2 | Link Layer's task pool| OOM on heap #0 only occurs in bundles with built-in FreeRTOS. Link Layer's task pool is unlikely to get exhausted. ### How to deal with it? * FreeRTOS's heap: Check memory leaks regarding heap usage (`pvPortMalloc`/`vPortFree`) of FreeRTOS; If heap size is not enough for the application, use NoOS variant and build RTOS externally. * Link Layer's heap: Check memory leaks regarding heap usage (`ll_malloc`/`ll_free`) of Link Layer; Avoid push too much data (`att_server_notify`/`gatt_client_write_value_of_characteristic`/...) into BLE stack with the help of `ll_get_heap_free_size`.
## Internal or Unknown Error ---- Please contact us for further support.