Can't build stable and older firmware for hardware target

I am having issues with building PX4 v1.13 for hardware targets.
OS: Ubuntu 18.04

What has worked so far:

  • Built the firmware on the “main” branch for hardware targets and jmavsim simulation. No issues here.
  • Built the firmware on the “stable” branch for jmavsim simulation. This works fine as well.

What has not worked:

  • Building the firmware on the “stable” branch of px4 for the following targets:
  1. pixhawk 4 - make px4_fmu-v4_default
[283/1133] Building CXX object src/lib/rc/CMakeFiles/rc.dir/sbus.cpp.obj
FAILED: src/lib/rc/CMakeFiles/rc.dir/sbus.cpp.obj 
/usr/bin/ccache /opt/gcc-arm-none-eabi-9-2020-q2-update/bin/arm-none-eabi-g++ -DAPP_VERSION_MAJOR=0 -DAPP_VERSION_MINOR=1 -DCONFIG_ARCH_BOARD_PX4_FMU_V4 -DCONSTRAINED_MEMORY -DHW_UAVCAN_NAME=\"org.px4.fmu-v4_cannode\" -DHW_VERSION_MAJOR=1 -DHW_VERSION_MINOR=0 -D_SYS_CDEFS_H_ -D_SYS_REENT_H_ -D__CUSTOM_FILE_IO__ -D__PX4_LINUX -D__PX4_NUTTX -D__STDC_FORMAT_MACROS 
/home/PX4-Autopilot/src/lib/rc/sbus.cpp:61:10: fatal error: asm-generic/termbits.h: No such file or directory
   61 | #include <asm-generic/termbits.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
  1. Cube orange - make cubepilot_cubeorange
[485/1112] Building CXX object src/drivers/gps/CMakeFiles/drivers__gps.dir/gps.cpp.obj
FAILED: src/drivers/gps/CMakeFiles/drivers__gps.dir/gps.cpp.obj 
/usr/bin/ccache /opt/gcc-arm-none-eabi-9-2020-q2-update/bin/arm-none-eabi-g++ -DCONFIG_ARCH_BOARD_CUBEPILOT_CUBEORANGE -DMODULE_NAME=\"gps\" -DPX4_MAIN=gps_app_main -D_SYS_CDEFS_H_ -D_SYS_REENT_H_ -D__CUSTOM_FILE_IO__ -D__PX4_LINUX -D__PX4_NUTTX -D__STDC_FORMAT_MACROS
/home/PX4-Autopilot/src/drivers/gps/gps.cpp:78:10: fatal error: linux/spi/spidev.h: No such file or directory
   78 | #include <linux/spi/spidev.h>
      |          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.

The above “make” commands also failed for older versions of px4.

Calling “make” for other build targets (for example: make px4_fmu-v4pro_default) results in the same “#include <linux/spi/spidev.h> no such file or directory” as that shown above.

Has anyone else run into similar issues? Any advice would be much appreciated. What puzzles me most is that all of the above commands work for the firmware on the “main” branch.

I suggest to look at the diffs of these files between the version that works and the one that does not. That should give you an indication how you can fix it.

In general we don’t support Ubuntu 18.04 anymore.

1 Like

I have not been able to identify the cause of this issue, but I have found that I can compile the aforementioned older versions of the firmware on a clean install of Ubuntu 18.04 on a different computer. My process for this was as follows:

On a clean install of Ubuntu 18.04:

  1. Clone the PX4 github repo
  2. Switched to the stable branch (at the time of this writing, this is PX4 v1.13)
  3. Installed the toolchain via ./PX4-Autopilot/Tools/setup/
  4. Built the firmware

The original issue may have arisen due to other stuff on my computer interfering with PX4. Another potential source of the issue was that I had originally used the toolchain install script on the main branch to setup PX4 before trying to switch to the firmware on the stable branch.

Why don’t you use Ubuntu 20.04 or 22.04?

Hi, I am new to PX4 and ran into the same problem (librc build fails - cannot find asm-generic/termbits.h) when trying to build px4_fmu-v5_default firmware. Tried v1.13.3, and a few other recent stable tags.

The problem seems to be that __PX4_LINUX is getting defined even though the build target is not actually running Linux, which then causes a couple librc files to look for Linux headers instead of NuttX headers. Long story short, seems to be related to newer versions of cmake (>= 3.25). A fix was implemented on the main branch in Dec. '22, which probably explains why the main branch build worked ok (see commit 685d5cb473355df7e3ac28c7256b49371e1bc0d8). It looks like this fix went into v1.14.0-beta2.

With this fix, I was able to build px4_fmu-v5_default firmware, v1.13.3.

Oh, where was this fix? If you can share it, I’ll backport it to the v1.13 branch.

I believe it is commit 685d5cb473355df7e3ac28c7256b49371e1bc0d8 (SHA1 ID) in the main PX4 repo ( from Dec. 13, '22.

Thanks @mattp256, backport coming: [BACKPORT v1.13] fix kconfig: rename LINUX to LINUX_TARGET by julianoes · Pull Request #21500 · PX4/PX4-Autopilot · GitHub