Skip to content

fix(tlora-pager): Remove SDCARD_USE_SPI1 so SX1262 and SD can share bus#9870

Merged
thebentern merged 1 commit into
meshtastic:developfrom
mesh-malaysia:tlora-pager-sd
Mar 19, 2026
Merged

fix(tlora-pager): Remove SDCARD_USE_SPI1 so SX1262 and SD can share bus#9870
thebentern merged 1 commit into
meshtastic:developfrom
mesh-malaysia:tlora-pager-sd

Conversation

@ndoo

@ndoo ndoo commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

Problem:

  • Inserting a µSD card causes RadioLib to hit a critical error and reboot
  • Device enters a boot loop as the SD card remains inserted

Reproduction:

  • Insert a µSD card and power on
  • RadioLib reports a critical error on boot
  • Device reboots, repeating indefinitely

Root cause:

  • On T-Lora Pager, SX1262 and the µSD slot share the same physical SPI bus (same SCK/MOSI/MISO pins, differentiated only by CS)
  • SDCARD_USE_SPI1 is intended for boards where SD is on a separate SPI bus; it initializes a second ESP32 SPI peripheral (SPI3) for SD
  • SPI2 is already driving those same pins for LoRa, so both controllers simultaneously drive the same GPIO lines, causing bus contention

Fix:

  • Remove SDCARD_USE_SPI1 so both devices share a single SPI peripheral (SPI2), with CS pins providing device selection as intended
  • Tested on a custom fork of device-ui; LoRa and SD card map tiles both work correctly with an SD card inserted

Testing:

tlora-pager-tft is currently broken due to no mainline device-ui support. If you replace the device-ui in lib_deps with https://github.com/Meshtastic-Malaysia/device-ui/archive/refs/heads/tlora-pager-tft-pluginbased.zip you should be able to build a working Device UI and test with a µSD with maps on it.

🤝 Attestations

  • I have tested that my proposed changes behave as described.
  • I have tested that my proposed changes do not cause any obvious regressions on the following devices:
    • Heltec (Lora32) V3
    • LilyGo T-Deck
    • LilyGo T-Beam
    • RAK WisBlock 4631
    • Seeed Studio T-1000E tracker card
    • Other (please specify below)
      • TLora Pager TFT

@github-actions github-actions Bot added the bugfix Pull request that fixes bugs label Mar 9, 2026
@ndoo

ndoo commented Mar 9, 2026

Copy link
Copy Markdown
Contributor Author

This tripped me up:

SDCARD_USE_SPI1 -> HSPI → SPI3
SX1262 is on SPI → SPI2 (FSPI)

Removing SDCARD_USE_SPI1 makes SD share SPI2 (FSPI).

IMG_9449

@thebentern thebentern requested a review from mverch67 March 9, 2026 22:37

@mverch67 mverch67 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tried it with my T-Lora Pager and SD card. It didn't find the SD card whether SDCARD_USE_SP1 was defined or not. It seems there are further adaptations necessary.

@ndoo

ndoo commented Mar 10, 2026 via email

Copy link
Copy Markdown
Contributor Author

@ndoo

ndoo commented Mar 10, 2026 via email

Copy link
Copy Markdown
Contributor Author

@mverch67 mverch67 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the SPI GPIO definitions SD card and radio are using the same GPIO, so they supposed to share indeed the same SPI.

…are SPI bus

Problem:
- Inserting a µSD card causes RadioLib to hit a critical error and reboot
- Device enters a boot loop as the SD card remains inserted

Reproduction:
- Insert a µSD card and power on
- RadioLib reports a critical error on boot
- Device reboots, repeating indefinitely

Root cause:
- On T-Lora Pager, SX1262 and the µSD slot share the same physical SPI bus
  (same SCK/MOSI/MISO pins, differentiated only by CS)
- SDCARD_USE_SPI1 is intended for boards where SD is on a separate SPI bus;
  it initializes a second ESP32 SPI peripheral (SPI3) for SD
- SPI2 is already driving those same pins for LoRa, so both controllers
  simultaneously drive the same GPIO lines, causing bus contention

Fix:
- Remove SDCARD_USE_SPI1 so both devices share a single SPI peripheral (SPI2),
  with CS pins providing device selection as intended
- Tested on a custom fork of device-ui; LoRa and SD card map tiles both work
  correctly with an SD card inserted

Signed-off-by: Andrew Yong <me@ndoo.sg>
@ndoo ndoo force-pushed the tlora-pager-sd branch 2 times, most recently from 68b4667 to 9b71b58 Compare March 13, 2026 07:56
@ndoo

ndoo commented Mar 13, 2026

Copy link
Copy Markdown
Contributor Author

Sorry, accidentally pushed some testing commits, resetting and force push…

@thebentern thebentern merged commit 959756a into meshtastic:develop Mar 19, 2026
139 of 140 checks passed
thebentern pushed a commit that referenced this pull request Mar 19, 2026
…are SPI bus (#9870)

Problem:
- Inserting a µSD card causes RadioLib to hit a critical error and reboot
- Device enters a boot loop as the SD card remains inserted

Reproduction:
- Insert a µSD card and power on
- RadioLib reports a critical error on boot
- Device reboots, repeating indefinitely

Root cause:
- On T-Lora Pager, SX1262 and the µSD slot share the same physical SPI bus
  (same SCK/MOSI/MISO pins, differentiated only by CS)
- SDCARD_USE_SPI1 is intended for boards where SD is on a separate SPI bus;
  it initializes a second ESP32 SPI peripheral (SPI3) for SD
- SPI2 is already driving those same pins for LoRa, so both controllers
  simultaneously drive the same GPIO lines, causing bus contention

Fix:
- Remove SDCARD_USE_SPI1 so both devices share a single SPI peripheral (SPI2),
  with CS pins providing device selection as intended
- Tested on a custom fork of device-ui; LoRa and SD card map tiles both work
  correctly with an SD card inserted

Signed-off-by: Andrew Yong <me@ndoo.sg>
jeek pushed a commit to jeek/Meshtastic-Exploiteers-Hacker-Pager that referenced this pull request Jun 30, 2026
…are SPI bus (meshtastic#9870)

Problem:
- Inserting a µSD card causes RadioLib to hit a critical error and reboot
- Device enters a boot loop as the SD card remains inserted

Reproduction:
- Insert a µSD card and power on
- RadioLib reports a critical error on boot
- Device reboots, repeating indefinitely

Root cause:
- On T-Lora Pager, SX1262 and the µSD slot share the same physical SPI bus
  (same SCK/MOSI/MISO pins, differentiated only by CS)
- SDCARD_USE_SPI1 is intended for boards where SD is on a separate SPI bus;
  it initializes a second ESP32 SPI peripheral (SPI3) for SD
- SPI2 is already driving those same pins for LoRa, so both controllers
  simultaneously drive the same GPIO lines, causing bus contention

Fix:
- Remove SDCARD_USE_SPI1 so both devices share a single SPI peripheral (SPI2),
  with CS pins providing device selection as intended
- Tested on a custom fork of device-ui; LoRa and SD card map tiles both work
  correctly with an SD card inserted

Signed-off-by: Andrew Yong <me@ndoo.sg>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Pull request that fixes bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants