Mistake on this page? Email us

Porting the Device Management Update client to systems running Edge Core

The update process in Linux is driven mainly by shell scripts that you can adapt to a new target. To learn more about the scripts and how to configure them for your system, please read the instructions provided in the Linux update implementation section of the Porting devices document.

Integrating update with Pelion Edge

The Pelion Edge Yocto image for the Raspberry Pi 3 Model B+ target has two parts:

Note: The scripts are examples and are designed to work only with the Pelion Edge Yocto image. Please modify the scripts for your requirements.

The scripts require the image to support OverlayFS and these partitions:

  • factory: A read-only, lower directory file system that contains the image burned at the factory.
  • upgrade: A read-only, lower directory file system overlaid on top of the factory file system. By default, the directory is empty. This partition stores the files applied during the firmware update process.
  • user: A read-write, upper directory file system that contains the files you modify.
  • boot: A read-write partition that contains the boot loader.
  • userdata: A read-write partition to store the Linux user space program data. The data stored in this partition is protected during the factory update process unless you perform a factory reset.

In this example, the system uses these shell scripts to perform a firmware update:

  • arm_update_activate.sh: This script runs after Edge core downloads the firmware image.

    1. The firmware update process erases the user partition and copies the files to the upgrade partition. To protect the files during this process, you need to copy them to the userdata partition, which is protected.

      Therefore, the script copies the header file, which contains the metadata associated with the firmware image, to a directory under userdata:

      cp $HEADER /userdata/extended/header.bin
      

      After the firmware update is applied, Edge core uses this header file to verify whether the update was successful.

    2. Save the Pelion Edge service logs:

      cp -R /wigwag/log/* /userdata/.logs-before-upgrade/
      

      You might need these logs for debugging after the update.

    3. Save the firmware image on the file system:

      mv $FIRMWARE /upgrades/firmware.tar.gz
      
    4. Unpack the firmware tarball into the user partition under the /upgrades folder and reboot the gateway:

      tar -xzf /upgrades/firmware.tar.gz -C /upgrades/
      

      The update process starts when the system detects the required files.

    5. Exit the script with the appropriate error code. If the code is a nonzero value, Edge core notifies Pelion Device Management the update has failed.

  • arm_update_active_details.sh: Returns the version (and associated metadata) of the active (running) firmware.

    1. Provide the header file you saved before the start of firmware update process:

      cp /userdata/extended/header.bin $HEADER
      
    2. Exit the script with the appropriate error code. If the code is a nonzero value, Edge core notifies Pelion Device Management the update has failed.

  • arm_update_cmdline.sh: This file parses the command-line parameters passed to the shell scripts when called by the C source file specified in the pal-linux/source directory. In this case, it's the update source file for Yocto target.