You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多
文档控制台
免费开始使用

ESP32 S3双SPI(HSPI/FSPI)初始化SD卡触发Guru Meditation Error求助

ESP32-S3 N16R8双SPI设备(SD卡+电子纸)初始化触发StoreProhibited崩溃

问题描述

自定义ESP32-S3 N16R8开发板,外接3.3V SD卡槽与2.9寸电子纸屏,二者硬件引脚无冲突。单独使用SD卡或电子纸均能正常工作,但尝试同时使用两个SPI总线(HSPI分配给SD卡、FSPI分配给电子纸,或互换分配)时,初始化SD卡阶段设备会重启并触发如下错误:

Guru Meditation Error: Core 1 panic'ed (StoreProhibited). Exception was unhandled.

测试代码

#include <SPI.h>
#include <SD.h>
#include <GxEPD2_BW.h>

// Pins for SD card (SPI1)
#define SD_CS_PIN    10
#define SD_CLK_PIN   12
#define SD_MISO_PIN  13
#define SD_MOSI_PIN  11

// Pins for ePaper (SPI2)
#define PIN_CS   39
#define PIN_DC   2
#define PIN_RES  38
#define PIN_BUSY 1
#define PIN_SCK  36
#define PIN_MISO -1  // Not used
#define PIN_MOSI 35

// Create two SPI objects
SPIClass spiSD(HSPI);  // SPI for SD card
SPIClass spiEPD(FSPI); // SPI for ePaper

// Initialize the display (replace the model if necessary)
GxEPD2_BW<GxEPD2_290_GDEY029T94, GxEPD2_290_GDEY029T94::HEIGHT> display(GxEPD2_290_GDEY029T94(PIN_CS, PIN_DC, PIN_RES, PIN_BUSY));


void setup() {
  Serial.begin(115200);
  delay(1000);

  // --- Initialize SPI for ePaper ---
  pinMode(PIN_CS, OUTPUT);
  digitalWrite(PIN_CS, HIGH); // Disable ePaper before setting up SPI
  spiEPD.begin(PIN_SCK, PIN_MISO, PIN_MOSI, PIN_CS);

  // --- Initialize ePaper ---
  Serial.println("Initializing ePaper...");
  //display.epd2.selectSPI(spiEPD, SPISettings(1000000, MSBFIRST, SPI_MODE0)); // You can also bind spiEPD this way
  SPISettings epdsettings(115200, MSBFIRST, SPI_MODE0);  // Speed, bit order, and SPI mode

  display.init(115200, true, 50, false,spiEPD,epdsettings);
  Serial.println("ePaper initialized.");
  delay(2000);

  // --- Initialize SPI for SD ---
  pinMode(SD_CS_PIN, OUTPUT);
  digitalWrite(SD_CS_PIN, HIGH); // Disable SD before setting up SPI
  spiSD.begin(SD_CLK_PIN, SD_MISO_PIN, SD_MOSI_PIN); // You can add SD_CS_PIN, but this doesn't solve the problem

  // --- Initialize SD card ---
  Serial.println("Initializing SD...");
  if (!SD.begin(SD_CS_PIN, spiSD,4000000)) { // You can use 1000000, but it doesn't affect much
    Serial.println("SD card initialization failed!");
  } else {
    Serial.println("SD card initialized successfully.");
  }

  delay(2000);
}

void loop() {
  // Main code
}

串口监视器输出

18:11:33.495 > Initializing ePaper...
18:11:33.606 > ePaper initialized.
18:11:35.594 > Initializing SD...
18:11:35.778 > Guru Meditation Error: Core  1 panic'ed (StoreProhibited). Exception was unhandled.
18:11:35.783 > 
18:11:35.783 > Core  1 register dump:
18:11:35.783 > PC      : 0x4037d770  PS      : 0x00060c33  A0      : 0x8037fed0  A1      : 0x3fcebc80  
18:11:35.783 > A2      : 0xcde8cde8  A3      : 0xb33fffff  A4      : 0x0000cdcd  A5      : 0x00060c23  
18:11:35.783 > A6      : 0x00060c20  A7      : 0x0000abab  A8      : 0x0000abab  A9      : 0xffffffff  
18:11:35.783 > A10     : 0x00060823  A11     : 0x00000000  A12     : 0x00060820  A13     : 0x3d8008f8
18:11:35.783 > A14     : 0x90e8cde8  A15     : 0x00ffffff  SAR     : 0x00000001  EXCCAUSE: 0x0000001d
18:11:35.783 > EXCVADDR: 0xcde8cde8  LBEG    : 0x400570e8  LEND    : 0x400570f3  LCOUNT  : 0x00000000
18:11:35.783 >
18:11:35.783 >
18:11:35.783 > Backtrace: 0x4037d76d:0x3fcebc80 0x3fcebcc0 0x40380029:0x3fcebce0 0x40377743:0x3fcebd00 0x4037780a:0x3fcebd30 0x42012609:0x3fcebd80 0x420135f5:0x3fcebda0 0x42003f8e:0x3fcebe80 0x42003118:0x3fcebed0 0x42001c7e:0x3fcebf00 0x4200683e:0x3fcebf40
18:11:35.783 >
18:11:35.783 >
18:11:35.783 >
18:11:35.783 >
18:11:35.783 > ELF file SHA256: 9c4519ee94579542
18:11:35.783 >
18:11:35.783 > Rebooting...
18:11:35.783 > ESP-ROM:esp32s3-20210327
18:11:35.783 > Build:Mar 27 2021
18:11:35.784 > Saved PC:0x4202d43e
18:11:35.784 > SPIWP:0xee
18:11:35.784 > mode:DIO, clock div:1
18:11:35.784 > load:0x3fce3808,len:0x4bc
18:11:35.784 > load:0x403c9700,len:0xbd8
18:11:35.791 > load:0x403cc700,len:0x2a0c
18:11:35.797 > entry 0x403c98d0

PlatformIO配置

[env:esp32s3box]
platform = espressif32
board = esp32s3box
framework = arduino
upload_speed = 921600
monitor_speed = 115200
monitor_filters = 
    send_on_enter
    time
lib_extra_dirs = lib
lib_deps = 
    ZinggJM/GxEPD2
    bblanchon/ArduinoJson@^7.1.0
    plerup/EspSoftwareSerial@^8.2.0
    SD

已尝试的解决方案

  • 调换SD卡与电子纸的SPI总线分配(HSPI/FSPI互换)
  • 调整两个设备的初始化顺序(先初始化SD卡,再初始化电子纸)
  • 手动设置所有SPI引脚的模式

以上操作均无法解决问题,寻求可行的调试或解决方法。

内容的提问来源于stack exchange,提问作者bomz

火山引擎 最新活动