This is the documentation for the latest (main) development branch of Zephyr. If you are looking for the documentation of previous releases, use the drop-down menu on the left and select the desired version.

Hardware Information

Overview

The HW Info API provides access to hardware information such as device identifiers and reset cause flags.

Reset cause flags can be used to determine why the device was reset; for example due to a watchdog timeout or due to power cycling. Different devices support different subset of flags. Use hwinfo_get_supported_reset_cause to retrieve the flags that are supported by that device.

Configuration Options

Related configuration options:

API Reference

group hwinfo_interface

Hardware Information Interface.

Defines

RESET_PIN
RESET_SOFTWARE
RESET_BROWNOUT
RESET_POR
RESET_WATCHDOG
RESET_DEBUG
RESET_SECURITY
RESET_LOW_POWER_WAKE
RESET_CPU_LOCKUP
RESET_PARITY
RESET_PLL
RESET_CLOCK

Functions

ssize_t hwinfo_get_device_id(uint8_t *buffer, size_t length)

Copy the device id to a buffer.

This routine copies “length” number of bytes of the device ID to the buffer. If the device ID is smaller then length, the rest of the buffer is left unchanged. The ID depends on the hardware and is not guaranteed unique.

Drivers are responsible for ensuring that the ID data structure is a sequence of bytes. The returned ID value is not supposed to be interpreted based on vendor-specific assumptions of byte order. It should express the identifier as a raw byte sequence, doing any endian conversion necessary so that a hex representation of the bytes produces the intended serial number.

Parameters
  • buffer – Buffer to write the ID to.

  • length – Max length of the buffer.

Returns

  • size – of the device ID copied.

  • -ENOTSUP – if there is no implementation for the particular device.

  • any – negative value on driver specific errors.

int hwinfo_get_reset_cause(uint32_t *cause)

Retrieve cause of device reset.

This routine retrieves the flags that indicate why the device was reset.

On some platforms the reset cause flags accumulate between successive resets and this routine may return multiple flags indicating all reset causes since the device was powered on. If you need to retrieve the cause only for the most recent reset call hwinfo_clear_reset_cause after calling this routine to clear the hardware flags before the next reset event.

Successive calls to this routine will return the same value, unless hwinfo_clear_reset_cause has been called.

Parameters
  • cause – OR’d reset_cause flags

Returns

  • zero – if successful.

  • -ENOTSUP – if there is no implementation for the particular device.

  • any – negative value on driver specific errors.

int hwinfo_clear_reset_cause(void)

Clear cause of device reset.

Clears reset cause flags.

Returns

  • zero – if successful.

  • -ENOTSUP – if there is no implementation for the particular device.

  • any – negative value on driver specific errors.

int hwinfo_get_supported_reset_cause(uint32_t *supported)

Get supported reset cause flags.

Retrieves all reset_cause flags that are supported by this device.

Parameters
  • supported – OR’d reset_cause flags that are supported

Returns

  • zero – if successful.

  • -ENOTSUP – if there is no implementation for the particular device.

  • any – negative value on driver specific errors.