From fb56dc477e00dc5c76caa76cda816626dfa7bfe6 Mon Sep 17 00:00:00 2001 From: elecpower Date: Sun, 2 Jun 2024 19:12:53 +1000 Subject: [PATCH] Fix 32 bit arm toolchain path add more options --- tools/msys2_build_32_64.sh | 4 +- tools/msys2_common_32_64.sh | 6 +- tools/msys2_setup_buildenv_stage1_32_64.sh | 45 +++++++---- tools/msys2_setup_buildenv_stage2_32_64.sh | 90 ++++++++++++++-------- 4 files changed, 96 insertions(+), 49 deletions(-) diff --git a/tools/msys2_build_32_64.sh b/tools/msys2_build_32_64.sh index 95fdd8b0b72..eadc1d18d5f 100755 --- a/tools/msys2_build_32_64.sh +++ b/tools/msys2_build_32_64.sh @@ -65,7 +65,7 @@ BRANCH_NAME="main" BRANCH_EDGETX_VERSION=unknown BRANCH_QT_VERSION=unknown -ARM_TOOLCHAIN_DIR="C:\Program Files (x86)\GNU Arm Embedded Toolchain\10 2020-q4-major\bin" +ARM_TOOLCHAIN_DIR="/c/Program Files (x86)/GNU Arm Embedded Toolchain/10 2020-q4-major/bin" QT_ROOT_DIR="${HOME}/qt" ROOT_DIR="${HOME}" SOURCE_DIR="${REPO_OWNER}/${REPO_NAME}" @@ -566,7 +566,7 @@ fi # builds if [[ $BUILD_FIRMWARE -eq 1 ]]; then # required for compile and elf-size-report.sh - PATH=${PATH}:${ARM_TOOLCHAIN_DIR} + PATH=${ARM_TOOLCHAIN_DIR}:${PATH} for ((i = 0; i < ${#RADIO_TYPES[@]}; ++i)); do create_output_dir ${RADIO_TYPES[i]} diff --git a/tools/msys2_common_32_64.sh b/tools/msys2_common_32_64.sh index 94a3906e86e..2081edbcf1f 100755 --- a/tools/msys2_common_32_64.sh +++ b/tools/msys2_common_32_64.sh @@ -77,10 +77,10 @@ function bool_to_text() { # Parameters: # 1 - boolean - if [[ $1 -eq 1 ]]; then - echo "Yes" - else + if [[ $1 -eq 0 ]]; then echo "No" + else + echo "Yes" fi } diff --git a/tools/msys2_setup_buildenv_stage1_32_64.sh b/tools/msys2_setup_buildenv_stage1_32_64.sh index daeb15eb3d1..bb299a5811a 100755 --- a/tools/msys2_setup_buildenv_stage1_32_64.sh +++ b/tools/msys2_setup_buildenv_stage1_32_64.sh @@ -1,5 +1,7 @@ #! /usr/bin/env bash +set -e + ## Bash script to setup EdgeTX 32 and 64 bit development environments first stage. if [[ ! "$MSYSTEM" == "MSYS" ]]; then @@ -15,6 +17,7 @@ source msys2_common_32_64.sh # Defaults INSTALL_64BIT=1 INSTALL_32BIT=0 +INSTALL_EXTRAS=1 # == Functions == @@ -29,8 +32,9 @@ Parser command options. Options: -h, --help display help text and exit -p, --pause pause after each command (default: false) - --no-64bit do not install 64-bit toolchain - --32bit install 32-bit toolchain + --no-64bit do not install 64-bit toolchain (default: install) + --32bit install 32-bit toolchain (default: do not install) + --no-extras do not install the extra base packages (default: install) EOF exit 1 } @@ -38,7 +42,7 @@ exit 1 # == End functions == short_options=hp -long_options="help, pause, no-64bit, 32bit" +long_options="help, pause, no-64bit, 32bit, no-extras" args=$(getopt --options "$short_options" --longoptions "$long_options" -- "$@") if [[ $? -gt 0 ]]; then @@ -50,10 +54,11 @@ eval set -- ${args} while true do case $1 in - -p | --pause) STEP_PAUSE=1 ; shift ;; + -p | --pause) STEP_PAUSE=1 ; shift ;; -h | --help) usage ; shift ;; --no-64bit) INSTALL_64BIT=0 ; shift ;; --32bit) INSTALL_32BIT=1 ; shift ;; + --no-extras) INSTALL_EXTRAS=0 ; shift ;; # -- means the end of the arguments; drop this, and break out of the while loop --) shift; break ;; *) >&2 echo Unsupported option: $1 @@ -61,16 +66,30 @@ do esac done -echo " -Execute with the following: +clear + +cat << EOF + +*********************************************************************** +* I M P O R T A N T * +* * +* The MSYS2 base packages MUST be updated PRIOR to running Stage 1. * +* * +* If you have not done so, abort this script. * +* * +* Then in a MSYS2 MSYS console (violet icon) session, * +* run the command 'pacman -Suy' * +*********************************************************************** + +Executing with the following options: Install 64-bit toolchain: $(bool_to_text ${INSTALL_64BIT}) Install 32-bit toolchain: $(bool_to_text ${INSTALL_32BIT}) + Install extra packages: $(bool_to_text ${INSTALL_EXTRAS}) Pause after each step: $(bool_to_text ${STEP_PAUSE}) -IMPORTANT: the MSYS2 base packages MUST be updated prior to running stage 1. - Run the command 'pacman -Suy' in MSYS2 MSYS console (violet icon). -" -read -p "Press any key to continue or ctrl+C to abort" +EOF + +read -p "Press Enter key to continue or Ctrl+C to abort" if [[ $INSTALL_64BIT -eq 1 ]]; then run_step "Installing 64-bit toolchain" "pacman -S --noconfirm mingw-w64-x86_64-toolchain" @@ -80,8 +99,8 @@ if [[ $INSTALL_32BIT -eq 1 ]]; then run_step "Installing 32-bit toolchain" "pacman -S --noconfirm mingw-w64-i686-toolchain" fi -if [[ $INSTALL_64BIT -eq 1 ]] || [[ $INSTALL_32BIT -eq 1 ]]; then - run_step "Installing git and make packages" "pacman -S --noconfirm git make" +if [[ $INSTALL_EXTRAS -eq 1 ]]; then + run_step "Installing git, make and tar packages" "pacman -S --noconfirm git make tar" fi -echo "This stage has finished. Please close the MSYS console and continue to stage 2." +echo "Stage 1 has finished. Please close the console and continue to Stage 2." diff --git a/tools/msys2_setup_buildenv_stage2_32_64.sh b/tools/msys2_setup_buildenv_stage2_32_64.sh index fb23f95d91e..e49bc2b8d08 100755 --- a/tools/msys2_setup_buildenv_stage2_32_64.sh +++ b/tools/msys2_setup_buildenv_stage2_32_64.sh @@ -1,5 +1,7 @@ #! /usr/bin/env bash +set -e + ## Bash script to setup EdgeTX development environment second stage. if [[ "$MSYSTEM" == "MSYS" ]]; then @@ -14,9 +16,10 @@ source msys2_common_32_64.sh # == Initialise variables == INSTALL_PACKAGES=1 -INSTALL_QT=1 +QT_INST=1 +QT_BINS=1 DOWNLOAD_DIR="${HOME}" -DOWNLOAD_ARM=1 +ARM_INST=1 INSTALL_ARM=1 # == Functions == @@ -33,10 +36,14 @@ Options: -d, --download-dir directory for the arm installer (default: ${DOWNLOAD_DIR}) -e, --edgetx-version installs the dependent Qt version (default: ${EDGETX_VERSION}) -h, --help display help text and exit - --no-download-arm do not download arm toolchain installer - --no-install-arm do not install arm toolchain + --no-arm do not download or install arm toolchain + --no-arm-installer do not download arm toolchain installer + --no-install-arm do not run arm toolchain installer --no-install-packages do not install packages - --no-install-qt do not install Qt + --no-qt do not install Qt installer or binaries + --no-qt-installer do not install Qt binaries installer + Note: common for 32bit and 64bit so only needs to be performed once + --no-qt-bins do not download Qt binaries -p, --pause pause after each command (default: false) -q, --qt-version version of Qt to install (default: ${QT_VERSION}) Note: Overrides EdgeTX dependent version. Allows installing multiple versions. @@ -47,7 +54,7 @@ exit 1 # == End functions == short_options=d:,e:,h,p,q: -long_options="download-dir:, edgetx-version:, help, no-download-arm, no-install-arm, no-install-packages, no-install-qt, pause, qt-version:" +long_options="download-dir:, edgetx-version:, help, no-arm, no-arm-installer, no-install-arm, no-install-packages, no-qt, no-qt-installer, no-qt-bins, pause, qt-version:" args=$(getopt --options "$short_options" --longoptions "$long_options" -- "$@") if [[ $? -gt 0 ]]; then @@ -63,10 +70,13 @@ do -e | --edgetx-version) EDGETX_VERSION="${2}" QT_VERSION="$(get_qt_version ${2})" ; shift 2 ;; -h | --help) usage ; shift ;; - --no-download-arm) DOWNLOAD_ARM=0 ; shift ;; + --no-arm-installer) ARM_INST=0 ; shift ;; --no-install-arm) INSTALL_ARM=0 ; shift ;; + --no-arm) ARM_INST=0; INSTALL_ARM=0 ; shift ;; --no-install-packages) INSTALL_PACKAGES=0 ; shift ;; - --no-install-qt) INSTALL_QT=0 ; shift ;; + --no-qt-installer) QT_INST=0 ; shift ;; + --no-qt-bins) QT_BINS=0 ; shift ;; + --no-qt) QT_INST=0; QT_BINS=0 ; shift ;; -p | --pause) STEP_PAUSE=1 ; shift ;; -q | --qt-version) QT_VERSION="${2}" ; shift 2 ;; # -- means the end of the arguments; drop this, and break out of the while loop @@ -78,14 +88,10 @@ done # == Validation == -if [[ $DOWNLOAD_ARM -eq 1 ]] && [[ ! -d ${DOWNLOAD_DIR} ]]; then +if [[ $ARM_INST -eq 1 ]] && [[ ! -d ${DOWNLOAD_DIR} ]]; then fail "ARM installer download directory ${DOWNLOAD_DIR} does not exist" fi -if [[ $DOWNLOAD_ARM -eq 0 ]]; then - INSTALL_ARM=0 -fi - validate_edgetx_version split_version EDGETX_VERSION @@ -95,14 +101,17 @@ check_qt_arch_support # == End validation == +clear + cat << EOF -Execute with the following: +Executing with the following options: EdgeTX version: ${EDGETX_VERSION} Qt version: ${QT_VERSION} Install packages: $(bool_to_text ${INSTALL_PACKAGES}) - Install Qt: $(bool_to_text ${INSTALL_QT}) + Install Qt installer: $(bool_to_text ${QT_INST}) + Download Qt binaries: $(bool_to_text ${QT_BINS}) ARM download directory: ${DOWNLOAD_DIR} - Download ARM installer $(bool_to_text ${DOWNLOAD_ARM}) + Download ARM installer $(bool_to_text ${ARM_INST}) Install ARM toolchain $(bool_to_text ${INSTALL_ARM}) Pause after each step: $(bool_to_text ${STEP_PAUSE}) EOF @@ -111,10 +120,6 @@ read -p "Press Enter Key to continue or Ctrl+C to abort" # == Execute == -# Notes: -# Nov 2023 openssl and zlib installed in the base dev toolchain -# psutil is a dependency of aqtinstall but fails to install via dependencies so explicitly install python-psutil - if [[ $INSTALL_PACKAGES -eq 1 ]]; then new_step "Installing packages" @@ -122,9 +127,8 @@ if [[ $INSTALL_PACKAGES -eq 1 ]]; then ${MINGW_PACKAGE_PREFIX}-cmake \ ${MINGW_PACKAGE_PREFIX}-python-pip \ ${MINGW_PACKAGE_PREFIX}-python-pillow \ - ${MINGW_PACKAGE_PREFIX}-python-lz4 \ - ${MINGW_PACKAGE_PREFIX}-python-psutil \ ${MINGW_PACKAGE_PREFIX}-libjpeg-turbo \ + ${MINGW_PACKAGE_PREFIX}-zlib \ ${MINGW_PACKAGE_PREFIX}-libtiff \ ${MINGW_PACKAGE_PREFIX}-freetype \ ${MINGW_PACKAGE_PREFIX}-lcms2 \ @@ -135,28 +139,52 @@ if [[ $INSTALL_PACKAGES -eq 1 ]]; then ${MINGW_PACKAGE_PREFIX}-SDL2 \ ${MINGW_PACKAGE_PREFIX}-clang \ ${MINGW_PACKAGE_PREFIX}-nsis \ - ${MINGW_PACKAGE_PREFIX}-dfu-util - -# Needs fix for 32bit for dfu-util + ${MINGW_PACKAGE_PREFIX}-openssl \ + ${MINGW_PACKAGE_PREFIX}-wget \ + ${MINGW_PACKAGE_PREFIX}-python-psutil end_step $? "pacman -S --noconfirm " + new_step "Installing dfu-util" + + if [[ "${MINGW_PACKAGE_PREFIX}" == "mingw-w64-x86_64" ]]; then + pacman -S --noconfirm ${MINGW_PACKAGE_PREFIX}-dfu-util + else + wget -qO- https://dfu-util.sourceforge.net/releases/dfu-util-0.11-binaries.tar.xz | tar -xJ + cp dfu-util-0.11-binaries/win32/dfu-util-static.exe /mingw32/bin/dfu-util.exe + cp dfu-util-0.11-binaries/win32/libusb-1.0.dll /mingw32/bin/libusb-1.0.dll + cp dfu-util-0.11-binaries/win32/libusb-1.0.dll.a /mingw32/bin/libusb-1.0.dll.a + fi + + end_step $? "Installing dfu-util" + run_step "Upgrading pip" "python -m pip install -U pip" - run_step "Installing Python clang" "python -m pip install clang" + # wheel required for aqtinstall run_step "Installing Python setuptools and wheel" "python -m pip install setuptools wheel" - run_step "Installing Python jinja2" "python -m pip install jinja2" + if [[ "${MINGW_PACKAGE_PREFIX}" == "mingw-w64-x86_64" ]]; then + run_step "Installing lz4" "pacman -S --noconfirm ${MINGW_PACKAGE_PREFIX}-python-lz4" + else + run_step "Installing lz4" "python -m pip install lz4" + fi + + run_step "Installing Python clang and jinja2" "python -m pip install clang jinja2" +fi + +if [[ $QT_INST -eq 1 ]]; then + # Notes: + # this will also install dependencies + # Nov 2023 psutil is a dependency of aqtinstall but fails to install via dependencies so explicitly install python-psutil # Nov 2023 # From https://github.com/miurahr/aqtinstall Install section # When you want to use it on MSYS2/Mingw64 environment, you need to set environmental variable export SETUPTOOLS_USE_DISTUTILS=stdlib, # because of setuptools package on mingw wrongly raise error VC6.0 is not supported export SETUPTOOLS_USE_DISTUTILS=stdlib - # this will also install dependencies and see note above re psutil issue run_step "Installing Python package aqtinstall" "python -m pip install aqtinstall" fi -if [[ $INSTALL_QT -eq 1 ]]; then +if [[ $QT_BINS -eq 1 ]]; then # if modules use syntax -m MODULE [MODULE] QT_MODULES= # supported versions of dependencies @@ -189,7 +217,7 @@ if [[ $INSTALL_QT -eq 1 ]]; then "python -m aqt install-qt --outputdir ${QT_INSTALL_DIR} ${QT_HOST} ${QT_TARGET} ${QT_VERSION} ${QT_ARCH} ${QT_MODULES}" fi -if [[ $DOWNLOAD_ARM -eq 1 ]]; then +if [[ $ARM_INST -eq 1 ]]; then # Note: the version needs to be kept in sync with EdgeTX/build-edgetx/dev/Dockerfile DOWNLOAD_FILE="gcc-arm-none-eabi-10-2020-q4-major-win32.exe" @@ -205,5 +233,5 @@ if [[ $DOWNLOAD_ARM -eq 1 ]]; then fi echo "" -echo "This stage of setting up EdgeTX build environment has finished" +echo "Stage 2 of setting up EdgeTX build environment has finished" echo ""