Skip to content

XIAO ESP32-C3 Rainmaker example crash #7903

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
MingyaoLiu opened this issue Feb 28, 2023 · 7 comments · Fixed by #8243
Closed
1 task done

XIAO ESP32-C3 Rainmaker example crash #7903

MingyaoLiu opened this issue Feb 28, 2023 · 7 comments · Fixed by #8243
Labels
Area: Rainmaker Issue is related to ESP Rainmaker. Status: Needs investigation We need to do some research before taking next steps on this issue
Milestone

Comments

@MingyaoLiu
Copy link

Board

Seeed XIAO ESP32-C3

Device Description

XIAO ESP32

Hardware Configuration

Nothing connected.

Version

v2.0.7

IDE Name

Arduino IDE

Operating System

windows 11

Flash frequency

80 or 40 tried both

PSRAM enabled

yes

Upload speed

921600

Description

Loaded a rainmaker example from arduino IDE on XIAO esp32c3, build successfully, crashes on XIAO. I tried 2 examples one is RMakerCustom, one is RMakerSwitch, both crashes.

Tried wifi provision and some BLE examples, all fine.

Sketch

//This example demonstrates the ESP RainMaker with a standard Switch device.
#include "RMaker.h"
#include "WiFi.h"
#include "WiFiProv.h"

#define DEFAULT_POWER_MODE true
const char *service_name = "PROV_1234";
const char *pop = "abcd1234";

//GPIO for push button
static int gpio_0 = 9;
static int gpio_switch = 7;

/* Variable for reading pin status*/
bool switch_state = true;

//The framework provides some standard device types like switch, lightbulb, fan, temperaturesensor.
static Switch my_switch;

void sysProvEvent(arduino_event_t *sys_event) {
  switch (sys_event->event_id) {
    case ARDUINO_EVENT_PROV_START:
#if CONFIG_IDF_TARGET_ESP32S2
      Serial.printf("\nProvisioning Started with name \"%s\" and PoP \"%s\" on SoftAP\n", service_name, pop);
      printQR(service_name, pop, "softap");
#else
      Serial.printf("\nProvisioning Started with name \"%s\" and PoP \"%s\" on BLE\n", service_name, pop);
      printQR(service_name, pop, "ble");
#endif
      break;
    case ARDUINO_EVENT_PROV_INIT:
      wifi_prov_mgr_disable_auto_stop(10000);
      break;
    case ARDUINO_EVENT_PROV_CRED_SUCCESS:
      wifi_prov_mgr_stop_provisioning();
      break;
    default:;
  }
}

void write_callback(Device *device, Param *param, const param_val_t val, void *priv_data, write_ctx_t *ctx) {
  const char *device_name = device->getDeviceName();
  const char *param_name = param->getParamName();

  if (strcmp(param_name, "Power") == 0) {
    Serial.printf("Received value = %s for %s - %s\n", val.val.b ? "true" : "false", device_name, param_name);
    switch_state = val.val.b;
    (switch_state == false) ? digitalWrite(gpio_switch, LOW) : digitalWrite(gpio_switch, HIGH);
    param->updateAndReport(val);
  }
}

void setup() {
  Serial.begin(115200);
  while (!Serial) {
    delay(500);
  }
  pinMode(gpio_0, INPUT);
  pinMode(gpio_switch, OUTPUT);
  digitalWrite(gpio_switch, DEFAULT_POWER_MODE);


  Node my_node;
  my_node = RMaker.initNode("ESP RainMaker Node");

  //Initialize switch device
  my_switch = Switch("Switch", &gpio_switch);

  //Standard switch device
  my_switch.addCb(write_callback);

  //Add switch device to the node
  my_node.addDevice(my_switch);

  //This is optional
  RMaker.enableOTA(OTA_USING_TOPICS);
  //If you want to enable scheduling, set time zone for your region using setTimeZone().
  //The list of available values are provided here https://rainmaker.espressif.com/docs/time-service.html
  // RMaker.setTimeZone("Asia/Shanghai");
  // Alternatively, enable the Timezone service and let the phone apps set the appropriate timezone
  RMaker.enableTZService();

  RMaker.enableSchedule();

  RMaker.enableScenes();

  RMaker.start();
  WiFi.onEvent(sysProvEvent);
  WiFiProv.beginProvision(WIFI_PROV_SCHEME_BLE, WIFI_PROV_SCHEME_HANDLER_FREE_BTDM, WIFI_PROV_SECURITY_1, pop, service_name);
}

