This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2640R2F: ECCROMCC26XX init params problem

Part Number: CC2640R2F

Hello! I'm trying to use ECCROMCC26XX driver for elliptic curve encryption on CC2640R2F. In ECCROMCC26XX.h there are lines:

* // Set the Malloc and Free functions for internal buffer allocation.
* params.malloc = (uint8_t *(*)(uint16_t))myMallocFunction;
* params.free = (void (*)(uint8_t *))myFreeFunction;

How this functions should look like?

 

  • Hello,

    I believe you can use the Standard C library here:

    * // Set the Malloc and Free functions for internal buffer allocation.
    params.malloc = (uint8_t *(*)(uint16_t))&malloc;
    params.free = (void (*)(uint8_t *))&free;

    Regards,

    AB

  • Thanks for reply! When I run code without these params I get ECCROMCC26XX_STATUS_ILLEGAL_PARAM status code from ECCROMCC26XX_genKeys. If I run code with these params programm doesn't go through function ECCROMCC26XX_genKeys and blocks. If I set timeout param, problem doesn't dissapear. Here is part of my code which uses this driver. This code runs in SimpleBLEPeripheral_taskFxn context of simple_periphearl_oad_on_chip example before application main loop.

    // Declaration of this client's ECCROMCC26XX parameters.
    ECCROMCC26XX_Params params;

    // Declaration of local public keys
    uint8_t localPrivateKey[32] = {0};
    uint8_t localPublicKeyX[32] = {0};
    uint8_t localPublicKeyY[32] = {0};
    uint8_t sharedSecretKeyX[32] = {0};
    uint8_t sharedSecretKeyY[32] = {0};

    localPrivateKey[31]=1;

    // Initialize ECC ROM driver
    ECCROMCC26XX_init();

    // Initialize this client's ECCROMCC26XX parameters.
    ECCROMCC26XX_Params_init(&params);

    // Set the Malloc and Free functions for internal buffer allocation.
    params.malloc=(ECCROMCC26XX_MallocCB)&malloc;
    params.free=(ECCROMCC26XX_FreeCB)&free;

    // If an indefinite timeout is undesirable, alter the timeout here.
    // the value specified here will be a multiple of Clock.tickPeriod is
    // specified as.
    params.timeout = 1000; // wait a maximum of 1000 system time units

    // Generate public keys
    ECCROMCC26XX_genKeys(localPrivateKey, localPublicKeyX,
    localPublicKeyY, &params);
  • Hello,

    I believe you will benefit from taking a look at out secure_fw example located in <SDK_LOCATION>/examples/<DEVICE>/ble_stack/secure_fw/src/secure_fw.c

    This example utilizes the ECC driver for secure BLE OAD.

    Regards,

    AB

  • This code resolved my issue. (without &)

    params.malloc=(ECCROMCC26XX_MallocCB)malloc;
    params.free=(ECCROMCC26XX_FreeCB)free;