ArduPilot SITL on FreeBSD 15.0 – successful build and a question about porting

Hello,

Over the last few days I have been experimenting with building and running ArduPilot on FreeBSD 15.0.

My goal was to see whether ArduPilot SITL (Software-In-The-Loop) could be used as a development and training platform on FreeBSD without relying on Linux.

The result was surprisingly good.

The following components are working:

  • ArduPilot SITL
  • MAVProxy
  • MAVProxy Console
  • MAVProxy Map
  • GUIDED mode
  • STABILIZE mode
  • MAVLink telemetry
  • AP_Bootloader build
  • STM32 flashing via dfu-util

System used:

Code:
FreeBSD 15.0-RELEASE-p5 amd64
clang 19
Python 3.11

Build issues encountered

ArduPilot contains a few Linux-specific assumptions that prevent it from building on FreeBSD out of the box.

1. libraries/AP_HAL_SITL/UART_utils.cpp

Build failed with:

Code:
fatal error: 'asm/termbits.h' file not found

The code uses Linux-specific interfaces:

Code:
#include <asm/ioctls.h>
#include <asm/termbits.h>

struct termios2
TCGETS2
TCSETS2
BOTHER

FreeBSD does not provide these APIs.

I modified the code to use the existing POSIX termios path:

Code:
#include <sys/ioctl.h>
#include <termios.h>

and standard termios functionality instead of Linux-specific termios2.

Example diff:

Code:
-#include <asm/ioctls.h>
-#include <asm/termbits.h>
+#include <sys/ioctl.h>
+#include <termios.h>

2. libraries/AP_Filesystem/AP_Filesystem_posix.cpp

Build failed with:

Code:
fatal error: 'sys/vfs.h' file not found

On FreeBSD I replaced it with:

Code:
#ifdef __FreeBSD__
#include <sys/param.h>
#include <sys/mount.h>
#else
#include <sys/vfs.h>
#endif

Example diff:

Code:
+#ifdef __FreeBSD__
+#include <sys/param.h>
+#include <sys/mount.h>
+#else
 #include <sys/vfs.h>
+#endif

Bootloader build

While building AP_Bootloader I encountered errors such as:

Code:
struct _reent declared inside parameter list

The issue turned out not to be ArduPilot itself, but the ARM toolchain.

The FreeBSD package:

Code:
/usr/local/bin/arm-none-eabi-gcc
and
Code:
export PATH=/usr/local/gcc-arm-embedded-14.2.rel1/bin:$PATH
export MAKE=gmake

was built with:

Code:
--without-headers

and therefore lacks the required newlib headers.

After switching to:

Code:
/usr/local/gcc-arm-embedded-14.2.rel1/bin/arm-none-eabi-gcc

the bootloader built successfully without any source code modifications.

Python dependencies

Installed via pip:

Code:
MAVProxy
pymavlink
dronecan
empy
fastcrc
geocoder
pexpect
pyserial
pynmeagps

Installed via pkg:

Code:
opencv
proj
git 
gmake 
python 
py311-pip 
py311-sqlite3

The MAVProxy map module initially failed because OpenCV was missing:

Code:
ModuleNotFoundError: No module named 'cv2'

After installing OpenCV, the map module loaded successfully.

Result

ArduPilot SITL is now running correctly on FreeBSD.

Example commands tested successfully:

Code:
mode guided
arm throttle
takeoff 20
velocity 1 0 0
mode land
link files
Code:
sudo ln -s /usr/local/bin/python3.11 /usr/local/bin/python
sudo ln -s /usr/local/bin/python3.11 /usr/local/bin/python3

MAVProxy Console and Map are both operational.

Question to the FreeBSD community

Would there be any interest in creating a proper FreeBSD port for ArduPilot SITL?

At least for my setup, only two relatively small source code changes were required to get SITL running.

I would be interested in hearing opinions about:

  • Creating a FreeBSD port for ArduPilot SITL
  • Adding official FreeBSD support upstream
  • Maintaining a small FreeBSD compatibility patch set

Perhaps there are already users running ArduPilot or PX4 on FreeBSD who could share their experience.

Thank you.
 

Attachments

  • sitl.jpg
    sitl.jpg
    326.2 KB · Views: 8
  • sitlmap.jpg
    sitlmap.jpg
    329.7 KB · Views: 5
Back
Top