Skip to content

Ardupilot Debug Setup

Hardware Requirement

  • Debug Probe
    • Vimdrones STLinkV3 Probe - Purchase Link
    • Optical:
      • any stlink v2, v3
  • Device
    • Pixhawk4
    • SH1.00mm 6P/10P Pixhawk Standard Cable (Device has Pixhawk Standard Port Only)
    • Optical:
      • any ardupilot flight controller with SWD interface
      • any AP_Periph device with SWD interface

Wiring Diagram

Vimdrones STLinkV3 Probe pixhawk wiring diagram

Software Requirement

Build Ardupilot Firmware

In Terminal - Clone ardupilot project

git clone --recurse-submodules https://github.com/ArduPilot/ardupilot.git
cd ardupilot

  • Setup OS Dependency

  • Firmware Build

    ./waf configure --board Pixhawk4
    ./waf copter #change target type here, ie plane, rover 
    
    #check build result
    ➜  ardupilot git:(Copter-4.5.1) file build/Pixhawk4/bin/*
    build/Pixhawk4/bin/arducopter:             ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, with debug_info, not stripped
    build/Pixhawk4/bin/arducopter.apj:         ASCII text, with very long lines (65435)
    build/Pixhawk4/bin/arducopter.bin:         TTComp archive data, binary, 4K dictionary
    build/Pixhawk4/bin/arducopter_with_bl.hex: ASCII text
    

  • Bootloader Build
    ./waf configure --board Pixhawk4 --bootloader
    ./waf bootloader 
    
    #check build result
    ➜  ardupilot git:(Copter-4.5.1) file build/Pixhawk4/bootloader/*             
    build/Pixhawk4/bootloader/AP_Bootloader: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, with debug_info, not stripped
    ➜  ardupilot git:(Copter-4.5.1) file build/Pixhawk4/bin/AP_Bootloader.*
    build/Pixhawk4/bin/AP_Bootloader.apj: JSON data
    build/Pixhawk4/bin/AP_Bootloader.bin: TTComp archive data, binary, 4K dictionary
    build/Pixhawk4/bin/AP_Bootloader.hex: ASCII text
    
  • Create openocd target specific ie. Pixhawk4.cfg

    source [find interface/stlink.cfg]
    source [find target/stm32f7x.cfg]
    

  • Create vscode launch file .vscode/launch.json

    {
        "version": "0.2.0",
        "configurations": [
            {
                "name": "ArduCopter",
                "cwd": "${workspaceFolder}",
                "executable": "${workspaceFolder}/build/Pixhawk4/bin/arducopter",
                "liveWatch": {
                    "enabled": true,
                    "samplesPerSecond": 4
                },
                "request": "launch",
                "type": "cortex-debug",
                "servertype": "openocd",
                "configFiles": [
                    "${workspaceFolder}/Pixhawk4.cfg",
                ]
            },
            {
                "name": "AP_Bootloader",
                "cwd": "${workspaceFolder}",
                "executable": "${workspaceFolder}/build/Pixhawk4/bootloader/AP_Bootloader",
                "livewatch": {
                    "enabled": true,
                    "samplespersecond": 4
                },
                "request": "launch",
                "type": "cortex-debug",
                "servertype": "openocd",
                "configFiles": [
                    "${workspaceFolder}/Pixhawk4.cfg"
                ],
            },
        ]
    }