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

NRF9160 partitions issue with hardware CC310 crypto library

Hello everyone!

I've tried to run mbedtls crypto functions which are using cc310 hardware implementation and I have partitions overlap issue.


Our main goal is to test RSA-related functions to understand better how we can work with this library.
I've found an "mbedtls_rsa_self_test" routine which already calls everything which we need use.
This function is located into the "secure_service.c" file (ncs\nrf\subsys\spm\secure_service.c).
To use this "mbedtls_rsa_self_test" function we uncommented line #define MBEDTLS_SELF_TEST placed in "\ncs\mbedtls\include\mbedtls\config.h"

It is important to note, that according to the nrfxlib documentation, the only one way to work with cc310 module is using secure mode. https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrfxlib/crypto/doc/nrf_cc310_mbedcrypto.html
This part is described in the "Usage restrictions" section:
"On the nRF9160 SiP, the nrf_cc310_mbedcrypto library is restricted to only work in secure processing environment. The library uses mutexes to ensure single usage of hardware modules."

Here is a part of the source code where I call this routine:

__TZ_NONSECURE_ENTRY_FUNC
int spm_request_random_number(u8_t *output, size_t len, size_t *olen)
{
int err;

mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", err );


if (len != MBEDTLS_ENTROPY_MAX_GATHER) {
return -EINVAL;
}

err = mbedtls_hardware_poll(&rng_workbuf, output, len, olen);

#if 1
if(mbedtls_rsa_self_test(1) != 0)
{
mbedtls_printf( "RSA failed\n");
}
#endif
return err;
}

The thing is that build fails while we are using such solution. I see some linker error, which says that partition size limit is exceeded. I've already posted a ticket with a very similar issue, you can check it here: https://devzone.nordicsemi.com/f/nordic-q-a/50155/nrf9160-memory-partition 

I tried to change Zephyr's partitions, you can find all the necessary information in the attached files.
As far as I understood, all libraries which are required for mdedTLS should be called from the security region only. In this case they will be located into the mcuboot partition, that's why I also increased size reserved for spm. It was done using the "spm_menuconfig" option in the menuconfig (Project -> Configure nRF SDK Project). I've found "Modules -> Nordic nRF Connect -> SPM -> Current app is SPM - > Flash space reserved for SPM" parameter and changed it's value from 0xc000 (48Kb) to to 0x1CCCC (115Kb).

Unfortunately, it led me to the following error:

1> c:/gnuarmemb/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/bin/ld.exe: SPM and app are sharing an SPU region. Cannot partition flash correctly into secure and non-secure. Adjust partitions sizes so they are placed in separate regions.
1> collect2.exe: error: ld returned 1 exit status
Build failed

It is obvious that I do somethibng wrong here, so I really need some help with those partitions and with mbedtls_rsa_self_test.
I hope that someone can help me with it. Thanks in advance anyone who will at least try to understand what is going on here!
IDE which I am using is "Segger Embedded Studio V4.18 (Nordic Edition)"

Here is a full build log which I see:

Building ‘spm/zephyr/include/generated/driver-validation.h’ from solution ‘build’ in configuration ‘Common’
Building ‘spm/zephyr/CMakeFiles/spm_driver_validation_h_target’ from solution ‘build’ in configuration ‘Common’
Building ‘spm/zephyr/spm_driver_validation_h_target’ from solution ‘build’ in configuration ‘Common’
Building ‘spm/zephyr/include/generated/kobj-types-enum.h’ from solution ‘build’ in configuration ‘Common’
Building ‘spm/zephyr/include/generated/otype-to-str.h’ from solution ‘build’ in configuration ‘Common’
Building ‘spm/zephyr/CMakeFiles/spm_kobj_types_h_target’ from solution ‘build’ in configuration ‘Common’
Building ‘spm/zephyr/spm_kobj_types_h_target’ from solution ‘build’ in configuration ‘Common’
Building ‘spm/zephyr/misc/generated/syscalls.json’ from solution ‘build’ in configuration ‘Common’
Building ‘spm/zephyr/include/generated/syscall_list.h’ from solution ‘build’ in configuration ‘Common’
Building ‘spm/zephyr/CMakeFiles/spm_syscall_list_h_target’ from solution ‘build’ in configuration ‘Common’
Building ‘spm/zephyr/include/generated/syscall_dispatch.c’ from solution ‘build’ in configuration ‘Common’
Building ‘spm/zephyr/spm_syscall_list_h_target’ from solution ‘build’ in configuration ‘Common’
Building ‘spm/zephyr/include/generated/syscall_macros.h’ from solution ‘build’ in configuration ‘Common’
Building ‘spm/zephyr/CMakeFiles/spm_syscall_macros_h_target’ from solution ‘build’ in configuration ‘Common’
Building ‘spm/zephyr/spm_syscall_macros_h_target’ from solution ‘build’ in configuration ‘Common’
Building ‘cmake_object_order_depends_target_spm_offsets’ from solution ‘build’ in configuration ‘Common’
Building ‘spm/zephyr/spm_offsets’ from solution ‘build’ in configuration ‘Common’
Building ‘spm/zephyr/include/generated/offsets.h’ from solution ‘build’ in configuration ‘Common’
Building ‘spm/zephyr/CMakeFiles/spm_offsets_h’ from solution ‘build’ in configuration ‘Common’
Building ‘spm/zephyr/spm_offsets_h’ from solution ‘build’ in configuration ‘Common’
Building ‘cmake_object_order_depends_target_spm_app’ from solution ‘build’ in configuration ‘Common’
Building ‘cmake_object_order_depends_target_spm_arch__arm__core’ from solution ‘build’ in configuration ‘Common’
Building ‘cmake_object_order_depends_target_spm_arch__arm__core__cortex_m’ from solution ‘build’ in configuration ‘Common’
Building ‘cmake_object_order_depends_target_spm_arch__arm__core__cortex_m__mpu’ from solution ‘build’ in configuration ‘Common’
Building ‘cmake_object_order_depends_target_spm_drivers__serial’ from solution ‘build’ in configuration ‘Common’
Building ‘cmake_object_order_depends_target_spm_kernel’ from solution ‘build’ in configuration ‘Common’
Building ‘cmake_object_order_depends_target_spm_lib__libc__minimal’ from solution ‘build’ in configuration ‘Common’
Building ‘cmake_object_order_depends_target_spm_mbedcrypto_vanilla’ from solution ‘build’ in configuration ‘Common’
Building ‘cmake_object_order_depends_target_spm_mbeddrbg’ from solution ‘build’ in configuration ‘Common’
Building ‘cmake_object_order_depends_target_spm_zephyr’ from solution ‘build’ in configuration ‘Common’
Building ‘spm/zephyr/linker.cmd’ from solution ‘build’ in configuration ‘Common’
Building ‘spm/zephyr/CMakeFiles/spm_linker_script_target’ from solution ‘build’ in configuration ‘Common’
Building ‘spm/zephyr/spm_linker_script_target’ from solution ‘build’ in configuration ‘Common’
Building ‘cmake_object_order_depends_target_spm_zephyr_prebuilt’ from solution ‘build’ in configuration ‘Common’
Building ‘spm/spm_app/libspm_app.a’ from solution ‘build’ in configuration ‘Common’
Building ‘spm/zephyr/libspm_zephyr.a’ from solution ‘build’ in configuration ‘Common’
Building ‘spm/zephyr/arch/arm/core/libspm_arch__arm__core.a’ from solution ‘build’ in configuration ‘Common’
Building ‘spm/zephyr/arch/arm/core/cortex_m/libspm_arch__arm__core__cortex_m.a’ from solution ‘build’ in configuration ‘Common’
Building ‘spm/zephyr/arch/arm/core/cortex_m/mpu/libspm_arch__arm__core__cortex_m__mpu.a’ from solution ‘build’ in configuration ‘Common’
Building ‘spm/zephyr/lib/libc/minimal/libspm_lib__libc__minimal.a’ from solution ‘build’ in configuration ‘Common’
Building ‘spm/zephyr/drivers/serial/libspm_drivers__serial.a’ from solution ‘build’ in configuration ‘Common’
Building ‘spm/zephyr/modules/nrfxlib/nrf_security/src/mbedtls/libspm_mbeddrbg.a’ from solution ‘build’ in configuration ‘Common’
Building ‘spm/zephyr/modules/nrfxlib/nrf_security/src/mbedtls/libspm_mbedcrypto_vanilla.a’ from solution ‘build’ in configuration ‘Common’
Building ‘spm/zephyr/kernel/libspm_kernel.a’ from solution ‘build’ in configuration ‘Common’
Building ‘spm/zephyr/spm_zephyr_prebuilt.elf’ from solution ‘build’ in configuration ‘Common’
1> Linking ‘spm_zephyr_prebuilt.elf’
1> Memory region Used Size Region Size %age Used
1> FLASH: 64 KB 117964 B 55.56%
1> SRAM: 11252 B 64 KB 17.17%
1> c:/gnuarmemb/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/bin/ld.exe: SPM and app are sharing an SPU region. Cannot partition flash correctly into secure and non-secure. Adjust partitions sizes so they are placed in separate regions.
1> collect2.exe: error: ld returned 1 exit status
1> IDT_LIST: 40 B 2 KB 1.95%
Build failed

NXM.zipnrf9160_pca10090_boot_0x25000.zip

Parents
  • Hi,

    The linker issue is due to a too small partition size. That is also the case for the second issue, so you should expand that further since the SPU regions are 32 kB.

    The reason is that the SPM and application must be placed in different SPU regions (of 32 kB size) because one is secure and the other is non-secure. So the second error you get is because the region is large enough to fit the code, but you need additional empty space to place the app in a new region.

    Note that there is an issue with RSA in the current nrf_cc310_mbedcrypto library that you will likely meet. This will be fixed in the next release, which I expect will be out quite soon.

  • Do you mean that there are two regions: secure and non-secure (32Kb each) and secure region is big enough, while non-secure is too small and should be increased?

    Could you clarify where I can change this?

    Thanks in advance.

  • Hi,

    You should increase the size of the flash space reserve for SPM so that it ends at the end of a 32 kB region. So setting it to 0x8000 should work.

  • Hi.

    I aligned now all partitions by 32Kb.

    And tried compile SPM with RSA mbed TLS function.

    Same error. I tried with SPM reserved size 0x8000, 0x19000, and 0x20000.

    Do you have any ideas how we solve this problem?

    Could you also try compile my sources at your side?

    Here error when I set flash reserved page size to 0x19000

    Building ‘spm/zephyr/include/generated/driver-validation.h’ from solution ‘build’ in configuration ‘Common’
      Combining ‘spm/zephyr/include/generated/driver-validation.h’
    Building ‘spm/zephyr/CMakeFiles/spm_driver_validation_h_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/spm_driver_validation_h_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/include/generated/kobj-types-enum.h’ from solution ‘build’ in configuration ‘Common’
      Combining ‘spm/zephyr/include/generated/kobj-types-enum.h’
    Building ‘spm/zephyr/include/generated/otype-to-str.h’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/CMakeFiles/spm_kobj_types_h_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/spm_kobj_types_h_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/misc/generated/syscalls.json’ from solution ‘build’ in configuration ‘Common’
      Combining ‘spm/zephyr/misc/generated/syscalls.json’
    Building ‘spm/zephyr/include/generated/syscall_list.h’ from solution ‘build’ in configuration ‘Common’
      Combining ‘spm/zephyr/include/generated/syscall_list.h’
    Building ‘spm/zephyr/CMakeFiles/spm_syscall_list_h_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/include/generated/syscall_dispatch.c’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/spm_syscall_list_h_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/include/generated/syscall_macros.h’ from solution ‘build’ in configuration ‘Common’
      Combining ‘spm/zephyr/include/generated/syscall_macros.h’
    Building ‘spm/zephyr/CMakeFiles/spm_syscall_macros_h_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/spm_syscall_macros_h_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_offsets’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/spm_offsets’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘offsets.c’
    Building ‘spm/zephyr/include/generated/offsets.h’ from solution ‘build’ in configuration ‘Common’
      Combining ‘spm/zephyr/include/generated/offsets.h’
    Building ‘spm/zephyr/CMakeFiles/spm_offsets_h’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/spm_offsets_h’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_app’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_arch__arm__core’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_arch__arm__core__cortex_m’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_arch__arm__core__cortex_m__mpu’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_drivers__serial’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_kernel’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_lib__libc__minimal’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_mbedcrypto_vanilla’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_mbeddrbg’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_zephyr’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/linker.cmd’ from solution ‘build’ in configuration ‘Common’
      Combining ‘spm/zephyr/linker.cmd’
    Building ‘spm/zephyr/CMakeFiles/spm_linker_script_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/spm_linker_script_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_zephyr_prebuilt’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/spm_app/libspm_app.a’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘main.c’
      Archiving ‘libspm_app.a’
    Building ‘spm/zephyr/libspm_zephyr.a’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘isr_tables.c’
      Compiling ‘sw_isr_common.c’
      Compiling ‘arm_core_cmse.c’
      Compiling ‘arm_core_tz.c’
      Compiling ‘crc32_sw.c’
      Compiling ‘crc16_sw.c’
      Compiling ‘crc8_sw.c’
      Compiling ‘crc7_sw.c’
      Compiling ‘fdtable.c’
      Compiling ‘mempool.c’
      Compiling ‘rb.c’
      Compiling ‘thread_entry.c’
      Compiling ‘work_q.c’
      Compiling ‘printk.c’
      Compiling ‘configs.c’
      Compiling ‘soc.c’
      Compiling ‘mpu_regions.c’
      Compiling ‘system_nrf9160.c’
      Compiling ‘nrfx_glue.c’
      Compiling ‘power.c’
      Compiling ‘reboot.c’
      Compiling ‘policy_residency.c’
      Compiling ‘uart_console.c’
      Compiling ‘nrf_power_clock.c’
      Compiling ‘sys_clock_init.c’
      Compiling ‘nrf_rtc_timer.c’
      Compiling ‘spm.c’
      Compiling ‘secure_services.c’
        implicit declaration of function 'SEGGER_RTT_Init' [-Wimplicit-function-declaration]
        'err' is used uninitialized in this function [-Wuninitialized]
      Compiling ‘SEGGER_RTT.c’
      Compiling ‘SEGGER_RTT_zephyr.c’
      Archiving ‘libspm_zephyr.a’
    Building ‘spm/zephyr/arch/arm/core/libspm_arch__arm__core.a’ from solution ‘build’ in configuration ‘Common’
      Assembling ‘exc_exit.S’
      Assembling ‘swap_helper.S’
      Assembling ‘cpu_idle.S’
      Assembling ‘fault_s.S’
      Assembling ‘isr_wrapper.S’
      Compiling ‘irq_init.c’
      Compiling ‘swap.c’
      Compiling ‘fault.c’
      Compiling ‘irq_manage.c’
      Compiling ‘thread.c’
      Compiling ‘fatal.c’
      Compiling ‘sys_fatal_error_handler.c’
      Compiling ‘thread_abort.c’
      Archiving ‘libspm_arch__arm__core.a’
    Building ‘spm/zephyr/arch/arm/core/cortex_m/libspm_arch__arm__core__cortex_m.a’ from solution ‘build’ in configuration ‘Common’
      Assembling ‘vector_table.S’
      Assembling ‘reset.S’
      Assembling ‘nmi_on_reset.S’
      Compiling ‘prep_c.c’
      Compiling ‘scb.c’
      Compiling ‘nmi.c’
      Compiling ‘exc_manage.c’
      Archiving ‘libspm_arch__arm__core__cortex_m.a’
    Building ‘spm/zephyr/arch/arm/core/cortex_m/mpu/libspm_arch__arm__core__cortex_m__mpu.a’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘arm_core_mpu.c’
      Compiling ‘arm_mpu.c’
      Archiving ‘libspm_arch__arm__core__cortex_m__mpu.a’
    Building ‘spm/zephyr/lib/libc/minimal/libspm_lib__libc__minimal.a’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘atoi.c’
      Compiling ‘strtol.c’
      Compiling ‘strtoul.c’
      Compiling ‘malloc.c’
      Compiling ‘bsearch.c’
      Compiling ‘exit.c’
      Compiling ‘strncasecmp.c’
      Compiling ‘strstr.c’
      Compiling ‘string.c’
      Compiling ‘prf.c’
      Compiling ‘stdout_console.c’
      Compiling ‘sprintf.c’
      Compiling ‘fprintf.c’
      Archiving ‘libspm_lib__libc__minimal.a’
    Building ‘spm/zephyr/drivers/serial/libspm_drivers__serial.a’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘uart_nrfx_uarte.c’
      Archiving ‘libspm_drivers__serial.a’
    Building ‘spm/zephyr/modules/nrfxlib/nrf_security/src/mbedtls/libspm_mbeddrbg.a’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘ctr_drbg.c’
      Compiling ‘entropy.c’
      Archiving ‘libspm_mbeddrbg.a’
    Building ‘spm/zephyr/modules/nrfxlib/nrf_security/src/mbedtls/libspm_mbedcrypto_vanilla.a’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘aes.c’
      Compiling ‘aesni.c’
      Compiling ‘arc4.c’
      Compiling ‘aria.c’
      Compiling ‘asn1parse.c’
      Compiling ‘asn1write.c’
      Compiling ‘base64.c’
      Compiling ‘bignum.c’
      Compiling ‘blowfish.c’
      Compiling ‘camellia.c’
      Compiling ‘ccm.c’
      Compiling ‘chacha20.c’
      Compiling ‘chachapoly.c’
      Compiling ‘cipher.c’
      Compiling ‘cmac.c’
      Compiling ‘des.c’
      Compiling ‘dhm.c’
      Compiling ‘ecdh.c’
      Compiling ‘ecdsa.c’
      Compiling ‘ecjpake.c’
      Compiling ‘ecp.c’
      Compiling ‘ecp_curves.c’
      Compiling ‘entropy_poll.c’
      Compiling ‘error.c’
      Compiling ‘gcm.c’
      Compiling ‘havege.c’
      Compiling ‘hkdf.c’
      Compiling ‘hmac_drbg.c’
      Compiling ‘md.c’
      Compiling ‘md2.c’
      Compiling ‘md4.c’
      Compiling ‘md5.c’
      Compiling ‘md_wrap.c’
      Compiling ‘memory_buffer_alloc.c’
      Compiling ‘nist_kw.c’
      Compiling ‘oid.c’
      Compiling ‘padlock.c’
      Compiling ‘pk.c’
      Compiling ‘pk_wrap.c’
      Compiling ‘pkcs12.c’
      Compiling ‘pkcs5.c’
      Compiling ‘pkparse.c’
      Compiling ‘pkwrite.c’
      Compiling ‘platform.c’
        implicit declaration of function 'SEGGER_RTT_Write' [-Wimplicit-function-declaration]
      Compiling ‘platform_util.c’
      Compiling ‘poly1305.c’
      Compiling ‘ripemd160.c’
      Compiling ‘rsa.c’
      Compiling ‘rsa_internal.c’
      Compiling ‘sha1.c’
      Compiling ‘sha256.c’
      Compiling ‘sha512.c’
      Compiling ‘threading.c’
      Compiling ‘timing.c’
      Compiling ‘version.c’
      Compiling ‘version_features.c’
      Compiling ‘xtea.c’
      Compiling ‘cipher_wrap.c’
      Compiling ‘pem.c’
      Archiving ‘libspm_mbedcrypto_vanilla.a’
    Building ‘spm/zephyr/kernel/libspm_kernel.a’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘device.c’
      Compiling ‘errno.c’
      Compiling ‘idle.c’
      Compiling ‘init.c’
      Compiling ‘mailbox.c’
      Compiling ‘mem_slab.c’
      Compiling ‘mempool.c’
      Compiling ‘msg_q.c’
      Compiling ‘mutex.c’
      Compiling ‘pipes.c’
      Compiling ‘queue.c’
      Compiling ‘sched.c’
      Compiling ‘sem.c’
      Compiling ‘stack.c’
      Compiling ‘system_work_q.c’
      Compiling ‘thread.c’
      Compiling ‘thread_abort.c’
      Compiling ‘version.c’
      Compiling ‘work_q.c’
      Compiling ‘smp.c’
      Compiling ‘timeout.c’
      Compiling ‘timer.c’
      Archiving ‘libspm_kernel.a’
    Building ‘spm/zephyr/spm_zephyr_prebuilt.elf’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘empty_file.c’
      Linking ‘spm_zephyr_prebuilt.elf’
        KB       100 KB     64.00%
        B        64 KB     17.17%
        B         2 KB      1.95%
        SPM and app are sharing an SPU region. Cannot partition flash correctly into secure and non-secure. Adjust partitions sizes so they are placed in separate regions.
        ld returned 1 exit status
    Build failed

    Here error when I set flash reserved page size to 0x8000

    Building ‘spm/zephyr/include/generated/driver-validation.h’ from solution ‘build’ in configuration ‘Common’
      Combining ‘spm/zephyr/include/generated/driver-validation.h’
    Building ‘spm/zephyr/CMakeFiles/spm_driver_validation_h_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/spm_driver_validation_h_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/include/generated/kobj-types-enum.h’ from solution ‘build’ in configuration ‘Common’
      Combining ‘spm/zephyr/include/generated/kobj-types-enum.h’
    Building ‘spm/zephyr/include/generated/otype-to-str.h’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/CMakeFiles/spm_kobj_types_h_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/spm_kobj_types_h_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/misc/generated/syscalls.json’ from solution ‘build’ in configuration ‘Common’
      Combining ‘spm/zephyr/misc/generated/syscalls.json’
    Building ‘spm/zephyr/include/generated/syscall_list.h’ from solution ‘build’ in configuration ‘Common’
      Combining ‘spm/zephyr/include/generated/syscall_list.h’
    Building ‘spm/zephyr/CMakeFiles/spm_syscall_list_h_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/include/generated/syscall_dispatch.c’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/spm_syscall_list_h_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/include/generated/syscall_macros.h’ from solution ‘build’ in configuration ‘Common’
      Combining ‘spm/zephyr/include/generated/syscall_macros.h’
    Building ‘spm/zephyr/CMakeFiles/spm_syscall_macros_h_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/spm_syscall_macros_h_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_offsets’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/spm_offsets’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘offsets.c’
    Building ‘spm/zephyr/include/generated/offsets.h’ from solution ‘build’ in configuration ‘Common’
      Combining ‘spm/zephyr/include/generated/offsets.h’
    Building ‘spm/zephyr/CMakeFiles/spm_offsets_h’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/spm_offsets_h’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_app’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_arch__arm__core’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_arch__arm__core__cortex_m’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_arch__arm__core__cortex_m__mpu’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_drivers__serial’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_kernel’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_lib__libc__minimal’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_mbedcrypto_vanilla’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_mbeddrbg’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_zephyr’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/linker.cmd’ from solution ‘build’ in configuration ‘Common’
      Combining ‘spm/zephyr/linker.cmd’
    Building ‘spm/zephyr/CMakeFiles/spm_linker_script_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/spm_linker_script_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_zephyr_prebuilt’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/spm_app/libspm_app.a’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘main.c’
      Archiving ‘libspm_app.a’
    Building ‘spm/zephyr/libspm_zephyr.a’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘isr_tables.c’
      Compiling ‘sw_isr_common.c’
      Compiling ‘arm_core_cmse.c’
      Compiling ‘arm_core_tz.c’
      Compiling ‘crc32_sw.c’
      Compiling ‘crc16_sw.c’
      Compiling ‘crc8_sw.c’
      Compiling ‘crc7_sw.c’
      Compiling ‘fdtable.c’
      Compiling ‘mempool.c’
      Compiling ‘rb.c’
      Compiling ‘thread_entry.c’
      Compiling ‘work_q.c’
      Compiling ‘printk.c’
      Compiling ‘configs.c’
      Compiling ‘soc.c’
      Compiling ‘mpu_regions.c’
      Compiling ‘system_nrf9160.c’
      Compiling ‘nrfx_glue.c’
      Compiling ‘power.c’
      Compiling ‘reboot.c’
      Compiling ‘policy_residency.c’
      Compiling ‘uart_console.c’
      Compiling ‘nrf_power_clock.c’
      Compiling ‘sys_clock_init.c’
      Compiling ‘nrf_rtc_timer.c’
      Compiling ‘spm.c’
      Compiling ‘secure_services.c’
        implicit declaration of function 'SEGGER_RTT_Init' [-Wimplicit-function-declaration]
        'err' is used uninitialized in this function [-Wuninitialized]
      Compiling ‘SEGGER_RTT.c’
      Compiling ‘SEGGER_RTT_zephyr.c’
      Archiving ‘libspm_zephyr.a’
    Building ‘spm/zephyr/arch/arm/core/libspm_arch__arm__core.a’ from solution ‘build’ in configuration ‘Common’
      Assembling ‘exc_exit.S’
      Assembling ‘swap_helper.S’
      Assembling ‘cpu_idle.S’
      Assembling ‘fault_s.S’
      Assembling ‘isr_wrapper.S’
      Compiling ‘irq_init.c’
      Compiling ‘swap.c’
      Compiling ‘fault.c’
      Compiling ‘irq_manage.c’
      Compiling ‘thread.c’
      Compiling ‘fatal.c’
      Compiling ‘sys_fatal_error_handler.c’
      Compiling ‘thread_abort.c’
      Archiving ‘libspm_arch__arm__core.a’
    Building ‘spm/zephyr/arch/arm/core/cortex_m/libspm_arch__arm__core__cortex_m.a’ from solution ‘build’ in configuration ‘Common’
      Assembling ‘vector_table.S’
      Assembling ‘reset.S’
      Assembling ‘nmi_on_reset.S’
      Compiling ‘prep_c.c’
      Compiling ‘scb.c’
      Compiling ‘nmi.c’
      Compiling ‘exc_manage.c’
      Archiving ‘libspm_arch__arm__core__cortex_m.a’
    Building ‘spm/zephyr/arch/arm/core/cortex_m/mpu/libspm_arch__arm__core__cortex_m__mpu.a’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘arm_core_mpu.c’
      Compiling ‘arm_mpu.c’
      Archiving ‘libspm_arch__arm__core__cortex_m__mpu.a’
    Building ‘spm/zephyr/lib/libc/minimal/libspm_lib__libc__minimal.a’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘atoi.c’
      Compiling ‘strtol.c’
      Compiling ‘strtoul.c’
      Compiling ‘malloc.c’
      Compiling ‘bsearch.c’
      Compiling ‘exit.c’
      Compiling ‘strncasecmp.c’
      Compiling ‘strstr.c’
      Compiling ‘string.c’
      Compiling ‘prf.c’
      Compiling ‘stdout_console.c’
      Compiling ‘sprintf.c’
      Compiling ‘fprintf.c’
      Archiving ‘libspm_lib__libc__minimal.a’
    Building ‘spm/zephyr/drivers/serial/libspm_drivers__serial.a’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘uart_nrfx_uarte.c’
      Archiving ‘libspm_drivers__serial.a’
    Building ‘spm/zephyr/modules/nrfxlib/nrf_security/src/mbedtls/libspm_mbeddrbg.a’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘ctr_drbg.c’
      Compiling ‘entropy.c’
      Archiving ‘libspm_mbeddrbg.a’
    Building ‘spm/zephyr/modules/nrfxlib/nrf_security/src/mbedtls/libspm_mbedcrypto_vanilla.a’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘aes.c’
      Compiling ‘aesni.c’
      Compiling ‘aria.c’
      Compiling ‘arc4.c’
      Compiling ‘asn1parse.c’
      Compiling ‘asn1write.c’
      Compiling ‘base64.c’
      Compiling ‘bignum.c’
      Compiling ‘blowfish.c’
      Compiling ‘camellia.c’
      Compiling ‘ccm.c’
      Compiling ‘chacha20.c’
      Compiling ‘chachapoly.c’
      Compiling ‘cipher.c’
      Compiling ‘cmac.c’
      Compiling ‘des.c’
      Compiling ‘dhm.c’
      Compiling ‘ecdh.c’
      Compiling ‘ecdsa.c’
      Compiling ‘ecjpake.c’
      Compiling ‘ecp.c’
      Compiling ‘ecp_curves.c’
      Compiling ‘entropy_poll.c’
      Compiling ‘error.c’
      Compiling ‘gcm.c’
      Compiling ‘havege.c’
      Compiling ‘hkdf.c’
      Compiling ‘hmac_drbg.c’
      Compiling ‘md.c’
      Compiling ‘md2.c’
      Compiling ‘md4.c’
      Compiling ‘md5.c’
      Compiling ‘md_wrap.c’
      Compiling ‘memory_buffer_alloc.c’
      Compiling ‘nist_kw.c’
      Compiling ‘oid.c’
      Compiling ‘padlock.c’
      Compiling ‘pk.c’
      Compiling ‘pk_wrap.c’
      Compiling ‘pkcs12.c’
      Compiling ‘pkcs5.c’
      Compiling ‘pkparse.c’
      Compiling ‘pkwrite.c’
      Compiling ‘platform.c’
        implicit declaration of function 'SEGGER_RTT_Write' [-Wimplicit-function-declaration]
      Compiling ‘platform_util.c’
      Compiling ‘poly1305.c’
      Compiling ‘ripemd160.c’
      Compiling ‘rsa.c’
      Compiling ‘rsa_internal.c’
      Compiling ‘sha1.c’
      Compiling ‘sha256.c’
      Compiling ‘sha512.c’
      Compiling ‘threading.c’
      Compiling ‘timing.c’
      Compiling ‘version.c’
      Compiling ‘version_features.c’
      Compiling ‘xtea.c’
      Compiling ‘cipher_wrap.c’
      Compiling ‘pem.c’
      Archiving ‘libspm_mbedcrypto_vanilla.a’
    Building ‘spm/zephyr/kernel/libspm_kernel.a’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘device.c’
      Compiling ‘errno.c’
      Compiling ‘idle.c’
      Compiling ‘init.c’
      Compiling ‘mailbox.c’
      Compiling ‘mem_slab.c’
      Compiling ‘mempool.c’
      Compiling ‘msg_q.c’
      Compiling ‘mutex.c’
      Compiling ‘pipes.c’
      Compiling ‘queue.c’
      Compiling ‘sched.c’
      Compiling ‘sem.c’
      Compiling ‘stack.c’
      Compiling ‘system_work_q.c’
      Compiling ‘thread.c’
      Compiling ‘thread_abort.c’
      Compiling ‘work_q.c’
      Compiling ‘version.c’
      Compiling ‘smp.c’
      Compiling ‘timeout.c’
      Compiling ‘timer.c’
      Archiving ‘libspm_kernel.a’
    Building ‘spm/zephyr/spm_zephyr_prebuilt.elf’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘empty_file.c’
      Linking ‘spm_zephyr_prebuilt.elf’
        KB        32 KB    200.00%
        B        64 KB     17.17%
        spm\zephyr\spm_zephyr_prebuilt.elf section `_TEXT_SECTION_NAME_2' will not fit in region `FLASH'
        SPM and app are sharing an SPU region. Cannot partition flash correctly into secure and non-secure. Adjust partitions sizes so they are placed in separate regions.
        region `FLASH' overflowed by 32768 bytes
        ld returned 1 exit status
        B         2 KB      1.95%
    Build failed

    New partitions sizes I added to attached files.Also I added my spm and secure_service sample project files and all build directories.

    nrf9160_pca10090_32Kb_aligned.zip

    spm_folder_from_subsys_folder.zip

    nrf9160_sample_folder_spm_reserved_size_0x8000.zipnrf9160_sample_folder_spm_reserved_size_0x19000.zip

Reply
  • Hi.

    I aligned now all partitions by 32Kb.

    And tried compile SPM with RSA mbed TLS function.

    Same error. I tried with SPM reserved size 0x8000, 0x19000, and 0x20000.

    Do you have any ideas how we solve this problem?

    Could you also try compile my sources at your side?

    Here error when I set flash reserved page size to 0x19000

    Building ‘spm/zephyr/include/generated/driver-validation.h’ from solution ‘build’ in configuration ‘Common’
      Combining ‘spm/zephyr/include/generated/driver-validation.h’
    Building ‘spm/zephyr/CMakeFiles/spm_driver_validation_h_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/spm_driver_validation_h_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/include/generated/kobj-types-enum.h’ from solution ‘build’ in configuration ‘Common’
      Combining ‘spm/zephyr/include/generated/kobj-types-enum.h’
    Building ‘spm/zephyr/include/generated/otype-to-str.h’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/CMakeFiles/spm_kobj_types_h_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/spm_kobj_types_h_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/misc/generated/syscalls.json’ from solution ‘build’ in configuration ‘Common’
      Combining ‘spm/zephyr/misc/generated/syscalls.json’
    Building ‘spm/zephyr/include/generated/syscall_list.h’ from solution ‘build’ in configuration ‘Common’
      Combining ‘spm/zephyr/include/generated/syscall_list.h’
    Building ‘spm/zephyr/CMakeFiles/spm_syscall_list_h_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/include/generated/syscall_dispatch.c’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/spm_syscall_list_h_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/include/generated/syscall_macros.h’ from solution ‘build’ in configuration ‘Common’
      Combining ‘spm/zephyr/include/generated/syscall_macros.h’
    Building ‘spm/zephyr/CMakeFiles/spm_syscall_macros_h_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/spm_syscall_macros_h_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_offsets’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/spm_offsets’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘offsets.c’
    Building ‘spm/zephyr/include/generated/offsets.h’ from solution ‘build’ in configuration ‘Common’
      Combining ‘spm/zephyr/include/generated/offsets.h’
    Building ‘spm/zephyr/CMakeFiles/spm_offsets_h’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/spm_offsets_h’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_app’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_arch__arm__core’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_arch__arm__core__cortex_m’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_arch__arm__core__cortex_m__mpu’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_drivers__serial’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_kernel’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_lib__libc__minimal’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_mbedcrypto_vanilla’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_mbeddrbg’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_zephyr’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/linker.cmd’ from solution ‘build’ in configuration ‘Common’
      Combining ‘spm/zephyr/linker.cmd’
    Building ‘spm/zephyr/CMakeFiles/spm_linker_script_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/spm_linker_script_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_zephyr_prebuilt’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/spm_app/libspm_app.a’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘main.c’
      Archiving ‘libspm_app.a’
    Building ‘spm/zephyr/libspm_zephyr.a’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘isr_tables.c’
      Compiling ‘sw_isr_common.c’
      Compiling ‘arm_core_cmse.c’
      Compiling ‘arm_core_tz.c’
      Compiling ‘crc32_sw.c’
      Compiling ‘crc16_sw.c’
      Compiling ‘crc8_sw.c’
      Compiling ‘crc7_sw.c’
      Compiling ‘fdtable.c’
      Compiling ‘mempool.c’
      Compiling ‘rb.c’
      Compiling ‘thread_entry.c’
      Compiling ‘work_q.c’
      Compiling ‘printk.c’
      Compiling ‘configs.c’
      Compiling ‘soc.c’
      Compiling ‘mpu_regions.c’
      Compiling ‘system_nrf9160.c’
      Compiling ‘nrfx_glue.c’
      Compiling ‘power.c’
      Compiling ‘reboot.c’
      Compiling ‘policy_residency.c’
      Compiling ‘uart_console.c’
      Compiling ‘nrf_power_clock.c’
      Compiling ‘sys_clock_init.c’
      Compiling ‘nrf_rtc_timer.c’
      Compiling ‘spm.c’
      Compiling ‘secure_services.c’
        implicit declaration of function 'SEGGER_RTT_Init' [-Wimplicit-function-declaration]
        'err' is used uninitialized in this function [-Wuninitialized]
      Compiling ‘SEGGER_RTT.c’
      Compiling ‘SEGGER_RTT_zephyr.c’
      Archiving ‘libspm_zephyr.a’
    Building ‘spm/zephyr/arch/arm/core/libspm_arch__arm__core.a’ from solution ‘build’ in configuration ‘Common’
      Assembling ‘exc_exit.S’
      Assembling ‘swap_helper.S’
      Assembling ‘cpu_idle.S’
      Assembling ‘fault_s.S’
      Assembling ‘isr_wrapper.S’
      Compiling ‘irq_init.c’
      Compiling ‘swap.c’
      Compiling ‘fault.c’
      Compiling ‘irq_manage.c’
      Compiling ‘thread.c’
      Compiling ‘fatal.c’
      Compiling ‘sys_fatal_error_handler.c’
      Compiling ‘thread_abort.c’
      Archiving ‘libspm_arch__arm__core.a’
    Building ‘spm/zephyr/arch/arm/core/cortex_m/libspm_arch__arm__core__cortex_m.a’ from solution ‘build’ in configuration ‘Common’
      Assembling ‘vector_table.S’
      Assembling ‘reset.S’
      Assembling ‘nmi_on_reset.S’
      Compiling ‘prep_c.c’
      Compiling ‘scb.c’
      Compiling ‘nmi.c’
      Compiling ‘exc_manage.c’
      Archiving ‘libspm_arch__arm__core__cortex_m.a’
    Building ‘spm/zephyr/arch/arm/core/cortex_m/mpu/libspm_arch__arm__core__cortex_m__mpu.a’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘arm_core_mpu.c’
      Compiling ‘arm_mpu.c’
      Archiving ‘libspm_arch__arm__core__cortex_m__mpu.a’
    Building ‘spm/zephyr/lib/libc/minimal/libspm_lib__libc__minimal.a’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘atoi.c’
      Compiling ‘strtol.c’
      Compiling ‘strtoul.c’
      Compiling ‘malloc.c’
      Compiling ‘bsearch.c’
      Compiling ‘exit.c’
      Compiling ‘strncasecmp.c’
      Compiling ‘strstr.c’
      Compiling ‘string.c’
      Compiling ‘prf.c’
      Compiling ‘stdout_console.c’
      Compiling ‘sprintf.c’
      Compiling ‘fprintf.c’
      Archiving ‘libspm_lib__libc__minimal.a’
    Building ‘spm/zephyr/drivers/serial/libspm_drivers__serial.a’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘uart_nrfx_uarte.c’
      Archiving ‘libspm_drivers__serial.a’
    Building ‘spm/zephyr/modules/nrfxlib/nrf_security/src/mbedtls/libspm_mbeddrbg.a’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘ctr_drbg.c’
      Compiling ‘entropy.c’
      Archiving ‘libspm_mbeddrbg.a’
    Building ‘spm/zephyr/modules/nrfxlib/nrf_security/src/mbedtls/libspm_mbedcrypto_vanilla.a’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘aes.c’
      Compiling ‘aesni.c’
      Compiling ‘arc4.c’
      Compiling ‘aria.c’
      Compiling ‘asn1parse.c’
      Compiling ‘asn1write.c’
      Compiling ‘base64.c’
      Compiling ‘bignum.c’
      Compiling ‘blowfish.c’
      Compiling ‘camellia.c’
      Compiling ‘ccm.c’
      Compiling ‘chacha20.c’
      Compiling ‘chachapoly.c’
      Compiling ‘cipher.c’
      Compiling ‘cmac.c’
      Compiling ‘des.c’
      Compiling ‘dhm.c’
      Compiling ‘ecdh.c’
      Compiling ‘ecdsa.c’
      Compiling ‘ecjpake.c’
      Compiling ‘ecp.c’
      Compiling ‘ecp_curves.c’
      Compiling ‘entropy_poll.c’
      Compiling ‘error.c’
      Compiling ‘gcm.c’
      Compiling ‘havege.c’
      Compiling ‘hkdf.c’
      Compiling ‘hmac_drbg.c’
      Compiling ‘md.c’
      Compiling ‘md2.c’
      Compiling ‘md4.c’
      Compiling ‘md5.c’
      Compiling ‘md_wrap.c’
      Compiling ‘memory_buffer_alloc.c’
      Compiling ‘nist_kw.c’
      Compiling ‘oid.c’
      Compiling ‘padlock.c’
      Compiling ‘pk.c’
      Compiling ‘pk_wrap.c’
      Compiling ‘pkcs12.c’
      Compiling ‘pkcs5.c’
      Compiling ‘pkparse.c’
      Compiling ‘pkwrite.c’
      Compiling ‘platform.c’
        implicit declaration of function 'SEGGER_RTT_Write' [-Wimplicit-function-declaration]
      Compiling ‘platform_util.c’
      Compiling ‘poly1305.c’
      Compiling ‘ripemd160.c’
      Compiling ‘rsa.c’
      Compiling ‘rsa_internal.c’
      Compiling ‘sha1.c’
      Compiling ‘sha256.c’
      Compiling ‘sha512.c’
      Compiling ‘threading.c’
      Compiling ‘timing.c’
      Compiling ‘version.c’
      Compiling ‘version_features.c’
      Compiling ‘xtea.c’
      Compiling ‘cipher_wrap.c’
      Compiling ‘pem.c’
      Archiving ‘libspm_mbedcrypto_vanilla.a’
    Building ‘spm/zephyr/kernel/libspm_kernel.a’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘device.c’
      Compiling ‘errno.c’
      Compiling ‘idle.c’
      Compiling ‘init.c’
      Compiling ‘mailbox.c’
      Compiling ‘mem_slab.c’
      Compiling ‘mempool.c’
      Compiling ‘msg_q.c’
      Compiling ‘mutex.c’
      Compiling ‘pipes.c’
      Compiling ‘queue.c’
      Compiling ‘sched.c’
      Compiling ‘sem.c’
      Compiling ‘stack.c’
      Compiling ‘system_work_q.c’
      Compiling ‘thread.c’
      Compiling ‘thread_abort.c’
      Compiling ‘version.c’
      Compiling ‘work_q.c’
      Compiling ‘smp.c’
      Compiling ‘timeout.c’
      Compiling ‘timer.c’
      Archiving ‘libspm_kernel.a’
    Building ‘spm/zephyr/spm_zephyr_prebuilt.elf’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘empty_file.c’
      Linking ‘spm_zephyr_prebuilt.elf’
        KB       100 KB     64.00%
        B        64 KB     17.17%
        B         2 KB      1.95%
        SPM and app are sharing an SPU region. Cannot partition flash correctly into secure and non-secure. Adjust partitions sizes so they are placed in separate regions.
        ld returned 1 exit status
    Build failed

    Here error when I set flash reserved page size to 0x8000

    Building ‘spm/zephyr/include/generated/driver-validation.h’ from solution ‘build’ in configuration ‘Common’
      Combining ‘spm/zephyr/include/generated/driver-validation.h’
    Building ‘spm/zephyr/CMakeFiles/spm_driver_validation_h_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/spm_driver_validation_h_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/include/generated/kobj-types-enum.h’ from solution ‘build’ in configuration ‘Common’
      Combining ‘spm/zephyr/include/generated/kobj-types-enum.h’
    Building ‘spm/zephyr/include/generated/otype-to-str.h’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/CMakeFiles/spm_kobj_types_h_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/spm_kobj_types_h_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/misc/generated/syscalls.json’ from solution ‘build’ in configuration ‘Common’
      Combining ‘spm/zephyr/misc/generated/syscalls.json’
    Building ‘spm/zephyr/include/generated/syscall_list.h’ from solution ‘build’ in configuration ‘Common’
      Combining ‘spm/zephyr/include/generated/syscall_list.h’
    Building ‘spm/zephyr/CMakeFiles/spm_syscall_list_h_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/include/generated/syscall_dispatch.c’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/spm_syscall_list_h_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/include/generated/syscall_macros.h’ from solution ‘build’ in configuration ‘Common’
      Combining ‘spm/zephyr/include/generated/syscall_macros.h’
    Building ‘spm/zephyr/CMakeFiles/spm_syscall_macros_h_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/spm_syscall_macros_h_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_offsets’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/spm_offsets’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘offsets.c’
    Building ‘spm/zephyr/include/generated/offsets.h’ from solution ‘build’ in configuration ‘Common’
      Combining ‘spm/zephyr/include/generated/offsets.h’
    Building ‘spm/zephyr/CMakeFiles/spm_offsets_h’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/spm_offsets_h’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_app’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_arch__arm__core’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_arch__arm__core__cortex_m’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_arch__arm__core__cortex_m__mpu’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_drivers__serial’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_kernel’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_lib__libc__minimal’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_mbedcrypto_vanilla’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_mbeddrbg’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_zephyr’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/linker.cmd’ from solution ‘build’ in configuration ‘Common’
      Combining ‘spm/zephyr/linker.cmd’
    Building ‘spm/zephyr/CMakeFiles/spm_linker_script_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/zephyr/spm_linker_script_target’ from solution ‘build’ in configuration ‘Common’
    Building ‘cmake_object_order_depends_target_spm_zephyr_prebuilt’ from solution ‘build’ in configuration ‘Common’
    Building ‘spm/spm_app/libspm_app.a’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘main.c’
      Archiving ‘libspm_app.a’
    Building ‘spm/zephyr/libspm_zephyr.a’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘isr_tables.c’
      Compiling ‘sw_isr_common.c’
      Compiling ‘arm_core_cmse.c’
      Compiling ‘arm_core_tz.c’
      Compiling ‘crc32_sw.c’
      Compiling ‘crc16_sw.c’
      Compiling ‘crc8_sw.c’
      Compiling ‘crc7_sw.c’
      Compiling ‘fdtable.c’
      Compiling ‘mempool.c’
      Compiling ‘rb.c’
      Compiling ‘thread_entry.c’
      Compiling ‘work_q.c’
      Compiling ‘printk.c’
      Compiling ‘configs.c’
      Compiling ‘soc.c’
      Compiling ‘mpu_regions.c’
      Compiling ‘system_nrf9160.c’
      Compiling ‘nrfx_glue.c’
      Compiling ‘power.c’
      Compiling ‘reboot.c’
      Compiling ‘policy_residency.c’
      Compiling ‘uart_console.c’
      Compiling ‘nrf_power_clock.c’
      Compiling ‘sys_clock_init.c’
      Compiling ‘nrf_rtc_timer.c’
      Compiling ‘spm.c’
      Compiling ‘secure_services.c’
        implicit declaration of function 'SEGGER_RTT_Init' [-Wimplicit-function-declaration]
        'err' is used uninitialized in this function [-Wuninitialized]
      Compiling ‘SEGGER_RTT.c’
      Compiling ‘SEGGER_RTT_zephyr.c’
      Archiving ‘libspm_zephyr.a’
    Building ‘spm/zephyr/arch/arm/core/libspm_arch__arm__core.a’ from solution ‘build’ in configuration ‘Common’
      Assembling ‘exc_exit.S’
      Assembling ‘swap_helper.S’
      Assembling ‘cpu_idle.S’
      Assembling ‘fault_s.S’
      Assembling ‘isr_wrapper.S’
      Compiling ‘irq_init.c’
      Compiling ‘swap.c’
      Compiling ‘fault.c’
      Compiling ‘irq_manage.c’
      Compiling ‘thread.c’
      Compiling ‘fatal.c’
      Compiling ‘sys_fatal_error_handler.c’
      Compiling ‘thread_abort.c’
      Archiving ‘libspm_arch__arm__core.a’
    Building ‘spm/zephyr/arch/arm/core/cortex_m/libspm_arch__arm__core__cortex_m.a’ from solution ‘build’ in configuration ‘Common’
      Assembling ‘vector_table.S’
      Assembling ‘reset.S’
      Assembling ‘nmi_on_reset.S’
      Compiling ‘prep_c.c’
      Compiling ‘scb.c’
      Compiling ‘nmi.c’
      Compiling ‘exc_manage.c’
      Archiving ‘libspm_arch__arm__core__cortex_m.a’
    Building ‘spm/zephyr/arch/arm/core/cortex_m/mpu/libspm_arch__arm__core__cortex_m__mpu.a’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘arm_core_mpu.c’
      Compiling ‘arm_mpu.c’
      Archiving ‘libspm_arch__arm__core__cortex_m__mpu.a’
    Building ‘spm/zephyr/lib/libc/minimal/libspm_lib__libc__minimal.a’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘atoi.c’
      Compiling ‘strtol.c’
      Compiling ‘strtoul.c’
      Compiling ‘malloc.c’
      Compiling ‘bsearch.c’
      Compiling ‘exit.c’
      Compiling ‘strncasecmp.c’
      Compiling ‘strstr.c’
      Compiling ‘string.c’
      Compiling ‘prf.c’
      Compiling ‘stdout_console.c’
      Compiling ‘sprintf.c’
      Compiling ‘fprintf.c’
      Archiving ‘libspm_lib__libc__minimal.a’
    Building ‘spm/zephyr/drivers/serial/libspm_drivers__serial.a’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘uart_nrfx_uarte.c’
      Archiving ‘libspm_drivers__serial.a’
    Building ‘spm/zephyr/modules/nrfxlib/nrf_security/src/mbedtls/libspm_mbeddrbg.a’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘ctr_drbg.c’
      Compiling ‘entropy.c’
      Archiving ‘libspm_mbeddrbg.a’
    Building ‘spm/zephyr/modules/nrfxlib/nrf_security/src/mbedtls/libspm_mbedcrypto_vanilla.a’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘aes.c’
      Compiling ‘aesni.c’
      Compiling ‘aria.c’
      Compiling ‘arc4.c’
      Compiling ‘asn1parse.c’
      Compiling ‘asn1write.c’
      Compiling ‘base64.c’
      Compiling ‘bignum.c’
      Compiling ‘blowfish.c’
      Compiling ‘camellia.c’
      Compiling ‘ccm.c’
      Compiling ‘chacha20.c’
      Compiling ‘chachapoly.c’
      Compiling ‘cipher.c’
      Compiling ‘cmac.c’
      Compiling ‘des.c’
      Compiling ‘dhm.c’
      Compiling ‘ecdh.c’
      Compiling ‘ecdsa.c’
      Compiling ‘ecjpake.c’
      Compiling ‘ecp.c’
      Compiling ‘ecp_curves.c’
      Compiling ‘entropy_poll.c’
      Compiling ‘error.c’
      Compiling ‘gcm.c’
      Compiling ‘havege.c’
      Compiling ‘hkdf.c’
      Compiling ‘hmac_drbg.c’
      Compiling ‘md.c’
      Compiling ‘md2.c’
      Compiling ‘md4.c’
      Compiling ‘md5.c’
      Compiling ‘md_wrap.c’
      Compiling ‘memory_buffer_alloc.c’
      Compiling ‘nist_kw.c’
      Compiling ‘oid.c’
      Compiling ‘padlock.c’
      Compiling ‘pk.c’
      Compiling ‘pk_wrap.c’
      Compiling ‘pkcs12.c’
      Compiling ‘pkcs5.c’
      Compiling ‘pkparse.c’
      Compiling ‘pkwrite.c’
      Compiling ‘platform.c’
        implicit declaration of function 'SEGGER_RTT_Write' [-Wimplicit-function-declaration]
      Compiling ‘platform_util.c’
      Compiling ‘poly1305.c’
      Compiling ‘ripemd160.c’
      Compiling ‘rsa.c’
      Compiling ‘rsa_internal.c’
      Compiling ‘sha1.c’
      Compiling ‘sha256.c’
      Compiling ‘sha512.c’
      Compiling ‘threading.c’
      Compiling ‘timing.c’
      Compiling ‘version.c’
      Compiling ‘version_features.c’
      Compiling ‘xtea.c’
      Compiling ‘cipher_wrap.c’
      Compiling ‘pem.c’
      Archiving ‘libspm_mbedcrypto_vanilla.a’
    Building ‘spm/zephyr/kernel/libspm_kernel.a’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘device.c’
      Compiling ‘errno.c’
      Compiling ‘idle.c’
      Compiling ‘init.c’
      Compiling ‘mailbox.c’
      Compiling ‘mem_slab.c’
      Compiling ‘mempool.c’
      Compiling ‘msg_q.c’
      Compiling ‘mutex.c’
      Compiling ‘pipes.c’
      Compiling ‘queue.c’
      Compiling ‘sched.c’
      Compiling ‘sem.c’
      Compiling ‘stack.c’
      Compiling ‘system_work_q.c’
      Compiling ‘thread.c’
      Compiling ‘thread_abort.c’
      Compiling ‘work_q.c’
      Compiling ‘version.c’
      Compiling ‘smp.c’
      Compiling ‘timeout.c’
      Compiling ‘timer.c’
      Archiving ‘libspm_kernel.a’
    Building ‘spm/zephyr/spm_zephyr_prebuilt.elf’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘empty_file.c’
      Linking ‘spm_zephyr_prebuilt.elf’
        KB        32 KB    200.00%
        B        64 KB     17.17%
        spm\zephyr\spm_zephyr_prebuilt.elf section `_TEXT_SECTION_NAME_2' will not fit in region `FLASH'
        SPM and app are sharing an SPU region. Cannot partition flash correctly into secure and non-secure. Adjust partitions sizes so they are placed in separate regions.
        region `FLASH' overflowed by 32768 bytes
        ld returned 1 exit status
        B         2 KB      1.95%
    Build failed

    New partitions sizes I added to attached files.Also I added my spm and secure_service sample project files and all build directories.

    nrf9160_pca10090_32Kb_aligned.zip

    spm_folder_from_subsys_folder.zip

    nrf9160_sample_folder_spm_reserved_size_0x8000.zipnrf9160_sample_folder_spm_reserved_size_0x19000.zip

Children
Related