Skip to main content

Local Upgrade

Overview

Local upgrade is a function used to upgrade the firmware of payload devices. With the local upgrade feature, developers can conveniently provide users with the ability to install local firmware upgrade package files to upgrade the firmware of the payload devices.

Firmware Transfer Protocol

When developing the local upgrade function, developers can call the UAV_Upgrade_init interface to specify the transfer protocol and configure the transfer settings.

Using UAVFTP Protocol

UAVFTP, or UAV Common File Transfer Protocol, is Autel's proprietary file transfer protocol. Developers can obtain the necessary files by calling the specified interface. When upgrading the payload device firmware using the UAVFTP protocol, refer to UAV_Upgrade_FirmwareDownload to understand the method of obtaining the firmware, and initialize the structure when calling the UAV_Upgrade_init() interface.

Note:

  • This transfer method can be used for devices running Linux or devices without network ports.
  • The transfer speed is typically slow, as it uses command signal transmission to transfer the firmware.

Implementing Local Upgrade Functionality

1. Local Upgrade Module Initialization

Before using the local upgrade function, initialize the upgrade module and specify the transfer protocol used during the firmware upgrade.

returnCode = UAV_Upgrade_init(&g_uavUpgradeHandler);
if (returnCode != 0) {
LOG_INFO("UAV_Upgrade_init error, return code = %d", returnCode);
return returnCode;
}

2. Upgrade Process

Developers should implement a function for local firmware upgrades based on the T_UAVUpgradeHandler structure and register the payload device's local upgrade callback function via the T_UAVUpgradeHandler() interface. Use the UAV_Upgrade_Query() function to query the upgrade status of the payload device.

Using the Local Upgrade Function

Running the Program with Upgrade Functionality

When using the local upgrade feature, refer to the example program for running instructions and compile the program that supports the local upgrade functionality.

Linux Platform Environment Setup

To use the upgrade function, set the program to start by default, following these steps:

  1. Copy the compiled program to the /usr/local/example/ directory.

    Enter the following commands in the terminal:

    • chmod 666 /dev/ttyUSB0
    • chmod 755 /usr/local/example/upgrade
    • /usr/local/example/upgrade&

    Note:

    • ttyUSB0 is the serial port device connecting to the payload device. Developers should modify the name based on the actual situation.
  2. Restart the payload device, and check if the program is running correctly by entering ps aux | grep upgrade in the terminal.

HC32F4 Platform Environment Setup

To use the local upgrade functionality on the HC32F4 platform, developers need to first burn the Bootloader to the development platform, and then burn the payload device firmware.

  1. Use the script to build and burn the Bootloader. The build script and product directory are:

    • samples\sample_c\platform\rtos_freertos\hc32f460\04_tools\all_make.bat
    • samples\sample_c\platform\rtos_freertos\hc32f460\04_tools\release
  2. Build and Burn Firmware Based on SDK lib

    • Refer to the samples\sample_c\platform\rtos_freertos\hc32f460\02_app\projects\app.uvprojx project.

Note:

  • The Bootloader is a program that runs when the MCU powers on. It is used to update the application firmware and execute the application firmware.
  • Application firmware: Implements the software functionality of the payload device, compiled with Payload SDK Lib.

Sample Upgrade Principle Introduction

Linux Program File Upgrade Principle

The upgrade function allows the retrieval of firmware files that need to be updated (via the UAVFTP protocol). The firmware files replace the previously running program files, and the system completes the firmware upgrade upon reboot.

  • Related References:
  • Payload device upgrade process: example/upgrade.
  • Using the local upgrade function: example/upgrade.cxx.

HC32F4 Microcontroller Program Upgrade Principle

Payload devices developed for the HC32F4 platform read the firmware files directly from Flash memory and run the payload device program. Therefore, developers need to first burn the Bootloader, followed by burning the application firmware.

HC32F4 Firmware Upgrade Process

  1. After powering on the HC32F4 platform, the MCU will start.
  2. When the aircraft triggers the upgrade process, the upgrade file will be sent to the payload device through the upgrade interface, and the upgrade will proceed. For implementation details, refer to the run example program.

Related References:

  • samples\module_sample\test_upgrade.c