-
Notifications
You must be signed in to change notification settings - Fork 0
/
pico_setup.sh
executable file
·159 lines (129 loc) · 3.75 KB
/
pico_setup.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/bin/bash
# Exit on error
set -e
# Number of cores when running make
JNUM=`nproc`
# Where will the output go?
OUTDIR="$(pwd)/pico"
# Install dependencies
GIT_DEPS="git"
SDK_DEPS="cmake gcc g++"
OPENOCD_DEPS="automake autoconf @development-tools @c-development texinfo libtool libftdi-devel libusb1-devel"
UART_DEPS="minicom"
# Build full list of dependencies
DEPS="$GIT_DEPS $SDK_DEPS"
if [[ "$SKIP_OPENOCD" == 1 ]]; then
echo "Skipping OpenOCD (debug support)"
else
DEPS="$DEPS $OPENOCD_DEPS"
fi
if [[ "$SKIP_VSCODE" == 1 ]]; then
echo "Skipping VSCODE"
fi
echo "Installing Dependencies"
sudo dnf update
sudo dnf install -y $DEPS
echo "Creating $OUTDIR"
# Create pico directory to put everything in
mkdir -p $OUTDIR
cd $OUTDIR
# Clone sw repos
GITHUB_PREFIX="https://github.com/raspberrypi/"
GITHUB_SUFFIX=".git"
SDK_BRANCH="master"
for REPO in sdk examples extras playground
do
DEST="$OUTDIR/pico-$REPO"
if [ -d $DEST ]; then
echo "$DEST already exists so skipping"
else
REPO_URL="${GITHUB_PREFIX}pico-${REPO}${GITHUB_SUFFIX}"
echo "Cloning $REPO_URL"
git clone -b $SDK_BRANCH $REPO_URL
# Any submodules
cd $DEST
git submodule update --init
cd $OUTDIR
# Define PICO_SDK_PATH in ~/.bashrc
VARNAME="PICO_${REPO^^}_PATH"
echo "Adding $VARNAME to ~/.bashrc"
echo "export $VARNAME=$DEST" >> ~/.bashrc
export ${VARNAME}=$DEST
fi
done
cd $OUTDIR
# Pick up new variables we just defined
source ~/.bashrc
# Build a couple of examples
cd "$OUTDIR/pico-examples"
mkdir build
cd build
cmake ../ -DCMAKE_BUILD_TYPE=Debug
for e in blink hello_world
do
echo "Building $e"
cd $e
make -j$JNUM
cd ..
done
cd $OUTDIR
# Picoprobe and picotool
for REPO in picoprobe picotool
do
DEST="$OUTDIR/$REPO"
REPO_URL="${GITHUB_PREFIX}${REPO}${GITHUB_SUFFIX}"
git clone $REPO_URL
# Build both
cd $DEST
mkdir build
cd build
cmake ../
make -j$JNUM
if [[ "$REPO" == "picotool" ]]; then
echo "Installing picotool to /usr/local/bin/picotool"
sudo cp picotool /usr/local/bin/
fi
cd $OUTDIR
done
if [ -d openocd ]; then
echo "openocd already exists so skipping"
SKIP_OPENOCD=1
fi
if [[ "$SKIP_OPENOCD" == 1 ]]; then
echo "Won't build OpenOCD"
else
# Build OpenOCD
echo "Building OpenOCD"
cd $OUTDIR
# Should we include picoprobe support (which is a Pico acting as a debugger for another Pico)
INCLUDE_PICOPROBE=1
OPENOCD_BRANCH="rp2040"
OPENOCD_CONFIGURE_ARGS="--enable-ftdi --enable-sysfsgpio --enable-bcm2835gpio"
if [[ "$INCLUDE_PICOPROBE" == 1 ]]; then
OPENOCD_CONFIGURE_ARGS="$OPENOCD_CONFIGURE_ARGS --enable-picoprobe"
fi
git clone "${GITHUB_PREFIX}openocd${GITHUB_SUFFIX}" -b $OPENOCD_BRANCH --depth=1
cd openocd
./bootstrap
./configure --prefix=/usr $OPENOCD_CONFIGURE_ARGS
make -j$JNUM
sudo make install
fi
cd $OUTDIR
# Liam needed to install these to get it working
if [[ "$SKIP_VSCODE" == 1 ]]; then
echo "Won't include VSCODE"
else
echo "Installing VSCODE"
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo'
dnf check-update
sudo dnf install code
# Get extensions
code --install-extension marus25.cortex-debug
code --install-extension twxs.cmake
code --install-extension ms-vscode.cmake-tools
code --install-extension ms-vscode.cpptools
code --install-extension ms-vscode.cpptools-extension-pack
code --install-extension ms-vscode.cpptools-themes
fi