This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Failing to build latest OpenThread library

Hi all, I tried to build the latest OpenThread libraries but after copying the library files in the SDK, I fail to compile the examples. Everything was fine when building with the OpenThread libraries files provided in the Nordic SDK. So, I maybe do something wrong when I build the OpenThread library. Please find here below the error log. I think that the problem can be in the wrong paths "/home/rolu/repos/openthread_graviton..." and "c:\repos\thread\sdk\sdk\nrf5\components..." which are not in my environment. Can anyone please help me to understand? Thank you.

Compiling file: main.c
Linking target: _build/nrf52840_xxaa.out
../../../../../../../external/openthread/lib/gcc/libopenthread-cli.a(libopenthread_cli_a-cli.o): In function `Thread::Cli::Interpreter::HandleIcmpReceive(Thread::Message&, Thread::Ip6::MessageInfo const&, Thread::Ip6::IcmpHeader const&)':
/home/rolu/repos/openthread_graviton/examples/../src/cli/cli.cpp:1357: undefined reference to `Thread::Message::GetLength() const'
/home/rolu/repos/openthread_graviton/examples/../src/cli/cli.cpp:1357: undefined reference to `Thread::Message::GetOffset() const'
/home/rolu/repos/openthread_graviton/examples/../src/cli/cli.cpp:1369: undefined reference to `Thread::Message::GetOffset() const'
../../../../../../../external/openthread/lib/gcc/libopenthread-cli.a(libopenthread_cli_a-cli.o): In function `Thread::Timer::IsRunning() const':
/home/rolu/repos/openthread_graviton/examples/../src/core/common/timer.hpp:190: undefined reference to `Thread::TimerScheduler::IsAdded(Thread::Timer const&)'
../../../../../../../external/openthread/lib/gcc/libopenthread-cli.a(libopenthread_cli_a-cli.o): In function `Thread::Cli::Interpreter::HandleDiagnosticGetResponse(Thread::Message&, Thread::Ip6::MessageInfo const&)':
/home/rolu/repos/openthread_graviton/examples/../src/cli/cli.cpp:2866: undefined reference to `Thread::Message::GetLength() const'
/home/rolu/repos/openthread_graviton/examples/../src/cli/cli.cpp:2866: undefined reference to `Thread::Message::GetOffset() const'
/home/rolu/repos/openthread_graviton/examples/../src/cli/cli.cpp:2873: undefined reference to `Thread::Message::GetOffset() const'
../../../../../../../external/openthread/lib/gcc/libmbedcrypto.a(mbedtls_openthread_lib_hardware_entropy.c.o): In function `mbedtls_hardware_poll':
c:\repos\thread\sdk\sdk\nrf5\components\thread\experimental\crypto\lib_nrf52\armgcc/../../hardware_entropy.c:37: undefined reference to `otPlatRandomSecureGet'
collect2: error: ld returned 1 exit status
make: *** [_build/nrf52840_xxaa.out] Error 1
  • Hello Marco!

    Thanks for raising this issue!

    As you probably guess, there were quite a lot of changes in OpenThread repository since our last release. Based on your output i see two problems:

    1. libopenthread-cli.a - OpenThread has deprecated a usage of this library, and instead introduced two new ones:

      • libopenthread-cli-ftd.a (for Full Thread Device)
      • libopenthread-cli-mtd.a (for Minimal Thread Device)

      And since you probably only replaced all old libraries, you still try to link examples with old version of libopenthread-cli.

      To fix that, you need to correct the name of the library in the proper Makefile of the example. E.g. $(SDK_ROOT)/external/openthread/lib/gcc/libopenthread-cli.a to $(SDK_ROOT)/external/openthread/lib/gcc/libopenthread-cli-ftd.a

    2. The second problem that you have expirienced hardware_entropy.c:37: undefined reference to "otPlatRandomSecureGet" is caused by the new API introduced here and to fix it, you have two ways:

      • use libmbedcrypto.a library from the OpenThread repository (without hardware acceleration)
      • recompile libmbedcrypto.a with a hardware acceleration as it is explained here. Note that you need to align API with the new OpenThread in components/thread/experimental/crypto/hardware_entropy.c file.

    In the mbedtls_hardware_poll function you should replace the usage of otPlatRandomSecureGet with otPlatRandomGetTrue with appropriate function parameters.

    e.g. (not tested)

    int mbedtls_hardware_poll(void *data, unsigned char *output, size_t len, size_t *olen)
    {
        ThreadError error;
    
        (void)data;
    
        error = otPlatRandomGetTrue((uint8_t *)output, len);
    
        if (error == kThreadError_None)
        {
            *olen = len;
        }
        else
        {
            return MBEDTLS_ERR_ENTROPY_SOURCE_FAILED;
        }
    
        return 0;
    }
    
  • Thank you very much for your detailed answer. I'm out of office at the moment for a few days but I'll try your suggested solution asap and I'll let you know. Thank you.

Related