This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

libopenthread-nrf52840-sdk is reserving a SPI instance

Hello,

I cannot add SPI0 to my application because OpenThread library was built with it without any interest of that. Could you fix it please ? (I need the 3 SPI peripherals)

Linking target: _build/nrf52840_xxaa.out
../../../../../10_Tools/nRF5_SDK_for_Thread_and_Zigbee_2.0.0_29775ac/external/openthread/lib/gcc/libopenthread-nrf52840-sdk.a(libopenthread_nrf52840_sdk_a-spi-slave.o): In function `SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler':
/build/KNGP-TOLL1-JOB1/openthread/examples/../examples/platforms/nrf52840/spi-slave.c:191: multiple definition of `SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler'
_build/nrf52840_xxaa/nrfx_spim.c.o:F:\Git\Leolab\Projects\Clairvoyant\6_Sources\ble_thread_swi_template\pca10056\s140\armgcc/../../../../../10_Tools/nRF5_SDK_for_Thread_and_Zigbee_2.0.0_29775ac/modules/nrfx/drivers/src/nrfx_spim.c:676: first defined here
collect2.exe: error: ld returned 1 exit status
../../../../../10_Tools/nRF5_SDK_for_Thread_and_Zigbee_2.0.0_29775ac/components/toolchain/gcc/Makefile.common:292: recipe for target '_build/nrf52840_xxaa.out' failed
mingw32-make: *** [_build/nrf52840_xxaa.out] Error 1

  • Hello,

    Please see this documentation:
    https://www.nordicsemi.com/DocLib/Content/SDK_Doc/Thread_SDK/v2-0-0/thread_intro

    From one of the "Note" sections:

    "The above hardware resources are reserved for the OpenThread libraries delivered with this SDK. However, you can specify other instances of some peripherals such as Timers, PPIs, SWI, or UART and rebuild libraries. Refer to platform-config.h and nrf_802154_config.h to see the current configuration. You can also disable support for SPI by adding the DISABLE_SPI=1parameter."

    So you need to add this define (DISABLE_SPI=1);

    and build openthread again.

    If you want to make sure that the examples still work, please build using the same version of OpenThread that is used for creating the SDK. From another "Note" section

    "OpenThread is still in prerelease phase and its API changes frequently. Keep in mind that when the API changes, the examples might not compile with the latest OpenThread version right away without fixes."

    The version used to build the SDK is found in nRF5_SDK_for_Thread_and_Zigbee_2.0.0_29775ac\external\openthread\project\readme.txt:

    "OpenThread libraries projects are based on the following commit of OpenThread: 704511c96e0d093139e4b80ef0739ed2d701afb1".

    So if you build this version without the SPI, you should be able to use SPI0 as well.

    Best regards,

    Edvin

  • If you look at theses outputs. Exemples were integrated in the library so it will be better to fix it in Nordic distribution.

    ../../../../../10_Tools/nRF5_SDK_for_Thread_and_Zigbee_2.0.0_29775ac/external/openthread/lib/gcc/libopenthread-nrf52840-softdevice-sdk.a(libopenthread_nrf52840_softdevice_sdk_a-spi-slave.o): In function `SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler':

    /build/KNGP-TOLL1-JOB1/openthread/examples/../examples/platforms/nrf52840/spi-slave.c:191: multiple definition of `SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler'

  • Sorry. I don't follow. Where are these outputs from?

    BR,

    Edvin

  • Hello,

    When you try to use SPI0 or TWI0 with OpenThread lib, you get that outputs.

  • Hello,

    Yes. The openthread library that is included in SDK for Thread and Zigbee 2.0.0 uses SPI0 by default. This is because our SDK has examples where the nRF acts as a Network Co Processor (NCP). This is why the openthread library that is built for the SDK is using the SPI0. 

    Now, if you need to use SPI0, you must rebuild the openthread library. How to do this is described here. As it says near the top of that page, you would need to add DISABLE_SPI=1 in platform-config.h before building the library. Also note that if you build the latest release of openthread, it would cause all (at least most) of the examples to break. To still be able to use the examples as they are in the SDK, you would need to build the same version that is used with the SDK. The version that is used is mentioned in the file:

    SDK_for_thread_and_zigbee_2.0.0\external\openthread\project\readme.txt

    Now, if possible, the easier workaround is probably to not use SPI0 or TWI0 in your application. If possible, you may use SPI1, SPI2 or SPI3 instead. 

    Best regards,

    Edvin

Related