Hi, i am trying to use a timer interrupt while i am also sniffing for IEEE 802.11 beacon frames. When i tested the sniffer and the timers separate everything worked fine but when i combined the two i get the following error:
Guru Meditation Error: Core 0 panic'ed (Interrupt wdt timeout on CPU0)
Core 0 register dump:
PC : 0x4008973c PS : 0x00060034 A0 : 0x80089f60 A1 : 0x3ffbe140
A2 : 0x3ffbec64 A3 : 0x0000cdcd A4 : 0xb33fffff A5 : 0x00000001
A6 : 0x00060021 A7 : 0x0000abab A8 : 0x0000cdcd A9 : 0x0000cdcd
A10 : 0x3ffbebe4 A11 : 0x3ffc0d58 A12 : 0x3ffaebe0 A13 : 0x3ffb2d40
A14 : 0x0000002a A15 : 0x3ffb2d10 SAR : 0x0000001e EXCCAUSE: 0x00000005
EXCVADDR: 0x00000000 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xffffffe2
Core 0 was running in ISR context:
EPC1 : 0x400d224c EPC2 : 0x00000000 EPC3 : 0x00000000 EPC4 : 0x4008973c
Backtrace: 0x4008973c:0x3ffbe140 0x40089f5d:0x3ffbe170 0x4008b16b:0x3ffbe190 0x4008ae41:0x3ffbe1b0 0x400817fe:0x3ffbe1c0 0x400d2249:0x3ff
b2cb0 0x400d16cd:0x3ffb2cd0 0x400d18be:0x3ffb2cf0 0x400d18f9:0x3ffb2d10 0x400d155e:0x3ffb2d30 0x4011a532:0x3ffb2d80 0x4008f9a1:0x3ffb2da0
0x4008b07d:0x3ffb2de0
Core 1 register dump:
PC : 0x4008b972 PS : 0x00060e34 A0 : 0x8008a2bb A1 : 0x3ffbe680
A2 : 0x3ffb82a0 A3 : 0x3ffb8074 A4 : 0x00000001 A5 : 0x00000001
A6 : 0x00060e23 A7 : 0x00000000 A8 : 0x3ffb8074 A9 : 0x3ffb8074
A10 : 0x00000018 A11 : 0x00000018 A12 : 0x00000001 A13 : 0x00000001
A14 : 0x00060e21 A15 : 0x00000000 SAR : 0x00000015 EXCCAUSE: 0x00000005
EXCVADDR: 0x00000000 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xfffffffd
Backtrace: 0x4008b972:0x3ffbe680 0x4008a2b8:0x3ffbe6a0 0x40088d43:0x3ffbe6c0 0x400d223d:0x3ffbe700 0x400d16cd:0x3ffbe720 0x400d18be:0x3ff
be740 0x400d18d1:0x3ffbe760 0x400d132e:0x3ffbe780 0x4008103d:0x3ffbe7a0 0x400817f5:0x3ffbe7c0 0x400d270f:0x3ffb1fb0 0x4008b07d:0x3ffb1fd0
This is what i get when i decode the stack trace:
PC: 0x4008973a: vTaskSuspendAll at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/tasks.c line 2143
EXCVADDR: 0x00000000
Decoding stack results
0x4008973a: vTaskSuspendAll at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/tasks.c line 2143
0x40089f5d: prvAddNewTaskToReadyList at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/tasks.c line 1197
0x4008b16b: prvProcessTimerOrBlockTask at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/timers.c line 583
0x4008ae41: pvTaskIncrementMutexHeldCount at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/tasks.c line 4572
0x400817fe: esp_timer_impl_get_time at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/esp_timer_esp32.c line 198
0x400d2249: uartFlush at C:\Users\thoma\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.4\cores\esp32\esp32-hal-uart.c line 343
If anyone knows what the problem is or has a solution that would be very useful.
( I think the problem occurs when the a timer interrupt occurs when the code is executing the interrupt service routine of the sniffer or the other way around. But i am not sure of this.)
The code I used is bellow, thanks!!
code:
#include <Arduino.h>
#include "esp_timer.h" // lib for timermanagement
#include <PriUint64.h>// lib to print 64 bit nr
#include "esp_wifi.h"// lib for Wi-Fi
/*----------------------Random-----------------------*/
#define period 1000000
int curChannel = 1;
int counter=1;
uint8_t MAC_odisee[6]={0x88,0x1D,0xFC,0x30,0xD6,0x90}; // mac adres random router in b225 on channel 1
/*----------------------declarations-----------------------*/
// declare hw timer
hw_timer_t * timer1 = NULL;
//filter for sniffing
const wifi_promiscuous_filter_t filt={
//filter for management frames: frame control= b 0000 0001 = WIFI_PROMIS_FILTER_MASK_MGMT
.filter_mask= WIFI_PROMIS_FILTER_MASK_MGMT
};
// new structure for frame control bytes
typedef struct {
uint16_t version:2;
uint16_t type:2;
uint16_t subtype:4;
uint16_t to_ds:1;
uint16_t from_ds:1;
uint16_t mf:1;
uint16_t retry:1;
uint16_t pwr:1;
uint16_t more:1;
uint16_t w:1;
uint16_t o:1;
}__attribute__((packed)) wifi_ieee80211_frame_ctrl_t;
// new structure for payload of 802.11 frame
typedef struct {
uint8_t timestamp[8]; // timestamp
uint8_t beaconinterval[2]; // beacon interval
uint8_t capabilityinfo[2]; // capability info
uint8_t lengthssid[2];
unsigned char rest[]; // payload met eerste bytes=ssid (ssid heeft variabele lengte!!)
}__attribute__((packed)) wifi_ieee80211_payload;
// new structure for mac header
typedef struct {
wifi_ieee80211_frame_ctrl_t frame_ctrl; // frame control
int16_t duration;
uint8_t addr1[6]; // receiver address
uint8_t addr2[6]; // sender address
uint8_t addr3[6]; // filtering address
int16_t seqctl; // sequence control
unsigned char payload[]; // payload
} __attribute__((packed)) wifi_ieee80211_mac_hdr_t;
// new structure for ieee 802.11 frame
typedef struct {
wifi_ieee80211_mac_hdr_t hdr; // mac header
uint8_t payload[0]; /* network data ended with 4 bytes csum (CRC32) */
}__attribute__((packed)) wifi_ieee80211_packet_t;
/*----------------------functions-----------------------*/
// callback for timer 1
void callbacktimer1(){
counter++;
timerAlarmWrite(timer1, period*counter , false); // set next interrupt
timerAlarmEnable(timer1); // enable interrupt
Serial.print("callback: ");
Serial.println(counter);
}
// callback for wifi sniffer
void sniffercallback(void* buf, wifi_promiscuous_pkt_type_t type) { //This is where packets end up after they get sniffed
//take timestamp
//TODO: controleren of timestamps opgeslaan blijven als de core reset!!
//u<int64_t time = timerRead(timer1);
/*
data is passed to buf
buf contains radio meta data (wifi_pkt_rx_ctrl_trx_ctrl) and the payload
radio meta data can be accessed by pkt->rx_ctrl.member
payload is parsed to multiple data structures
*/
wifi_promiscuous_pkt_t *pkt = (wifi_promiscuous_pkt_t*)buf; // move data from buffer to wifi_promiscuous_pkt_t data type
wifi_ieee80211_packet_t *ipkt = (wifi_ieee80211_packet_t *)pkt->payload; // put packet in wifi_ieee80211_packet_t data type
wifi_ieee80211_mac_hdr_t *hdr = &ipkt->hdr; // put mac header in wifi_ieee80211_mac_hdr_t datatype
wifi_ieee80211_frame_ctrl_t *framecontrol = &hdr->frame_ctrl; // put 2 framecontrol bytes into framecontrol datatype
wifi_ieee80211_payload *payload = (wifi_ieee80211_payload*)&ipkt->payload; // put payload of frame in structure ieee80211_payload datatype
if(framecontrol->subtype==8){
// check if it is the right access point
bool juisteMAC=true;
/*
for(int i=0;i<6;i++){// compare MAC address against adres of masteresp32
if(MAC_odisee!=hdr->addr3){
juisteMAC=false;
}
}*/
if(juisteMAC){// do stuf if it is the right access point
//TODO save timestamp + id !!!!!!!!!
// ------------------------------------------------------------print info---------------------------------------------------------------------
// print ssid
int lengtessid = (payload->lengthssid[0]<<8) | (payload->lengthssid[1]); // bepaal lengte ssid
Serial.println("ssid: ");
char SSID[lengtessid];
for(int i=0; i<lengtessid;i++){
SSID=payload->rest;
Serial.print(SSID);
}
Serial.println();
// print beacon interval
Serial.print("Beacon interval in TU: ");
Serial.print(payload->beaconinterval[0]); //6400 voor 100 TU (1 TU = 1.024 milliseconden)
Serial.println(payload->beaconinterval[1]);
//print mac adres
Serial.print("MAC-adres: ");
for(int i=0;i<6;i++){
Serial.print(hdr->addr3,HEX);
Serial.print(":");
}
Serial.println();
//print id of the puls
Serial.print("id van de puls: ");
uint64_t id;
id= ((uint64_t)(payload->timestamp[7])<<56)+
((uint64_t)(payload->timestamp[6])<<48)+
((uint64_t)(payload->timestamp[5])<<40)+
((uint64_t)(payload->timestamp[4])<<32)+
((uint64_t)(payload->timestamp[3])<<24)+
((uint64_t)(payload->timestamp[2])<<16)+
((uint64_t)(payload->timestamp[1])<<8)+
((uint64_t)(payload->timestamp[0]));
for(int i=7;i>=0;i--){
Serial.print(payload->timestamp,HEX);
Serial.print(",");
}
Serial.print(PriUint64<DEC>(id));
for(int i=0;i<8;i++){
Serial.print(payload->timestamp);
}
Serial.println();
// print MAC-level-timestamp
Serial.print("MAC-level timestamp: ");
Serial.println(pkt->rx_ctrl.timestamp);
// print signal strength
Serial.print("signal strength: ");
Serial.print(pkt->rx_ctrl.rssi);
Serial.println(" dbm");
//print channel
Serial.print("channel: ");
Serial.println(curChannel);
Serial.println("--------------------------------------------------------------next frame-------------------------------------------------");
}
}
}
void setup() {
//initialize timer
timer1 = timerBegin(0, 80, true); // timer_id = 0; prescaler=80 => 1 tick = 1 µs; countUp = true;
timerAttachInterrupt(timer1, &callbacktimer1, true); // atatch callback to timer1
timerAlarmWrite(timer1, period, false); // set compare value for timer
timerAlarmEnable(timer1); // enable timer interrupt
//start Serial
Serial.begin(115200);
//initialize Wi-Fi
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
esp_wifi_init(&cfg);
esp_wifi_set_storage(WIFI_STORAGE_RAM);
esp_wifi_set_mode(WIFI_MODE_NULL);
esp_wifi_start();
esp_wifi_set_promiscuous(true); // enable promiscuous mode
esp_wifi_set_promiscuous_filter(&filt); // set filter
esp_wifi_set_promiscuous_rx_cb(&sniffercallback); // atatch callback function
esp_wifi_set_channel(curChannel, WIFI_SECOND_CHAN_NONE);// set Wi-Fi channel
}
void loop() {
// put your main code here, to run repeatedly:
}
I get Guru Meditation Error:
-
- Posts: 9730
- Joined: Thu Nov 26, 2015 4:08 am
Re: I get Guru Meditation Error:
Hoi, I think your issue is that you're printing something in the timer 'callback' (which actually is an interrupt handler). Printing in an interrupt handler will lead to issues.
Who is online
Users browsing this forum: No registered users and 59 guests