5340 TF-M compile error

1. I downloaded the trusted-firmware-m-TF-Mv1.7.0 from trustedfirmware offical website.

2. The command executed successfully: cmake -DTFM_PLATFORM=nordic_nrf/nrf5340dk_nrf5340_cpuapp -DTFM_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake -G"Unix Makefiles" ..

D:\sdk\tf-m\trusted-firmware-m-TF-Mv1.7.0\NNRF>cmake -DTFM_PLATFORM=nordic_nrf/nrf5340dk_nrf5340_cpuapp -DTFM_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake -G"Unix Makefiles" ..
fatal: not a git repository (or any of the parent directories): .git
-- TF-Mv1.7.0
------------ Display partition configuration - start ------------
   Non-Secure Mailbox Agent                  OFF
   Protected Storage Partition               OFF
   TF-M Internal Trusted Storage Partition   OFF
   TFM Crypto Partition                      OFF
   TFM Platform Partition                    OFF
   TFM Initial Attestation Partition         OFF
   TFM Firmware Update Partition             OFF
------------ Display partition configuration - end ------------
Start to generate partition files:
Per-partition files done:
-- Configuring done
-- Generating done
-- Build files have been written to: D:/sdk/tf-m/trusted-firmware-m-TF-Mv1.7.0/NNRF

3. make install report below error

