mirror of
https://github.com/espruino/Espruino.git
synced 2025-12-08 19:06:15 +00:00
130 lines
4.5 KiB
Bash
Executable File
130 lines
4.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# This file is part of Espruino, a JavaScript interpreter for Microcontrollers
|
|
#
|
|
# Copyright (C) 2017 Gordon Williams <gw@pur3.co.uk>
|
|
# wilberforce (Rhys Williams)
|
|
#
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
#
|
|
# -----------------------------------------------------------------------------
|
|
# Setup toolchain and libraries for build targets, installs if missing
|
|
# set env vars for builds
|
|
# For use in:
|
|
# Travis
|
|
# Firmware builds
|
|
# Docker
|
|
#
|
|
# -----------------------------------------------------------------------------
|
|
|
|
if [ $# -eq 0 ]
|
|
then
|
|
echo "USAGE:"
|
|
echo "source scripts/provision.sh {BOARD}"
|
|
return 1
|
|
fi
|
|
|
|
# set the current board
|
|
BOARDNAME=$1
|
|
FAMILY=`scripts/get_board_info.py $BOARDNAME 'board.chip["family"]'`
|
|
|
|
if [ "$FAMILY" = "ESP32" ]; then
|
|
echo ESP32
|
|
# needed for esptool for merging binaries
|
|
sudo DEBIAN_FRONTEND=noninteractive apt-get install -qq -y python python-pip
|
|
sudo pip -q install pyserial
|
|
# SDK
|
|
if [ ! -d "app" ]; then
|
|
echo installing app folder
|
|
curl -Ls https://github.com/espruino/EspruinoBuildTools/raw/master/esp32/deploy/app.tgz | tar xfz - --no-same-owner
|
|
#curl -Ls https://github.com/espruino/EspruinoBuildTools/raw/ESP32-v3.0/esp32/deploy/app.tgz | tar xfz - --no-same-owner
|
|
fi
|
|
if [ ! -d "esp-idf" ]; then
|
|
echo installing esp-idf folder
|
|
curl -Ls https://github.com/espruino/EspruinoBuildTools/raw/master/esp32/deploy/esp-idf.tgz | tar xfz - --no-same-owner
|
|
#curl -Ls https://github.com/espruino/EspruinoBuildTools/raw/ESP32-v3.0/esp32/deploy/esp-idf.tgz | tar xfz - --no-same-owner
|
|
fi
|
|
if ! type xtensa-esp32-elf-gcc 2> /dev/null > /dev/null; then
|
|
echo installing xtensa-esp32-elf-gcc
|
|
if [ ! -d "xtensa-esp32-elf" ]; then
|
|
curl -Ls https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz | tar xfz - --no-same-owner
|
|
else
|
|
echo "Folder found"
|
|
fi
|
|
fi
|
|
which xtensa-esp32-elf-gcc
|
|
export ESP_IDF_PATH=`pwd`/esp-idf
|
|
export ESP_APP_TEMPLATE_PATH=`pwd`/app
|
|
export PATH=$PATH:`pwd`/xtensa-esp32-elf/bin/
|
|
return 0
|
|
elif [ "$FAMILY" = "ESP8266" ]; then
|
|
echo ESP8266
|
|
if [ ! -d "ESP8266_NONOS_SDK-2.2.1" ]; then
|
|
echo ESP8266_NONOS_SDK-2.2.1
|
|
curl -Ls https://github.com/espruino/EspruinoBuildTools/raw/master/esp8266/ESP8266_NONOS_SDK-2.2.1.tgz| tar Jxf - --no-same-owner
|
|
fi
|
|
if ! type xtensa-lx106-elf-gcc 2> /dev/null > /dev/null; then
|
|
echo installing xtensa-lx106-elf-gcc
|
|
if [ ! -d "xtensa-lx106-elf" ]; then
|
|
curl -Ls http://s3.voneicken.com/xtensa-lx106-elf-20160330.tgx | tar Jxf - --no-same-owner
|
|
else
|
|
echo "Folder found"
|
|
fi
|
|
|
|
fi
|
|
which xtensa-lx106-elf-gcc
|
|
export ESP8266_SDK_ROOT=`pwd`/ESP8266_NONOS_SDK-2.2.1
|
|
export PATH=$PATH:`pwd`/xtensa-lx106-elf/bin/
|
|
return 0
|
|
elif [ "$FAMILY" = "LINUX" ]; then
|
|
echo LINUX
|
|
# Raspberry Pi?
|
|
return 0
|
|
elif [ "$FAMILY" = "NRF52" ]; then
|
|
echo NRF52
|
|
if ! type nrfutil 2> /dev/null > /dev/null; then
|
|
echo Installing nrfutil
|
|
sudo DEBIAN_FRONTEND=noninteractive apt-get install -qq -y python python-pip
|
|
sudo pip -q install nrfutil
|
|
fi
|
|
ARM=1
|
|
elif [ "$FAMILY" = "NRF51" ]; then
|
|
ARM=1
|
|
elif [ "$FAMILY" = "STM32F1" ]; then
|
|
ARM=1
|
|
elif [ "$FAMILY" = "STM32F3" ]; then
|
|
ARM=1
|
|
elif [ "$FAMILY" = "STM32F4" ]; then
|
|
ARM=1
|
|
elif [ "$FAMILY" = "STM32L4" ]; then
|
|
ARM=1
|
|
elif [ "$FAMILY" = "EFM32GG" ]; then
|
|
ARM=1
|
|
elif [ "$FAMILY" = "SAMD" ]; then
|
|
ARM=1
|
|
else
|
|
echo "Unknown board ($BOARDNAME) or family ($FAMILY)"
|
|
return 1
|
|
fi
|
|
|
|
if [ $ARM = "1" ]; then
|
|
# defaulting to ARM
|
|
echo ARM
|
|
if ! type arm-none-eabi-gcc 2> /dev/null > /dev/null; then
|
|
echo installing gcc-arm-embedded
|
|
#sudo add-apt-repository -y ppa:team-gcc-arm-embedded/ppa
|
|
#sudo apt-get update
|
|
#sudo DEBIAN_FRONTEND=noninteractive apt-get --force-yes --yes install libsdl1.2-dev gcc-arm-embedded
|
|
# Unpack - newer, and much faster
|
|
if [ ! -d "gcc-arm-none-eabi-6-2017-q1-update" ]; then
|
|
curl -Ls https://github.com/espruino/EspruinoBuildTools/raw/master/arm/gcc-arm-none-eabi-6-2017-q1-update-linux.tar.bz2 | tar xfj - --no-same-owner
|
|
else
|
|
echo "Folder found"
|
|
fi
|
|
export PATH=$PATH:`pwd`/gcc-arm-none-eabi-6-2017-q1-update/bin
|
|
fi
|
|
return 0
|
|
fi
|