Local Upgrade

No Rating


Local upgrade is a function for upgrading the firmware of the payload device. Developers can use the local update function to facilitate users to select the local firmware file through DJI Assistant 2 to update the firmware of the payload device.

Firmware transfer protocol

When developing the local upgrade function, you can call the interface DjiUpgrade_Init to specify the transmission protocol and configure the transmission setting information.

Using FTP protocol

PSDK supports developers to use FTP protocol to transfer firmware to be upgraded. When developers use FTP protocol to transfer firmware, they need to deploy the corresponding FTP server for the load device. For details, please refer to Deploying FTP Server.


  • Only load devices developed based on the Linux platform support the developer to use the FTP protocol to transfer the firmware to be upgraded through the network port.
  • When using the FTP protocol to transfer the payload device firmware, the user account is: psdk_payload_ftp The password is: DJi_#$31FTP

Using DCFTP protocol

DCFTP, DJI Common File Transfer Protocol, is DJI's unique file transfer protocol. Developers can obtain the required files by calling the specified interface. When using the DCFTP protocol to upgrade the firmware of the payload device, please refer to T_DjiUpgradeDcftpFileTransferOpt to learn how to obtain the firmware, and initialize the structure when calling the DjiUpgrade_Init() interface.


  • This method can be used to transfer firmware using RTOS or load device without network port.
  • Since this method uses the command signal transmission channel to transmit firmware, the transmission speed is slower.

Deploy FTP server

To facilitate developers use the FTP protocol to transfer the firmware required for the payload device, please follow the steps below to deploy the FTP server using vsftpd.

1. Install FTP server

  1. Download vsftpdopen in new window.
  2. Install the vsftpd server installation package:

Instructions: For the complete installation method, please refer to the INSTALL file in the directory to install vsftpd.

  • Use tar -zxvf vsftpd-*.*.*.tar.gz command to extract the installation package
  • Go to cd vsftpd-*.*.*/ directory
  • Install the FTP server in the following order:
cp vsftpd /usr/local/sbin/vsftpd
cp vsftpd.conf.5 /usr/local/man/man5
cp vsftpd.8 /usr/local/man/man8
cp vsftpd.conf /etc
  1. Create the secure_chroot_dir directory: mkdir /usr/share/empty

2. Configure FTP server

  1. Modify the configuration items:
  • In /etc/vsftpd.conf file, change anonymous_enable to NO
  • Set the following configuration items:
  1. Add users
  • Using the adduser command, specify the user directory with --home
  • Use userdel -r command to delete users
  • Add user permission to upgrade payload device firmware: adduser psdk_payload_ftp --home /upgrade
  • Enter the password according to the prompt: DJi_#$31

3. Run the FTP server

  1. Run the FTP server using sudo /usr/local/sbin/vsftpd & command
  2. Configure startup items: add /usr/local/sbin/vsftpd & to /etc/rc.local
  3. Use the command ps aux | grep vsftpd to check the running status of the FTP service

Implement local upgrade function

1. Local upgrade module initialization

Before using the local upgrade function, please initialize the upgrade module and specify the transmission protocol used to upgrade the firmware.

returnCode = DjiUpgrade_Init(&upgradeConfig);
USER_LOG_ERROR("DjiUpgrade_Init error, return code = %d", returnCode);
return returnCode;

2. Enable local upgrade function

Before using the local upgrade function, users need to enable the local upgrade function. After enabling the local upgrade function, DJI Assistant 2 will display the upgrade interface of the load device, and the user can select the desired firmware file to upgrade the load device.

returnCode = DjiUpgrade_EnableLocalUpgrade();
USER_LOG_ERROR("DjiUpgrade_EnableLocalUpgrade error, return code = %d", returnCode);
return returnCode;

3. Upgrade process

The developer implements the function of local upgrade of the load device according to the structure T_DjiUpgradeHandler, and registers the callback function of the local upgrade of the load device through the DjiUpgrade_RegHandler() interface; pushes the upgrade state of the load device through the function DjiUpgrade_PushUpgradeState().

Use local upgrade function

Run the program with the upgrade function

Please refer to Run the sampleopen in new window when using the "local upgrade" function, and compile the program that currently supports the local upgrade function.

Linux platform operating environment adjustment

In order to use the upgrade function, you need to set the program to start by default, please refer to the following steps:

  1. Copy the compiled application to the /usr/local/bin/ directory;
  2. Add the following configuration items in /etc/rc.local:
  • chmod 666 /dev/ttyUSB0
  • chmod 755 /usr/local/bin/dji_sdk_demo_linux
  • /usr/local/bin/dji_sdk_demo_linux&

Note: ttyUSB0 is the serial port device connected to the load device, the developer can modify the name according to the actual situation

  1. Restart the load device and check whether the program is running normally through the terminal command ps aux | grep dji_sdk_demo_linux
STM32F4 platform operating environment adjustment

To use the local upgrade function on the STM32F4 platform, the developer needs to burn the Bootloader into the development platformopen in new window, and then burn the firmware of the load device. The STM32F4Platform in the following directory can be psdk_development_board_1.0 (use the load device development board) or stm32f4_eval (use the STM32 development board).

  1. Burn the Bootloader into the microcontroller, and the Bootloader project directory is:
  • samples/sample_c/platform/rtos_freertos/stm32f4_discovery/project/mdk_bootloader
  1. Burn the application firmware into the microcontroller. The application firmware directory is:
  • samples/sample_c/platform/rtos_freertos/stm32f4_discovery/project/mdk


  • Bootloader is a program that runs when the MCU is powered on to update the application firmware and execute the application firmware.
  • Application firmware: realize the software function of the load device, compile the Payload SDK Lib.