D:\sdk\tf-m\trusted-firmware-m-TF-Mv1.7.0\NNRF>make install
[  1%] Building C object lib/fih/CMakeFiles/tfm_fih.dir/src/fih.o
[  1%] Linking C static library libtfm_fih.a
[  1%] Built target tfm_fih
[  1%] Building C object platform/target/nrf5340/nrf_common/CMakeFiles/tfm_s_scatter.dir/gcc/nordic_nrf_s.ld
[  1%] Built target tfm_s_scatter
[  2%] Building C object platform/CMakeFiles/platform_s.dir/ext/target/nordic_nrf/common/core/cmsis_drivers/Driver_Flash.o
[  2%] Building C object platform/CMakeFiles/platform_s.dir/__/lib/ext/hal_nordic-src/nrfx/drivers/src/nrfx_nvmc.o
[  3%] Building C object platform/CMakeFiles/platform_s.dir/ext/target/nordic_nrf/common/core/nrfx_glue.o
[  3%] Building C object platform/CMakeFiles/platform_s.dir/ext/target/nordic_nrf/common/core/native_drivers/mpu_armv8m_drv.o
[  4%] Building C object platform/CMakeFiles/platform_s.dir/ext/target/nordic_nrf/common/core/native_drivers/spu.o
[  4%] Building C object platform/CMakeFiles/platform_s.dir/__/lib/ext/hal_nordic-src/nrfx/mdk/system_nrf5340_application.o
[  4%] Building C object platform/CMakeFiles/platform_s.dir/ext/common/tfm_hal_reset_halt.o
[  5%] Building C object platform/CMakeFiles/platform_s.dir/ext/common/uart_stdout.o
[  5%] Building C object platform/CMakeFiles/platform_s.dir/ext/common/tfm_hal_memory_symbols.o
[  6%] Building C object platform/CMakeFiles/platform_s.dir/ext/common/template/attest_hal.o
[  6%] Building C object platform/CMakeFiles/platform_s.dir/ext/common/template/nv_counters.o
[  6%] Building C object platform/CMakeFiles/platform_s.dir/ext/common/template/tfm_rotpk.o
[  8%] Building C object platform/CMakeFiles/platform_s.dir/ext/common/template/crypto_nv_seed.o
[  8%] Building C object platform/CMakeFiles/platform_s.dir/ext/common/template/flash_otp_nv_counters_backend.o
[  9%] Building C object platform/CMakeFiles/platform_s.dir/ext/common/template/otp_flash.o
[  9%] Building C object platform/CMakeFiles/platform_s.dir/ext/common/provisioning.o
[  9%] Linking C static library libplatform_s.a
[  9%] Built target platform_s
[ 10%] Building C object secure_fw/partitions/lib/runtime/CMakeFiles/tfm_sprt.dir/crt_memcmp.o
[ 10%] Building C object secure_fw/partitions/lib/runtime/CMakeFiles/tfm_sprt.dir/crt_memmove.o
[ 10%] Building C object secure_fw/partitions/lib/runtime/CMakeFiles/tfm_sprt.dir/crt_strnlen.o
[ 11%] Building C object secure_fw/partitions/lib/runtime/CMakeFiles/tfm_sprt.dir/service_api.o
[ 11%] Building C object secure_fw/partitions/lib/runtime/CMakeFiles/tfm_sprt.dir/__/__/__/shared/crt_memcpy.o
[ 12%] Building C object secure_fw/partitions/lib/runtime/CMakeFiles/tfm_sprt.dir/__/__/__/shared/crt_memset.o
[ 12%] Building C object secure_fw/partitions/lib/runtime/CMakeFiles/tfm_sprt.dir/__/__/__/spm/cmsis_psa/psa_interface_sfn.o
[ 12%] Building C object secure_fw/partitions/lib/runtime/CMakeFiles/tfm_sprt.dir/__/__/__/__/interface/src/tfm_psa_call_pack.o
[ 13%] Linking C static library libtfm_sprt.a
[ 13%] Built target tfm_sprt
[ 15%] Building C object secure_fw/spm/CMakeFiles/tfm_spm.dir/ffm/tfm_boot_data.o
[ 15%] Building C object secure_fw/spm/CMakeFiles/tfm_spm.dir/ffm/utilities.o
[ 15%] Building C object secure_fw/spm/CMakeFiles/tfm_spm.dir/cmsis_psa/arch/tfm_arch.o
[ 16%] Building C object secure_fw/spm/CMakeFiles/tfm_spm.dir/cmsis_psa/main.o
[ 16%] Building C object secure_fw/spm/CMakeFiles/tfm_spm.dir/cmsis_psa/spm_ipc.o
[ 17%] Building C object secure_fw/spm/CMakeFiles/tfm_spm.dir/cmsis_psa/static_loader.o
[ 17%] Building C object secure_fw/spm/CMakeFiles/tfm_spm.dir/ffm/psa_api.o
[ 17%] Building C object secure_fw/spm/CMakeFiles/tfm_spm.dir/ffm/backend_sfn.o
[ 18%] Building C object secure_fw/spm/CMakeFiles/tfm_spm.dir/cmsis_psa/tfm_core_svcalls_ipc.o
[ 18%] Building C object secure_fw/spm/CMakeFiles/tfm_spm.dir/cmsis_psa/tfm_pools.o
[ 19%] Building C object secure_fw/spm/CMakeFiles/tfm_spm.dir/ns_client_ext/tfm_spm_ns_ctx.o
[ 19%] Building C object secure_fw/spm/CMakeFiles/tfm_spm.dir/cmsis_psa/arch/tfm_arch_v8m_main.o
[ 20%] Building C object secure_fw/spm/CMakeFiles/tfm_spm.dir/__/__/platform/ext/common/tfm_hal_nvic.o
[ 20%] Building C object secure_fw/spm/CMakeFiles/tfm_spm.dir/__/partitions/ns_agent_tz/ns_agent_tz_init.o
[ 20%] Building C object secure_fw/spm/CMakeFiles/tfm_spm.dir/__/partitions/ns_agent_tz/ns_agent_tz_v80m.o
[ 22%] Building C object secure_fw/spm/CMakeFiles/tfm_spm.dir/__/__/platform/ext/target/nordic_nrf/common/core/tfm_hal_isolation.o
[ 22%] Building C object secure_fw/spm/CMakeFiles/tfm_spm.dir/__/__/platform/ext/target/nordic_nrf/common/core/tfm_hal_platform_common.o
[ 23%] Building C object secure_fw/spm/CMakeFiles/tfm_spm.dir/__/__/platform/ext/target/nordic_nrf/common/core/faults.o
[ 23%] Building C object secure_fw/spm/CMakeFiles/tfm_spm.dir/__/__/platform/ext/target/nordic_nrf/common/nrf5340/target_cfg.o
[ 23%] Building C object secure_fw/spm/CMakeFiles/tfm_spm.dir/__/__/platform/ext/target/nordic_nrf/nrf5340dk_nrf5340_cpuapp/tfm_hal_platform.o
[ 24%] Building C object secure_fw/spm/CMakeFiles/tfm_spm.dir/__/partitions/ns_agent_tz/load_info_ns_agent_tz.o
[ 24%] Linking C static library libtfm_spm.a
[ 24%] Built target tfm_spm
[ 24%] Building C object secure_fw/CMakeFiles/tfm_s.dir/partitions/ns_agent_tz/psa_api_veneers_v80m.o
[ 24%] Building C object secure_fw/CMakeFiles/tfm_s.dir/__/platform/ext/target/nordic_nrf/common/nrf5340/gcc/startup_nrf5340.o
[ 25%] Building C object secure_fw/CMakeFiles/tfm_s.dir/__/platform/ext/common/faults.o
[ 25%] Building C object secure_fw/CMakeFiles/tfm_s.dir/partitions/ns_agent_tz/load_info_ns_agent_tz.o
[ 26%] Linking C executable ../bin/tfm_s.axf
d:/software/gnu/arm-gnu-toolchain-12.2.mpacbti-rel1-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: d:/software/gnu/arm-gnu-toolchain-12.2.mpacbti-rel1-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/12.2.1/thumb/v8-m.main/nofp\libc_nano.a(libc_a-closer.o): in function `_close_r':
closer.c:(.text._close_r+0xc): warning: _close is not implemented and will always fail
d:/software/gnu/arm-gnu-toolchain-12.2.mpacbti-rel1-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: d:/software/gnu/arm-gnu-toolchain-12.2.mpacbti-rel1-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/12.2.1/thumb/v8-m.main/nofp\libc_nano.a(libc_a-lseekr.o): in function `_lseek_r':
lseekr.c:(.text._lseek_r+0x10): warning: _lseek is not implemented and will always fail
d:/software/gnu/arm-gnu-toolchain-12.2.mpacbti-rel1-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: d:/software/gnu/arm-gnu-toolchain-12.2.mpacbti-rel1-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/12.2.1/thumb/v8-m.main/nofp\libc_nano.a(libc_a-readr.o): in function `_read_r':
readr.c:(.text._read_r+0x10): warning: _read is not implemented and will always fail
d:/software/gnu/arm-gnu-toolchain-12.2.mpacbti-rel1-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: d:/software/gnu/arm-gnu-toolchain-12.2.mpacbti-rel1-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/12.2.1/thumb/v8-m.main/nofp\libc_nano.a(libc_a-writer.o): in function `_write_r':
writer.c:(.text._write_r+0x10): warning: _write is not implemented and will always fail
d:/software/gnu/arm-gnu-toolchain-12.2.mpacbti-rel1-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: ../bin/tfm_s.axf has a LOAD segment with RWX permissions
Memory region         Used Size  Region Size  %age Used
           FLASH:       15876 B       254 KB      6.10%
             RAM:        5780 B       256 KB      2.20%
