[FL-2554] Embedded arm-none-eabi toolchain (#1351)
This commit is contained in:
45
scripts/toolchain/fbtenv.cmd
Normal file
45
scripts/toolchain/fbtenv.cmd
Normal file
@@ -0,0 +1,45 @@
|
||||
@echo off
|
||||
|
||||
if not [%FBT_ROOT%] == [] (
|
||||
goto already_set
|
||||
)
|
||||
|
||||
set "FBT_ROOT=%~dp0\..\..\"
|
||||
pushd %FBT_ROOT%
|
||||
set "FBT_ROOT=%cd%"
|
||||
popd
|
||||
|
||||
if not [%FBT_NOENV%] == [] (
|
||||
exit /b 0
|
||||
)
|
||||
|
||||
set "FLIPPER_TOOLCHAIN_VERSION=3"
|
||||
set "FBT_TOOLCHAIN_ROOT=%FBT_ROOT%\toolchain\i686-windows"
|
||||
|
||||
|
||||
if not exist "%FBT_TOOLCHAIN_ROOT%" (
|
||||
powershell -ExecutionPolicy Bypass -File %FBT_ROOT%\scripts\toolchain\windows-toolchain-download.ps1 "%flipper_toolchain_version%"
|
||||
)
|
||||
if not exist "%FBT_TOOLCHAIN_ROOT%\VERSION" (
|
||||
powershell -ExecutionPolicy Bypass -File %FBT_ROOT%\scripts\toolchain\windows-toolchain-download.ps1 "%flipper_toolchain_version%"
|
||||
)
|
||||
set /p REAL_TOOLCHAIN_VERSION=<%FBT_TOOLCHAIN_ROOT%\VERSION
|
||||
if not "%REAL_TOOLCHAIN_VERSION%" == "%FLIPPER_TOOLCHAIN_VERSION%" (
|
||||
powershell -ExecutionPolicy Bypass -File %FBT_ROOT%\scripts\toolchain\windows-toolchain-download.ps1 "%flipper_toolchain_version%"
|
||||
)
|
||||
|
||||
|
||||
set "HOME=%USERPROFILE%"
|
||||
set "PYTHONHOME=%FBT_TOOLCHAIN_ROOT%\python"
|
||||
set "PATH=%FBT_TOOLCHAIN_ROOT%\python;%FBT_TOOLCHAIN_ROOT%\bin;%FBT_TOOLCHAIN_ROOT%\protoc\bin;%FBT_TOOLCHAIN_ROOT%\openocd\bin;%PATH%"
|
||||
set "PROMPT=(fbt) %PROMPT%"
|
||||
|
||||
:already_set
|
||||
|
||||
if not "%1" == "env" (
|
||||
echo *********************************
|
||||
echo * fbt build environment *
|
||||
echo *********************************
|
||||
cd %FBT_ROOT%
|
||||
cmd /k
|
||||
)
|
54
scripts/toolchain/fbtenv.sh
Executable file
54
scripts/toolchain/fbtenv.sh
Executable file
@@ -0,0 +1,54 @@
|
||||
#!/bin/sh
|
||||
|
||||
# unofficial strict mode
|
||||
set -eu;
|
||||
|
||||
FLIPPER_TOOLCHAIN_VERSION="3";
|
||||
|
||||
get_kernel_type()
|
||||
{
|
||||
SYS_TYPE="$(uname -s)"
|
||||
if [ "$SYS_TYPE" = "Darwin" ]; then
|
||||
TOOLCHAIN_PATH="toolchain/x86_64-darwin";
|
||||
elif [ "$SYS_TYPE" = "Linux" ]; then
|
||||
TOOLCHAIN_PATH="toolchain/x86_64-linux";
|
||||
elif echo "$SYS_TYPE" | grep -q "MINGW"; then
|
||||
echo "In MinGW shell use \"fbt.cmd\" instead of \"fbt\"";
|
||||
exit 1;
|
||||
else
|
||||
echo "Your system is not supported. Sorry. Please report us your configuration.";
|
||||
exit 1;
|
||||
fi
|
||||
}
|
||||
|
||||
check_download_toolchain()
|
||||
{
|
||||
if [ ! -d "$SCRIPT_PATH/$TOOLCHAIN_PATH" ]; then
|
||||
download_toolchain;
|
||||
elif [ ! -f "$SCRIPT_PATH/$TOOLCHAIN_PATH/VERSION" ]; then
|
||||
download_toolchain;
|
||||
elif [ "$(cat "$SCRIPT_PATH/$TOOLCHAIN_PATH/VERSION")" -ne "$FLIPPER_TOOLCHAIN_VERSION" ]; then
|
||||
download_toolchain;
|
||||
fi
|
||||
}
|
||||
|
||||
download_toolchain()
|
||||
{
|
||||
chmod 755 "$SCRIPT_PATH/scripts/toolchain/unix-toolchain-download.sh";
|
||||
"$SCRIPT_PATH/scripts/toolchain/unix-toolchain-download.sh" "$FLIPPER_TOOLCHAIN_VERSION" || exit 1;
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
if [ -z "${SCRIPT_PATH:-}" ]; then
|
||||
echo "Mannual running this script is now allowed.";
|
||||
exit 1;
|
||||
fi
|
||||
get_kernel_type; # sets TOOLCHAIN_PATH
|
||||
check_download_toolchain;
|
||||
PATH="$SCRIPT_PATH/$TOOLCHAIN_PATH/python/bin:$PATH";
|
||||
PATH="$SCRIPT_PATH/$TOOLCHAIN_PATH/bin:$PATH";
|
||||
PATH="$SCRIPT_PATH/$TOOLCHAIN_PATH/protobuf/bin:$PATH";
|
||||
PATH="$SCRIPT_PATH/$TOOLCHAIN_PATH/openocd/bin:$PATH";
|
||||
}
|
||||
main;
|
135
scripts/toolchain/unix-toolchain-download.sh
Executable file
135
scripts/toolchain/unix-toolchain-download.sh
Executable file
@@ -0,0 +1,135 @@
|
||||
#!/bin/sh
|
||||
# shellcheck disable=SC2086,SC2034
|
||||
|
||||
# unofficial strict mode
|
||||
set -eu;
|
||||
|
||||
check_system()
|
||||
{
|
||||
VER="$1"; # toolchain version
|
||||
printf "Checking kernel type..";
|
||||
SYS_TYPE="$(uname -s)"
|
||||
if [ "$SYS_TYPE" = "Darwin" ]; then
|
||||
echo "darwin";
|
||||
TOOLCHAIN_URL="https://update.flipperzero.one/builds/toolchain/gcc-arm-none-eabi-10.3-x86_64-darwin-flipper-$VER.tar.gz";
|
||||
TOOLCHAIN_PATH="toolchain/x86_64-darwin";
|
||||
elif [ "$SYS_TYPE" = "Linux" ]; then
|
||||
echo "linux";
|
||||
TOOLCHAIN_URL="https://update.flipperzero.one/builds/toolchain/gcc-arm-none-eabi-10.3-x86_64-linux-flipper-$VER.tar.gz";
|
||||
TOOLCHAIN_PATH="toolchain/x86_64-linux";
|
||||
else
|
||||
echo "unsupported.";
|
||||
echo "Your system is unsupported.. sorry..";
|
||||
exit 1;
|
||||
fi
|
||||
}
|
||||
|
||||
check_tar()
|
||||
{
|
||||
printf "Checking tar..";
|
||||
if ! tar --version > /dev/null 2>&1; then
|
||||
echo "no";
|
||||
exit 1;
|
||||
fi
|
||||
echo "yes";
|
||||
}
|
||||
|
||||
|
||||
curl_wget_check()
|
||||
{
|
||||
printf "Checking curl..";
|
||||
if ! curl --version > /dev/null 2>&1; then
|
||||
echo "no";
|
||||
printf "Checking wget..";
|
||||
if ! wget --version > /dev/null 2>&1; then
|
||||
echo "no";
|
||||
echo "No curl or wget found in your PATH.";
|
||||
echo "Please provide it or download this file:";
|
||||
echo;
|
||||
echo "$TOOLCHAIN_URL";
|
||||
echo;
|
||||
echo "And place in repo root dir mannualy.";
|
||||
exit 1;
|
||||
fi
|
||||
echo "yes"
|
||||
DOWNLOADER="wget";
|
||||
DOWNLOADER_ARGS="--show-progress --progress=bar:force -qO";
|
||||
return;
|
||||
fi
|
||||
echo "yes"
|
||||
DOWNLOADER="curl";
|
||||
DOWNLOADER_ARGS="--progress-bar -SLo";
|
||||
}
|
||||
|
||||
check_downloaded_toolchain()
|
||||
{
|
||||
printf "Checking downloaded toolchain tgz..";
|
||||
if [ -f "$REPO_ROOT/$TOOLCHAIN_TAR" ]; then
|
||||
echo "yes";
|
||||
return 0;
|
||||
fi
|
||||
echo "no";
|
||||
return 1;
|
||||
}
|
||||
|
||||
download_toolchain()
|
||||
{
|
||||
echo "Downloading toolchain:";
|
||||
"$DOWNLOADER" $DOWNLOADER_ARGS "$REPO_ROOT/$TOOLCHAIN_TAR" "$TOOLCHAIN_URL";
|
||||
echo "done";
|
||||
}
|
||||
|
||||
remove_old_tooclhain()
|
||||
{
|
||||
printf "Removing old toolchain (if exist)..";
|
||||
rm -rf "${REPO_ROOT:?}/$TOOLCHAIN_PATH";
|
||||
echo "done";
|
||||
}
|
||||
|
||||
show_unpack_percentage()
|
||||
{
|
||||
LINE=0;
|
||||
while read -r line; do
|
||||
LINE=$(( LINE + 1 ));
|
||||
if [ $(( LINE % 300 )) -eq 0 ]; then
|
||||
printf "#";
|
||||
fi
|
||||
done
|
||||
echo " 100.0%";
|
||||
}
|
||||
|
||||
unpack_toolchain()
|
||||
{
|
||||
echo "Unpacking toolchain:";
|
||||
tar -xvf "$REPO_ROOT/$TOOLCHAIN_TAR" -C "$REPO_ROOT/" 2>&1 | show_unpack_percentage;
|
||||
mkdir -p "$REPO_ROOT/toolchain";
|
||||
mv "$REPO_ROOT/$TOOLCHAIN_DIR" "$REPO_ROOT/$TOOLCHAIN_PATH/";
|
||||
echo "done";
|
||||
}
|
||||
|
||||
clearing()
|
||||
{
|
||||
printf "Clearing..";
|
||||
rm -rf "${REPO_ROOT:?}/$TOOLCHAIN_TAR";
|
||||
echo "done";
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
SCRIPT_PATH="$(cd "$(dirname "$0")" && pwd -P)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_PATH/../../" && pwd)";
|
||||
check_system "$1"; # recives TOOLCHAIN_VERSION, defines TOOLCHAIN_URL and TOOLCHAIN_PATH
|
||||
check_tar;
|
||||
TOOLCHAIN_TAR="$(basename "$TOOLCHAIN_URL")";
|
||||
TOOLCHAIN_DIR="$(echo "$TOOLCHAIN_TAR" | sed "s/-$VER.tar.gz//g")";
|
||||
if ! check_downloaded_toolchain; then
|
||||
curl_wget_check;
|
||||
download_toolchain;
|
||||
fi
|
||||
remove_old_tooclhain;
|
||||
unpack_toolchain;
|
||||
}
|
||||
|
||||
trap clearing EXIT;
|
||||
trap clearing 2; # SIGINT not coverable by EXIT
|
||||
main "$1"; # toochain version
|
34
scripts/toolchain/windows-toolchain-download.ps1
Normal file
34
scripts/toolchain/windows-toolchain-download.ps1
Normal file
@@ -0,0 +1,34 @@
|
||||
Set-StrictMode -Version 2.0
|
||||
$ErrorActionPreference = "Stop"
|
||||
[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"
|
||||
$repo_root = (Get-Item "$PSScriptRoot\..\..").FullName
|
||||
$toolchain_version = $args[0]
|
||||
$toolchain_url = "https://update.flipperzero.one/builds/toolchain/gcc-arm-none-eabi-10.3-i686-windows-flipper-$toolchain_version.zip"
|
||||
$toolchain_zip = "gcc-arm-none-eabi-10.3-i686-windows-flipper-$toolchain_version.zip"
|
||||
$toolchain_dir = "gcc-arm-none-eabi-10.3-i686-windows-flipper"
|
||||
|
||||
if (Test-Path -LiteralPath "$repo_root\toolchain\i686-windows") {
|
||||
Write-Host -NoNewline "Removing old Windows toolchain.."
|
||||
Remove-Item -LiteralPath "$repo_root\toolchain\i686-windows" -Force -Recurse
|
||||
Write-Host "done!"
|
||||
}
|
||||
if (!(Test-Path -Path "$repo_root\$toolchain_zip" -PathType Leaf)) {
|
||||
Write-Host -NoNewline "Downloading Windows toolchain.."
|
||||
$wc = New-Object net.webclient
|
||||
$wc.Downloadfile("$toolchain_url", "$repo_root\$toolchain_zip")
|
||||
Write-Host "done!"
|
||||
}
|
||||
|
||||
if (!(Test-Path -LiteralPath "$repo_root\toolchain")) {
|
||||
New-Item "$repo_root\toolchain" -ItemType Directory
|
||||
}
|
||||
|
||||
Write-Host -NoNewline "Unziping Windows toolchain.."
|
||||
Add-Type -Assembly "System.IO.Compression.Filesystem"
|
||||
[System.IO.Compression.ZipFile]::ExtractToDirectory("$toolchain_zip", "$repo_root\")
|
||||
Move-Item -Path "$repo_root\$toolchain_dir" -Destination "$repo_root\toolchain\i686-windows"
|
||||
Write-Host "done!"
|
||||
|
||||
Write-Host -NoNewline "Clearing temporary files.."
|
||||
Remove-Item -LiteralPath "$repo_root\$toolchain_zip" -Force
|
||||
Write-Host "done!"
|
Reference in New Issue
Block a user