| This article is not applicable to M33-TD flavor |
This article gives information about the OP-TEE OS Calibration PTA.
1. PTA Calibration purpose[edit | edit source]
The purpose of this article is to explain how to access internal oscillators calibration service.
These internal oscillators are initially calibrated at chip production level. However, they can be affected by temperature and voltage variations. It is important to provide a mechanism to compensate the effects of these variations to achieve a good frequency accuracy.
The service provides a way to request a periodic calibration of the oscillator based on timer comparison between an oscillator and a refence clock derived from the HSE clock that is considered always accurate:
- calibration on
HSIand onCSIfor STM32MP1 series - calibration on
MSIfor STM32MP2 series (theHSIcalibration is not based on user request transmitted by PTA)
Refer to STM32 MPU reference manuals for detailed information on the timer channels that can be used for internal oscillator calibration input.
2. System overview[edit | edit source]
2.1. Components description[edit | edit source]
Non secure world:
- Calibration Timer (User Space): User space service (systemd based) that calls the calibration binary at every chosen timer expiration. See How to activate internal oscillators calibration to manage the service.
- Calibration (User Space): User space client application that connects to the calibration PTA over a session to request the calibration execution.
Find these calibration features at : stm32mp-calibration/
- TEE Core API Lib (User Space): Library called by the client application to access to the kernel space.
- OP-TEE driver (Kernel Space): Generic driver that send the message to the OP-TEE OS.
Secure world:
- Calibration PTA (OP-TEE core): Interface that exposes the calibration specific services.
- Calibration driver (OP-TEE core): Specific calibration driver that controls and calculates the calibration values.
- TIM driver (OP-TEE core): Timer driver using the OP-TEE counter framework.
- STM32 peripherals (Hardware): Access to hardware specific peripherals (RCC, TIM) under firewall access control.
2.2. API description[edit | edit source]
The calibration interface is provided by a pseudo trusted applications (PTA) in OP-TEE, accessible from the normal world with the GlobalPlatform TEE Client API. The calibration PTA offers a single interface to request a calibration with the API defined in lib/libutee/include/stm32_pta_calib.h .
The calibration is started by the calibration drivers activated in the OP-TEE device tree:
- on
HSIand/or onCSIfor STM32MP1 series - on
MSIcalibration for STM32MP2 series
(theHSIcalibration is not started on PTA request but with HSI monitoring)
In OpenSTLinux, this API is used by a Linux Daemon.
3. Configuration[edit | edit source]
3.1. OP-TEE_OS configuration[edit | edit source]
Activate Calibration PTA with the associated driver in OP-TEE configuration:
- for STM32MP1 series calibration driver in:
- core/arch/arm/plat-stm32mp1/drivers/stm32mp1_calib.c (4.0.0-stm32mp-r2) for ecosystem release ≤ v6.2.1

- core/drivers/clk/clk-stm32mp1-cal.c
- core/arch/arm/plat-stm32mp1/drivers/stm32mp1_calib.c (4.0.0-stm32mp-r2) for ecosystem release ≤ v6.2.1
- activated in core/arch/arm/plat-stm32mp1/conf.mk with
CFG_STM32_CLKCALIB ?=y
- for STM32MP2 series (core/drivers/clk/clk-stm32mp2-cal.c ), in core/arch/arm/plat-stm32mp2/conf.mk with:
CFG_STM32MP2_CLK_CAL ?=y
3.2. Device tree configuration[edit | edit source]
Detailed DT configuration for STM32 internal peripherals:
4. How to use the framework[edit | edit source]
A default calibration application is released in the OpenSTLinux ecosystem to give a reference implementation for the calibration service.
See the page How to activate internal oscillators calibration for details.
5. References[edit | edit source]