Skip to content

Commit

Permalink
tools: Update toolchain version
Browse files Browse the repository at this point in the history
- Update toolchain version to 10.3
- Fix a bug that checksum failed at installing linux aarch64 toolchain
- Refactoring
  • Loading branch information
SPRESENSE committed Feb 14, 2023
1 parent c901346 commit b8bd50b
Showing 1 changed file with 67 additions and 40 deletions.
107 changes: 67 additions & 40 deletions install-tools.sh
Expand Up @@ -44,13 +44,14 @@ NXTOOLARCHIVE=${NXTOOL}.tar.gz
GENROMFS=genromfs-0.5.2

CROSSBASEURL=https://developer.arm.com/-/media/Files/downloads/gnu-rm
CROSSTOOLDIR=9-2019q4
CROSSTOOLFILE=gcc-arm-none-eabi-9-2019-q4-major
CROSSTOOLDIR=10.3-2021.10
CROSSTOOLFILE=gcc-arm-none-eabi-10.3-2021.10

# MD5 check sums
TOOLCHAINSUM_win=82525522fefbde0b7811263ee8172b10
TOOLCHAINSUM_mac=241b64f0578db2cf146034fc5bcee3d4
TOOLCHAINSUM_linux=fe0029de4f4ec43cf7008944e34ff8cc
TOOLCHAINSUM_win=2bc8f0c4c4659f8259c8176223eeafc1
TOOLCHAINSUM_mac=7f2a7b7b23797302a9d6182c6e482449
TOOLCHAINSUM_linux_x86_64=2383e4eb4ea23f248d33adc70dc3227e
TOOLCHAINSUM_linux_aarch64=3fe3d8bb693bd0a6e4615b6569443d0d

OPENOCDBASEURL=https://github.com/sonydevworld/spresense-openocd-prebuilt/releases/download
OPENOCDRELEASE=v0.10.0-spr1
Expand Down Expand Up @@ -123,6 +124,11 @@ mac_install_tools()
: # do nothing
}

wsl_install_tools()
{
linux_install_tools # XXX: We expects that Ubuntu runs on WSL
}

