| #!/bin/bash -e |
| |
| |
| |
| |
| |
|
|
| echo "Fix 1/3: motor port -> /dev/ttyAMA3 (udev)" |
| |
| install -d -m 0755 /etc/udev/rules.d |
| cat > /etc/udev/rules.d/99-reachy-cm5-motor.rules <<'RULE' |
| |
| SUBSYSTEM=="tty", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="55d3", SYMLINK+="ttyAMA3", GROUP="dialout", MODE="0660" |
| KERNEL=="ttyAMA2", SYMLINK+="ttyAMA3", GROUP="dialout", MODE="0660" |
| RULE |
|
|
| echo "Fix 2/3: shutdown button -> gpiozero lgpio backend" |
| install -d -m 0755 /etc/systemd/system/gpio-shutdown-daemon.service.d |
| cat > /etc/systemd/system/gpio-shutdown-daemon.service.d/10-cm5-lgpio.conf <<'DROP' |
| [Service] |
| Environment=GPIOZERO_PIN_FACTORY=lgpio |
| DROP |
| source /opt/uv/env 2>/dev/null || true |
| if [ -f /venvs/mini_daemon/bin/activate ]; then |
| source /venvs/mini_daemon/bin/activate |
| uv pip install lgpio || pip install lgpio || true |
| fi |
|
|
| echo "Fix 3/3: software H264 encoder for the WebRTC stream" |
| |
| |
| cat > /venvs/mini_daemon/lib/python3.12/site-packages/sitecustomize.py <<'PY' |
| |
| def _sw_encoder(): |
| try: |
| from reachy_mini.media import media_server as ms |
| from gi.repository import Gst |
| except Exception: |
| return |
| def sw_branch(self, queue_webrtc, pipeline, webrtcsink): |
| convert = Gst.ElementFactory.make("videoconvert") |
| x264 = Gst.ElementFactory.make("x264enc") |
| caps_h264 = Gst.ElementFactory.make("capsfilter") |
| if not all([convert, x264, caps_h264]): |
| raise RuntimeError("Failed to create x264 encoder elements") |
| Gst.util_set_object_arg(x264, "tune", "zerolatency") |
| Gst.util_set_object_arg(x264, "speed-preset", "ultrafast") |
| x264.set_property("bitrate", 5000) |
| x264.set_property("key-int-max", 60) |
| caps_h264.set_property("caps", Gst.Caps.from_string( |
| "video/x-h264,stream-format=byte-stream,alignment=au," |
| "level=(string)3.1,profile=(string)constrained-baseline")) |
| for elem in (convert, x264, caps_h264): |
| pipeline.add(elem) |
| queue_webrtc.link(convert) |
| convert.link(x264) |
| x264.link(caps_h264) |
| caps_h264.link(webrtcsink) |
| ms.GstMediaServer._build_rpi_encoder_branch = sw_branch |
| _sw_encoder() |
| PY |
|
|
| echo "CM5 fixes applied." |
|
|