-
-
Notifications
You must be signed in to change notification settings - Fork 54
/
install-pi.sh
executable file
·125 lines (108 loc) · 4.08 KB
/
install-pi.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/env bash
# Install Rust and Mynewt Build Tools for Raspberry Pi. Based on https://mynewt.apache.org/latest/newt/install/newt_linux.html.
echo "Installing Rust and Mynewt Build Tools for Raspberry Pi..."
set -e # Exit when any command fails.
set -x # Echo all commands.
# Preqrequisites: (Remove folders ~/pinetime-rust-mynewt and ~/openocd-spi if they exist)
# sudo apt install -y wget p7zip-full
# cd ~
# wget https://github.com/lupyuen/pinetime-rust-mynewt/releases/download/v2.0.2/pinetime-rust-mynewt.7z
# 7z x pinetime-rust-mynewt.7z
# rm pinetime-rust-mynewt.7z
# cd ~/pinetime-rust-mynewt
# scripts/install-pi.sh
# Configure scripts for Raspberry Pi
echo "source scripts/nrf52-pi/config.sh" >scripts/config.sh
set +x; echo; echo "----- Setting versions..."; set -x
source scripts/install-version.sh
set +x; echo; echo "----- Installing Rust. When prompted, press Enter to select default option..."; sleep 5; set -x
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
rustup default nightly
rustup update
rustup target add thumbv7em-none-eabihf
set +x; echo; echo "----- Installing build tools..."; set -x
sudo apt install -y wget git autoconf libtool make pkg-config libusb-1.0-0 libusb-1.0-0-dev libhidapi-dev libftdi-dev telnet p7zip-full
set +x; echo; echo "----- Installing gcc..."; set -x
sudo apt install -y gcc-arm-none-eabi
set +x; echo; echo "----- Installing gdb..."; set -x
if [ ! -e /usr/bin/arm-none-eabi-gdb ]; then
sudo apt install -y gdb-multiarch
sudo ln -s /usr/bin/gdb-multiarch /usr/bin/arm-none-eabi-gdb
fi
set +x; echo; echo "----- Installing VSCode..."; set -x
if [ ! -e /usr/bin/code-oss ]; then
cd ~
wget https://code.headmelted.com/installers/apt.sh
chmod +x apt.sh
sudo -s ./apt.sh
fi
set +x; echo; echo "----- Installing openocd-spi..."; set -x
if [ ! -d $HOME/openocd-spi ]; then
pushd $HOME
git clone --branch $openocd_version https://github.com/lupyuen/openocd-spi
cd openocd-spi
./bootstrap
./configure --enable-sysfsgpio --enable-bcm2835spi --enable-cmsis-dap
make
popd
fi
cp $HOME/openocd-spi/src/openocd $HOME/pinetime-rust-mynewt/openocd/bin/openocd
# Install go for building newt
set +x; echo; echo "----- Installing go..."; set -x
golangpath=/usr/lib/go-1.13.6/bin
if [ ! -e $golangpath/go ]; then
if [[ $(uname -m) == aarch64 ]];then
wget https://dl.google.com/go/go1.13.6.linux-arm64.tar.gz
else
wget https://dl.google.com/go/go1.13.6.linux-armv6l.tar.gz
fi
tar xf go*.tar.gz
sudo mv go /usr/lib/go-1.13.6
rm go*.tar.gz
echo export PATH=$golangpath:\$PATH >> ~/.bashrc
echo export PATH=$golangpath:\$PATH >> ~/.profile
echo export GOROOT= >> ~/.bashrc
echo export GOROOT= >> ~/.profile
fi
export PATH=$golangpath:$PATH
# Prevent mismatch library errors when building newt.
export GOROOT=
go version # Should show "go1.13" or later.
# Change owner from root back to user for the installed packages.
set +x; echo; echo "----- Fixing ownership..."; set -x
if [ -d "$HOME/.caches" ]; then
sudo chown -R $USER:$USER "$HOME/.caches"
fi
if [ -d "$HOME/.config" ]; then
sudo chown -R $USER:$USER "$HOME/.config"
fi
if [ -d "$HOME/opt" ]; then
sudo chown -R $USER:$USER "$HOME/opt"
fi
set +x; echo; set -x
# Build newt in /tmp/mynewt. Copy to /usr/local/bin.
set +x; echo; echo "----- Installing newt..."; set -x
if [ ! -e /usr/local/bin/newt ]; then
mynewtpath=/tmp/mynewt
if [ -d $mynewtpath ]; then
rm -rf $mynewtpath
fi
mkdir $mynewtpath
pushd $mynewtpath
git clone --branch $mynewt_version https://github.com/apache/mynewt-newt/
cd mynewt-newt/
./build.sh
sudo mv newt/newt /usr/local/bin
popd
fi
newt version # Should show "Version: 1.7.0" or later. Should NOT show "...-dev".
# echo "----- Installing mynewt..."
# Remove the existing Mynewt OS in "repos"
# if [ -d repos ]; then
# rm -rf repos
# fi
# Download Mynewt OS into the current project folder, under "repos" subfolder.
# newt install -v -f
set +x # Stop echoing all commands.
echo ✅ ◾ ️Done!