Skip to content

Instantly share code, notes, and snippets.

@Williangalvani
Last active September 18, 2024 17:03
Show Gist options
  • Save Williangalvani/cf07ee4aff9050185e61f62cb4d674fa to your computer and use it in GitHub Desktop.
Save Williangalvani/cf07ee4aff9050185e61f62cb4d674fa to your computer and use it in GitHub Desktop.
bulding and debugging ardusub dev with gcc 10.2 for navigator

Instructions for building and debugging ArduSub in Blueos

This uses a fixed gcc version, 10.2, as that is what ardupilot is using, and seems to play along fine with glibc and gdbserver in blueos.

10.3 WILL NOT WORK IN BLUEOS

wget --no-clobber http://new.galvanicloop.com:8000/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf.tar.xz
tar -xxvf gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf.tar.xz
git clone --recurse-submodules --branch Sub-4.1 https://github.com/ArduPilot/ardupilot.git


pip install future

Build the firmware with debug symbols:

LIB_RT="/home/will/raspbian_libs/glibc_2.31_extracted/lib/arm-linux-gnueabihf/"
TOOLCHAIN="$PWD/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf"

cd ardupilot
./waf configure \
  --board Navigator \
  --toolchain "${TOOLCHAIN}" \
  --debug

Upload the file to BlueOS. it will generate a pretty large file, with roughly 20MB, when regular firmware is 2MB.

It will look like nothing works, gdbserver will only start it once a client connects.

For debugging with GDB using VsVode:

create this debug configuration in VSCode: launch.json: change the path to where your gcc-arm install is located


{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [

    // The attach profiles are used to connect to a running instance of SITL (ie the executable)
        {
            "name": "(gdb) Attach to Sub on Navigator",
            "type": "cppdbg",
            "request": "launch",
            "targetArchitecture": "arm",
            "miDebuggerPath": "/home/will/arm-gcc/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-gdb",
            "miDebuggerArgs": "--cd=${workspaceFolder} --nx",
            "MIMode": "gdb",
             "program": "${workspaceFolder}/build/navigator/bin/ardusub",
              "setupCommands": [
                {"text": "set remotetimeout 5"},
                {"text": "target remote blueos.local:5555"},
                {"text": "set sysroot target:"},
            ],
            "launchCompleteCommand": "None",
            "externalConsole": false,
            "cwd": "${workspaceFolder}"
        }
    ]
}
@clydemcqueen
Copy link

Thanks for this. A few questions:

Re: gcc 10.2, I'm using gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf -- I assume this is OK?

In general, why are these 3 libraries required? I can compile and run on the Pi4 under BlueOS w/o them using the ARM gcc 10.2 toolchain. (But I am seeing strange behavior after ~15 minutes, so perhaps I have answered my own question.)

I don't see librt at https://archive.raspbian.org/raspbian/pool/main/g/glibc/ -- is there another location?

For libc the latest version appears to be deb11u6 (vs u3) -- OK to use?

@Williangalvani
Copy link
Author

@clydemcqueen I haven`t needed the lib anymore, so I dropped it out of the gist.
I uploaded a tar file of the compiler to my personal server, for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment