FOTA Update

FOTA stands for Firmware Over the Air, allowing you to update the on-board sketch binary using Wi-Fi.

The LHTTPUpdate library allows you to download a FOTA binary from a given HTTP URL, and apply it to LinkIt 7697.

Example

  • Upgrade your LinkIt 7697 Arduino BSP to v0.10.5 or later version.

  • Select LinkIt 7697 from Tools > Board menu.

  • Open Examples > LHTTPUpdate > LHTTPUpdate

  • Change the ssid and pass according to your Wi-Fi AP setting:

    char ssid[] = "yourapssid";      // your WPA2 network SSID (AP name)
    char pass[] = "yourpassword";    // your WPA2 network password
  • Click Upload to upload the sketch to LinkIt 7697

  • After upload, open the Serial Monitor

  • You should see the following message:

    HTTPUpdate example begins.
    Attempting to connect to SSID: yourssid
    Connected to wifi
    Begin downloading new firmware
    Press RST key to reboot to updated firmware version.
    After reboot, it may take a while to update the firmware.
    The USR LED lights up during the update process.

    This means the example is now downloading the new binary from the URL http://download.labs.mediatek.com/resource/fota_example.bin

  • Press RST button to reboot and replace on-board binary with the downloaded sketch binary(fota_example.bin)

  • It may take sometime for the update process to complete. After complete, the board starts blinking - and the on-board sketch binary is now updated.

How It Works

The sketch downloads the "FOTA binary" from http://download.labs.mediatek.com/resource/fota_example.bin, using the following call:

fotaUpdater.update(fotaBinaryURL);

The FOTA binary is a processed sketch binary. It is compressed and checksum to ensure that corruptions can be detected during the update process.

During the update() method, the FOTA binary is written in to the FOTA region of the on-board flash. The on-board flash layout is shown below:

After finish downloading the FOTA binary, the update() method flags the FOTA region as ready to update.

After the system reboots, the bootloader detects new binaries in the FOTA region, uncompress and verifies it, and write the new binary to the CM4 firmware region.

And completes the FOTA operation.

How to Generate FOTA Binary

As we mentioned, the FOTA binary is a processed sketch binary. You can follow these steps to generate the FOTA binary:

Windows FOTA ROM Package Tool

We denote the FOTA ROM Package root folder as $FOTA_ROOT.

  • Copy $FOTA_ROOT\_ini\template\mt7697\FOTARomPacker.ini to _ini

  • Modify $FOTA_ROOT\_ini\FOTARomPacker.ini

    [General Setting]
    Base_Directory=.\_Load\mt7697
    
    [CM4 bin]
    File=fota_example.bin
    Start_Address=0x79000
    Partition_Size=0x1ED000
    Is_Compressed=true

    Modify the File attribute.

Do not change the Start_Address, Partiion_Size and Is_Compressed option. These settings must match the flash layout of LinkIt 7697.

  • Copy the sketch binary to $FOTA_ROOT\_Load\mt7697

  • Execute the script gen_image.bat

  • The generated FOTA binary is located in the _Output folder

After generating the FOTA binary, you can then host the binary in a HTTP server and use LHTTPUpdate.update() to download and apply the FOTA binary.

Last updated