collect2.exe: error: ld returned 1 exit status
make[2]: *** [secure_fw/CMakeFiles/tfm_s.dir/build.make:152: bin/tfm_s.axf] Error 1
make[1]: *** [CMakeFiles/Makefile2:860: secure_fw/CMakeFiles/tfm_s.dir/all] Error 2
make: *** [makefile:136: all] Error 2

4. It's very strange that the ld will link the `_lseek_r`, `_close_r'`, why ?

Parents
  • Hello,

    In case you are not aware, we already have support for building TF-M with application examples in our nRF Connect SDK as explained in the SDK documentation here: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/app_dev/tfm/index.html#ug-tfm. This includes integration with our crypto services. Or have you considered this already? 

    If you still want to build the TF-M from the ARM repo, please try Zephyr SDK as suggested by Håkon in this thread:  TF-M build failed: bin/tfm_s.axf 

    Best regards,

    Vidar

  • 1. Hi thanks for your suggestion, then I used  nRF Connect SDK(V), but I don't use the Zephyr_SDK(network reason, it's very hard to download the Zephyr_SDK V0.15.2 from github), I downloaded the GNU ARM toolchain V11.2(gcc-arm-11.2-2022.02-mingw-w64-i686-arm-none-eabi) and configured the ZEPHYR_TOOLCHAIN_VARIANT.

    2. I can compile the tfm_hello_world successfully, but there is no log from USB-UART(I have tried all of the 3 USB-UART, baudrate:115200, stopbit:1, partial: none, bytesize:8, flowcontrol: none), below is the compile log

    D:\sdk\nordic\ncs\nrf\samples\tfm\tfm_hello_world>west build -b nrf5340dk_nrf5340_cpuapp_ns
    -- west build: generating a build system
    Loading Zephyr default modules (Zephyr base (cached)).
    -- Application: D:/sdk/nordic/ncs/nrf/samples/tfm/tfm_hello_world
    -- Cache files will be written to: D:/sdk/nordic/ncs/zephyr/.cache
    -- Zephyr version: 3.1.99 (D:/sdk/nordic/ncs/zephyr)
    -- Found west (found suitable version "1.0.0", minimum required is "0.7.1")
    -- Board: nrf5340dk_nrf5340_cpuapp_ns
    -- Found toolchain: gnuarmemb (D:/software/gnu/gcc-arm-11.2-2022.02-mingw-w64-i686-arm-none-eabi)
    -- Found BOARD.dts: D:/sdk/nordic/ncs/zephyr/boards/arm/nrf5340dk_nrf5340/nrf5340dk_nrf5340_cpuapp_ns.dts
    -- Generated zephyr.dts: D:/sdk/nordic/ncs/nrf/samples/tfm/tfm_hello_world/build/zephyr/zephyr.dts
    -- Generated devicetree_unfixed.h: D:/sdk/nordic/ncs/nrf/samples/tfm/tfm_hello_world/build/zephyr/include/generated/devicetree_unfixed.h
    -- Generated device_extern.h: D:/sdk/nordic/ncs/nrf/samples/tfm/tfm_hello_world/build/zephyr/include/generated/device_extern.h
    -- Including generated dts.cmake file: D:/sdk/nordic/ncs/nrf/samples/tfm/tfm_hello_world/build/zephyr/dts.cmake
    Parsing D:/sdk/nordic/ncs/zephyr/Kconfig
    Loaded configuration 'D:/sdk/nordic/ncs/zephyr/boards/arm/nrf5340dk_nrf5340/nrf5340dk_nrf5340_cpuapp_ns_defconfig'
    Merged configuration 'D:/sdk/nordic/ncs/nrf/samples/tfm/tfm_hello_world/prj.conf'
    Configuration saved to 'D:/sdk/nordic/ncs/nrf/samples/tfm/tfm_hello_world/build/zephyr/.config'
    Kconfig header saved to 'D:/sdk/nordic/ncs/nrf/samples/tfm/tfm_hello_world/build/zephyr/include/generated/autoconf.h'
    -- The C compiler identification is GNU 11.2.1
    -- The CXX compiler identification is GNU 11.2.1
    -- The ASM compiler identification is GNU
    -- Found assembler: D:/software/gnu/gcc-arm-11.2-2022.02-mingw-w64-i686-arm-none-eabi/bin/arm-none-eabi-gcc.exe
    Dropping partition 'nonsecure_storage' since it is empty.
    -- Configuring done
    -- Generating done
    -- Build files have been written to: D:/sdk/nordic/ncs/nrf/samples/tfm/tfm_hello_world/build
    -- west build: building application
    [6/246] Generating include/generated/version.h
    -- Zephyr version: 3.1.99 (D:/sdk/nordic/ncs/zephyr), build: v3.1.99-ncs1-3
    [53/246] Generating ../../tfm/CMakeCache.txt
    -- The C compiler identification is GNU 11.2.1
    -- The ASM compiler identification is GNU
    -- Found assembler: D:/software/gnu/gcc-arm-11.2-2022.02-mingw-w64-i686-arm-none-eabi/bin/arm-none-eabi-gcc.exe
    -- Found Python3: D:/Users/zhongchengzhi/AppData/Local/Programs/Python/Python38/python.exe (found version "3.8.2") found components: Interpreter
    -- Found Python3: D:/Users/zhongchengzhi/AppData/Local/Programs/Python/Python38/python.exe (found suitable exact version "3.8.2") found components: Interpreter
    -- Cache files will be written to: D:/sdk/nordic/ncs/zephyr/.cache
    -- Configuring done
    -- Generating done
    -- Build files have been written to: D:/sdk/nordic/ncs/nrf/samples/tfm/tfm_hello_world/build/tfm
    [1/2] Re-running CMake...-- Found Python3: D:/Users/zhongchengzhi/AppData/Local/Programs/Python/Python38/python.exe (found version "3.8.2") found components: Interpreter
    -- Found Python3: D:/Users/zhongchengzhi/AppData/Local/Programs/Python/Python38/python.exe (found suitable exact version "3.8.2") found components: Interpreter
    -- Cache files will be written to: D:/sdk/nordic/ncs/zephyr/.cache
    -- Configuring done
    -- Generating done
    -- Build files have been written to: D:/sdk/nordic/ncs/nrf/samples/tfm/tfm_hello_world/build/tfm
    
    [169/169] Linking C static library secure_fw\libtfm_s_veneers.a
    
    [64/246] Performing install step for 'tfm'
    -- Install configuration: "MinSizeRel"
    [135/246] Building C object zephyr/arch/arch/arm/core/aarch32/mpu/CMakeFiles/arch__arm__core__aarch32__mpu.dir/arm_core_mpu.c.obj
    D:/sdk/nordic/ncs/zephyr/arch/arm/core/aarch32/mpu/arm_core_mpu.c: In function 'z_arm_configure_dynamic_mpu_regions':
    D:/sdk/nordic/ncs/zephyr/arch/arm/core/aarch32/mpu/arm_core_mpu.c:311:9: warning: 'arm_core_mpu_configure_dynamic_mpu_regions' reading 12 bytes from a region of size 0 [-Wstringop-overread]
      311 |         arm_core_mpu_configure_dynamic_mpu_regions(dynamic_regions,
          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      312 |                                                    region_num);
          |                                                    ~~~~~~~~~~~
    D:/sdk/nordic/ncs/zephyr/arch/arm/core/aarch32/mpu/arm_core_mpu.c:311:9: note: referencing argument 1 of type 'const struct z_arm_mpu_partition *'
    In file included from D:/sdk/nordic/ncs/zephyr/arch/arm/core/aarch32/mpu/arm_core_mpu.c:12:
    D:/sdk/nordic/ncs/zephyr/arch/arm/core/aarch32/mpu/arm_core_mpu_dev.h:187:6: note: in a call to function 'arm_core_mpu_configure_dynamic_mpu_regions'
      187 | void arm_core_mpu_configure_dynamic_mpu_regions(
          |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    [234/246] Linking C executable zephyr\zephyr_pre0.elf
    
    [238/246] Linking C executable zephyr\zephyr_pre1.elf
    
    [244/246] Linking C executable zephyr\zephyr.elf
    Memory region         Used Size  Region Size  %age Used
               FLASH:       21836 B       992 KB      2.15%
                SRAM:        4288 B       480 KB      0.87%
            IDT_LIST:          0 GB         2 KB      0.00%
    [246/246] Generating zephyr/merged.hex

    3. Below is the flash down log

    D:\sdk\nordic\ncs\nrf\samples\tfm\tfm_hello_world>west flash --erase
    -- west flash: rebuilding
    [0/20] Performing build step for 'tfm'ninja: no work to do.
    
    -- west flash: using runner nrfjprog
    -- runners.nrfjprog: mass erase requested
    Using board 960163997
    -- runners.nrfjprog: Flashing file: D:\sdk\nordic\ncs\nrf\samples\tfm\tfm_hello_world\build\zephyr\merged.hex
    Parsing image file.
    Verifying programming.
    Verified OK.
    Applying pin reset.
    -- runners.nrfjprog: Board with serial number 960163997 flashed successfully.
    

    4. Could you please have a look, thank you so much( My board is nRF5340 PDK)

  • Hi,

    Do you have access to a non-preview kit you can test with (i.e. nRF5340 DK and not the nRF5340 PDK)? The engineering revision of the nRF5340 IC used on the preview kit is no longer supported, and it has several errata's/limitations which can explain why the sample is not functional on your board.

    nRF5340 Engineering A Errata

  • 1. OK, thanks very much, I will try one nRF5340 DK board,.

    1. Could you send me the errata's link, have a nice day Slight smile

Reply Children
No Data
Related