Skip to content

hdcasey/meshcore-cardputer-adv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

MeshCore Companion Radio — M5Stack Cardputer ADV + Cap LoRa-1262

MeshCore v1.15.0 BLE companion radio firmware for the M5Stack Cardputer Advanced paired with the M5Stack Cap LoRa-1262 (SX1262, EU868).

The Cardputer-specific hardware support and keyboard UI were originally created by @Stachugit. This repo contributes it to the MeshCore v1.15.0 codebase and fixes a crash caused by excessive static DRAM usage.


Hardware

Component Details
MCU ESP32-S3, dual-core 240 MHz
Flash / PSRAM 8 MB Flash, 8 MB PSRAM
LoRa SX1262 via Cap LoRa-1262 (EU868, DIO2 RF switch, 3.3V TCXO)
Display 240×135 LCD (LovyanGFX via M5Cardputer library)
Input Built-in keyboard
GPS ATGM336H-6N on Serial1 (G15/G13)
BLE Companion pairing

Patches applied to MeshCore v1.15.0

All changes are in patches/. Apply them on top of the upstream meshcore-dev/MeshCore source.

Hardware variant (variants/m5stack_cardputer/)

  • M5CardputerBoard.h — SX1262 + Cap LoRa-1262 board driver (IO expander, RF switch, TCXO)
  • target.cpp / target.h — PlatformIO target wiring
  • platformio.ini — build environments for Cap LoRa-1262

Display driver (src/helpers/ui/)

  • M5CardputerDisplay.h/.cppDisplayDriver implementation using LovyanGFX (via M5Cardputer library)

Keyboard UI (examples/companion_radio/ui-keyboard/)

  • UITask.cpp/.h — keyboard-driven companion UI
  • settings_impl.cpp — settings screen

Companion radio API patches (examples/companion_radio/)

  • MyMesh.h/.cppsaveContacts(), saveChannels(), factoryReset() moved to public; queueOutgoingMessageForBLE() added
  • NodePrefs.hscreen_timeout_seconds field added
  • UITask.h — dispatcher: HEADLESS_UI=1 → keyboard UI, else → ui-new

Memory fix

The original config had 163 KB of static DRAM used (49.9% of 320 KB), leaving insufficient room for the BLE stack and runtime heap. Fixed by:

  • MAX_CONTACTS: 200 → 100
  • OFFLINE_QUEUE_SIZE: 256 → 64
  • Removed unused lvgl lib_dep (display uses LovyanGFX, not LVGL)
  • Removed CONFIG_BT_* build flags that are IDF sdkconfig options and have no effect in Arduino mode
  • Disabled MESH_DEBUG in production

Result: static RAM 163 KB → 111 KB (34%), freeing 52 KB headroom.


Build

Requires PlatformIO.

git clone https://github.com/meshcore-dev/MeshCore.git
cd MeshCore

# Clone patches alongside
git clone https://github.com/hdcasey/meshcore-cardputer-adv.git patches_repo

# Apply patches
cp patches_repo/patches/boards/m5stack_cardputer.json                           boards/
cp patches_repo/patches/variants/m5stack_cardputer/platformio.ini               variants/m5stack_cardputer/
cp patches_repo/patches/variants/m5stack_cardputer/M5CardputerBoard.h           variants/m5stack_cardputer/
cp patches_repo/patches/variants/m5stack_cardputer/target.cpp                   variants/m5stack_cardputer/
cp patches_repo/patches/variants/m5stack_cardputer/target.h                     variants/m5stack_cardputer/
cp patches_repo/patches/variants/m5stack_cardputer/test_main.cpp                variants/m5stack_cardputer/
cp patches_repo/patches/src/helpers/ui/M5CardputerDisplay.cpp                   src/helpers/ui/
cp patches_repo/patches/src/helpers/ui/M5CardputerDisplay.h                     src/helpers/ui/
cp patches_repo/patches/examples/companion_radio/MyMesh.cpp                     examples/companion_radio/
cp patches_repo/patches/examples/companion_radio/MyMesh.h                       examples/companion_radio/
cp patches_repo/patches/examples/companion_radio/NodePrefs.h                    examples/companion_radio/
cp patches_repo/patches/examples/companion_radio/UITask.h                       examples/companion_radio/
mkdir -p examples/companion_radio/ui-keyboard
cp patches_repo/patches/examples/companion_radio/ui-keyboard/UITask.cpp         examples/companion_radio/ui-keyboard/
cp patches_repo/patches/examples/companion_radio/ui-keyboard/UITask.h           examples/companion_radio/ui-keyboard/
cp patches_repo/patches/examples/companion_radio/ui-keyboard/settings_impl.cpp  examples/companion_radio/ui-keyboard/

# Build
pio run -e M5stack_cardputer_cap_lora1262_companion

Flash

Single merged binary (easiest)

esptool.py --chip esp32s3 --port /dev/ttyACM0 --baud 460800 \
  write_flash --flash_mode keep --flash_size 8MB \
  0x0 M5stack_cardputer_cap_lora1262_companion-v1.15.0-merged.bin

macOS: /dev/cu.usbmodem*

To enter bootloader mode: hold G0 (bottom-left keyboard key) and press Reset, then release.

Separate parts

esptool.py --chip esp32s3 --port /dev/ttyACM0 --baud 460800 \
  write_flash --flash_mode keep --flash_size 8MB \
  0x0     bootloader.bin \
  0x8000  partitions.bin \
  0x10000 firmware.bin

First boot

Set node name, region (EU_868), and BLE PIN (default 123456) via the MeshCore companion app on Android/iOS.


Credits

About

MeshCore companion radio for M5Stack Cardputer ADV + Cap LoRa-1262 (SX1262, EU868)

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages