Generate SAML11 Secure and Non-Secure Touch Projects
Contents
- Introduction
- Objective
- Materials
- Procedure
- Working with the Atmel Start QTouch SAML11 TrustZone Example Project
- Results
Introduction
The ATSAML11 is an Arm® Cortex®-M23 based MCU featuring Arm TrustZone® technology which provides additional security features. SAML11 flash can be partitioned as secure vs non-secure. The touch library can reside in either the secure flash area or the non-secure flash area. Even if the touch library has to reside and run from a non-secure flash area, the device still needs to boot up in the secure flash area and then the program execution will jump into a non-secure flash area.
SAM L11 Projects classification concerning the security features is provided below.
- Non-Secure Project - By default, a SAM L11 project created in START comes without the TrustZone Manager middleware and it is considered a non-secure project. To import a non-secure project to the IDE, a secure linker script, a library, and a header file needs to be added.
- Secure Project - Add the TrustZone Manager middleware in START to convert a non-secure project to a secure project and then configure the TrustZone settings.
Objective
The following lab shows you how to create ATSAML11 QTouch® secure and non-secure projects in START, and import them into Atmel Studio. This project is generated for the ATSAML11 Xplained Pro along with the QT7 Xplained Pro Extension Kit.
Materials
Hardware Tools
Software Tools
Procedure
Open the CREATE NEW PROJECT wizard in Atmel START
Go to http://start.atmel.com and click on the CREATE NEW PROJECT button.
Select the device and middleware and create the project
Configure TrustZone settings
After project creation, the project dashboard will open as follows. Click on TRUSTZONE_MANAGER_0 to configure the TrustZone settings.
Configure the TrustZone Manager settings as shown in the figure below.
The SERCOM1 fuse has to be checked in the TrustZone settings to configure PA18 and PA19 as touch lines. In addition, secure and non-secure stacks and other peripherals are to be configured either as secure or non-secure depending on your application.
Add and configure button and slider sensors to the project
Refer to the link below to add buttons, slider sensors, configure the driven shield, debug pins, and generate the project from START as per the SAML11E16 and QT7 design files:
Based on the design files, the Y lines should be selected as follows:
Working with the Atmel Start QTouch SAML11 TrustZone Example Project
SAML11 Non-Secure Project Import and Creation in Atmel Studio
Download the 'QTouch SAM L11 Trustzone Settings Example Project'
- Go to http://start.atmel.com and click on the 'BROWSE EXAMPLES' button.
- Type "saml11" in the Search box and select 'QTouch-SAML11-Trustzone-Project' from the list.
- Click on 'DOWNLOAD SELECTED EXAMPLE'.
Open Atmel Studio and import the QTouch SAML11 TrustZone Project
Setup the Peripherals
The peripherals needed for a Non-Secure QTouch project can also be configured as non-secure by setting them as 1 in the trustzone_config.h file in the QTouch SAML11 Trustzone Project after downloading it. The list of the peripherals to be configured as non-secure for a QTouch project is given below. Other peripherals can also be configured in the trustzone_config.h file as needed in your application.
- PTC
- RTC
- PORT
- SERCOM used for UART (Data Visualizer Interface)
- SERCOM1 (Linked with XY14 (PA18) and XY15 (PA19)
Build the project and keep it aside
Import the SAM L11 Non-Secure QTouch Project (without TrustZone) generated from START to the QTouch SAM L11 TrustZone solution.
From the Studio menu bar, click on File->Import->Atmel Start Project.
Browse for the Veneer Header File, libsecure_gateway_veneer.lib, and Non-Secure Project Linker Script from the created QTouch SAM L11 TrustZone Project and click OK.
Now the Secure and Non-Secure Projects are in a single solution as shown below.
Build the L11-Non-Secure project and keep it aside.
Now both projects have been created and built.
SAML11 Non-Secure Project Device Programming for Debug
Set the StartUp Project
Right-click on the 'L11_Non-Secure_QT7 project' and choose 'Set as StartUp Project'.
Add the TrustZone Project
Add the Secure QTouch SAML11 TrustZone Project generated elf file under Additional modules in the Non-Secure_QT7 project's 'Advanced Properties'.
Erase the Device
Choose 'Chip erase All (CE2)' from the L11_Non-Secure_QT7 Tool Program settings.
Start Debugging
Click either the Start Debugging and Break or the Start Debugging buttons to flash the code and start debugging. Open the Data Visualizer, browse the scripts, and connect it to see the touch status.
Programming the Project in Release Mode
Erase Secure Memory and Program Secure Code
- Uncheck the 'Erase Flash before programming' option.
- Choose the 'Chip Erase Secure (CE1)' option and erase the device by clicking the Erase now button.
- Browse for the QTouch SAML11 TrustZone Project generated hex file and click the Program button.
Erase Non-Secure Memory and Program Non-Secure Code
- Uncheck the 'Erase Flash before programming' option.
- Choose the 'Chip Erase Nonsecure (CE0)' option and erase the device by clicking the Erase now button.
- Browse for the L11_Non-Secure_QT7 project-generated hex file and click the Program button.
Read the Fuse Settings of the Device
Program Fuses
Program the 'USER_WORD_2' to 'USER_WORD_6' fuses with the settings shown below:
Now the device is ready with the QTouch code. Open the Data Visualizer, browse the scripts, and connect it to see the touch status.
SAM L11 Secure Project Import and Creation in Atmel Studio
Now TrustZone is part of the QTouch project itself as marked below.
Results
SAML11 Secure and Non-Secure projects were generated from START, created projects by importing to Atmel Studio and programmed successfully.