From ac81f8482d57f0aa6f1ec9fa774ecc19dbd75c66 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 23 Jul 2021 08:00:06 +1000 Subject: [PATCH 1/8] AP_Compass: fixed build warning on g++ 10.2 --- libraries/AP_Compass/Compass_learn.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/AP_Compass/Compass_learn.cpp b/libraries/AP_Compass/Compass_learn.cpp index b9d142c8b0cc4..e93cafdadc3dc 100644 --- a/libraries/AP_Compass/Compass_learn.cpp +++ b/libraries/AP_Compass/Compass_learn.cpp @@ -164,7 +164,9 @@ void CompassLearn::update(void) sample_available = false; num_samples = 0; have_earth_field = false; - memset(predicted_offsets, 0, sizeof(predicted_offsets)); + for (auto &v : predicted_offsets) { + v.zero(); + } worst_error = 0; best_error = 0; best_yaw_deg = 0; From 29106d95fc6c65f3966c4f95958b365e5f7168ac Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 23 Jul 2021 08:29:12 +1000 Subject: [PATCH 2/8] waf: added --assert-cc-version configure option this will allow build_binaries.py to confirm it is using the right compiler for each build --- Tools/ardupilotwaf/boards.py | 7 +++++++ wscript | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/Tools/ardupilotwaf/boards.py b/Tools/ardupilotwaf/boards.py index a1fbd2dc05367..40dfdd0316e30 100644 --- a/Tools/ardupilotwaf/boards.py +++ b/Tools/ardupilotwaf/boards.py @@ -156,6 +156,13 @@ def configure_env(self, cfg, env): cfg.msg("CXX Compiler", "%s %s" % (cfg.env.COMPILER_CXX, ".".join(cfg.env.CC_VERSION))) + if cfg.options.assert_cc_version: + cfg.msg("Checking compiler", "%s %s" % (cfg.options.assert_cc_version, ".".join(cfg.env.CC_VERSION))) + have_version = cfg.env.COMPILER_CXX+"-"+'.'.join(list(cfg.env.CC_VERSION)) + want_version = cfg.options.assert_cc_version + if have_version != want_version: + cfg.fatal("cc version mismatch: %s should be %s" % (have_version, want_version)) + if 'clang' in cfg.env.COMPILER_CC: env.CFLAGS += [ '-fcolor-diagnostics', diff --git a/wscript b/wscript index 008734c95a1fc..d5aadebd288f3 100644 --- a/wscript +++ b/wscript @@ -286,6 +286,10 @@ configuration in order to save typing. default=None, help='Extra hwdef.dat file for custom build.') + g.add_option('--assert-cc-version', + default=None, + help='fail configure if not using the specified gcc version') + def _collect_autoconfig_files(cfg): for m in sys.modules.values(): paths = [] From 8dd9981e94e2fe1888c1c68ac06b33b039473804 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 26 Jul 2021 07:40:53 +1000 Subject: [PATCH 3/8] Tools: removed remnants of px4 build support --- Tools/scripts/build_binaries.py | 109 ++------------------------------ 1 file changed, 6 insertions(+), 103 deletions(-) diff --git a/Tools/scripts/build_binaries.py b/Tools/scripts/build_binaries.py index 7a23af758e181..20a68d4a69192 100755 --- a/Tools/scripts/build_binaries.py +++ b/Tools/scripts/build_binaries.py @@ -347,7 +347,7 @@ def touch_filepath(self, filepath): pass def build_vehicle(self, tag, vehicle, boards, vehicle_binaries_subdir, - binaryname, px4_binaryname, frames=[None]): + binaryname, frames=[None]): '''build vehicle binaries''' self.progress("Building %s %s binaries (cwd=%s)" % (vehicle, tag, os.getcwd())) @@ -439,7 +439,7 @@ def build_vehicle(self, tag, vehicle, boards, vehicle_binaries_subdir, "bin", "".join([binaryname, framesuffix])) files_to_copy = [] - extensions = [".px4", ".apj", ".abin", "_with_bl.hex", ".hex"] + extensions = [".apj", ".abin", "_with_bl.hex", ".hex"] if vehicle == 'AP_Periph': # need bin file for uavcan-gui-tool and MissionPlanner extensions.append('.bin') @@ -465,97 +465,6 @@ def build_vehicle(self, tag, vehicle, boards, vehicle_binaries_subdir, # record some history about this build self.history.record_build(githash, tag, vehicle, board, frame, bare_path, t0, time_taken_to_build) - if not self.checkout(vehicle, tag, "PX4", None): - self.checkout(vehicle, "latest") - return - - board_list = self.run_program('BB-WAF', ['./waf', 'list_boards']) - board_list = board_list.split(' ') - self.checkout(vehicle, "latest") - if 'px4-v2' not in board_list: - print("Skipping px4 builds") - return - - # PX4-building - board = "px4" - for frame in frames: - self.progress("Building frame %s for board %s" % (frame, board)) - if frame is None: - framesuffix = "" - else: - framesuffix = "-%s" % frame - - if not self.checkout(vehicle, tag, "PX4", frame): - msg = ("Failed checkout of %s %s %s %s" % - (vehicle, "PX4", tag, frame)) - self.progress(msg) - self.error_strings.append(msg) - self.checkout(vehicle, "latest") - continue - - try: - deadwood = "../Build.%s" % vehicle - if os.path.exists(deadwood): - self.progress("#### Removing (%s)" % deadwood) - shutil.rmtree(os.path.join(deadwood)) - except Exception as e: - self.progress("FIXME: narrow exception (%s)" % repr(e)) - - self.progress("Building %s %s PX4%s binaries" % - (vehicle, tag, framesuffix)) - ddir = os.path.join(self.binaries, - vehicle_binaries_subdir, - self.hdate_ym, - self.hdate_ymdhm, - "".join(["PX4", framesuffix])) - if self.skip_build(tag, ddir): - continue - - for v in ["v1", "v2", "v3", "v4", "v4pro"]: - px4_v = "%s-%s" % (board, v) - - if self.skip_board_waf(px4_v): - continue - - if os.path.exists(self.buildroot): - shutil.rmtree(self.buildroot) - - self.progress("Configuring for %s in %s" % - (px4_v, self.buildroot)) - try: - self.run_waf(["configure", "--board", px4_v, - "--out", self.buildroot, "clean"]) - except subprocess.CalledProcessError: - self.progress("waf configure failed") - continue - try: - self.run_waf([ - "build", - "--targets", - os.path.join("bin", - "".join([binaryname, framesuffix]))]) - except subprocess.CalledProcessError: - msg = ("Failed build of %s %s%s %s for %s" % - (vehicle, board, framesuffix, tag, v)) - self.progress(msg) - self.error_strings.append(msg) - continue - - oldfile = os.path.join(self.buildroot, px4_v, "bin", - "%s%s.px4" % (binaryname, framesuffix)) - newfile = "%s-%s.px4" % (px4_binaryname, v) - self.progress("Copying (%s) to (%s)" % (oldfile, newfile,)) - try: - shutil.copyfile(oldfile, newfile) - except Exception as e: - self.progress("FIXME: narrow exception (%s)" % repr(e)) - msg = ("Failed build copy of %s PX4%s %s for %s" % - (vehicle, framesuffix, tag, v)) - self.progress(msg) - self.error_strings.append(msg) - continue - # FIXME: why the two stage copy?! - self.copyit(newfile, ddir, tag, vehicle) self.checkout(vehicle, "latest") def common_boards(self): @@ -685,7 +594,6 @@ def build_arducopter(self, tag): boards, "Copter", "arducopter", - "ArduCopter", frames=[None, "heli"]) def build_arduplane(self, tag): @@ -696,8 +604,7 @@ def build_arduplane(self, tag): "ArduPlane", boards, "Plane", - "arduplane", - "ArduPlane") + "arduplane") def build_antennatracker(self, tag): '''build Tracker binaries''' @@ -706,8 +613,7 @@ def build_antennatracker(self, tag): "AntennaTracker", boards, "AntennaTracker", - "antennatracker", - "AntennaTracker",) + "antennatracker") def build_rover(self, tag): '''build Rover binaries''' @@ -716,8 +622,7 @@ def build_rover(self, tag): "Rover", boards, "Rover", - "ardurover", - "Rover") + "ardurover") def build_ardusub(self, tag): '''build Sub binaries''' @@ -725,8 +630,7 @@ def build_ardusub(self, tag): "ArduSub", self.common_boards(), "Sub", - "ardusub", - "ArduSub") + "ardusub") def build_AP_Periph(self, tag): '''build AP_Periph binaries''' @@ -735,7 +639,6 @@ def build_AP_Periph(self, tag): "AP_Periph", boards, "AP_Periph", - "AP_Periph", "AP_Periph") def generate_manifest(self): From 98a76bd735584b94639271ad5cd95d157176dbca Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 26 Jul 2021 07:26:09 +1000 Subject: [PATCH 4/8] Tools: use 10.2.1 compiler for latest builds of ChibiOS boards --- Tools/scripts/build_binaries.py | 55 ++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 8 deletions(-) diff --git a/Tools/scripts/build_binaries.py b/Tools/scripts/build_binaries.py index 20a68d4a69192..3a30c5fe63876 100755 --- a/Tools/scripts/build_binaries.py +++ b/Tools/scripts/build_binaries.py @@ -32,6 +32,28 @@ running_python3 = True +def is_chibios_build(board): + '''see if a board is using HAL_ChibiOS''' + hwdef_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "libraries", "AP_HAL_ChibiOS", "hwdef") + return os.path.exists(os.path.join(hwdef_dir, board, "hwdef.dat")) + + +def get_required_compiler(tag, board): + '''return required compiler for a build tag. + return format is the version string that waf configure will detect. + You should setup a link from this name in $HOME/arm-gcc directory pointing at the + appropriate compiler + ''' + if not is_chibios_build(board): + # only override compiler for ChibiOS builds + return None + if tag == 'latest': + # use 10.2.1 compiler for master builds + return "g++-10.2.1" + # for all other builds we use the default compiler in $PATH + return None + + class build_binaries(object): def __init__(self, tags): self.tags = tags @@ -62,21 +84,34 @@ def board_options(self, board): return ["--static"] return [] - def run_waf(self, args): + def run_waf(self, args, compiler=None): if os.path.exists("waf"): waf = "./waf" else: waf = os.path.join(".", "modules", "waf", "waf-light") cmd_list = [waf] cmd_list.extend(args) - self.run_program("BB-WAF", cmd_list) - - def run_program(self, prefix, cmd_list, show_output=True): + env = None + if compiler is not None: + # default to $HOME/arm-gcc, but allow for any path with AP_GCC_HOME environment variable + gcc_home = os.environ.get("AP_GCC_HOME", os.path.join(os.environ["HOME"], "arm-gcc")) + gcc_path = os.path.join(gcc_home, compiler, "bin") + if os.path.exists(gcc_path): + # setup PATH to point at the right compiler, and setup to use ccache + env = os.environ.copy() + env["PATH"] = gcc_path + ":" + env["PATH"] + env["CC"] = "ccache arm-none-eabi-gcc" + env["CXX"] = "ccache arm-none-eabi-g++" + else: + raise Exception("BB-WAF: Missing compiler %s" % gcc_path) + self.run_program("BB-WAF", cmd_list, env=env) + + def run_program(self, prefix, cmd_list, show_output=True, env=None): if show_output: self.progress("Running (%s)" % " ".join(cmd_list)) p = subprocess.Popen(cmd_list, bufsize=1, stdin=None, stdout=subprocess.PIPE, close_fds=True, - stderr=subprocess.STDOUT) + stderr=subprocess.STDOUT, env=env) output = "" while True: x = p.stdout.readline() @@ -164,7 +199,7 @@ def checkout(self, vehicle, ctag, cboard=None, cframe=None, submodule_update=Tru return False def skip_board_waf(self, board): - '''check if we should skip this build because we don't support the + '''check if we should skip this build because we do not support the board in this release ''' @@ -409,15 +444,19 @@ def build_vehicle(self, tag, vehicle, boards, vehicle_binaries_subdir, "--board", board, "--out", self.buildroot, "clean"] + gccstring = get_required_compiler(tag, board) + if gccstring is not None: + waf_opts += ["--assert-cc-version", gccstring] + waf_opts.extend(self.board_options(board)) - self.run_waf(waf_opts) + self.run_waf(waf_opts, compiler=gccstring) except subprocess.CalledProcessError: self.progress("waf configure failed") continue try: target = os.path.join("bin", "".join([binaryname, framesuffix])) - self.run_waf(["build", "--targets", target]) + self.run_waf(["build", "--targets", target], compiler=gccstring) except subprocess.CalledProcessError: msg = ("Failed build of %s %s%s %s" % (vehicle, board, framesuffix, tag)) From 08620abbd74b0e2f2811f60c8bfdaa74ac41d8f4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 26 Jul 2021 08:06:40 +1000 Subject: [PATCH 5/8] Tools: switched development to the 10.2.1 compiler for STM32 --- Tools/debug/README.md | 2 +- Tools/environment_install/install-prereqs-arch.sh | 4 ++-- Tools/environment_install/install-prereqs-mac.sh | 2 +- Tools/environment_install/install-prereqs-ubuntu.sh | 4 ++-- Tools/scripts/configure-ci.sh | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Tools/debug/README.md b/Tools/debug/README.md index 117f69900d386..1cf7510d3221e 100644 --- a/Tools/debug/README.md +++ b/Tools/debug/README.md @@ -22,7 +22,7 @@ your black magic probe, or install the provided udev rules file so that the probe will be loaded as /dev/ttyBmpGdb Now make sure you have the right version of arm-none-eabi-gdb -installed. We recommend version 6-2017-q2-update, which is available +installed. We recommend version 10-2020-q4-major, which is available here: https://firmware.ardupilot.org/Tools/STM32-tools/ Now build ArduPilot with the --debug configure option. You may also diff --git a/Tools/environment_install/install-prereqs-arch.sh b/Tools/environment_install/install-prereqs-arch.sh index 43c3c7afe10bc..f82c1b703276e 100755 --- a/Tools/environment_install/install-prereqs-arch.sh +++ b/Tools/environment_install/install-prereqs-arch.sh @@ -14,8 +14,8 @@ PYTHON3_PKGS="pyserial empy geocoder" # GNU Tools for ARM Embedded Processors # (see https://launchpad.net/gcc-arm-embedded/) -ARM_ROOT="gcc-arm-none-eabi-6-2017-q2-update" -ARM_TARBALL="$ARM_ROOT-linux.tar.bz2" +ARM_ROOT="gcc-arm-none-eabi-10-2020-q4-major" +ARM_TARBALL="$ARM_ROOT-x86_64-linux.tar.bz2" ARM_TARBALL_URL="https://firmware.ardupilot.org/Tools/STM32-tools/$ARM_TARBALL" # Ardupilot Tools diff --git a/Tools/environment_install/install-prereqs-mac.sh b/Tools/environment_install/install-prereqs-mac.sh index c900479803dc7..922ccc553e06b 100755 --- a/Tools/environment_install/install-prereqs-mac.sh +++ b/Tools/environment_install/install-prereqs-mac.sh @@ -62,7 +62,7 @@ fi function install_arm_none_eabi_toolchain() { # GNU Tools for ARM Embedded Processors # (see https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads) - ARM_ROOT="gcc-arm-none-eabi-6-2017-q2-update" + ARM_ROOT="gcc-arm-none-eabi-10-2020-q4-major" ARM_TARBALL="$ARM_ROOT-mac.tar.bz2" ARM_TARBALL_URL="https://firmware.ardupilot.org/Tools/STM32-tools/$ARM_TARBALL" if [ ! -d $OPT/$ARM_ROOT ]; then diff --git a/Tools/environment_install/install-prereqs-ubuntu.sh b/Tools/environment_install/install-prereqs-ubuntu.sh index 34747bb26eefd..68d44856a7180 100755 --- a/Tools/environment_install/install-prereqs-ubuntu.sh +++ b/Tools/environment_install/install-prereqs-ubuntu.sh @@ -142,8 +142,8 @@ fi function install_arm_none_eabi_toolchain() { # GNU Tools for ARM Embedded Processors # (see https://launchpad.net/gcc-arm-embedded/) - ARM_ROOT="gcc-arm-none-eabi-6-2017-q2-update" - ARM_TARBALL="$ARM_ROOT-linux.tar.bz2" + ARM_ROOT="gcc-arm-none-eabi-10-2020-q4-major" + ARM_TARBALL="$ARM_ROOT-x86_64-linux.tar.bz2" ARM_TARBALL_URL="https://firmware.ardupilot.org/Tools/STM32-tools/$ARM_TARBALL" if [ ! -d $OPT/$ARM_ROOT ]; then ( diff --git a/Tools/scripts/configure-ci.sh b/Tools/scripts/configure-ci.sh index e5ef01c8752b8..946423471f156 100755 --- a/Tools/scripts/configure-ci.sh +++ b/Tools/scripts/configure-ci.sh @@ -6,8 +6,8 @@ set -ex # Disable ccache for the configure phase, it's not worth it export CCACHE_DISABLE="true" -ARM_ROOT="gcc-arm-none-eabi-6-2017-q2-update" -ARM_TARBALL="$ARM_ROOT-linux.tar.bz2" +ARM_ROOT="gcc-arm-none-eabi-10-2020-q4-major" +ARM_TARBALL="$ARM_ROOT-x86_64-linux.tar.bz2" RPI_ROOT="master" RPI_TARBALL="$RPI_ROOT.tar.gz" @@ -83,7 +83,7 @@ ln -s ~/opt/$CCACHE_ROOT/ccache ~/ccache/clang exportline="export PATH=$HOME/ccache" exportline="${exportline}:$HOME/bin" exportline="${exportline}:$HOME/.local/bin" -exportline="${exportline}:$HOME/opt/gcc-arm-none-eabi-6-2017-q2-update/bin" +exportline="${exportline}:$HOME/opt/gcc-arm-none-eabi-10-2020-q4-major/bin" exportline="${exportline}:$HOME/opt/tools-master/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin" exportline="${exportline}:$HOME/opt/arm-linux-musleabihf-cross/bin" exportline="${exportline}:$HOME/opt/$CCACHE_ROOT" From 025810d325bad2593ff100bc50a2bc7e9d300755 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 26 Jul 2021 14:38:10 +1000 Subject: [PATCH 6/8] AP_InertialSensor: fixed build warning --- libraries/AP_InertialSensor/AP_InertialSensor_tempcal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/AP_InertialSensor/AP_InertialSensor_tempcal.cpp b/libraries/AP_InertialSensor/AP_InertialSensor_tempcal.cpp index cefe84f6f441e..c672683a480a9 100644 --- a/libraries/AP_InertialSensor/AP_InertialSensor_tempcal.cpp +++ b/libraries/AP_InertialSensor/AP_InertialSensor_tempcal.cpp @@ -376,7 +376,7 @@ void AP_InertialSensor::TCal::update_gyro_learning(const Vector3f &gyro, float t */ void AP_InertialSensor::TCal::Learn::reset(float temperature) { - memset(state, 0, sizeof(state)); + memset((void*)&state[0], 0, sizeof(state)); start_tmax = tcal.temp_max; accel_start.zero(); for (uint8_t i=0; i Date: Mon, 26 Jul 2021 14:38:35 +1000 Subject: [PATCH 7/8] waf: added 10.2.1 gcc to whitelist of compilers for -Werror --- Tools/ardupilotwaf/boards.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Tools/ardupilotwaf/boards.py b/Tools/ardupilotwaf/boards.py index 40dfdd0316e30..38fa77a16aca0 100644 --- a/Tools/ardupilotwaf/boards.py +++ b/Tools/ardupilotwaf/boards.py @@ -769,6 +769,7 @@ def configure_env(self, cfg, env): ('6','3','1'), ('9','2','1'), ('9','3','1'), + ('10','2','1'), ] if cfg.options.Werror or cfg.env.CC_VERSION in gcc_whitelist: From 62c29776b8f4d9f3027a18f98c6eb8b5a5f8cd99 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 27 Jul 2021 08:26:09 +1000 Subject: [PATCH 8/8] ChibiOS: update submodule to match HEAD revision --- modules/ChibiOS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ChibiOS b/modules/ChibiOS index 7f9254cd93099..95e4022452786 160000 --- a/modules/ChibiOS +++ b/modules/ChibiOS @@ -1 +1 @@ -Subproject commit 7f9254cd93099eaa7dbf45b5eba6b38efc6185b3 +Subproject commit 95e4022452786a28b89aae6463faf3dd1d10c712