PSDK 3.5 M30T Network connection not working / payload negotiate failing

Completed

Comments

5 comments

  • Josh

    I am having the same issue. Did you ever figure it out?

    0
    Comment actions Permalink
  • TuBsIMN

    Yes i actually found the solution. The problem is that the Pi is not properly starting the USB-RNDIS.

    First you need to set the correct cmdline.txt and config.txt values you can find everywhere on "usb-gadget" tutorials. But DO NOT insert the g_ether value in cmdline.txt.

    Then you need to create a script that starts the RNDIS and execute that as root (on bootup) while the dnsmasq service is configured and running. You then need to connect the Pi to a different Linux machine and check if the usb0 connection is recognized by the other maschine and get the correct VID and PID from lsusb (or get it from the script, you have to set those values yourself). After that insert these values into the network.h file, compile again and you should be good to go.

    If everything works you should see a usb0 connection in "ifconfig -a" and get the 10.55.0.1 IPv4 address. After you successfuly connect to the drone and the payload negotiate finishes this ip gets changed because the drone is then the host. The "Waiting payload negotiate finish" should also take more time and only come approx. 2 times if it works.

    PS: You need to connect the Pi with a USB-C cable directly from its power input to the drone. It does not work if you connect the drone to one of the USB-A ports.

    PPS: Even if the usb0 connection is correct and works fine you can not ping the drone which is weird but apparently normal. But you should be able to ping a different linux maschine if you connect the pi to that.

    I do not have access to my script but this is a helpful tutorial which explains most of it:
    https://raspiproject.altervista.org/raspberry-pi-4-as-usb-c-gadget/

    I hope i can help somebody. This took me so much time to figure out.

    1
    Comment actions Permalink
  • Larry

    TuBsIMN could you let me know how you compiled the Payload SDK example code on the Raspberry Pi 4? I am having issues compiling it. I get the following error:

    libpayloadsdk.a: error adding symbols: file format not recognized

    0
    Comment actions Permalink
  • TuBsIMN

    Hi Larry, you need to modifiy the top level CMakeLists.txt to include the correct psdk library for the Pi4 processor architecture. The one that worked for me is the psdk_lib/lib/arm-linux-gnueabihf-gcc/libpayloadsdk.a.

    Either hardcode this path in the corresponding lines or better add another elseif that checks for the pi architecture and sets the correct path.

    1
    Comment actions Permalink
  • Josh

    Hi TuBsIMN. I have been trying for weeks to implement what you've suggested. I am wondering if you have any other advice. I will describe my system in detail. 

    • I have set up the usb0 network according to the script you linked.

    usb0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 10.55.0.1  netmask 255.255.255.248  broadcast 10.55.0.7
            inet6 fe80::2dd:dcff:feeb:6da1  prefixlen 64  scopeid 0x20<link>
            ether 00:dd:dc:eb:6d:a1  txqueuelen 1000  (Ethernet)
            RX packets 0  bytes 0 (0.0 B)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 0  bytes 0 (0.0 B)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

    • I have configured dji_sdk_config.h to use UART and network device:

    /* Define to prevent recursive inclusion -------------------------------------*/
    #ifndef DJI_SDK_CONFIG_H
    #define DJI_SDK_CONFIG_H

    /* Includes ------------------------------------------------------------------*/

    #ifdef __cplusplus
    extern "C" {
    #endif

    /* Exported constants --------------------------------------------------------*/
    #define DJI_USE_ONLY_UART                  (0)
    #define DJI_USE_UART_AND_USB_BULK_DEVICE   (1)
    #define DJI_USE_UART_AND_NETWORK_DEVICE    (2)

    /*!< Attention: Select your hardware connection mode here.
    * */
    #define CONFIG_HARDWARE_CONNECTION         DJI_USE_UART_AND_NETWORK_DEVICE

    /* Exported types ------------------------------------------------------------*/

    /* Exported functions --------------------------------------------------------*/

    #ifdef __cplusplus
    }
    #endif

    #endif // DJI_SDK_CONFIG_H

    • I have configured hal_network.h to use usb0 and just set up the same USB VID/PID for my USB device as you have:

    /* Define to prevent recursive inclusion -------------------------------------*/
    #ifndef HAL_NETWORK_H
    #define HAL_NETWORK_H

    /* Includes ------------------------------------------------------------------*/
    #include "dji_platform.h"

    #ifdef __cplusplus
    extern "C" {
    #endif

    /* Exported constants --------------------------------------------------------*/

    /** @attention  User can config network card name here, if your device is not MF2C/G, please comment below and add your
     * NIC name micro define as #define 'LINUX_NETWORK_DEV   "your NIC name"'.
     */
    #ifdef PLATFORM_ARCH_x86_64
    #define LINUX_NETWORK_DEV           "usb0"
    #else
    #define LINUX_NETWORK_DEV           "usb0"
    #endif
    /**
     * @attention
     */

    #ifdef PLATFORM_ARCH_x86_64
    #define USB_NET_ADAPTER_VID                   (0x0525)
    #define USB_NET_ADAPTER_PID                   (0xA4A2)
    #else
    #define USB_NET_ADAPTER_VID                   (0x0525)
    #define USB_NET_ADAPTER_PID                   (0xA4A2)
    #endif

    #define LINUX_CMD_STR_MAX_SIZE      (128)

    /* Exported types ------------------------------------------------------------*/

    /* Exported functions --------------------------------------------------------*/
    T_DjiReturnCode HalNetWork_Init(const char *ipAddr, const char *netMask, T_DjiNetworkHandle *halObj);
    T_DjiReturnCode HalNetWork_DeInit(T_DjiNetworkHandle halObj);
    T_DjiReturnCode HalNetWork_GetDeviceInfo(T_DjiHalNetworkDeviceInfo *deviceInfo);

    #ifdef __cplusplus
    }
    #endif

    #endif // HAL_NETWORK_H

    • If I connect with UART only, I get a success:

    [0.013][core]-[Info]-[DjiCore_Init:101) Payload SDK Version : V3.5.0-beta.0-build.1765 
    [1.065][adapter]-[Info]-[DjiAccessAdapter_Init:186) Identify aircraft series is Matrice 350 Series 
    [1.066][adapter]-[Info]-[DjiAccessAdapter_Init:206) Identify mount position type is Extension Port Type 
    [1.076][adapter]-[Info]-[DjiAccessAdapter_Init:301) Identity uart0 baudrate is 921600 bps 
    [3.103][adapter]-[Info]-[DjiPayloadNegotiate_Init:197) Waiting payload negotiate finish. 
    [4.103][adapter]-[Info]-[DjiPayloadNegotiate_Init:201) No need wait negotiate finished 
    [6.167][adapter]-[Info]-[DjiPayloadNegotiate_Init:197) Waiting payload negotiate finish. 
    [7.167][adapter]-[Info]-[DjiPayloadNegotiate_Init:201) No need wait negotiate finished 
    [8.804][core]-[Info]-[DjiIdentityVerify_UpdatePolicy:470) Updating dji sdk policy file... 
    [9.804][core]-[Info]-[DjiIdentityVerify_UpdatePolicy:473) Update dji sdk policy file successfully 
    [9.828][core]-[Info]-[DjiCore_Init:169) Identify AircraftType = Matrice 350 RTK, MountPosition = Extension Port, SdkAdapterType = None 
    [9.844][core]-[Info]-[DjiCore_ApplicationStart:239) Start dji sdk application 
    [9.844][user]-[Info]-[DjiUser_ApplicationStart:261) Application start. 
    [10.577][infor]-[Info]-[DjiAircraftInfo_NotifyMobileAppInfoHandle:589) Set mobile app info, language is English, screen type is Big Screen

    However, if I try to use the network device I get similar negotiation errors as you did.

    [0.014][core]-[Info]-[DjiCore_Init:101) Payload SDK Version : V3.5.0-beta.0-build.1765 
    [1.088][adapter]-[Info]-[DjiAccessAdapter_Init:186) Identify aircraft series is Matrice 350 Series 
    [1.088][adapter]-[Info]-[DjiAccessAdapter_Init:206) Identify mount position type is Extension Port Type 
    [1.098][adapter]-[Info]-[DjiAccessAdapter_Init:301) Identity uart0 baudrate is 921600 bps 
    [3.136][adapter]-[Info]-[DjiPayloadNegotiate_Init:197) Waiting payload negotiate finish. 
    [4.136][adapter]-[Info]-[DjiPayloadNegotiate_Init:197) Waiting payload negotiate finish. 
    [5.137][adapter]-[Info]-[DjiPayloadNegotiate_Init:197) Waiting payload negotiate finish. 
    [6.137][adapter]-[Info]-[DjiPayloadNegotiate_Init:197) Waiting payload negotiate finish. 
    [7.137][adapter]-[Info]-[DjiPayloadNegotiate_Init:197) Waiting payload negotiate finish. 
    [8.137][adapter]-[Error]-[DjiAccessAdapter_Init:312) Payload negotiate error, returnCode = 225 
    [8.137][adapter]-[Error]-[DjiAccessAdapter_Init:318) Payload negotiate error, returnCode = 225 
    [8.137][core]-[Error]-[DjiCore_Init:121) Access adapter init error, stat:225 
    terminate called after throwing an instance of 'std::runtime_error'
      what():  Core init error.
    Aborted

    I don't know what I'm doing wrong. I have gotten it working on the Jetson Nano relatively easily. That one instantiates a network bridge by default though, and the connection is actually done through the network bridge. I wonder if the fact that I'm using a Matrice 350 instead of Matrice 30 also means that the configuration must be different. I really wish this was actually documented somewhere because this is some of the most frustrating BS I have had to deal with in a long time.

    DJI Developer Support You guys are slacking and have not responded to this post even once. Please do your job and support your clients.

    0
    Comment actions Permalink

Please sign in to leave a comment.