Last edited one year ago

How to activate HSI and CSI oscillators calibration

Applicable for STM32MP13x lines, STM32MP15x lines

1. Article purpose[edit | edit source]

The purpose of this article is to explain how to calibrate the HSI and CSI oscillators in the RCC, by using the OP-TEE Calibration PTA. The Linux client application, periodically called by a systemd[1] service. This systemd service is linked to a systemd timer, which defines when to call the application.

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 HSI or CSI) and a clock that is derived from the HSE clock that is considered as always accurate.

Refer to STM32MP13 reference manuals or STM32MP15 reference manuals for detailed information on the timer channels that can be used for HSI or CSI 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.

4. References[edit | edit source]

  1. https://optee.readthedocs.io/en/latest/architecture/trusted_applications.html
  2. https://systemd.io/
  3. https://optee.readthedocs.io/en/latest/architecture/globalplatform_api.html