Skip to content

Commit

Permalink
Fix 32 bit arm toolchain path add more options
Browse files Browse the repository at this point in the history
  • Loading branch information
elecpower committed Jun 4, 2024
1 parent 6eb58be commit fb56dc4
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 49 deletions.
4 changes: 2 additions & 2 deletions tools/msys2_build_32_64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

This comment has been minimized.

Copy link
@gagarinlg

gagarinlg Jun 4, 2024

Member

We will switch the ARM toolchain to th current ARM GCC Release soon

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}"
Expand Down Expand Up @@ -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]}
Expand Down
6 changes: 3 additions & 3 deletions tools/msys2_common_32_64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
45 changes: 32 additions & 13 deletions tools/msys2_setup_buildenv_stage1_32_64.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -15,6 +17,7 @@ source msys2_common_32_64.sh
# Defaults
INSTALL_64BIT=1
INSTALL_32BIT=0
INSTALL_EXTRAS=1

# == Functions ==

Expand All @@ -29,16 +32,17 @@ 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
}

# == 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
Expand All @@ -50,27 +54,42 @@ 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
usage ;;
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"
Expand All @@ -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."
90 changes: 59 additions & 31 deletions tools/msys2_setup_buildenv_stage2_32_64.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#! /usr/bin/env bash

set -e

## Bash script to setup EdgeTX development environment second stage.

if [[ "$MSYSTEM" == "MSYS" ]]; then
Expand All @@ -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 ==
Expand All @@ -33,10 +36,14 @@ Options:
-d, --download-dir <directory> directory for the arm installer (default: ${DOWNLOAD_DIR})
-e, --edgetx-version <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> version of Qt to install (default: ${QT_VERSION})
Note: Overrides EdgeTX dependent version. Allows installing multiple versions.
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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
Expand All @@ -111,20 +120,15 @@ 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"

pacman -S --noconfirm \
${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 \
Expand All @@ -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 <packages>"

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
Expand Down Expand Up @@ -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"
Expand All @@ -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 ""

0 comments on commit fb56dc4

Please sign in to comment.