Last edited 2 weeks ago

How to activate internal oscillators calibration

Applicable for STM32MP13x lines  STM32MP15x lines    STM32MP23x lines  STM32MP25x lines


1. Article purpose[edit | edit source]

The purpose of this article is to explain how to calibrate internal oscillators in the RCC, by using the OP-TEE Calibration PTA[1]. In OpenSTLinux systemd [2], the client application is periodically called by a timer service[3].

These clocks are internal oscillators whose frequency can be affected by temperature and voltage variations. To achieve a good clock accuracy, it is important to provide a mechanism to compensate the effects of these variations.

The clock calibration algorithm is based on the comparison of a timer (fed by internal oscillators) and a clock that is derived from the HSE clock that is considered as always accurate.

Refer to STM32 MPU reference manuals for detailed information on the timer channels that can be used for internal oscillator calibration input.

2. Linux Daemon[edit | edit source]

The Linux calibration client relies on the fact that STM32MPU boards supports the systemd suite that starts the system. This suite handles daemons execution with a huge quantity of settings.

Regarding clock calibration: a service, responsible for executing the client calibration binary is linked to a timer.

You can change the timer settings by editing the Timer section in the stm32mp-calibration.timer file. By default, the timer trigger is set to 1 minute with an accuracy of 5 seconds, using the systemd timer OnCalendar and AccuracySec settings:

   [Timer]
   Unit=stm32mp-calibration.service
   OnBootSec=1min
   OnCalendar=*-*-* *:*:00
   AccuracySec=5sec

The Unit setting is used to specify which service should be called when the timer is triggered. The OnBootSec setting specifies the time after boot at which the timer should start.

This daemon is part of a specific OP-TEE add-ons repository: stm32mp-calibration/ , with systemd service in scripts and the Client Application (CA) source in host .

3. OP-TEE PTA[edit | edit source]

The calibration binary is a Client Application (CA) connected to the OP-TEE Calibration PTA.

This PTA must be activated in OP-TEE with OP-TEE_Calibration_PTA_overview#Configuration compilation flag and device tree.

4. References[edit | edit source]