AnsweredAssumed Answered

QN9080 - possible memory leak in the BT stack \ issue with whitelist

Question asked by Max Asaulov on Dec 5, 2017
Latest reply on Feb 16, 2018 by Rodríguez

Hi.

 

I'm working on implementing firmware for a device that uses observer role to get sensor data and cache it. It also uses the peripheral role to send collected data to the phone when it's available. Because It's not possible to run a scan and advertise (required for a phone to connect) at the same time the code was implemented to switch between this functions periodically. I've noticed that after a few connect/disconnect events gScanCommandFailed_c/gAdvertisingCommandFailed_c are generated. After some time I've found that this happens due to 100% usage of the heap (MemManager). I've activated the MEM_STATISTICS/MEM_TRACKING/MEM_DEBUG_OUT_OF_MEMORY capabilities and reproduce this issues. MEM_TRACKING reports that most memory is used by:

allocAdr - 0x37843 <L2ca_HciEventCallback+14>
pCaller - 0x298e9 <Ble_HciRecv+780>

Unfortunately, these functions are in the pre-compiled libraries.

 

Any ideas how to fix it?

 

The second issue is related to whitelist: It's not possible to connect to the device the second time (I assume that pair/bond was done during first connection ) if the `gAdvParams.filterPolicy = gProcessWhiteListOnly_c;` is used. I've tested on three different example projects from the SDK (I've enabled paring/bonding for them in the app_preinclude.h). I've checked that IRK is distributed from the phone.

 

SDK: SDK_2.2_QN908xCDK_Beta
IDE: mcuxpressoide-10.0.2_411
System : Ubuntu 16.04

 

P.S: I've found a few issues with SDK, but they are not critical for me :

  1. After use of `NVM_Status_t NvFormat(void);` NVM module is not functioning properly - bonding information is not saved between reboots. Fix that worked for me - manually erase the NVM storage area.
  2. With `#define gAppUseNvm_d 1` examples are not starting due to the high priority of the NVM thread.
  3. I2C_MasterTransferDMA is not working properly with subaddress. Fix :
    @@ -316,6 +316,7 @@ static status_t I2C_RunTransferStateMachineDMA(I2C_Type *base, i2c_master_dma_ha
    DMA_PrepareTransfer(&xferConfig, handle->subaddrBuf, (void *)&base->MSTDAT, sizeof(uint8_t),
    handle->remainingSubaddr, kDMA_MemoryToPeripheral, NULL);
    DMA_SubmitTransfer(handle->dmaHandle, &xferConfig);
    + DMA_StartTransfer(handle->dmaHandle);
    handle->remainingSubaddr = 0;
    if (transfer->dataSize)

 

Regards,
Max.

Outcomes