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}"
}
]
}
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?