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

NRF9160 Memory partition

Hello guys,

I wanted try run on NRF9160 hardware CC310 cryptographic module.

I installed all software and tried run secure_services demo. Thats works, cool!

In next step I tried run RSA cryptographic fuctions. I found example in downloaded folders and added in secure_services.c my new code which should works with RSA, but I can not compile now.

I added next test code to secure_services demo:

        int keysize;
        int ret;

mbedtls_mpi N, P, Q, D, E, DP, DQ, QP;

        mbedtls_rsa_context rsa;
        mbedtls_ctr_drbg_context ctr_drbg;
        keysize = 2048;
        //for( ; keysize <= 4096; keysize *= 2 )
        //{
        while(1)
        {
            //mbedtls_snprintf( title, sizeof( title ), "RSA-%d", keysize );
            mbedtls_ctr_drbg_init( &ctr_drbg );
            mbedtls_rsa_init( &rsa, MBEDTLS_RSA_PKCS_V15, 0 );

            mbedtls_mpi_init( &N ); mbedtls_mpi_init( &P ); mbedtls_mpi_init( &Q );
            mbedtls_mpi_init( &D ); mbedtls_mpi_init( &E ); mbedtls_mpi_init( &DP );
            mbedtls_mpi_init( &DQ ); mbedtls_mpi_init( &QP );

            mbedtls_rsa_gen_key( &rsa, myrand, NULL, keysize, 65537 );


           if( ( ret = mbedtls_rsa_export    ( &rsa, &N, &P, &Q, &D, &E ) ) != 0 ||
               ( ret = mbedtls_rsa_export_crt( &rsa, &DP, &DQ, &QP ) )      != 0 )
           {
             for(int i = 0; i < 5; i++)
             {
               i = 5;
             }
           }

           if((ret = mbedtls_rsa_public( &rsa, buf, buf )) != 0)
           {
             for(int i = 0; i < 5; i++)
             {
               i = 5;
             }           
           };
           if((ret = mbedtls_rsa_private( &rsa, myrand, NULL, buf, buf )) != 0)
           {
             for(int i = 0; i < 5; i++)
             {
               i = 5;
             }           
           };

            mbedtls_rsa_free( &rsa );
        }

And received flowing problems:

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 81920 bytes

ld returned 1 exit status

As I understood this problem with not enough memory for code which are placed in secure partition?

How can I fixed it?

Thanks.

Related