|
| 1 | +.. _arc_secure_service: |
| 2 | + |
| 3 | +ARC Secure Service |
| 4 | +################## |
| 5 | + |
| 6 | +Overview |
| 7 | +******** |
| 8 | + |
| 9 | +This sample implements a simple secure service based on ARC SecureShield to |
| 10 | +demonstrate how a secure zephyr application runs together with a normal |
| 11 | +Zephyr application. |
| 12 | + |
| 13 | +In this sample: |
| 14 | + |
| 15 | +* Secure application will be in the secure memory space defined in |
| 16 | + ``arc_mpu_regions.c``. Half of RAM and ROM is allocated to secure world, |
| 17 | + the other half is allocated to normal world. |
| 18 | + |
| 19 | +* Memory not allocated to the secure application is allocated to |
| 20 | + the normal application. |
| 21 | + |
| 22 | +* By default, all the peripheral space is normal mode accessible, i.e., |
| 23 | + the peripherals are shared between normal mode and secure mode. If some |
| 24 | + peripherals are required by secure world, it can be done by adding static |
| 25 | + mpu entry in ``arc_mpu_regions.c``. |
| 26 | + |
| 27 | +* The interrupts of two internal timers are configure as normal interrupts, |
| 28 | + so the normal zephyr's kernel tick can work correctly. |
| 29 | + |
| 30 | +* Secure interrupts priority > secure threads priority > normal interrupts |
| 31 | + priority > normal threads priority. |
| 32 | + |
| 33 | + |
| 34 | +Requirements |
| 35 | +************ |
| 36 | + |
| 37 | +To use this sample, ARC processor should be equipped with ARC SecureShield. In |
| 38 | +Zephyr, the following board configurations are supported: |
| 39 | + |
| 40 | +* em_starterkit_em7d |
| 41 | + * secure application: em_starterkit_em7d_secure |
| 42 | + * normal application: em_starterkit_em7d_normal |
| 43 | +* nsim_sem |
| 44 | + * secure application: nsim_sem |
| 45 | + * normal application: nsim_sem_normal |
| 46 | + |
| 47 | +Building and Running |
| 48 | +******************** |
| 49 | + |
| 50 | +Building |
| 51 | +======== |
| 52 | + |
| 53 | +Secure application |
| 54 | +^^^^^^^^^^^^^^^^^^ |
| 55 | + |
| 56 | +First, you should build the secure application. |
| 57 | + |
| 58 | +.. zephyr-app-commands:: |
| 59 | + :zephyr-app: samples/boards/arc_secure_services |
| 60 | + :board: em_starterkit_em7d_secure nsim_sem |
| 61 | + :goals: build |
| 62 | + :compact: |
| 63 | + |
| 64 | +Normal application |
| 65 | +^^^^^^^^^^^^^^^^^^ |
| 66 | + |
| 67 | +Currently, in normal application, MPU is not accessible, so no user space and |
| 68 | +mpu-based stack checking. |
| 69 | + |
| 70 | +Here,take :ref:'dining-philosophers-sample' as an example for normal |
| 71 | +application. |
| 72 | + |
| 73 | +.. zephyr-app-commands:: |
| 74 | + :zephyr-app: samples/philosophers |
| 75 | + :board: em_starterkit_em7d_normal nsim_sem_normal |
| 76 | + :goals: build |
| 77 | + :compact: |
| 78 | + |
| 79 | +Running |
| 80 | +======= |
| 81 | + |
| 82 | +* Run using the bootloader |
| 83 | + |
| 84 | +The bootloader should load the secure and normal application into the correct place, |
| 85 | +then jump to the entry of the secure application. The entry of normal application |
| 86 | +is hardcoded in secure application. Secure application will boot normal application. |
| 87 | + |
| 88 | +* Run using the debugger (recommended) |
| 89 | + |
| 90 | +Use the gdb debugger to load and run the two applications. |
| 91 | + |
| 92 | +For em starter kit, run the following commands |
| 93 | + |
| 94 | +.. code-block:: console |
| 95 | +
|
| 96 | + # load secure application first |
| 97 | + $ cd samples/boards/arc_secure_services/build |
| 98 | + $ west debug |
| 99 | + # load normal application |
| 100 | + $ monitor load_image ../../../philosophers/build/zepher/zephyr.elf |
| 101 | + $ c |
| 102 | +
|
| 103 | +For nsim sem, you need two consoles: one for application output, and one for |
| 104 | +debugger. |
| 105 | + |
| 106 | +In the console for output: |
| 107 | + |
| 108 | +.. code-block:: console |
| 109 | +
|
| 110 | + # open debug server |
| 111 | + $ cd samples/boards/arc_secure_services/build |
| 112 | + $ west debugserver |
| 113 | +
|
| 114 | +In the console for debugger: |
| 115 | + |
| 116 | +.. code-block:: console |
| 117 | +
|
| 118 | + # open debug server |
| 119 | + $ cd samples/boards/arc_secure_services/build |
| 120 | + $ arc-elf32-gdb zephyr/zephyr.elf |
| 121 | + $ target remote :3333 |
| 122 | + # load normal application |
| 123 | + $ load ../../../philosophers/build/zepher/zephyr.elf |
| 124 | + # load secure application |
| 125 | + $ load |
| 126 | + $ c |
0 commit comments