void loop() {
  if (digitalRead(gpio_0) == LOW) {  //Push button pressed
    Serial.printf("PRESSED.\n");

    // Key debounce handling
    delay(100);
    int startTime = millis();
    while (digitalRead(gpio_0) == LOW) delay(50);
    int endTime = millis();

    if ((endTime - startTime) > 10000) {
      // If key pressed for more than 10secs, reset all
      Serial.printf("Reset to factory.\n");
      RMakerFactoryReset(2);
    } else if ((endTime - startTime) > 3000) {
      Serial.printf("Reset Wi-Fi.\n");
      // If key pressed for more than 3secs, but less than 10, reset Wi-Fi
      RMakerWiFiReset(2);
    } else {
      // Toggle device state
      switch_state = !switch_state;
      Serial.printf("Toggle State to %s.\n", switch_state ? "true" : "false");
      my_switch.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, switch_state);
      (switch_state == false) ? digitalWrite(gpio_switch, LOW) : digitalWrite(gpio_switch, HIGH);
    }
  }
  delay(100);
}

Debug Message

22:58:55.138 -> Rebooting...
22:58:55.138 -> ESP-ROM:esp32c3-api1-20210207
22:58:55.138 -> Build:Feb  7 2021
22:58:55.138 -> rst:0x3 (RTC_SW_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT)
22:58:55.138 -> Saved PC:0x403819b0
22:58:55.138 -> SPIWP:0xee
22:58:55.138 -> mode:DIO, clock div:1
22:58:55.138 -> load:0x3fcd5810,len:0x438
22:58:55.138 -> load:0x403cc710,len:0x91c
22:58:55.138 -> load:0x403ce710,len:0x25b0
22:58:55.138 -> entry 0x403cc710
22:58:56.810 -> btdm: bss start 0x3fcdf0a8, len 40
22:58:56.810 -> btdm: data start 0x3fcdf09c, data start rom 0x400591fc, len 12
22:58:56.810 -> MAGIC fadebead VERSION 00010006
22:58:56.810 -> E (1687) simple_ble: simple_ble_start enable controller failed 257
22:58:56.810 -> E (1693) protocomm_ble: simple_ble_start failed w/ error code 0x101
22:58:56.810 -> E (1699) wifi_prov_scheme_ble: Failed to start protocomm BLE service
22:58:56.842 -> E (1705) wifi_prov_mgr: Failed to start service
22:58:56.842 -> [  1701][E][WiFiProv.cpp:145] beginProvision(): wifi_prov_mgr_start_provisioning failed!
22:58:57.262 -> Guru Meditation Error: Core  0 panic'ed (Load access fault). Exception was unhandled.
22:58:57.262 -> 
22:58:57.262 -> Core  0 register dump:
22:58:57.262 -> MEPC    : 0x4038f95a  RA      : 0x4038f9ee  SP      : 0x3fca3940  GP      : 0x3fc91c00  
22:58:57.262 -> TP      : 0x3fc4ccb0  T0      : 0x4005890e  T1      : 0x4038fb92  T2      : 0x00000000  
22:58:57.262 -> S0/FP   : 0x7f997590  S1      : 0x3fcdff80  A0      : 0x3fcdff88  A1      : 0x00000001  
22:58:57.262 -> A2      : 0xabba1234  A3      : 0xabba1234  A4      : 0x00000001  A5      : 0x00000000  
22:58:57.262 -> A6      : 0x00000000  A7      : 0x3fca9f70  S2      : 0x00000001  S3      : 0x3fc9b000  
22:58:57.262 -> S4      : 0x3fc9b000  S5      : 0x00000003  S6      : 0x00000004  S7      : 0x00000000  
22:58:57.262 -> S8      : 0x00000000  S9      : 0x00000000  S10     : 0x00000000  S11     : 0x00000000  
22:58:57.262 -> T3      : 0x00000000  T4      : 0x00000000  T5      : 0x00000000  T6      : 0x00000000  
22:58:57.262 -> MSTATUS : 0x00001881  MTVEC   : 0x40380001  MCAUSE  : 0x00000005  MTVAL   : 0x7f997590  
22:58:57.262 -> MHARTID : 0x00000000  
22:58:57.262 -> Stack memory:
22:58:57.262 -> 3fca3940: 0x000005e0 0x3c1496bc 0x3fcdff88 0x4202cb10 0x000005e0 0x3fcdff88 0x3fcdf96c 0x4038f9ee
22:58:57.262 -> 3fca3960: 0x3fc9b000 0x3c1496bc 0x42023eca 0x4202407e 0x3fc9b000 0xffffffff 0x00000000 0x00000002
22:58:57.262 -> 3fca3980: 0x3fc9b000 0xffffffff 0x3fca84e0 0x4201b6d0 0x00000000 0x00000000 0x00000000 0x00000000
22:58:57.262 -> 3fca39a0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x4038cd0a
22:58:57.262 -> 3fca39c0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5
22:58:57.262 -> 3fca39e0: 0xa5a5a5a5 0xbaad5678 0x00000160 0xabba1234 0x00000154 0x3fca38a0 0x000005e0 0x3fc975d0
22:58:57.262 -> 3fca3a00: 0x3fc975d0 0x3fca39f4 0x3fc975c8 0x00000007 0x3fca2d2c 0x3fca2d2c 0x3fca39f4 0x00000000
22:58:57.262 -> 3fca3a20: 0x00000012 0x3fca2de4 0x00546974 0x00000000 0x00000000 0x00000020 0x00000000 0x3fca39e0
22:58:57.262 -> 3fca3a40: 0x00000012 0x00000000 0x00000000 0x00000000 0x00000000 0x3fca0b54 0x3fca0bbc 0x3fca0c24
22:58:57.262 -> 3fca3a60: 0x00000000 0x00000000 0x00000001 0x00000000 0x00000000 0x00000000 0x421218a6 0x00000000
22:58:57.262 -> 3fca3a80: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
22:58:57.262 -> 3fca3aa0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
22:58:57.262 -> 3fca3ac0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
22:58:57.262 -> 3fca3ae0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
22:58:57.262 -> 3fca3b00: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
22:58:57.262 -> 3fca3b20: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
22:58:57.262 -> 3fca3b40: 0x00000000 0x3f000000 0xbaad5678 0x00000060 0xabba1234 0x00000054 0x3fca3b58 0x3fca3b58
22:58:57.262 -> 3fca3b60: 0x3fca3b58 0x3fca3b58 0x00000000 0x3fca3b70 0xffffffff 0x3fca3b70 0x3fca3b70 0x00000000
22:58:57.262 -> 3fca3b80: 0x3fca3b84 0xffffffff 0x3fca3b84 0x3fca3b84 0x00000000 0x00000001 0x00000000 0x0000ffff
22:58:57.262 -> 3fca3ba0: 0x00000000 0xb33fffff 0x00000000 0xbaad5678 0x00000060 0xabba1234 0x00000054 0x3fca3bbc
22:58:57.262 -> 3fca3bc0: 0x3fca3bbc 0x3fca3bbc 0x3fca3bbc 0x00000000 0x3fca3bd4 0xffffffff 0x3fca3bd4 0x3fca3bd4
22:58:57.262 -> 3fca3be0: 0x00000000 0x3fca3be8 0xffffffff 0x3fca3be8 0x3fca3be8 0x00000001 0x00000001 0x00000000
22:58:57.262 -> 3fca3c00: 0x0000ffff 0x00000000 0xb33fffff 0x00000000 0xbaad5678 0x00000030 0xabba1234 0x00000024
22:58:57.262 -> 3fca3c20: 0x00002008 0x00000000 0x3fca3c2c 0xffffffff 0x3fca3c2c 0x3fca3c2c 0x00000000 0xb33fffff
22:58:57.262 -> 3fca3c40: 0x00000000 0xbaad5678 0x000000e0 0xabba1234 0x000000d4 0x3fca3ca8 0x3fca3cb4 0x3fca3d28
22:58:57.262 -> 3fca3c60: 0x3fca3cb0 0x00000000 0x3fca3c6c 0xffffffff 0x3fca3c6c 0x3fca3c6c 0x00000001 0x3fca3c80
22:58:57.262 -> 3fca3c80: 0xffffffff 0x3fca9794 0x3fca9794 0x00000000 0x00000020 0x00000004 0x0000ffff 0x00000000
22:58:57.262 -> 3fca3ca0: 0xb33fffff 0x00000000 0x3fcaff30 0x3fcb43d0 0x3fcb70e4 0x4005890e 0x4038b68e 0xffffffff
22:58:57.262 -> 3fca3cc0: 0x00000000 0x00000000 0x00000001 0x00000001 0x00000000 0x00000001 0x600c0000 0x3fc9b000
22:58:57.262 -> 3fca3ce0: 0x3fcdfaac 0x807fffff 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
22:58:57.262 -> 3fca3d00: 0x00000000 0x00000000 0x00000000 0x00000000 0x00020000 0xffffffff 0xffffffff 0xffffffff
22:58:57.262 -> 3fca3d20: 0x00000000 0x00000000 0xbaad5678 0x00000024 0xabba1234 0x00000018 0x3c146b78 0x3fca7994
22:58:57.423 -> 
22:58:57.423 -> 
22:58:57.423 -> 
22:58:57.423 -> ELF file SHA256: 4faa426969ea8030
22:58:57.423 ->

