-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path20-dev-tools.sh
More file actions
executable file
·101 lines (94 loc) · 4.12 KB
/
Copy path20-dev-tools.sh
File metadata and controls
executable file
·101 lines (94 loc) · 4.12 KB
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
#!/bin/bash
# Copyright (c) 2026 Jim Wyatt
# SPDX-License-Identifier: MIT
# Root-level steps for the west-based dev environment.
#
# sudo bash ~/two-computers-one-board/provision/20-dev-tools.sh
#
# Idempotent. Every change has its revert in the comment above it.
#
# This frees /dev/ttyHS1 (arduino-router holds it) and installs clangd. It does
# NOT purge the Arduino packages - that is 40-purge-arduino.sh, deliberately
# separate and later, because it is the step you cannot casually undo.
set -uo pipefail
# shellcheck source=provision/lib.sh
. "$(cd "$(dirname "$0")" && pwd)/lib.sh"
need_root
echo "== Before =="
free -h | sed -n 2p
# --- 1. clangd: C/C++ IntelliSense. .vscode/settings.json expects it plus a
# --- compile_commands.json, which zbuild.sh symlinks in from the west build.
# ---
# --- The version is discovered rather than pinned: Debian ships clangd-19
# --- Host C compiler. The stock image has NO cc at all - gcc is `un`, not
# --- merely absent - and two things quietly need one.
#
# native_sim. The ztest suites build for the host, not the MCU, so they do not
# use the Zephyr SDK's arm-zephyr-eabi toolchain that everything else here
# relies on. Without gcc, twister reports
#
# CMake Error ... Could not find CMAKE_C_COMPILER using the following names: gcc
#
# for every suite, which means `tools/check.sh mcu` and mcu/ztest.sh - the gate
# the README tells you to run on the board - could never have passed on a board
# provisioned by this repo. The firmware builds fine throughout, because that is
# a cross build and carries its own compiler, so nothing else hints at it.
#
# spidev. It is a C extension with no aarch64 wheel, so pip builds it from
# source. 10-optimize-board.sh already installs python3-dev for the headers,
# which is only half of what compiling needs - and provisioning the headers
# without the compiler is a strong tell that this was the missing half.
#
# REVERT: apt-get remove -y gcc make
step "host C compiler"
apt_install gcc make
# --- here, but a later image ships a different one and a pinned name 404s.
# REVERT: apt-get remove -y clangd-<v> && rm /usr/bin/clangd
step "clangd"
if command -v clangd >/dev/null 2>&1; then
skip "clangd present: $(clangd --version 2>/dev/null | head -1)"
else
CLANGD_PKG=""
for v in 19 18 17 16 15 14; do
if apt-cache show "clangd-$v" >/dev/null 2>&1; then
CLANGD_PKG="clangd-$v"
break
fi
done
[ -n "$CLANGD_PKG" ] || CLANGD_PKG=clangd
apt_install "$CLANGD_PKG"
# The unversioned name is what .vscode/settings.json and clangd extensions
# look for; Debian's versioned package does not provide it.
if [ ! -e /usr/bin/clangd ] && [ -x "/usr/bin/${CLANGD_PKG}" ]; then
ln -sf "/usr/bin/${CLANGD_PKG}" /usr/bin/clangd
did "/usr/bin/clangd -> $CLANGD_PKG"
fi
fi
# --- 2. Arduino services. The MCU no longer runs Arduino firmware, so the
# --- Router Bridge has nothing to talk to. arduino-router also holds
# --- /dev/ttyHS1 open, which blocks you from reading the Zephyr console.
# --- Frees ~105 MB and releases the UART.
# REVERT: systemctl enable --now arduino-router arduino-app-cli
step "Arduino services"
disable_unit arduino-router.service arduino-router-serial.service \
arduino-app-cli.service arduino-avahi-serial.service
# --- 3. Docker: exists only to run Arduino Brick container images. ~105 MB.
# REVERT: systemctl enable --now docker docker.socket containerd
step "Docker"
disable_unit docker.service docker.socket containerd.service
# --- 4. Verify the UART is actually free now. This is the whole point of the
# --- step, and it is cheap to check rather than assert.
step "verify /dev/ttyHS1 is free"
if [ ! -e /dev/ttyHS1 ]; then
warn "/dev/ttyHS1 does not exist - is this an UNO Q?"
elif holder=$(fuser /dev/ttyHS1 2>/dev/null | tr -s ' ' ' ' | sed 's/^ *//;s/ *$//') && [ -n "$holder" ]; then
# fuser pads its output, and unquoted padding turns into empty ps arguments.
warn "/dev/ttyHS1 held by PID(s) $holder: $(ps -o comm= -p "${holder// /,}" 2>/dev/null | tr '\n' ' ')"
warn " unoq-cpu-bars holding it is expected - see provision/50-cpu-bars.sh"
else
skip "/dev/ttyHS1 is free"
fi
echo
echo "== After =="
free -h | sed -n 2p
summary