Skip to content

Commit 2a49c57

Browse files
committed
fix broke
bt add bleak and kernel submodule bt service don't steal from gps bump
1 parent 53a8f7e commit 2a49c57

File tree

8 files changed

+268
-1
lines changed

8 files changed

+268
-1
lines changed

Dockerfile.agnos

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,13 @@ RUN source $XDG_DATA_HOME/venv/bin/activate && \
130130
cd /tmp/agnos/uv && \
131131
MAKEFLAGS="-j$(nproc)" UV_NO_CACHE=1 UV_PROJECT_ENVIRONMENT=$XDG_DATA_HOME/venv uv sync --frozen --inexact --compile-bytecode
132132

133+
# Symlink vendored C++ headers and libs to system paths
134+
RUN ln -s $XDG_DATA_HOME/venv/lib/python3.12/site-packages/capnproto/install/include/capnp /usr/include/capnp && \
135+
ln -s $XDG_DATA_HOME/venv/lib/python3.12/site-packages/capnproto/install/include/kj /usr/include/kj && \
136+
ln -s $XDG_DATA_HOME/venv/lib/python3.12/site-packages/capnproto/install/lib/libcapnp.a /usr/lib/aarch64-linux-gnu/libcapnp.a && \
137+
ln -s $XDG_DATA_HOME/venv/lib/python3.12/site-packages/capnproto/install/lib/libkj.a /usr/lib/aarch64-linux-gnu/libkj.a && \
138+
ln -s $XDG_DATA_HOME/venv/lib/python3.12/site-packages/eigen/install/eigen3 /usr/include/eigen3
139+
133140
# Install nice to haves
134141
COPY ./userspace/install_extras.sh /tmp/agnos/
135142
RUN /tmp/agnos/install_extras.sh
@@ -210,6 +217,9 @@ COPY ./userspace/files/avahi-override.conf /etc/systemd/system/avahi-daemon.serv
210217
# Prevent polkitd memory leak from getting out of hand by restarting it every ~day
211218
COPY ./userspace/files/polkit-override.conf /etc/systemd/system/polkit.service.d/override.conf
212219

220+
# Ensure bluetoothd starts after BT HCI is initialized
221+
COPY ./userspace/files/bluetooth-override.conf /etc/systemd/system/bluetooth.service.d/override.conf
222+
213223
# Remove qt network bearer plugins
214224
RUN rm -rf /usr/lib/aarch64-linux-gnu/qt5/plugins/bearer
215225

userspace/files/bt-hci.service

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[Unit]
2+
Description=Bluetooth HCI
3+
After=init-qcom.service
4+
Before=bluetooth.service
5+
6+
[Service]
7+
Type=forking
8+
ExecStart=/usr/comma/bt_init.sh
9+
ExecStop=/usr/bin/killall hciattach
10+
Restart=on-failure
11+
RestartSec=5
12+
13+
[Install]
14+
WantedBy=multi-user.target

userspace/install_extras.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44

55
apt-fast update && apt-fast install -y --no-install-recommends \
66
bash-completion \
7+
bluez \
78
btop \
89
hyperfine \
910
iperf \
1011
iperf3 \
1112
dnsmasq \
1213
irqtop \
14+
rfkill \
1315
ripgrep \
1416
ncdu \
1517
nfs-common \

userspace/services.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ systemctl enable agnos-debug.service
1414
systemctl enable gpio.service
1515
systemctl enable lte.service
1616
systemctl enable sound.service
17+
systemctl enable bt-hci.service
1718
systemctl enable magic.service
1819
systemctl enable init-qcom.service
1920
systemctl enable varwatch.service

userspace/usr/comma/bt_init.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
# Initialize WCN3990 Bluetooth adapter on comma four
3+
4+
set -e
5+
6+
# Kill any stale hciattach
7+
killall hciattach 2>/dev/null || true
8+
sleep 1
9+
10+
# Power cycle BT chip via btpower ioctl (off then on)
11+
python3 -c "import fcntl,os; fd=os.open('/dev/btpower',os.O_RDWR); fcntl.ioctl(fd,0xbfad,0); os.close(fd)" 2>/dev/null || true
12+
sleep 2
13+
python3 -c "import fcntl,os; fd=os.open('/dev/btpower',os.O_RDWR); fcntl.ioctl(fd,0xbfad,1); os.close(fd)"
14+
sleep 3
15+
16+
# Unblock bluetooth
17+
rfkill unblock bluetooth
18+
sleep 1
19+
20+
# Attach UART — forks a daemon child that maintains hci0
21+
hciattach -s 115200 /dev/ttyHS1 qualcomm 115200 flow
22+
23+
# Wait for hci0 to appear (hciattach daemon initializes async)
24+
for i in $(seq 1 10); do
25+
hciconfig hci0 up 2>/dev/null && break
26+
sleep 1
27+
done

userspace/uv/pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ dependencies = [
1010

1111
# hardware.py
1212
"dbus-python",
13+
# glowd BLE
14+
"bleak",
1315
# amplifier.py
1416
"smbus2",
1517

userspace/uv/uv.lock

Lines changed: 211 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)