install_nxtools()
{
local _kconfig=${SPRROOT}/usr/bin/kconfig-conf
Expand Down Expand Up @@ -179,11 +185,12 @@ linux_install_toolchain()
return
fi

_fn=${CROSSTOOLFILE}-${_mach}-${OS}.tar.bz2
_fn=${CROSSTOOLFILE}-${_mach}-linux.tar.bz2

download ${CROSSBASEURL}/${CROSSTOOLDIR}/${_fn} ${_fn}

echo ${TOOLCHAINSUM_linux} ${_fn} > .sum
local _csum=TOOLCHAINSUM_linux_${_mach}
echo ${!_csum} ${_fn} > .sum
eval md5sum -c .sum
rm -f .sum
if [ "$?" -ne "0" ]; then
Expand All @@ -198,15 +205,21 @@ linux_install_toolchain()

win_install_toolchain()
{
local _target=${1:-${SPRROOT}/usr}

# Check the cross toolchain already exists

[ -e ${SPRROOT}/usr/bin/arm-none-eabi-gcc ] && return
[ -e ${_target}/bin/arm-none-eabi-gcc ] && return

local _fn=${CROSSTOOLFILE}-win32.zip

download ${CROSSBASEURL}/${CROSSTOOLDIR}/${_fn} ${_fn}

run_progress unzip -o -d ${SPRROOT}/usr ${_fn}
run_progress unzip ${_fn}

mkdir -p ${_target}
cp -ar ${CROSSTOOLFILE}/* ${_target}
rm -rf ${CROSSTOOLFILE}
}

mac_install_toolchain()
Expand All @@ -217,7 +230,7 @@ mac_install_toolchain()

# Download cross toolchain

local _fn=${CROSSTOOLFILE}-${OS}.tar.bz2
local _fn=${CROSSTOOLFILE}-mac.tar.bz2

download ${CROSSBASEURL}/${CROSSTOOLDIR}/${_fn} ${_fn}

Expand All @@ -232,11 +245,22 @@ mac_install_toolchain()
run_progress tar vjxf ${_fn} --strip-components=1 -C ${SPRROOT}/usr
}

wsl_install_toolchain()
{
# XXX: We need to both of linux and windows toolschains for different purpose,
# linux toolchain to use build, windows toolchain is only use gdb from IDE.

linux_install_toolchain
win_install_toolchain ${SPRROOT}/windows
}

openocd_need_update()
{
[ -e ${SPRROOT}/usr/bin/openocd ] || return 0
local _target=${1:-${SPRROOT}/usr}

[ -e ${_target}/bin/openocd ] || return 0

local _rev=`${SPRROOT}/usr/bin/openocd 2>&1 | head -n1 | sed -e 's/.*dev-\([0-9]*\)-.*/\1/'`
local _rev=`${_target}/bin/openocd 2>&1 | head -n1 | sed -e 's/.*dev-\([0-9]*\)-.*/\1/'`

# Test if unknown revision or revision less than OPENOCDREV
[ -z "${_rev}" ] || [ "${_rev}" -lt "${OPENOCDREV}" ] && return 0
Expand All @@ -247,8 +271,9 @@ linux_install_openocd()
{
local _fn=${OPENOCDVERDATE}
local _sha
local _target=${1:-${SPRROOT}/usr}

openocd_need_update || return
openocd_need_update $_target || return

local _mach=`uname -m 2>/dev/null`

Expand All @@ -271,8 +296,9 @@ win_install_openocd()
{
local _fn=${OPENOCDVERDATE}
local _sha=${_fn}.sha
local _target=${1:-${SPRROOT}/usr}

openocd_need_update || return
openocd_need_update $_target || return

if [ "`uname -m 2>/dev/null`" = "x86_64" ]; then
_fn=${_fn}-win64.zip
Expand All @@ -291,16 +317,17 @@ win_install_openocd()
# and move from appropriate directory level to SPRROOT.

run_progress unzip -o ${_fn}
cp -ar "${OPENOCDVERDATE}/"* ${SPRROOT}/usr || exit 1
cp -ar "${OPENOCDVERDATE}/"* ${_target} || exit 1
rm -rf "${OPENOCDVERDATE}"
}

mac_install_openocd()
{
local _fn=${OPENOCDVERDATE}-macosx.tar.bz2
local _sha=${_fn}.sha
local _target=${1:-${SPRROOT}/usr}

openocd_need_update || return
openocd_need_update $_target || return

download ${OPENOCDBASEURL}/${OPENOCDRELEASE}/${_fn} ${_fn}
download ${OPENOCDBASEURL}/${OPENOCDRELEASE}/${_sha} ${_sha}
Expand All @@ -310,6 +337,11 @@ mac_install_openocd()
run_progress tar vjxf ${_fn} --strip-components=1 -C ${SPRROOT}/usr
}

wsl_install_openocd()
{
win_install_openocd ${SPRROOT}/windows
}

while [ ! -z "$*" ]
do
case "$1" in
Expand Down Expand Up @@ -344,20 +376,23 @@ case "`uname -s`" in
esac

ARCH=`uname -m 2>/dev/null`
ISWSL=`uname -r | grep -i microsoft`
# 32bit linux is not supported
if [ "${OS}" == "linux" ]; then
if [ "${ARCH}" != "x86_64" ] && [ "${ARCH}" != "aarch64" ]; then
echo Sorry, this platform is not supported.
exit 1
echo Sorry, this platform is not supported.
exit 1
fi

if [ "$(grep enabled /proc/sys/fs/binfmt_misc/WSLInterop 2>/dev/null)" = "enabled" ]; then
OS="wsl"
fi
fi

# Switch SPRROOT by platform
if [ "${OS}" == "win" ]; then
SPRROOT=/opt/${SPRBASENAME}
SPRROOT=/opt/${SPRBASENAME}
else
SPRROOT=${HOME}/${SPRBASENAME}
SPRROOT=${HOME}/${SPRBASENAME}
fi

# Re-install
Expand All @@ -381,29 +416,21 @@ install_nxtools

echo "== Install cross toolchain"
${OS}_install_toolchain
if [ "${ISWSL}" != "" ]; then
# For WSL
SPRROOT=${HOME}/${SPRBASENAME}/windows
mkdir -p ${SPRROOT}/usr
win_install_toolchain
for exe in ${SPRROOT}/usr/bin/arm-none-eabi-*.exe
do
linkdest=$(dirname ${exe})/$(basename ${exe} .exe)
if [ ! -e ${linkdest} ]; then
ln -s ${exe} ${linkdest}
fi
done
SPRROOT=${HOME}/${SPRBASENAME}
fi

# Install openocd prebuilt binary

${OS}_install_openocd
if [ "${ISWSL}" != "" ]; then
# For WSL
SPRROOT=${HOME}/${SPRBASENAME}/windows
win_install_openocd
SPRROOT=${HOME}/${SPRBASENAME}

# On WSL, we need to symbolic links to .exe files and add x permission

if [ "$OS" = "wsl" ]; then
cd ${SPRROOT}/windows/bin
for f in *
do
chmod +x $f 2>/dev/null
ln -sf $f $(basename $f .exe) 2>/dev/null
done
cd - >/dev/null 2>&1
fi

# Create PATH environment setup support script
Expand Down

0 comments on commit b8bd50b

Please sign in to comment.