ESP32 + RGBMatrix + WiFi STA problem

Zhivoi
Posts: 3
Joined: Mon Feb 20, 2023 11:42 am

ESP32 + RGBMatrix + WiFi STA problem

Postby Zhivoi » Mon Feb 20, 2023 12:02 pm

Hello.
Faced a strange problem with ESP32-WROOM-32U.
If I initialize the RGBMatrix panel (32*64, NOT connected to ESP32board, only initialization), then initialize the STA wifi, the ESP immediately gives the error

Code: Select all

Guru Meditation Error: Core 1 panic'ed (Cache disabled but cached memory region accessed).
If I first do the Wi-Fi initialization, and then the RGBmatrix initialization - it works few seconds, and then rebooting with same error.

Code:

Code: Select all

#include <WiFi.h>
#include <Adafruit_GFX.h>
#include <RGBmatrixPanel.h>

#define A    12
#define B    16
#define C    17
#define D    18
#define CLK  15 
#define LAT  32 
#define OE   33

#define Sound 14 

RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, false, 64);

const char* ssid = "SSID";
const char* password = "PASSWORD";

void setup() 
{
  Serial.begin(115200);
  Serial.println("Starting Screen");
  Serial.println("");
  
  pinMode(Sound, OUTPUT);
 
 //beep on start 
  tone(Sound, 5000, 400);
  vTaskDelay(1000/portTICK_PERIOD_MS);
  noTone(Sound);

  Serial.println("Starting WiFi STA");
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  
  Serial.println("Starting Matrix");
  matrix.begin();                           // setup the LED matrix
  matrix.setTextWrap(false); // Don't wrap at end of line - will do ourselves
  matrix.fillScreen(0);
}

void loop() 
{
  vTaskDelay(1000/portTICK_PERIOD_MS);
}

Code: Select all

ELF file SHA256: 0000000000000000

Rebooting...
ets Jun  8 2016 00:22:57

rst:0x3 (SW_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1344
load:0x40078000,len:13864
load:0x40080400,len:3608
entry 0x400805f0
[     4][D][esp32-hal-cpu.c:244] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz
Starting Screen

[    32][D][Tone.cpp:124] tone(): _pin=14, frequency=5000 Hz, duration=400 ms
[    32][V][Tone.cpp:62] tone_init(): Creating tone queue
[    34][V][Tone.cpp:68] tone_init(): Tone queue created
[    39][V][Tone.cpp:72] tone_init(): Creating tone task
[    44][V][Tone.cpp:85] tone_init(): Tone task created
[    49][D][Tone.cpp:31] tone_task(): Task received from queue TONE_START: _pin=14, frequency=5000 Hz, duration=400 ms
[    59][D][Tone.cpp:33] tone_task(): Setup LED controll on channel 0
[  1049][D][Tone.cpp:105] noTone(): noTone was called
Starting WiFi STA
[  1049][D][Tone.cpp:45] tone_task(): Task received from queue TONE_END: pin=14
[  1066][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 0 - WIFI_READY
[  1152][V][WiFiGeneric.cpp:338] _arduino_event_cb(): STA Started
[  1154][V][WiFiGeneric.cpp:97] set_esp_interface_ip(): Configuring Station static IP: 0.0.0.0, MASK: 0.0.0.0, GW: 0.0.0.0
[  1154][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 2 - STA_START
Starting Matrix
[  3579][V][WiFiGeneric.cpp:360] _arduino_event_cb(): STA Disconnected: SSID: SSID, BSSID: 00:00:00:00:00:00, Reason: 201
[  3580][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 5 - STA_DISCONNECTED
[  3587][W][WiFiGeneric.cpp:950] _eventCallback(): Reason: 201 - NO_AP_FOUND
[  3593][D][WiFiGeneric.cpp:966] _eventCallback(): WiFi Reconnect Running
Guru Meditation Error: Core  1 panic'ed (Cache disabled but cached memory region accessed). 

Core  1 register dump:
PC      : 0x400d5c58  PS      : 0x00060035  A0      : 0x8008199d  A1      : 0x3ffbf21c  
A2      : 0x00000000  A3      : 0x0036f318  A4      : 0x8008f3a0  A5      : 0x3ffb7e50  
A6      : 0x00000003  A7      : 0x00060323  A8      : 0x800d5c58  A9      : 0x3ffbf1fc  
A10     : 0x0036f30f  A11     : 0x00000000  A12     : 0x0036f30e  A13     : 0x80000000  
A14     : 0x007bf298  A15     : 0x003fffff  SAR     : 0x00000020  EXCCAUSE: 0x00000007  
EXCVADDR: 0x00000000  LBEG    : 0x400852d5  LEND    : 0x400852dd  LCOUNT  : 0x00000027  


Backtrace:0x400d5c55:0x3ffbf21c |<-CORRUPTED
This happens both when powered by USB, and from a 3.3V power source, and from a 5V source. Nothing but a beeper on the 14th pin is connected to the board.

What could be causing the reboots?

ESP_Sprite
Posts: 9727
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32 + RGBMatrix + WiFi STA problem

Postby ESP_Sprite » Tue Feb 21, 2023 12:43 am

The root cause is that something (likely the timer interrupt for the matrix display) is trying to execute code from flash, but WiFi needs to write to that flash so it is unavailable. Probably a mistake in the rgbmatrix library I guesss; it should be entirely in IRAM. If you decode that backtrace, you may be able to find out what function is not and is causing the issue.

Zhivoi
Posts: 3
Joined: Mon Feb 20, 2023 11:42 am

Re: ESP32 + RGBMatrix + WiFi STA problem

Postby Zhivoi » Wed Feb 22, 2023 7:18 am

After commenting the line in RGBmatrixPanel.h , the reboots stopped, but of course the matrix does not show anything
//timer_start(TIMER_GROUP_1, TIMER_0);

Code: Select all

#if defined(ARDUINO_ARCH_ESP32)
  timer_config_t tim_config;
  tim_config.divider = 2; // Run Timer at 40 MHz
  tim_config.counter_dir = TIMER_COUNT_UP;
  tim_config.counter_en = TIMER_PAUSE;
  tim_config.alarm_en = TIMER_ALARM_EN;
  tim_config.auto_reload = TIMER_AUTORELOAD_EN;
  tim_config.intr_type = TIMER_INTR_LEVEL;

  timer_init(TIMER_GROUP_1, TIMER_0, &tim_config);
  /* Timer's counter will initially start from value below.
       Also, if auto_reload is set, this value will be automatically reload on
     alarm */
  timer_set_counter_value(TIMER_GROUP_1, TIMER_0, 0x00000000ULL);
  /* Configure the alarm value and the interrupt on alarm. */
  timer_set_alarm_value(TIMER_GROUP_1, TIMER_0, 10000);
  timer_enable_intr(TIMER_GROUP_1, TIMER_0);
  timer_isr_register(TIMER_GROUP_1, TIMER_0, IRQ_HANDLER, (void *)TIMER_0,
                     ESP_INTR_FLAG_IRAM, NULL);

  //timer_start(TIMER_GROUP_1, TIMER_0);

Zhivoi
Posts: 3
Joined: Mon Feb 20, 2023 11:42 am

Re: ESP32 + RGBMatrix + WiFi STA problem

Postby Zhivoi » Wed Feb 22, 2023 8:14 am

Changed the library to "ESP32-HUB75-MatrixPanel-I2S-DMA"
And it works well with wifi and matrix.

Who is online

Users browsing this forum: No registered users and 50 guests