SPIS Example for NRF Connect SDK

Hello ,

I am looking for a SPIS example for NRF5340 but I am unable to find it. I have developed some code using NRF52840 which I want to port it to NRF5340. Please advise me where I can look for it.

Regards.

Ahmed

Parents
  • Hi,

    I suggest looking at the samples under modules/hal/nordic/nrfx/samples/src/nrfx_spim_spis.

  • Hello Einar,

    I have seen these example but the issue is they build without any issues for NRF52840 but not for NRF5340.

    I am pasting the terminal's output.

    Building non_blocking
    C:\WINDOWS\system32\cmd.exe /d /s /c "west build --build-dir c:\ncsOLD\v2.3.0\modules\hal\nordic\nrfx\samples\src\nrfx_spim_spis\non_blocking\build c:\ncsOLD\v2.3.0\modules\hal\nordic\nrfx\samples\src\nrfx_spim_spis\non_blocking"

    [0/192] Performing build step for 'tfm'
    [1/113] Building C object secure_fw/partitions/crypto/mbedcrypto/nrf_security_src/CMakeFiles/crypto_service_mbedcrypto.dir/C_/ncsOLD/v2.3.0/modules/crypto/mbedtls/library/aria.o
    [2/113] Building C object secure_fw/partitions/crypto/mbedcrypto/nrf_security_src/CMakeFiles/crypto_service_mbedcrypto.dir/C_/ncsOLD/v2.3.0/modules/crypto/mbedtls/library/psa_crypto_slot_management.o
    FAILED: secure_fw/partitions/crypto/mbedcrypto/nrf_security_src/CMakeFiles/crypto_service_mbedcrypto.dir/C_/ncsOLD/v2.3.0/modules/crypto/mbedtls/library/psa_crypto_slot_management.o
    C:\ncsOLD\toolchains\v2.3.0\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -DBL1_HEADER_SIZE=0x000 -DBL1_TRAILER_SIZE=0x000 -DBL2_HEADER_SIZE=0x000 -DBL2_TRAILER_SIZE=0x000 -DCONFIG_HW_UNIQUE_KEY -DCONFIG_HW_UNIQUE_KEY_RANDOM -DCONFIG_TFM_DOORBELL_API=1 -DCONFIG_TFM_FP=0 -DCONFIG_TFM_PARTITION_META -DDAUTH_CHIP_DEFAULT -DMBEDTLS_CONFIG_FILE=\"nrf-config.h\" -DMBEDTLS_USER_CONFIG_FILE=\"nrf-config-user.h\" -DMCUBOOT_IMAGE_NUMBER=1 -DNRF5340_XXAA_APPLICATION -DNRF_ALLOW_NON_SECURE_RESET -DNRF_NS_STORAGE -DNRF_SKIP_FICR_NS_COPY_TO_RAM -DPLATFORM_DEFAULT_BL1 -DPSA_CRYPTO_SECURE -DTFM_FIH_PROFILE_OFF -DTFM_INTERNAL_TRUSTED_STORAGE_SERVICE_SID=0x00000070 -DTFM_LVL=1 -DTFM_PARTITION_CRYPTO -DTFM_PARTITION_LOG_LEVEL=TFM_PARTITION_LOG_LEVEL_SILENCE -DTFM_PARTITION_PLATFORM -DTFM_PSA_API -DTFM_SPM_LOG_LEVEL=TFM_SPM_LOG_LEVEL_SILENCE -D__NRF_TFM__ -IC:/ncsOLD/v2.3.0/modules/tee/tf-m/trusted-firmware-m/secure_fw/partitions/crypto -Isecure_fw/partitions/crypto/mbedcrypto/nrf_security_src/include/generated -IC:/ncsOLD/v2.3.0/nrfxlib/nrf_security/tfm/../include -IC:/ncsOLD/v2.3.0/nrfxlib/nrf_security/tfm/../include/mbedtls -IC:/ncsOLD/v2.3.0/nrfxlib/nrf_security/tfm/../include/psa -IC:/ncsOLD/v2.3.0/modules/crypto/mbedtls/include -IC:/ncsOLD/v2.3.0/modules/crypto/mbedtls/include/mbedtls -IC:/ncsOLD/v2.3.0/modules/crypto/mbedtls/include/psa -IC:/ncsOLD/v2.3.0/modules/crypto/mbedtls/library -IC:/ncsOLD/v2.3.0/nrfxlib/nrf_security/tfm/../../crypto/nrf_oberon/include -IC:/ncsOLD/v2.3.0/nrfxlib/nrf_security/tfm/../../crypto/nrf_oberon/include/mbedtls -IC:/ncsOLD/v2.3.0/nrfxlib/nrf_security/tfm/../../crypto/nrf_oberon/include/psa -IC:/ncsOLD/v2.3.0/modules/tee/tf-m/trusted-firmware-m/interface/include -Igenerated/interface/include -IC:/ncsOLD/v2.3.0/modules/tee/tf-m/trusted-firmware-m/platform/ext/target/nordic_nrf/common/core/. -IC:/ncsOLD/v2.3.0/modules/tee/tf-m/trusted-firmware-m/platform/ext/target/nordic_nrf/common/core/native_drivers -IC:/ncsOLD/v2.3.0/modules/hal/nordic/nrfx -IC:/ncsOLD/v2.3.0/modules/hal/nordic/nrfx/mdk -IC:/ncsOLD/v2.3.0/modules/hal/nordic/nrfx/drivers/include -IC:/ncsOLD/v2.3.0/modules/tee/tf-m/trusted-firmware-m/platform/ext/target/nordic_nrf/common/core/common -IC:/ncsOLD/v2.3.0/modules/tee/tf-m/trusted-firmware-m/platform/.. -IC:/ncsOLD/v2.3.0/modules/tee/tf-m/trusted-firmware-m/platform/ext/target/nordic_nrf/common/core/services/include -IC:/ncsOLD/v2.3.0/modules/tee/tf-m/trusted-firmware-m/platform/ext/target/nordic_nrf/common/nrf5340/. -IC:/ncsOLD/v2.3.0/nrf/modules/tfm/tfm/boards/partition -I../zephyr/include/generated -IC:/ncsOLD/v2.3.0/nrf/modules/tfm/tfm/boards/board -I../zephyr/misc/generated/syscalls_links/include -IC:/ncsOLD/v2.3.0/zephyr/include/zephyr -IC:/ncsOLD/v2.3.0/zephyr/include -IC:/ncsOLD/v2.3.0/nrf/modules/tfm/tfm/boards/services/include -IC:/ncsOLD/v2.3.0/nrf/include -IC:/ncsOLD/v2.3.0/nrf/modules/tfm/tfm/boards/include -IC:/ncsOLD/v2.3.0/nrf/include/tfm -IC:/ncsOLD/v2.3.0/modules/tee/tf-m/trusted-firmware-m/platform/ext/accelerator/interface -IC:/ncsOLD/v2.3.0/modules/tee/tf-m/trusted-firmware-m/platform/./ext -IC:/ncsOLD/v2.3.0/modules/tee/tf-m/trusted-firmware-m/platform/./ext/cmsis -IC:/ncsOLD/v2.3.0/modules/tee/tf-m/trusted-firmware-m/platform/./ext/common -IC:/ncsOLD/v2.3.0/modules/tee/tf-m/trusted-firmware-m/platform/./ext/driver -IC:/ncsOLD/v2.3.0/modules/tee/tf-m/trusted-firmware-m/platform/./include -IC:/ncsOLD/v2.3.0/modules/tee/tf-m/trusted-firmware-m/lib/fih/inc -isystem C:/ncsOLD/v2.3.0/nrfxlib/crypto/nrf_cc312_platform/include -isystem C:/ncsOLD/v2.3.0/nrfxlib/crypto/nrf_oberon/include/psa -isystem C:/ncsOLD/v2.3.0/nrfxlib/crypto/nrf_oberon/include -isystem C:/ncsOLD/v2.3.0/nrfxlib/crypto/nrf_oberon/include/mbedtls -mcpu=cortex-m33+nodsp -Os -DNDEBUG --specs=nano.specs -Wall -Wno-format -Wno-return-type -Wno-unused-but-set-variable -c -fdata-sections -ffunction-sections -fno-builtin -fshort-enums -funsigned-char -mthumb -nostdlib -std=c99 -gdwarf-4 -g -imacros C:/ncsOLD/v2.3.0/modules/hal/nordic/nrfx/samples/src/nrfx_spim_spis/non_blocking/build/zephyr/include/generated/autoconf.h -Wno-unused-function -Wno-unused-variable -Wno-unused-const-variable -Wno-unused-parameter -mfloat-abi=soft -mcmse -Wno-unused-value -MD -MT secure_fw/partitions/crypto/mbedcrypto/nrf_security_src/CMakeFiles/crypto_service_mbedcrypto.dir/C_/ncsOLD/v2.3.0/modules/crypto/mbedtls/library/psa_crypto_slot_management.o -MF secure_fw\partitions\crypto\mbedcrypto\nrf_security_src\CMakeFiles\crypto_service_mbedcrypto.dir\C_\ncsOLD\v2.3.0\modules\crypto\mbedtls\library\psa_crypto_slot_management.o.d -o secure_fw/partitions/crypto/mbedcrypto/nrf_security_src/CMakeFiles/crypto_service_mbedcrypto.dir/C_/ncsOLD/v2.3.0/modules/crypto/mbedtls/library/psa_crypto_slot_management.o -c C:/ncsOLD/v2.3.0/modules/crypto/mbedtls/library/psa_crypto_slot_management.c
    C:\ncsOLD\v2.3.0\modules\crypto\mbedtls\library\psa_crypto_slot_management.c:582:1: fatal error: opening dependency file secure_fw\partitions\crypto\mbedcrypto\nrf_security_src\CMakeFiles\crypto_service_mbedcrypto.dir\C_\ncsOLD\v2.3.0\modules\crypto\mbedtls\library\psa_crypto_slot_management.o.d: No such file or directory
      582 | }
          | ^
    compilation terminated.
    ninja: build stopped: subcommand failed.
    FAILED: modules/trusted-firmware-m/tfm-prefix/src/tfm-stamp/tfm-build tfm/secure_fw/s_veneers.o tfm/tf-m-tests/app/libtfm_api_ns.a tfm/generated/interface/include/psa_manifest/sid.h tfm/platform/libplatform_ns.a tfm/bin/tfm_s.elf tfm/bin/tfm_s.bin tfm/bin/tfm_s.hex tfm/bin/tfm_ns.bin tfm/bin/tfm_ns.hex tfm/bin/tfm_s_signed.bin tfm/bin/tfm_ns_signed.bin tfm/bin/tfm_s_ns_signed.bin tfm/install/interface/src/tfm_platform_ipc_api.c tfm/install/interface/src/tfm_ps_ipc_api.c tfm/install/interface/src/tfm_its_ipc_api.c tfm/install/interface/src/tfm_crypto_ipc_api.c tfm/install/interface/src/tfm_initial_attestation_ipc_api.c tfm/install/interface/src/tfm_firmware_update_ipc_api.c tfm/install/interface/src/tfm_psa_ns_api.c tfm/install/interface/src/tfm_platform_func_api.c tfm/install/interface/src/tfm_ps_func_api.c tfm/install/interface/src/tfm_its_func_api.c tfm/install/interface/src/tfm_crypto_func_api.c tfm/install/interface/src/tfm_initial_attestation_func_api.c tfm/install/interface/src/tfm_firmware_update_func_api.c tfm/install/interface/src/tfm_ioctl_core_ns_api.c
    cmd.exe /C "cd /D C:\ncsOLD\v2.3.0\modules\hal\nordic\nrfx\samples\src\nrfx_spim_spis\non_blocking\build\tfm && C:\ncsOLD\toolchains\v2.3.0\opt\bin\cmake.exe --build . -j 1"
    ninja: build stopped: subcommand failed.
    FATAL ERROR: command exited with status 1: 'c:\ncsOLD\toolchains\v2.3.0\opt\bin\cmake.EXE' --build 'c:\ncsOLD\v2.3.0\modules\hal\nordic\nrfx\samples\src\nrfx_spim_spis\non_blocking\build'


    fatal error: opening dependency file secure_fw\partitions\crypto\mbedcrypto\nrf_security_src\CMakeFiles\crypto_service_mbedcrypto.dir\C_\ncsOLD\v2.3.0\modules\crypto\mbedtls\library\psa_crypto_slot_management.o.d: No such file or directory
      582 | }

    Regards,

    Ahmed

  • Hi Ahmed,

    The sample builds out of the box for nrf5340dk_nrf5340_cpuapp, but there is an issue when building for nrf5340dk_nrf5340_cpuapp_ns (none-secure application with TF-M).

    There is no overlay for ns, so you should make a file under modules/hal/nordic/nrfx/samples/src/nrfx_spim_spis/boards/nrf5340dk_nrf5340_cpuapp_ns.overlay and copy in the content from modules/hal/nordic/nrfx/samples/src/nrfx_spim_spis/boards/nrf5340dk_nrf5340_cpuapp.overlay:

    &spi1 {
            status = "okay";
            compatible = "nordic,nrf-spim";
        };
        
        &spi2 {
            status = "okay";
            compatible = "nordic,nrf-spis";
            def-char = <0xFF>;
        };

Reply
  • Hi Ahmed,

    The sample builds out of the box for nrf5340dk_nrf5340_cpuapp, but there is an issue when building for nrf5340dk_nrf5340_cpuapp_ns (none-secure application with TF-M).

    There is no overlay for ns, so you should make a file under modules/hal/nordic/nrfx/samples/src/nrfx_spim_spis/boards/nrf5340dk_nrf5340_cpuapp_ns.overlay and copy in the content from modules/hal/nordic/nrfx/samples/src/nrfx_spim_spis/boards/nrf5340dk_nrf5340_cpuapp.overlay:

    &spi1 {
            status = "okay";
            compatible = "nordic,nrf-spim";
        };
        
        &spi2 {
            status = "okay";
            compatible = "nordic,nrf-spis";
            def-char = <0xFF>;
        };

Children
Related