firmware: Makefile build at pinned MeshCore, fix I2C pin override
The patch's -UPIN_WIRE_* flags undefined the new values too (PlatformIO emits -U after all -D), breaking Wire; use build_unflags instead. Regenerate the patch against MeshCore a366955c. On Apple Silicon, pin the native GCC 14 toolchain since the default GCC 7.2.1 is x86_64-only.
This commit is contained in:
1 parent
7d1846e3c9
commit
f1bd57a434
4 files changed
+68
-9
No files matched your search
@@ -13,3 +13,5 @@ palm-client/build/
|
||||
*.o
|
||||
# OS
|
||||
.DS_Store
|
||||
# MeshCore build checkout (firmware/Makefile)
|
||||
firmware/meshcore/
|
||||
@@ -0,0 +1,48 @@
|
||||
# MeshCore companion firmware for the SB-LoRa XIAO nRF52840 + Wio-SX1262 stack.
|
||||
#
|
||||
# make clone MeshCore at MESHCORE_REF into meshcore/, apply the patch, build
|
||||
# make upload build and flash the XIAO over USB (double-tap reset if it isn't found)
|
||||
# make monitor serial monitor on the XIAO's USB port
|
||||
# make clean remove the meshcore/ checkout
|
||||
#
|
||||
# MESHCORE_URL can point at a local clone to skip the download, e.g.
|
||||
# make MESHCORE_URL=~/Code_Repo/MeshCore-Stock
|
||||
|
||||
MESHCORE_URL ?= https://github.com/meshcore-dev/MeshCore.git
|
||||
MESHCORE_REF ?= a366955c
|
||||
PATCH := meshcore-xiao-nrf52-uart-companion.patch
|
||||
ENV := Xiao_nrf52_companion_radio_uart
|
||||
PIO ?= pio
|
||||
|
||||
# The nRF52 platform's default toolchain (GCC 7.2.1) is x86_64-only and needs
|
||||
# Rosetta on Apple Silicon. There, pin PlatformIO's native GCC 14 build instead
|
||||
# by appending to our env, which is the last section of the XIAO's ini.
|
||||
ifeq ($(shell uname -sm),Darwin arm64)
|
||||
TOOLCHAIN_PIN = platform_packages = platformio/toolchain-gccarmnoneeabi@1.140201.0
|
||||
endif
|
||||
|
||||
all: build
|
||||
|
||||
meshcore/.patched: $(PATCH)
|
||||
rm -rf meshcore
|
||||
git clone -q $(MESHCORE_URL) meshcore
|
||||
git -C meshcore checkout -q $(MESHCORE_REF)
|
||||
git -C meshcore apply ../$(PATCH)
|
||||
ifneq ($(TOOLCHAIN_PIN),)
|
||||
echo "$(TOOLCHAIN_PIN)" >> meshcore/variants/xiao_nrf52/platformio.ini
|
||||
endif
|
||||
touch $@
|
||||
|
||||
build: meshcore/.patched
|
||||
cd meshcore && $(PIO) run -e $(ENV)
|
||||
|
||||
upload: meshcore/.patched
|
||||
cd meshcore && $(PIO) run -e $(ENV) -t upload
|
||||
|
||||
monitor:
|
||||
cd meshcore && $(PIO) device monitor -b 115200
|
||||
|
||||
clean:
|
||||
rm -rf meshcore
|
||||
|
||||
.PHONY: all build upload monitor clean
|
||||
+11
-4
@@ -5,9 +5,16 @@
|
||||
Adds a `Xiao_nrf52_companion_radio_uart` PlatformIO env to MeshCore. It runs the companion protocol on the XIAO nRF52840's hardware UART, D6 (TX, P1.11) / D7 (RX, P1.12), at 115200 8N1, and moves I2C to unused internal pins 16/17.
|
||||
|
||||
```sh
|
||||
git clone https://github.com/meshcore-dev/MeshCore && cd MeshCore
|
||||
git apply /path/to/visormesh/firmware/meshcore-xiao-nrf52-uart-companion.patch
|
||||
pio run -e Xiao_nrf52_companion_radio_uart -t upload
|
||||
cd firmware
|
||||
make # clone MeshCore @ MESHCORE_REF into meshcore/, apply the patch, build
|
||||
make upload # flash the XIAO over USB
|
||||
make MESHCORE_URL=~/Code_Repo/MeshCore-Stock # clone from a local checkout instead of GitHub
|
||||
```
|
||||
|
||||
The patch was written against a MeshCore checkout from October 2026. If it no longer applies, check `examples/companion_radio/main.cpp` and `variants/xiao_nrf52/platformio.ini` for changes upstream. Record the MeshCore commit it applies cleanly to here once you've built it.
|
||||
The patch is generated against MeshCore `a366955c` (2026-09-30), pinned as `MESHCORE_REF` in the `Makefile`. `meshcore/` is a git-ignored build checkout.
|
||||
|
||||
I2C is moved off D6/D7 with `build_unflags`. A `-U` flag in `build_flags` doesn't work under PlatformIO: it collects `-D` defines together and emits `-U` after them, which erases the new value too.
|
||||
|
||||
On Apple Silicon without Rosetta, the nRF52 platform's default GCC 7.2.1 (x86_64-only) won't run. The Makefile pins PlatformIO's native GCC 14.2.1 for the build checkout instead (`TOOLCHAIN_PIN`). Stock MeshCore nRF52 releases use GCC 7, so treat GCC 14 builds as untested until they've run on hardware.
|
||||
|
||||
Verified: builds cleanly (RAM 60.8%, flash 54.0%); the compile flags show `PIN_WIRE_SCL=16`, `PIN_WIRE_SDA=17`, `SERIAL_TX=D6`, `SERIAL_RX=D7`.
|
||||
@@ -1,8 +1,8 @@
|
||||
diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp
|
||||
index 839d495..9d17efa 100644
|
||||
index 89f0e6cb..c4a38045 100644
|
||||
--- a/examples/companion_radio/main.cpp
|
||||
+++ b/examples/companion_radio/main.cpp
|
||||
@@ -80,7 +80,11 @@ MultiSerialInterface interface_manager;
|
||||
@@ -61,7 +61,11 @@ MultiSerialInterface interface_manager;
|
||||
#if defined(SERIAL_RX)
|
||||
#include <helpers/ArduinoSerialInterface.h>
|
||||
ArduinoSerialInterface hardware_serial_interface;
|
||||
@@ -16,10 +16,10 @@ index 839d495..9d17efa 100644
|
||||
|
||||
// platform file system
|
||||
diff --git a/variants/xiao_nrf52/platformio.ini b/variants/xiao_nrf52/platformio.ini
|
||||
index b40ebbc..e61a0fa 100644
|
||||
index 1076bd8d..6df3c80d 100644
|
||||
--- a/variants/xiao_nrf52/platformio.ini
|
||||
+++ b/variants/xiao_nrf52/platformio.ini
|
||||
@@ -118,3 +118,28 @@ build_src_filter = ${Xiao_nrf52.build_src_filter}
|
||||
@@ -119,3 +119,30 @@ build_src_filter = ${Xiao_nrf52.build_src_filter}
|
||||
+<../examples/kiss_modem/*.cpp>
|
||||
lib_deps =
|
||||
${Xiao_nrf52.lib_deps}
|
||||
@@ -30,9 +30,11 @@ index b40ebbc..e61a0fa 100644
|
||||
+extends = Xiao_nrf52
|
||||
+board_build.ldscript = boards/nrf52840_s140_v7_extrafs.ld
|
||||
+board_upload.maximum_size = 708608
|
||||
+build_unflags =
|
||||
+ -D PIN_WIRE_SCL=D6
|
||||
+ -D PIN_WIRE_SDA=D7
|
||||
+build_flags =
|
||||
+ ${Xiao_nrf52.build_flags}
|
||||
+ -UPIN_WIRE_SCL -UPIN_WIRE_SDA
|
||||
+ -D PIN_WIRE_SCL=16
|
||||
+ -D PIN_WIRE_SDA=17
|
||||
+ -I examples/companion_radio/ui-orig
|
||||
|
||||
Reference in new issue
Block a user