Skip to content

Commit 9fbed81

Browse files
author
Michael Stoops
committed
Bug fixes and improved compatibility.
1 parent 2d1dafe commit 9fbed81

File tree

4 files changed

+48
-71
lines changed

4 files changed

+48
-71
lines changed

README.md

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ Raspberry Pi Pico Setup provides a script for installing the Pico SDK and toolch
44

55
# How-To
66

7-
<<<<<<< HEAD
8-
Download and run `pico_setup.sh`.
9-
=======
107
Download and run `pico_setup.sh`:
118
```shell
129
wget https://raw.githubusercontent.com/raspberrypi/pico-setup/master/pico_setup.sh
@@ -16,30 +13,24 @@ chmod +x pico_setup
1613
The script uses sudo, so you may need to enter your password.
1714

1815
After the script is complete, reboot to ensure that all changes take effect, such as the UART settings and environment variables.
19-
>>>>>>> 4f2c6f4... Major rewrite. Added support for macOS, Debian, Ubuntu. Added test/validation script.
2016

2117
If you want the testing script and documentation, you can clone the git repo too.
2218

2319
# Support
2420

21+
This script works on most Debian-derived Linux distros and macOS, running on common Raspberry Pi, PC, and Mac hardware. This ***DOESN'T*** mean that all of the pico tools work properly on these platforms. It just means that this script runs and passes its own tests.
22+
2523
Operating systems:
2624
* Raspberry Pi OS (32-bit)
2725
* Debian 10 (Buster)
2826
* Ubuntu 20.10 (Groovy)
2927
* macOS 11 (Big Sur)
28+
* Ubuntu 20.04 on Windows Subsystem for Linux on Windows Server 2019 Base
29+
* Debian GNU/Linux 1.3.0.0 on Windows Subsystem for Linux on Windows Server 2019 Base
3030

31-
Hardware:
32-
<<<<<<< HEAD
33-
* Raspberry Pi 2/3/4/400
34-
* PC (x86_64)
35-
* Mac (both Intel and Apple Silicon)
36-
37-
Other versions may work, but haven't been tested. Use at your own risk.
38-
39-
# Testing
31+
This script does not support Windows natively, only Windows Subsystem for Linux.
4032

41-
See [test/README.md](test/README.md)
42-
=======
33+
Hardware:
4334
* Raspberry Pi 2/3/4/400/CM3/CM4
4435
* PC (x86_64)
4536
* Mac (both Intel and Apple Silicon)
@@ -49,4 +40,3 @@ Other OSes and hardware may work, but haven't been tested. Use at your own risk.
4940
# Testing
5041

5142
See [test/README.md](test/README.md).
52-
>>>>>>> 4f2c6f4... Major rewrite. Added support for macOS, Debian, Ubuntu. Added test/validation script.

pico_setup.sh

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
# Download and install Visual Studio Code and required extensions
2121

2222

23-
2423
# Exit on error
2524
set -e
2625
# Show all commands
@@ -112,7 +111,7 @@ phase_0() {
112111
install_toolchain_linux() {
113112
# Install toolchain for Linux
114113

115-
DEPS="git cmake gcc-arm-none-eabi build-essential gdb-multiarch automake autoconf build-essential texinfo libtool libftdi-dev libusb-1.0-0-dev"
114+
DEPS="python3 git cmake gcc-arm-none-eabi build-essential gdb-multiarch automake autoconf build-essential texinfo libtool libftdi-dev libusb-1.0-0-dev"
116115
if debian || ubuntu; then
117116
DEPS="${DEPS} pkg-config libstdc++-arm-none-eabi-newlib"
118117
fi
@@ -172,9 +171,10 @@ clone_repo() {
172171
fi
173172
}
174173

175-
set_envs() {
176-
# Permanently sets environment variables by adding them to the current user's profile script
177-
# arguments should be in the form of FOO=foo BAR=bar
174+
set_env() {
175+
# Permanently sets an environment variable by adding it to the current user's profile script
176+
# $1 should be in the form of FOO=foo
177+
EXPR="${1}"
178178

179179
# detect appropriate file for setting env vars
180180
if echo "${SHELL}" | grep -q zsh; then
@@ -186,25 +186,23 @@ set_envs() {
186186
fi
187187

188188
# ensure that appends go to a new line
189-
if [ -f ${FILE} ]; then
190-
if tail -n 1 ${FILE} | grep -q "^$"; then
189+
if [ -f "${FILE}" ]; then
190+
if tail -n 1 "${FILE}" | grep -q "^$"; then
191191
echo "${FILE} exists and has trailing newline."
192192
else
193193
echo "${FILE} exists but has no trailing newline. Adding newline."
194-
echo >> ${FILE}
194+
echo >> "${FILE}"
195195
fi
196196
fi
197197

198-
for EXPR in ${*}; do
199-
# set for now
200-
export "${EXPR}"
201-
202-
# set for later
203-
if ! grep -q "^export ${EXPR}$" ${FILE}; then
204-
echo "Setting env variable ${EXPR} in ${FILE}"
205-
echo "export ${EXPR}" >> ${FILE}
206-
fi
207-
done
198+
# set for now
199+
export "${EXPR}"
200+
201+
# set for later
202+
if ! grep -q "^export ${EXPR}$" "${FILE}"; then
203+
echo "Setting env variable ${EXPR} in ${FILE}"
204+
echo "export \"${EXPR}\"" >> "${FILE}"
205+
fi
208206
}
209207

210208
setup_sdk() {
@@ -216,7 +214,7 @@ setup_sdk() {
216214
# Set env var PICO_SDK_PATH
217215
REPO_UPPER=$(echo ${REPO_NAME} | tr "[:lower:]" "[:upper:]")
218216
REPO_UPPER=$(echo ${REPO_UPPER} | tr "-" "_")
219-
set_envs "${REPO_UPPER}_PATH=$DEST"
217+
set_env "${REPO_UPPER}_PATH=$DEST"
220218
}
221219

222220
enable_uart() {

test/README.md

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,18 @@ If all of the dependencies (APT repo, etc) are in good shape, this should work t
3232
Write fresh SD card with Raspberry Pi Imager.
3333

3434
### Raspberry Pi OS Lite (32-bit) on Raspberry Pi 4B
35-
Should be the same as the full OS. Currently, this will install Visual Studio Code, but that may change.
35+
Should be the same as the full OS, but doesn't install Visual Studio Code because there's no XWindows.
3636

3737
Write fresh SD card with Raspberry Pi Imager.
3838

3939
### Ubuntu Desktop 20.10 (64-bit) on Raspberry Pi 4B
40+
Not yet tested.
41+
42+
Less common. Should work a lot like Raspberry Pi OS, but with a couple different package dependencies.
43+
44+
Write fresh SD card with Raspberry Pi Imager.
45+
46+
### Ubuntu Server 20.10 (32-bit) on Raspberry Pi 4B
4047
Less common. Should work a lot like Raspberry Pi OS, but with a couple different package dependencies.
4148

4249
Write fresh SD card with Raspberry Pi Imager.
@@ -89,25 +96,29 @@ passwd admin
8996
### Windows Server 2016 Base on x86_64
9097
Not yet tested. See https://aws.amazon.com/marketplace/server/procurement?productId=13c2dbc9-57fc-4958-922e-a1ba7e223b0d.
9198

92-
### Ubuntu 20.04 on WSL2 on Windows Server 2019 Base on x86_64
93-
Not yet tested. https://aws.amazon.com/marketplace/server/procurement?productId=ef297a90-3ad0-4674-83b4-7f0ec07c39bb.
94-
95-
t3.large
99+
### Ubuntu 20.04 on WSL1 on Windows Server 2019 Base on x86_64
100+
Can be rented on [EC2](https://aws.amazon.com/marketplace/server/procurement?productId=ef297a90-3ad0-4674-83b4-7f0ec07c39bb) for pennies/hour. Recommend t3.large. Default user is `ec2-user`. Connect with Microsoft Remote Desktop.
96101

97-
https://docs.microsoft.com/en-us/windows/wsl/install-on-server
102+
Install WSL according to https://docs.microsoft.com/en-us/windows/wsl/install-on-server. Install Ubuntu for WSL
98103

99-
Download Linux archive
100-
101-
Find archive and extract all
102-
Run the program.
104+
In the Linux shell:
105+
```shell
106+
wget https://raw.githubusercontent.com/raspberrypi/pico-setup/master/pico_setup.sh
107+
chmod +x pico_setup.sh
108+
./pico_setup.sh
109+
```
103110

111+
### Debian GNU/Linux 1.3.0.0 on WSL1 on Windows Server 2019 Base on x86_64
112+
Similar instructions as Ubuntu, but using the Debian WSL package and you'll have to explicitly install wget:
113+
```shell
114+
sudo apt update
115+
sudo apt install -y wget
116+
```
104117

105-
### Debian 10 (Buster) on WSL2 on Windows Server 2016 Base on x86_64
106-
Not yet tested.
118+
Currently fails due to lack of python3.
107119

108120
## Scenarios
109121
Test some scenarios:
110122
* Shells: bash, zsh. It should be enough to switch shells and rerun the installer and test. You don't have to wipe the SD card/disk.
111123
* .profile or .zprofile doesn't end in newline
112-
* PWD containing space
113-
* Raspberry Pi OS Lite (32-bit) shouldn't install VS Code
124+
* PWD containing space. The script seems to handle it but a OpenOCD submodule, jimctl, doesn't.

test/test

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ set -ex
88

99
WORKING_DIR="$(pwd)/pico"
1010

11-
<<<<<<< HEAD
12-
=======
1311
linux() {
1412
# Returns true iff this is running on Linux
1513
uname | grep -q "^Linux$"
@@ -28,15 +26,12 @@ ubuntu() {
2826
return ${?}
2927
}
3028

31-
>>>>>>> 4f2c6f4... Major rewrite. Added support for macOS, Debian, Ubuntu. Added test/validation script.
3229
mac() {
3330
# Returns true iff this is running on macOS and presumably Apple hardware
3431
uname | grep -q "^Darwin$"
3532
return ${?}
3633
}
3734

38-
<<<<<<< HEAD
39-
=======
4035
raspberry_pi() {
4136
# Returns true iff this is running on a Raspberry Pi computer, regardless of the OS
4237
if [ -f /proc/cpuinfo ]; then
@@ -47,7 +42,6 @@ raspberry_pi() {
4742
}
4843

4944

50-
>>>>>>> 4f2c6f4... Major rewrite. Added support for macOS, Debian, Ubuntu. Added test/validation script.
5145
fail() {
5246
# Outputs a failure message and exits with the error code output by the previous call.
5347
# All args are echoed as a failure message.
@@ -82,8 +76,6 @@ test_pico_sdk() {
8276
test "${PICO_SDK_PATH}" = "${WORKING_DIR}/pico-sdk" || fail
8377
}
8478

85-
<<<<<<< HEAD
86-
=======
8779
test_uart() {
8880
# test that the UART is configured. Only works on Raspberry Pi OS on Raspberry Pi hardware.
8981
dpkg-query -s minicom || fail
@@ -92,7 +84,6 @@ test_uart() {
9284
grep -q "console=serial0" /boot/cmdline.txt && fail
9385
}
9486

95-
>>>>>>> 4f2c6f4... Major rewrite. Added support for macOS, Debian, Ubuntu. Added test/validation script.
9687
test_pico_examples() {
9788
test_git_repo pico-examples
9889

@@ -143,16 +134,10 @@ test_vscode_linux() {
143134
}
144135

145136
test_vscode_mac() {
146-
<<<<<<< HEAD
147-
echo "This script can't tell whether Visual Studio Code is installed on macOS"
148-
}
149-
150-
=======
151137
echo "Not yet implemented: testing Visual Studio Code on macOS"
152138
}
153139

154140

155-
>>>>>>> 4f2c6f4... Major rewrite. Added support for macOS, Debian, Ubuntu. Added test/validation script.
156141
# execute tests
157142
if mac; then
158143
test_toolchain_mac
@@ -162,13 +147,10 @@ fi
162147

163148
test_pico_sdk
164149

165-
<<<<<<< HEAD
166-
=======
167150
if raspbian && raspberry_pi; then
168151
test_uart
169152
fi
170153

171-
>>>>>>> 4f2c6f4... Major rewrite. Added support for macOS, Debian, Ubuntu. Added test/validation script.
172154
test_pico_examples
173155
test_pico_extras
174156
test_pico_playground
@@ -178,13 +160,9 @@ test_picotool
178160
if mac; then
179161
test_vscode_mac
180162
else
181-
<<<<<<< HEAD
182-
test_vscode_mac
183-
=======
184163
if dpkg-query -s xserver-xorg >> /dev/null && ! (debian || ubuntu); then
185164
test_vscode_linux
186165
fi
187-
>>>>>>> 4f2c6f4... Major rewrite. Added support for macOS, Debian, Ubuntu. Added test/validation script.
188166
fi
189167

190168
echo "Tests passed! 😁"

0 commit comments

Comments
 (0)