Build Ardupilot for 64 bit linux

Hi All,

I tried to compile Arducopter to run on Arm Linux board. The generated executable file doesn’t run because it was for 32 bit.

is there anyway to compile the code to run directly on 64 bit linux ?

pi@pi:~ $ uname -a
Linux pi 6.6.31+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.31-1+rpt1 (2024-05-29) aarch64 GNU/Linux
pi@pi:~ $ sudo ./arducopter 
-bash: ./arducopter: cannot execute: required file not found
pi@pi:~ $ file arducopter 
arducopter: ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, BuildID[sha1]=77bb833d9786ba181c135561ff32f6227eabe619, for GNU/Linux 3.2.0, not stripped

I made search and found this comment:

To build for an autopilot target on Linux you need the following tools and git repositories:

  • The gcc-arm cross-compiler from here (ArduPilot is only built and tested on these specific versions of gcc-arm; if installed with apt-get gcc-arm will not produce a working binary in many cases)

reference : Setting up the Build Environment (Linux/Ubuntu) — Dev documentation

is this still a valid arguement or this fact changed with time?
any detailed steps on how to install the cross compiler ? I followed the simple steps on the website but compiling didn’t succeed when I run ( make obal )

Hello,

the instruction for the toolchain on the wiki are for STM target. For Obal that use a RPI, the default rpi toolchain should be enough. We probably don’t install the 64bit toolchain for now, but you can install it manually .

From looking rapidly to the code, Obal default to arm-linux-gnueabihf that is 32bit toolchain, so you will need to pass manually the aarch64 toolchain on waf cmdline

Thx for the answer.

I tried arm-linux-gnueabihf toolchain on my X86 machine:

sudo apt install gcc-arm-linux-gnueabihf
sudo apt install g+±arm-linux-gnueabihf

The generated executables didn’t run on my Pi OS 64bit

I also tried:

sudo apt install crossbuild-essential-arm64
sudo apt install crossbuild-essential-armhf

it also didn’t work.

can you please provide me with steps for the 64 toolchain?

the issue is “arm” it should be aarch64

you mean this one ?

sudo apt install gcc-aarch64-linux-gnu

I gave it a try to compile

$ make obal
Setting top to                           : /apps/ardupilot 
Setting out to                           : /apps/ardupilot/build 
Autoconfiguration                        : enabled 
Checking for program 'python'            : /usr/bin/python 
Checking for python version >= 3.6.9     : 3.12.3 
Setting board to                         : obal 
Using toolchain                          : arm-linux-gnueabihf 
Could not find the program ['arm-linux-gnueabihf-ar']
(complete log in /apps/ardupilot/build/config.log)
make: *** [Makefile:31: obal] Error 1