DJI Payload SDK (PSDK)

repository·master·Indexed 19 days ago

https://github.com/dji-sdk/payload-sdk

A development kit for creating custom hardware payloads for DJI drones via X-Port, SkyPort, or extension ports. Supports Linux and RTOS platforms, including Manifold 3 and Matrice drone series. The SDK provides APIs for aircraft information, power management, data transmission, and firmware upgrades, along with tools like build_dpk.sh for generating .dpk application packages.

Tokens
11.9K
Snippets
26
Records
57
Agent score
65%

What's inside DJI Payload SDK

  1. Overview of DJI Payload SDK (PSDK)

    master

    The DJI Payload SDK (PSDK) is a development kit designed to enable developers to create payloads that can be mounted on DJI drones. By using hardware interfaces such as the X-Port, SkyPort, or extension port adapters, a payload can access drone information and resources.

    Common use cases for PSDK-enabled payloads include:

    • Automated Flight Controllers
    • Payload Controllers
    • Video Image Analysis Platforms
    • Mapping Cameras
    • Megaphones and Searchlights
  2. Understand the structure of FreeRTOS portable files

    master

    The FreeRTOS portable layer is organized into common kernel components and hardware/compiler-specific files. When configuring a port, you need to identify the correct directory based on your specific microcontroller architecture and compiler.

    • Common Components: Core kernel components are found in the base portable directories.
    • Memory Management: Sample memory allocators are located in FreeRTOS/Source/Portable/MemMang.
    • Hardware/Compiler Specifics: Files specific to a particular microcontroller or compiler are organized by directory name. The structure follows the pattern: FreeRTOS/Source/Portable/[compiler]/[architecture].

    If you only require a single specific port, you can ignore all other directories in the Portable folder.

  3. Match app.json identity and version with source code

    master

    To ensure successful installation of your .dpk package, you must synchronize the following fields in app.json with your application's source code:

    1. user_app_id: Must match the USER_APP_ID defined in your code.

      • C location: samples/sample_c/platform/linux/manifold3/application/dji_sdk_app_info.h (line 39)
      • C++ location: samples/sample_c++/platform/linux/manifold3/application/dji_sdk_app_info.h (line 39)
    2. firmware_version: Must match the firmwareVersion defined in your code.

      • C location: samples/sample_c/platform/linux/manifold3/application/main.c (line 99)
      • C++ location: samples/sample_c++/platform/linux/manifold3/application/application.cpp (line 183)
      • Format: xx.xx.xx.xx (four segments, 0-99 per segment, numbers and dots only).
  4. Understand the FreeRTOS kernel structure

    master

    The FreeRTOS kernel is organized into common core components and hardware-specific portable layers. When integrating or modifying the kernel, understand the following directory structure:

    • FreeRTOS/Source: Contains the core kernel logic common to all ports. The primary files are list.c, queue.c, and tasks.c.
    • FreeRTOS/Source/croutine.c: Implements optional co-routine functionality, typically reserved for extremely memory-constrained systems.
    • FreeRTOS/Source/Portable: Contains files specific to the target microcontroller (MCU) and/or the compiler being used.
    • FreeRTOS/Source/include: Contains the real-time kernel header files required for API access.
  5. Use file2c to embed binary files into C/C++ programs

    master

    The file2c command-line utility converts binary files into C source files (.h and .c). This allows you to embed external assets, such as images or configuration files, directly into your C or C++ project as byte arrays.

    # Example: Convert icon.png into icon_png.h and icon_png.c
    file2c icon.png
  6. Environment requirements for STM32F4 Discovery RTOS Sample

    master

    To run the Onboard SDK RTOS Sample on the STM32F407xG hardware, use one of the following recommended development environments:

    • Hardware: STM32F407xG (External Crystal Frequency: 8MHz)
    • IDE: Keil MDK v5.25.2.0
    • Toolchain: Armcc.exe V5.06 update 6 (build 750)
      • Assembler: Armasm.exe V5.06 update 6 (build 750)
      • Linker/Locator: ArmLink.exe V5.06 update 6 (build 750)
      • Library Manager: ArmAr.exe V5.06 update 6 (build 750)
      • Hex Converter: FromElf.exe V5.06 update 6 (build 750)

    Alternative Environment (CLion)

    • Hardware: STM32F407xG (External Crystal Frequency: 8MHz)
    • IDE: Clion 2021.1.3
    • C Compiler: gcc version 9.3.1 20200408 (GNU Arm Embedded Toolchain 9-2020-q2-update)
  7. Use build_dpk.sh to generate .dpk application packages

    master

    The build_dpk.sh tool is used to package an application into a .dpk installation package. It requires an input application configuration file (app.json) to define the package contents and metadata.

    Prerequisites

    • Python 3: A Python 3 environment must be installed.
    • dpkg: The dpkg tool must be available in your environment.

    Input Configuration

    The app.json file must follow specific filling specifications. You can find a reference implementation in the samples directory: samples/sample_c/platform/linux/manifold3/app_json/app.json

    For detailed instructions on how to populate the app.json fields, refer to the documentation located at: samples/sample_c/platform/linux/manifold3/app_json/README.md

    # Generate a .dpk package in the current directory
    build_dpk.sh -i ../../samples/sample_c/platform/linux/manifold3/app_json/app.json
    
    # Generate a .dpk package at a specific output path
    build_dpk.sh -i ../../samples/sample_c/platform/linux/manifold3/app_json/app.json -o ./my_app.dpk
  8. Setup the RTOS Sample for GD32F527 Development Board

    master

    This sample provides a Payload SDK RTOS implementation using FreeRTOS on the GD32F527ZMT7 hardware. To replicate the test environment, use the following specifications:

    Hardware Requirements

    • MCU: GD32F527ZMT7
    • External Crystal Frequency: 12MHz

    Toolchain and IDE

    • IDE: Keil MDK v5.26.2.0
    • Compiler/Assembler/Linker: Armcc.exe, Armasm.exe, ArmLink.exe, ArmAr.exe, and FromElf.exe (all version V5.06 update 6, build 750)

    Pin Definitions

    Ensure your hardware connections match these pin assignments:

    • Console UART: PC10 (TX), PC11 (RX)
    • Communication UART: PA9 (TX), PA10 (RX)
    • Interactive UART: PD8 (TX), PD9 (RX)
    • PPS PIN: PD2

    Console Settings

    • Baud Rate: 921600
  9. Configure app.json for .dpk package generation

    master

    The app.json file is a mandatory configuration file required to generate the .dpk application installation package. It contains metadata about your application, including identification, versioning, and localization.

    Critical Requirement: Several fields in app.json must strictly match the values defined in your source code. If these values do not match, the application will fail to install.

  10. Locate model files for new DJI hardware

    master

    For newer DJI models, model files are no longer maintained within the GitHub software package. Developers must visit the official DJI developer website to download the latest model files and review structural design standards.

    Visit the official documentation for the latest model instructions and design criteria: https://developer.dji.com/doc/payload-sdk-tutorial/en/model-instruction/payload-develop-criterion.html#structural-design-standards

  11. Choose the correct FreeRTOS port for ARM Cortex-M7

    master

    When running FreeRTOS on ARM Cortex-M7 microcontrollers within the PSDK environment, you must select a port based on the specific ARM Cortex-M7 core revision (e.g., 'r0p1').

    Selection Logic

    1. Identify your core revision: Check your microcontroller's documentation for the 'r' and 'p' numbers (e.g., r0p1).
    2. If your revision is r0p1: Use the specific Cortex-M7 r0p1 port. This port includes a minor errata workaround.
      • Path: /FreeRTOS/Source/portable/RVDS/ARM_CM7/r0p1
    3. If your revision is NOT r0p1: Use the ARM Cortex-M4F port. This is the recommended approach for all other revisions.
      • Path: /FreeRTOS/Source/portable/RVDS/ARM_CM4F
    4. If unsure: Use the r0p1 port, as it is compatible with all core revisions.