Other Steps to Reproduce

Any rainmaker example

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@MingyaoLiu MingyaoLiu added the Status: Awaiting triage Issue is waiting for triage label Feb 28, 2023
@MingyaoLiu
Copy link
Author

the code i pasted has some line different from the example, but loading the example and compile without modification also has the same crashing issue.
Also tried 'erase all flash before uploading', same result.

@MingyaoLiu
Copy link
Author

I tried 2.0.6, and the examples are loading and able to do provisioning.
I saw another thread that shows there are a bunch of error in rainmaker in 2.0.7: #7893
I guess they are the same issue.

@sanketwadekar
Copy link
Contributor

@SuGlider This crash is seen only when PSRAM is enabled. However, BLE memory allocation errors aren't resolved by disabling PSRAM. I've tried the WiFi Prov example and can confirm that the same errors are seen there too(errors are seen only if BT transport is used.)

@VojtechBartoska
Copy link
Contributor

Thanks for your comments @sanketwadekar. Any suggestions how to fix this?

@SuGlider SuGlider added Status: Needs investigation We need to do some research before taking next steps on this issue and removed Status: Awaiting triage Issue is waiting for triage labels Mar 2, 2023
@Jason2866
Copy link
Collaborator

C3 has no PSRAM so this can't be the reason.

@VojtechBartoska VojtechBartoska moved this from Todo to Under investigation in Arduino ESP32 Core Project Roadmap Mar 13, 2023
@VojtechBartoska VojtechBartoska moved this from Under investigation to In Progress in Arduino ESP32 Core Project Roadmap Mar 22, 2023
@VojtechBartoska VojtechBartoska moved this from In Progress to In Review in Arduino ESP32 Core Project Roadmap Apr 17, 2023
@VojtechBartoska
Copy link
Contributor

Hello, this is fixed with 2.0.8 . If you still face some issues, feel free to reopen.

@sanketwadekar
Copy link
Contributor

Hello, this is fixed with 2.0.8 . If you still face some issues, feel free to reopen.

The Bluetooth issue is not resolved yet. Please reopen this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Rainmaker Issue is related to ESP Rainmaker. Status: Needs investigation We need to do some research before taking next steps on this issue
Projects
Development

Successfully merging a pull request may close this issue.

6 participants