Step 6 - shoot building error reports
Now it is time to test the build. If you already pulled the PX4 source repo and made any build previously, do a clean first to clear any compiled binaries may be incompatible with Apple silicon.
make distclean
Again, do not forget to activate python virtual environment before start the build.
CMake version error
CMake Error at src/drivers/uavcan/libuavcan/CMakeLists.txt:5 (cmake_minimum_required):
Compatibility with CMake < 3.5 has been removed from CMake.
Update the VERSION argument <min> value. Or, use the <min>...<max> syntax
to tell CMake that the project requires at least <min> but has been updated
to work with policies introduced by <max> or earlier.
Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway.
Some CMakefiles in PX4 source tree still using elder version policy, which is not supported by CMake 4.0. Update the VERSION number of cmake_minimum_required function in reported file to newer version(3.9 for e.g.) can eliminate the error.
em package missing
Failed to import em: No module named 'em'
You may need to install it using:
pip3 install --user empy
package 'empy' seems not installed but required by some components. Install it manually can settle the error. However, do not use the --user option, as we now use virtual environment instead. And, if there is another error pop up after empy is installed
AttributeError: module 'em' has no attribute 'RAW_OPT'
this is because the required attribute by other part of PX4 source code has been removed in latest empy version. You need to rollback to previous version of empy to solve the problem.
pip3 uninstall empy
pip3 install empy==3.3.4
No module named 'pkg_resources'
in <module>
import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'
This error can be fixed by manually install,
python3 -m pip install setuptools
uninitialized [-Werror=uninitialized]
This error seems come out from the toolchain,
Firmware/platforms/nuttx/NuttX/nuttx/include/arch/armv7-m/irq.h:362:3: error: 'primask' is used uninitialized [-Werror=uninitialized]
362 | __asm__ __volatile__
| ^~~~~~~
compilation terminated due to -Wfatal-errors.
cc1plus: all warnings being treated as errors
This probably an imperfection of the new native toolchain. However we need to get it around to make the build through for now. Mute it simply by adding [Wno-error=uninitialized] is possible but may not the best solution because this can potentially hide other errors for real. So for the moment let's just amend the source code to get through this:
register uint32_t primask = 0;
-Werror=dangling-pointer=
Firmware/src/modules/control_allocator/ActuatorEffectiveness/ActuatorEffectivenessRotors.cpp: In member function 'virtual void ActuatorEffectivenessRotors::updateParams()':
Firmware/src/modules/control_allocator/ActuatorEffectiveness/ActuatorEffectivenessRotors.cpp:98:41:
error: dangling pointer to 'count' may be used [-Werror=dangling-pointer=]
98 | _geometry.num_rotors = math::min(NUM_ROTORS_MAX, (int)count);
| ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated due to -Wfatal-errors.
cc1plus: all warnings being treated as errors
This seems to be a false alarm from the toolchain, as the code here looks fine. However we need to push forward for now, so the work around here is to amend the code a little bit but without changing what it does exactly, just to make the toolchain happy.
Change this part of code to as below,
int res = param_get(_count_handle, &count);
_geometry.num_rotors = math::min(NUM_ROTORS_MAX, (int)count);
if (res != 0) {
PX4_ERR("param_get failed");
return;
}
for (int i = 0; i < _geometry.num_rotors; ++i) {
Done!