From 4d2d5fd88ca315c13b6a39c8c84632d9b84410d3 Mon Sep 17 00:00:00 2001 From: Henrik Muehe Date: Thu, 30 Apr 2026 15:57:31 +0200 Subject: [PATCH] Update BUILD.md: gplan.so can't be built from source on Bullseye Document GLIBC/GLIBCXX version constraints and Python 3.5 compat notes. Recommend using official release gplan.so instead. --- .pi/BUILD.md | 59 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 17 deletions(-) diff --git a/.pi/BUILD.md b/.pi/BUILD.md index 80b0b80..c485ed8 100644 --- a/.pi/BUILD.md +++ b/.pi/BUILD.md @@ -54,7 +54,23 @@ ELF 32-bit LSB shared object, ARM, EABI5 (linked against libpython3.5m.so.1.0) ``` If you see `ELF 64-bit LSB shared object, ARM aarch64` or `libpython3.9` — wrong. -**Option A: Build from source (recommended)** +**Option A: From official release (recommended)** + +```bash +curl -sL https://github.com/OneFinityCNC/onefinity-firmware/releases/download/v1.6.6/onefinity-1.6.6.tar.bz2 \ + | tar xjf - --include='*/gplan.so' -O > src/py/camotics/gplan.so +``` + +The gplan.so is pure G-code planning with no version-specific code — safe to +reuse across firmware versions. + +**Option B: From a working Pi** + +```bash +scp bbmc@10.1.10.55:/usr/local/lib/python3.5/dist-packages/bbctrl-*.egg/camotics/gplan.so src/py/camotics/ +``` + +**Option C: Build from source (broken — documented for reference)** Uses Docker's armv7 QEMU emulation on Apple Silicon. Requires a one-time copy of Python 3.5 headers from the Pi (~1.7MB): @@ -119,24 +135,23 @@ docker run --rm --platform linux/arm/v7 \ ' ``` -Why the relink step: SCons compiles `.o` files that are Python-version-agnostic -(they only use `#include ` which is ABI-compatible between 3.5-3.9 -for the subset camotics uses). The only version-specific part is the final -`-lpython3.X` link. So we let SCons build with 3.9 (since it ignores overrides) -then relink the same objects against 3.5m. +**Why this doesn't actually work:** The `.o` files compile fine and the +Python relink works, but the compiled objects use GLIBC_2.29+ symbols +(from Bullseye's glibc 2.31) and GLIBCXX_3.4.26+ (from GCC 10). The Pi's +Stretch has GLIBC_2.24 / GLIBCXX_3.4.22 max. Even with `-static-libstdc++ +-static-libgcc`, glibc symbols like `GLIBC_2.29` leak through the object +files compiled against Bullseye headers. -**Option B: From official release** +To truly build from source you'd need a Stretch armhf container — but +Stretch's archived repos have broken package metadata that prevents +installing build-essential + scons. The official gplan.so was built +in a Raspbian Stretch chroot (see `scripts/gplan-init-build.sh`). -```bash -curl -L https://github.com/OneFinityCNC/onefinity-firmware/releases/download/v1.6.6/onefinity-1.6.6.tar.bz2 \ - | tar xjf - --include='*/gplan.so' --strip-components=3 -C src/py/camotics/ -``` - -**Option C: From a working Pi** - -```bash -scp bbmc@10.1.10.55:/usr/local/lib/python3.5/dist-packages/bbctrl-*.egg/camotics/gplan.so src/py/camotics/ -``` +**Key Pi constraints for native code:** +- GLIBC ≤ 2.24 (Stretch) +- GLIBCXX ≤ 3.4.22 (GCC 6) +- Python 3.5m (`libpython3.5m.so.1.0`) +- ELF 32-bit ARM EABI5 ### bbserial.ko — kernel module @@ -230,6 +245,16 @@ Open http://localhost:8765 — full UI with emulated AVR. See `backup/onefinity-backup.sh` for details. Environment variables: `ONEFINITY_HOST` (default 10.1.10.55), `ONEFINITY_USER` (bbmc), `ONEFINITY_PASS` (onefinity). +## Python 3.5 Compatibility + +The Pi runs Python 3.5.3. Watch out for features added in later versions: +- No `f"strings"` (use `"%s" % var` or `"{}".format(var)`) +- No `subprocess.run(capture_output=True)` (use `stdout=PIPE, stderr=PIPE`) +- No `subprocess.run(text=True)` (use `.decode('utf-8')` on stdout/stderr) +- No `dataclasses`, no `:=` walrus operator +- No `asyncio.run()` (use `loop.run_until_complete()`) +- No `typing` generics like `dict[str, int]` (use `Dict[str, int]` from typing) + ## Pi Details | | |