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.

Compiler/LAUNCHXL-CC1352R1: CC1352R1 configuration for TRNG missing - after reversed fix gets only zero

Part Number: LAUNCHXL-CC1352R1

Tool/software: TI C/C++ Compiler

Hi,

TRNG didn't want to start because TRNG_count and TRNG_config were missing from board specific file. I tried to add those stuff to a board specific .c file and here is the result.

/*
 * =============================== TRNG ===============================
 */
#include <ti/drivers/TRNG.h>
#include <ti/drivers/trng/TRNGCC26X2.h>

TRNGCC26X2_Object trngObjects[CC1352R1_LAUNCHXL_TRNGCOUNT];

const TRNGCC26X2_HWAttrs trngHWAttrs[CC1352R1_LAUNCHXL_TRNGCOUNT] = {
    {
         .intPriority = ~0,
         .swiPriority = 0
    }
};

const TRNG_Config   TRNG_config[CC1352R1_LAUNCHXL_TRNGCOUNT] = {
    {
         .object = &trngObjects[CC1352R1_LAUNCHXL_TRNG0],
         .hwAttrs = &trngHWAttrs[CC1352R1_LAUNCHXL_TRNG0]
    }
};

const uint_least8_t TRNG_count = CC1352R1_LAUNCHXL_TRNGCOUNT;

/*!
 *  @def    CC1352R1_LAUNCHXL_TRNG
 *  @brief  Enum of TRNG modules
 */
typedef enum CC1352R1_LAUNCHXL_TRNGName {
    CC1352R1_LAUNCHXL_TRNG0 = 0,

    CC1352R1_LAUNCHXL_TRNGCOUNT
} CC1352R1_LAUNCHXL_TRNGName;

The program finally compiled but at the end, no matter which TRNG generator I use, I get only zeroes. The problem is that TRNG_config struct is missing .baseAddr parameter and I cannot set it during board specific configuration declaration - maybe that's the issue here? Maybe I got something extremly wrong? Can you help me out with this?

  • To further specify my issue, yes - TRNG was later initialized, handles created and functions called like in TIREX/TRNG.h text examples.
  • Later compared to what?

    You should not be required to set up something extra, the Easylink rfWsnNode example uses the TRNG and it runs without any issue.
  • After my initial changes to board source I later did all things by the book in main thread. Like I did with, for example, UART or GPIO module - Init, ParamsInit, etc.

    I understand that you are talking about the driverlib solution. I assume it works correctly seeing my TxCCA example and examples place dhere on this forum from other users. But at the end I should not need lower level libraries when, up until this moment, I could do everything with the higher level library that is TI Drivers. And I would like to point out that TRNG module is advertised as an available option here - http://dev.ti.com/tirex/content/simplelink_cc13x2_sdk_2_20_00_71/docs/tidrivers/doxygen/html/_t_r_n_g_8h.html . Unfortunately at this moment the board specific configuration for TRNG is not there along with UART or GPIO tables and attributes. The basic stuff like count of TRNG modules (TRNG_count undefined) is not there and while I can recreate this piece of code, it still doesn't want to work.

  • I have received a new board file from R&D including TRNG but I haven't had the time yet to see if this works better with the driver. I'll be back to you.
  • I have tested this by using the empty example in the CC13x2 SDK (2.20) on a CC1312 LP since that was what I have closest. The solution will be the same for all CC13x2 devices. I have attached the files I have done modifications to compared to the example. The entropyBuffer will contain the random value.

    Files.zip

  • So I once again added the same pieces of information as before (TRNG in both .c and .h board files as shown in your Files.zip example). I earlier never modified Board.h file so I made changes accordingly (added one new define that wasn't present before). Called your program inside main and was welcomed by error that passing volatile as parameter into CryptoKeyPlaintext_initBlankKey is not ok. Removing or appending volatile in various places makes program compile but I don't get any results. All are zero.

    Name : result
        Default:0
        Hex:0x00000000
        Decimal:0
        Octal:00
        Binary:00000000000000000000000000000000b

  • The volatile was added to make it easier to debug and should not be required.

    Just to check, it looks like you are looking at the variable 'result' which is just the status of the command. Have you checked entropyBuffer where the result of the TRNG_generateEntropy end up?
  • Oh ok wait...

    "The entropyBuffer will contain the random value." So I was supposed to take them out of the buffer all this time... Whoops...
    So I was right with the changes but I wasn't right with the result value.

    So since we are all here. How can I pass those values / functions so they can be used by EasyLink CCA example?
  • I mean, what should I pass to the easylinkParams.pGrnFxn param.
  • Hello, I am going to reuse my old topic.

    When I use TRNG_generateEntropyLessThan with one byte arrays and pass any type of upper bound limitation I can get only zeroes. Regular generateEntropy works very well and the results end up in entropyBuffer, in other cases they return zeroes. Below is the graph representing value appearances (0-255) after few hundred generator runs.

    I guess it works ok for regular function but I am not sure about the others.

  • Note that this driver is primary written to generate a private key for ECC. The driver is therefore written to generate large numbers since the key length is in the range of 128 bit and up. In an earlier post you asked about how to link the TRNG functions to easylink indicating that you are not using the driver to generate keys. If you want to return a 8 bit value, use the driverlib functions and not the driver.