You copied the Doc URL to your clipboard.

Building a Non-secure image that can call a Secure image

If you are building a Non-secure image that is to call a Secure image, you must obtain the import library package that was created for that Secure image.

The following procedure assumes that you have the import library package created using the ARMv8-M Security Extensions. The import library package identifies the entry points for the Secure image.

Procedure

  1. In the C program for your Non-secure nonsecure.c include the interface header file and use the entry functions as required, for example:
    #include <stdio.h>
    #include "myinterface_v1.h"

    int main(void) {
        int val1, val2, x;

        val1 = entry1(x);
        val2 = entry2(x);

        if (val1 == val2) {
            printf("val2 is equal to val1\n");
        } else {
            printf("val2 is different from val1\n");
        }

        return 0;
    }
  1. Create an object file, nonsecure.o:

      $ armclang -c --target arm-arm-none-eabi -march=ARMv8-M.main nonsecure.c -o nonsecure.o

  1. Create a scatter file for the Non-secure image, but without the Non-secure Callable (NSC) memory region, for example:
        LOAD_REGION 0x8000 0x3000
        {
            ER 0x8000
            {
                *(+RO,+RW,+ZI)
            }
            ARM_LIB_STACK 0x800000 EMPTY -0x10000
            {
            }
            ARM_LIB_HEAP  +0 EMPTY 0x10000
            {
            }
        }
        ...
  1. Link the object file using the import library, importlib_v1.o, and the scatter file to create the Non-secure image:

      $ armlink nonsecure.o importlib_v1.o -o nonsecure.axf --cpu=8-M.Main --scatter nonsecure.scf

Was this page helpful? Yes No