3.13.1 TrustZone Getting Started Application on SAM L11 Xplained Pro Evaluation Kit

Download

Description

This Application demonstrates the TrustZone feature on SAM L11 microcontroller (MCU). The application has two projects pertaining to Secure and Non-Secure modes of SAM L11, that work together on the same MCU and offers security isolation between the trusted and the non-trusted resources in the device.

The Secure mode application reads the current room temperature from the temperature sensor on the I/O1 Xplained Pro Extension Kit every 500 milliseconds. Further, the application writes the temperature readings to EEPROM and reads when a request received from the Non-secure mode application. The LED (LED0) is toggled every time the temperature is displayed on the serial console. The periodicity of the temperature values reading can be changed to 1 second, 2 seconds, 4 seconds, and back to 500 milliseconds every time when the user presses the switch SW0 on the SAM L11 Xplained Pro Evaluation Kit. The temperature readings are transferred to Non-secure mode application when it requests to Secure application through Non Secure Callable (NSC).

The Non-secure mode application requests the Secure mode application temperature values and prints them on a serial console once it receives from the Secure mode application. Further, when it receives a request from the user (in the form of a key press on the serial console), it will request Secure mode application to retrieve the last five stored temperature values in the EEPROM. The Non-secure application prints the last five stored temperature values on the console.

Modules/Technology Used

  • Peripheral Modules:
    • Secure PORT Pins (All pins by default are secure)
    • Secure I2C
    • Secure RTC
    • Secure EIC
    • Non-secure USART
    • Non-secure DMAC
    • Non-secure PORT Pins (USART Pins only)

Hardware Used

Software/Tools Used

This project has been verified to work with the following versions of software tools:

Refer Project Manifest for Secure and NonSecure projects present in harmony-manifest-success.yml under the project folder firmware/{Secure or NonSecure}/firmware/src/config/sam_l11_xpro

  • Refer the Release Notes to know the MPLAB X IDE and MCC Plugin version.
  • Any Serial Terminal application, such as Tera Term terminal application.

Because Microchip regularly updates tools, occasionally issue(s) could be discovered while using the newer versions of the tools. If the project does not seem to work and version incompatibility is suspected. It is recommended to double-check and use the same versions that the project was tested with. To download original version of MPLAB Harmony v3 packages, refer to document How to Use the MPLAB Harmony v3 Project Manifest Feature (DS90003305).

Setup

  • Connect the I/O1 Xplained Pro Extension Kit to the Extension Header 1 (EXT1) of the SAM L11 Xplained Pro Evaluation Kit.
  • The SAM L11 Xplained Pro Evaluation Kit allows the Embedded Debugger (EDBG) to be used for debugging. Connect the Type-A male to micro-B USB cable to the micro-B DEBUG USB port to power and debug the SAM L11 Xplained Pro Evaluation Kit.

Programming Hex File

The pre-built hex file can be programmed by following the below steps.

  • The TrustZone project will have Secure and Non-Secure pre-built hex files.
  • Program Secure hex file first followed by the Non-Secure hex file.
  • The following are the steps to program these hex files.
  • Download and extract the pic32cm_ls60_cpro_tz_getting_started project, if not done already.
  • Open MPLAB X IDE.
  • Close all existing projects in IDE if any project is opened

Step 1: Program the Secure Project hex file

  • Go to File -> Import -> Hex/ELF File.
  • In the Import Image File window,
    • Create Prebuilt Project,
  • Click the Browse button to select the prebuilt sam_l11_xpro_Secure.X.production.hex file from project path saml11_trustzone_getting_started/hex.
  • Select Device as ATSAML11E16A
  • Ensure the proper tool is selected under Hardware Tool and click on Next button.
    • Select Project Name and Folder,

- Select appropriate project name and folder and click on Finish button

  • Go to project properties and set Program Options under EDBG categories to erase and program only Secure memory region.
  • In MPLAB X IDE, click on Make and Program Device button to program the device.

Step 2: Program the Non-Secure Project hex file

  • Go to File -> Import -> Hex/ELF File
  • In the Import Image File window,
  • Create Prebuilt Project,
    • Click the Browse button to select the prebuilt sam_l11_xpro_NonSecure.X.production.hex file from project path saml11_trustzone _getting_started/hex.
    • Select Device as ATSAML11E16A.
    • Ensure the proper tool is selected under Hardware Tool and click on Next button.
  • Select Project Name and Folder,
    • Select appropriate project name and folder and click on Finish button
    • In the sam_l11_xpro_NonSecure.X.prebuilt project, right click on Loadables folder and click on Add Loadable File to add Secure Gateway veneer library as shown below.
  • Select sam_l11_xpro_Secure_sg_veneer.lib veneer library.
  • Expand Loadables folder to confirm that the veneer library is added to the Non-Secure project.
  • Go to project properties and set Program Options under EDBG categories to erase and program only Non-Secure memory region.
  • In MPLAB X IDE, click on Make and Program Device button to program the device.
  • Follow the steps in Running the Demo section below

Programming/Debugging Application Project

  • The Trustzone project can be opened in two ways.
    • Procedure 1:
      • Open MPLAB X IDE.
      • Close all existing projects in IDE (if any project is opened).
      • Go to File -> Open Project.
      • Select project path ../reference_apps/apps/sam_l11_xpro/saml11_trustzone_getting_started.
      • Select firmware folder, enable Open Required Projects and click on Open Project button.
      • Once the project opens, set the trustzone_sam_l11_xpro_NonSecure project as Main Project by right clicking on the project.
    • Procedure 2:
      • Open MPLAB X IDE.
      • Close all existing projects in IDE (if any project is opened).
      • Open the project (../saml11_trustzone_getting_started/firmware/NonSecure/firmware/sam_l11_xpro_NonSecure.X) in MPLAB X IDE.
  • Ensure SAML11 Xplained Pro is selected as hardware tool to program/debug the application.
  • Build the code and program the device by clicking on the Make and Program Device button in MPLAB X IDE tool bar
  • Follow the steps in Running the Demo section below.

Running the Demo

  • Open the Tera Term terminal application on the PC (from the Windows Start menu by pressing the Start button).
  • Change the baud rate to 115200.
  • The user should see the temperature values (in °F) being displayed on the terminal every 500 milliseconds, as shown below.
  • Notice the LED0 blinking at 500 millisecond rate.
  • The user may vary the temperature by placing the finger on the temperature sensor (for a few seconds).
  • Press the switch SW0 on SAM L11 Xplained Pro Evaluation Kit to change the default sampling rate to 1 second.
  • Every subsequent pressing of switch SW0 on SAM L11 Xplained Pro Evaluation Kit changes the default sampling rate to 2 seconds, 4 seconds, and 500 ms and back to 1 second in cyclic order as shown below.
  • While the temperature sampling rate changes on every switch SW0 press, notice the LED0 toggling at the same sampling rate.
  • Press any character on the terminal to display the last five values written to the EEPROM.

Comments