Error building esp32diy

I have a clean installed ubuntu system. Installed the xtensa libraries. Installed cmake. Tried running ./waf --board esp32diy; ./waf copter. Configure runs clean, but copter generates the following error:


Waf: Entering directory `/home/hangar2/ardupilot-esp/build/esp32diy'
[1/3] CMake Configure esp-idf
-- Configuring incomplete, errors occurred!
CMake Error at /usr/share/cmake-3.22/Modules/CMakeDetermineSystem.cmake:130 (message):
  Could not find toolchain file: /tools/cmake/toolchain-esp32.cmake
Call Stack (most recent call first):
  CMakeLists.txt:5 (project)


CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage

[2/3] CMake Build esp-idf showinc
No such file or directory
CMake Error: Generator: execution of make failed. Make command was:  -f Makefile showinc &&

Output from ./waf --configure esp32diy


./waf configure --board esp32diy
Setting top to                           : /home/hangar2/ardupilot-esp 
Setting out to                           : /home/hangar2/ardupilot-esp/build 
Autoconfiguration                        : enabled 
Checking for program 'python'            : /usr/bin/python3 
Checking for python version >= 3.6.9     : 3.10.6 
Setting board to                         : esp32diy 
Using toolchain                          : xtensa-esp32-elf 
Checking for 'g++' (C++ compiler)        : /home/tenchiro/esp/xtensa-esp32-elf/bin/xtensa-esp32-elf-g++ 
Checking for 'gcc' (C compiler)          : /home/tenchiro/esp/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc 
Checking for c flags '-MMD'              : yes 
Checking for cxx flags '-MMD'            : yes 
CXX Compiler                             : g++ 5.2.0 
Checking for program 'cmake'             : /usr/bin/cmake 
Checking for program 'ninja, ninja-build' : not found 
Checking for program 'make'               : /usr/bin/make 
USING EXPRESSIF IDF:/home/hangar2/ardupilot-esp/modules/esp_idf
USING DEFAULT_PARAMETERS:/home/hangar2/ardupilot-esp/libraries/AP_HAL_ESP32/boards/defaults.parm
Enabled OpenDroneID                       : no 
Enabled firmware ID checking              : no 
GPS Debug Logging                         : no 
Enabled custom controller                 : no 
Checking for HAVE_CMATH_ISFINITE          : no 
Checking for HAVE_CMATH_ISINF             : no 
Checking for HAVE_CMATH_ISNAN             : no 
Checking for NEED_CMATH_ISFINITE_STD_NAMESPACE : no 
Checking for NEED_CMATH_ISINF_STD_NAMESPACE    : no 
Checking for NEED_CMATH_ISNAN_STD_NAMESPACE    : no 
Checking for header endian.h                   : not found 
Checking for header byteswap.h                 : not found 
Checking for HAVE_MEMRCHR                      : no 
Configured VSCode Intellisense:                : no 
DC_DSDL compiler                               : /home/hangar2/ardupilot-esp/modules/DroneCAN/dronecan_dsdlc/dronecan_dsdlc.py 
Source is git repository                       : yes 
Update submodules                              : yes 
Checking for program 'git'                     : /usr/bin/git 
Checking for program 'xtensa-esp32-elf-size'   : /home/tenchiro/esp/xtensa-esp32-elf/bin/xtensa-esp32-elf-size 
Benchmarks                                     : disabled 
Unit tests                                     : enabled 
Scripting                                      : enabled 
Scripting runtime checks                       : enabled 
Debug build                                    : disabled 
Coverage build                                 : disabled 
Force 32-bit build                             : disabled 
Checking for program 'rsync'                   : /usr/bin/rsync 
'configure' finished successfully (0.476s)

By following the instructions here: ardupilot/README.md at master · ArduPilot/ardupilot · GitHub

I was able to get much further. There are a couple of glitches where 2 python packages are not installed by these procedures and have to be done manually. But after that, it begins to build.

However, at file 722, the build breaks. Here is the attached output:
[722/872] Compiling libraries/AP_DAL/AP_DAL.cpp
…/…/libraries/AP_Compass/AP_Compass.cpp: In member function ‘void Compass::_detect_backends()’:
…/…/libraries/AP_HAL_ESP32/boards/esp32diy.h:50:40: error: ‘DRIVER_ICM20948’ was not declared in this scope
#define HAL_MAG_PROBE_LIST ADD_BACKEND(DRIVER_ICM20948, AP_Compass_AK09916::probe_ICM20948_I2C(0, ROTATION_ROLL_180_YAW_270));
^~~~~~~~~~~~~~~
…/…/libraries/AP_Compass/AP_Compass.cpp:1054:30: note: in definition of macro ‘ADD_BACKEND’
do { if (_driver_enabled(driver_type)) { _add_backend(backend); }
^~~~~~~~~~~
…/…/libraries/AP_Compass/AP_Compass.cpp:1309:5: note: in expansion of macro ‘HAL_MAG_PROBE_LIST’
HAL_MAG_PROBE_LIST;
^~~~~~~~~~~~~~~~~~
compilation terminated due to -Wfatal-errors.

Waf: Leaving directory `/home/hangar2/ardupilot-esp/build/esp32diy’
Build failed
→ task in ‘objs/AP_Compass/ArduCopter’ failed (exit status 1):
{task 139963593347968: cxx AP_Compass.cpp → AP_Compass.cpp.3.o}
(run with -v to display more information)

It appears there is actually an error in the file esp32diy.h

Aside from the semicolon at the end, the DRIVER_ICM20948 is not present. Looking at the other build targets, esp32buzz actually comments out this line.

esp32buzz.h://#define HAL_MAG_PROBE_LIST ADD_BACKEND(DRIVER_ICM20948, AP_Compass_AK09916::probe_ICM20948_I2C(0, ROTATION_NONE));

When this change is made to esp32diy.h:

esp32diy.h://#define HAL_MAG_PROBE_LIST ADD_BACKEND(DRIVER_ICM20948, AP_Compass_AK09916::probe_ICM20948_I2C(0, ROTATION_ROLL_180_YAW_270));

It builds successfully. This needs to be fixed in the main stream, I think.

Advise on how to initiate that is appreciated.