Compile the firmware

  1. Modify the firmware version number Modify the version number of the firmware in the T_DjiTestUpgradeConfig structure definition.

Note: When modifying the version number, the version number must not be lower than the current version, that is, when the current firmware version number used by the load device is V02.01.00.03, please change the version number to V02.01.00.04, as follows example shown.

T_DjiTestUpgradeConfig testUpgradeConfig = {
.firmwareVersion = {1, 0, 0, 0},
.needReplaceProgramBeforeReboot = true
  1. Compile the file Compile the firmware files required for the upgrade of the load device:
  • STM32: The firmware of the load device is the dji_sdk_demo_linux.bin file in the STM32F4 project directory
  • Linux: The firmware of the load device is the compiled dji_sdk_demo_linux program file
  1. Modify the firmware file name After recompiling the firmware file, you need to modify the name of the compiled firmware, such as PSDK_APPALIAS_V02.01.00.04.bin. File name format: Product Name_Vaa.bb.cc.dd.bin
  • Product Name: load product name (if the developer has set a load alias, the name will be the load alias)
  • Vaa.bb.cc.dd: four-digit version number for the payload

Note: The version number in the firmware file name must be consistent with the version number defined in the code, otherwise the load device may fail to upgrade.

Using DJI Assistant 2 to upgrade the firmware

Open DJI Assistant 2 and select the compiled firmware upgrade file (PSDK_APPALIAS_V02.01.00.04.bin) to upgrade the firmware.

Figure 1. Using DJI Assistant 2 to upgrade the firmware of the payload

Sample upgrade principle introduction

Linux program file upgrade principle

Using the upgrade function, you can obtain the firmware file that needs to be updated (through FTP or DCFTP protocol), replace the firmware file with the original running program file, and complete the firmware upgrade after the system restarts.

Related References

  • Load device upgrade process: module_sample/upgrade/
  • Use local upgrade function: platform/linux/manifold2/application/main.c
  • Upgrade firmware for payloads developed on Linux platforms: platform/linux/common/upgrade_platform_opt

STM32F4 microcontroller program upgrade principle

The load device developed by STM32F4 directly reads the firmware file from the Flash and runs the load device program, so the developer needs to burn the Bootloader first and then the application firmware. For the steps of burning the Bootloader, please refer to Run the sampleopen in new window.

STM32F4 firmware upgrade process
  1. After the STM32F4 platform is powered on, it will start the MCU
  2. Run Bootloader and judge the upgrade status:
  • If there is no need to upgrade the firmware, the Bootloader will jump to the application firmware area and run the application firmware
  • If you need to upgrade the firmware of the load device, the Bootloader will jump to the application firmware area after replacing the firmware file, and run the application firmware

Related References

  • Implement Bootloader: platform/rtos_freertos/stm32f4_discovery/bootloader
  • Bootloader project directory: platform/rtos_freertos/stm32f4_discovery/project/mdk_bootloader
  • Implement the upgrade function: api_sample/upgrade/
  • STM32F4 upgrade: platform/rtos_freertos/stm32f4_discovery/drivers/upgrade_platform_opt_stm32
  • Initialize the upgrade function: platform/rtos_freertos/stm32f4_discovery/application/application.c

Note: stm32f4_discovery in the above directory can be either psdk_development_board_1.0 or stm32f4_eval.

Modify Flash address space (optional)
  1. Modify the address definition: Modify the address definition in the platform/rtos_freertos/STM32F4Platform/drivers/BSP/flash_if.h file
/* End of the Flash address */

/* Define the address from where user application will be loaded.
NOTE the 1st sector 0x08000000-0x08007FFF is reserved for the IAP code */

/* Define the user application size */

/* Define the address from where user application will be stored in upgrade mode */

/* Define the address for param store */

Address assignment statement:

  • bootloader: 0x08000000~0x08007FFF
  • Parameter Store Area: 0x08008000~0x0800FFFF
  • Application Firmware: 0x08010000~0x0807FFFF
  • Upgrade Firmware Store Area: 0x08080000~0x080FFFFF
  1. Configure the interrupt vector In the platform/rtos_freertos/STM32F4Platform/drivers/CMSIS/Device/Source/system_stm32f4xx.c file, fill in the offset address of the application firmware
/*!< Uncomment the following line if you need to relocate your vector Table in
Internal SRAM. */
/* #define VECT_TAB_SRAM */
//attention : this value is equal ( application address - 0x08000000 )
#define VECT_TAB_OFFSET 0x10000
#define VECT_TAB_OFFSET 0x00
  1. Modify the project configuration information Modify the project configuration information in Bootloader and application firmware, and fill in the correct Flash address.
  • Bootloader project directory: platform/rtos_freertos/stm32f4_discovery/project/mdk_bootloader
  • Application firmware project directory: platform/rtos_freertos/stm32f4_discovery/project/mdk

Figure 2. Modify project configuration information