STM32MP13 Tamper configuration

Applicable for STM32MP13x lines

1 Overview[edit]

The STM32 MPUs embed tamper detection management. Tamper management and configuration have been added to the secure OS to select and detect events.

STM32MP13 microprocessors offer 13 internal tampers and 8 external tampers.

The internal tampers are the following:

  • Backup domain voltage threshold monitoring
  • Temperature monitoring
  • LSE monitoring
  • HSE monitoring
  • RTC calendar overflow
  • JTAG/SWD access
  • ADC2 analog watchdog monitoring 1
  • Monotonic counter 1 overflow
  • Cryptograpic IPs fault (SAES or CRYP or PKA or TRNG)
  • Monotonic counter 2 overflow
  • IWDG reset when tamper flag is set
  • ADC2 analog watchdog monitoring 2
  • ADC2 analog watchdog monitoring 3

External tampers can be configured to be passive (detect a level or an hedge on one pin) or active (2 pins have to be linked together, and tamp hardware regularly send a random level on the OUT pin, then read IN pins and raise tamper if values mismatch).

On a tamper event detection, the backup registers are cleared and secrets in SRAM3, SAES, CRYP, HASH peripherals and PKA SRAM are erased also.

The Automatic erase mode can be configured for any tampers (internal and external). It is enabled by default but can be turned off (NOERASE) if the user application needs to control erase operations, if disable the backup registers, SRAM3, and RHUK (root hardware unique key) in BSEC are locked (no read nor write are possible until event acknowledged) but SAES, CRYP, HASH peripherals and PKA SRAM are always erased.

The Backup SRAM can be added in the list of secret IPs, and will have same behavior as the SRAM3 (erased or locked).

2 Software configuration[edit]

The tamper driver only exists in the OP-TEE Internal and external tampers have to be configured in:

The device tree enable the TAMP ip and configure the external tamper (active, passive, level, etc...) The main.c activate the wanted TAMPER_ID, in ERASE or NOERASE mode, and define the callback to call in case of event. An external TAMPER can be activate only if the corresponding TAMPER_ID is enable in device tree.

Example :

static uint32_t int_tamp1_callback(int id) {
	MSG("Backup domain voltage threshold monitoring tamper event occurs");
	
	/* ... */
	/* specific application event management */
	/* ... */
	
	return TAMP_CB_ACK_AND_RESET; 
}

stm32_tamp_activate(INT_TAMP1, TAMP_ERASE, tamp1_callback);

Value return by the callback define if the driver will ack the event, and reset the board. If the event is configured as NOERASE, the callback may check if true positive, and if yes, erase manually secret (with stm32_tamp_erase_secret()) and return TAMP_CB_ACK_AND_RESET, if false positive, juste return TAMP_CB_ACK (this will unlock secret IPs).

The main.c configure also the permission access of the TAMP register (privileged mode, secure mode), and if Backup SRAM is include in the secret IPs list.


2.1 Internal tampers[edit]

By default, only internal tampers 1, 2, 3 , 4, 7, 12 and 13 are enabled, configure as ERASE, and the callback will reset the board.

2.2 External tampers[edit]

On STM32MP13 Discovery Board only external tamper 2 is activated in main.c and enabled in device tree. Pressing the TAMP button will raise the EXT_TAMP2 event, erase all secret and reset the board.