Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EFR32] Heap fragmentation issue cause AddOpCert request to fail #7727

Merged
merged 1 commit into from
Jun 21, 2021

Conversation

jmartinez-silabs
Copy link
Member

@jmartinez-silabs jmartinez-silabs commented Jun 17, 2021

Problem

EFR32 examples fail Secure session establisment with a failure when adding OpCert

00> <info  > [ZCL] OpCreds: Failed AddOpCert request.

The error happend when trying to store the OperationCertificate for this admin, the creation of a new StorableAdminPairingInfo does a malloc of 1976 that fails.

CHIP_ERROR AdminPairingInfo::StoreIntoKVS(PersistentStorageDelegate * kvs)
{
    CHIP_ERROR err = CHIP_NO_ERROR;

    char key[KeySize()];
    ReturnErrorOnFailure(GenerateKey(mAdmin, key, sizeof(key)));

    StorableAdminPairingInfo * info = chip::Platform::New<StorableAdminPairingInfo>();
    ReturnErrorCodeIf(info == nullptr, CHIP_ERROR_NO_MEMORY);

The whole process does multiples mallocs of rather large size. #7695

After analysing the heap usage, There was enough free heap but not a big enough block for the StorableAdminPairingInfo

Change overview

Quick band AID fix: Adding 3k to the heap of efr32 examples helps with the current fragmentation issues.
Could Add more heap to the MG12 MCU family but MG21 is already starving for RAM.

TODO: refactor efr32 example to use heap4 for FreeRTOS and wrap all allocs to the freeRTOS api. Improve heap monitor and tracking to better analyse and optimize the heap usage.

Testing

Manual tests with python controller on the differents examples
connect -ble 3840 73141520 1234
confirm Secure Session to Device Established

Fixes #7390

@jmartinez-silabs jmartinez-silabs changed the title [EFR32] Heap fragmentation issues cause AddOpCert request to fail [EFR32] Heap fragmentation issue cause AddOpCert request to fail Jun 17, 2021
@jmartinez-silabs
Copy link
Member Author

@bzbarsky-apple @chrisdecenzo @Damian-Nordic Please can you take a look, I need one more approve so this can be merge and it is prevent example for running. Thank you.

@woody-apple woody-apple merged commit df8d5d1 into project-chip:master Jun 21, 2021
@jmartinez-silabs jmartinez-silabs deleted the fix_OpCert branch June 22, 2021 15:24
nikita-s-wrk pushed a commit to nikita-s-wrk/connectedhomeip that referenced this pull request Sep 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

chip-device-ctrl connected error
7 participants