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.

Random number generation

Other Parts Discussed in Thread: CC2650, BLE-STACK

My project is based on SimpleBLEPeripheral on Smart RF and CC2650.

I am trying to generate "true" random numbers using function Util_GetTRNG, but it appears to always return 0.

I checked at HAL layer and it seems that the hardware is initialized if not done explicitly. Also, this appears to be a "blocking" function, so I expect the result to be synchronous.

Any idea why I always get 0? The code is invoked after a connection is established in case it matters.

  • Hi,

    Can you provide some sample code showing the problem? We can try and reproduce it here.

    Best wishes
  • Hi Luca,

    When did you call Util_GetTRNG()? Since it is processed by the stack, ICall should have been initialized and the stack task should have been up and running by the time you call Util_GetTRNG in your application task's context. ICall initialization is supposed to be done in Main.c.

    - Cetri
  • Hi, I am observing the same issue in simpleBLECentral.c

    I added the following code:

    if (keys & KEY_LEFT)
    {
    uint32_t r = Util_GetTRNG();
    LCD_WRITE_STRING_VALUE("random", r, 10, LCD_PAGE0);
    }

    to SimpleBLECentral_handleKeys and I read always "0" on the LCD.

    I tried to do that after establishing a connection and no luck.

    On the peripheral, same deal. Is it because I need to initialize the TRNG hardware somehow?

  • Hi, I am observing the same issue in my project based on TimeApp example. There, Util_GetTRNG() is called inside TimeApp_passcodeEvt() to get the passcode used in the pairing process, but it is always returning 0.
  • Hi Sontono,

    Are you using CCS? There was an issue found recently where Util_GetTRNG() was returning 0 on CCS setups. This has been corrected and will be deployed in the next BLE-Stack release. You can implement the fix in the 2.0 SDK by modifying bleDispatch.c in the Stack project.

    Add the following line:
    stat = SUCCESS;
    to:
    static uint8 processICallUTIL()
    {
    ...
    case HCI_EXT_UTIL_GET_TRNG:
    {
    ..
    stat = SUCCESS; <-- Add this line
    break;
    }
    ...
    }

    Best wishes
  • Hi JXS,

    One more time, your indications are exact, quick and precise to solve my problem.
    I am very happy to count on all people at this community, especially TI staff. Your work is amazing!
    Thank you very much.