Recovery library (firmware update)

Recovery library implements an API that allows you to configure the different supported recovery commands and the reboot into recovery mode. This library is installed in the toolchain provided by Digi Embedded Yocto, so you can use it to develop your own custom application with support to trigger recovery commands. See Application development.

Using the library

To use the library you need to:

  1. Include the recovery header file in your application.
#include <recovery.h>
  1. Link against the recovery static library already included in the pre-compiled toolchain. See Application development. The library provides a pkg-config file recovery.pc, installed in the toolchain. To configure the proper compilation flags and linked libraries, add the following lines into your makefile:
[...]
 
CFLAGS += $(shell pkg-config --cflags recovery)
LDLIBS += $(shell pkg-config --libs --static recovery)
 
[...]

Implemented functions

These are the functions implemented on the current release:

Function Description
int update_firmware(const char *swu_path)

Configures recovery commands to update the firmware using the package specified in swu_path. It returns 0 on success, -1 on failure.

 

To start the update process you must call the reboot_recovery() function after this one.

int set_fs_encryption_key(const char *key)

Configures recovery commands to set a new file system encryption key. If key is empty or NULL, a random key will be generated. It returns 0 on success, -1 on failure.

 

To set the new configured encryption key you must call the reboot_recovery() function after this one.

 

CAUTION! Setting an encryption key without an update package to program causes the device not to boot.

int reboot_recovery(unsigned int reboot_timeout)

Reboots into recovery mode after reboot_timeout seconds. It returns -1 on failure, otherwise it does not return, the system reboots.

 

The configured recovery commands will be applied after booting in recovery mode.

int wipe_update_partition(void)

Configures recovery commands to wipe and format the update partition. It returns 0 on success, -1 on failure.

 

To start the wipe process you must call reboot_recovery() function after this one.

Example code