Skip to content
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

Hitting WDT resets with ESP8266 #2

Closed
caternuson opened this issue Dec 13, 2021 · 6 comments · Fixed by #3
Closed

Hitting WDT resets with ESP8266 #2

caternuson opened this issue Dec 13, 2021 · 6 comments · Fixed by #3

Comments

@caternuson
Copy link

Discovered while attempting to troubleshoot this thread:
https://forums.adafruit.com/viewtopic.php?f=19&t=185356

Seems like some kind of memory clobbering issue preventing the Arduino loop() from successfully looping and eventually hitting a WDT reset. Here is a simple sketch to demonstrate. Note it doesn't do anything other than call begin() on the MLX90640 instance.

#include <Adafruit_MLX90640.h>

Adafruit_MLX90640 mlx;
int count = 0;

void setup() {
  Serial.begin(115200);
  while (!Serial) delay(10);

  Serial.println("Adafruit MLX90640 Test");
  
  if (!mlx.begin()) {
    Serial.println("MLX90640 not found!");
    while (1) delay(10);
  }
  Serial.println("Found Adafruit MLX90640");
}

void loop() {
  Serial.print("count = "); Serial.println(count++);
  Serial.flush();
  delay(500);
}

Running that sketch on a Feather ESP8266 results in:
Screenshot from 2021-12-13 09-37-09

Simply comment out the call to begin(), and sketch runs as expected.
Screenshot from 2021-12-13 09-42-02

@JVaassen
Copy link

I tried to move 3 float arrays of 768 elements from their respective functions :
ExtractKtaPixelParameters
ExtractKvPixelParameters
ExtractAlphaParameters

to the front of the file and declared them static. It moves them from stack to heap. After that the demo works on ESP8266..
So the stack crash is solved. Probably setting a stack size param could also help, but didn't investigate yet.

@sorryusernameisalreadytaken

I am in the same boat.

@caternuson can you test this code:

#include <Adafruit_MLX90640.h>

Adafruit_MLX90640 mlx;
int count = 0;
static float mlx90640To[768];

void setup() {
  Serial.begin(115200);
  while (!Serial) delay(10);

  Serial.println("Adafruit MLX90640 Test");
  
  if (!mlx.begin()) {
    Serial.println("MLX90640 not found!");
    while (1) delay(10);
  }
  Serial.println("Found Adafruit MLX90640");
}

void loop() {
  Serial.print("count = "); Serial.println(count++);
  Serial.flush();
  
  mlx.getFrameData(mlx90640To);
  mlx.interpolateOutliers(mlx90640To);
  delay(50);
}

@JVaassen is this your idea?

@caternuson
Copy link
Author

@sorryusernameisalreadytaken Which library are you using? These methods are not in this one:

  mlx.getFrameData(mlx90640To);
  mlx.interpolateOutliers(mlx90640To);

@caternuson
Copy link
Author

Actually, thanks to @JVaassen 's tip, that helped find the issue. See PR #3 for a nominal fix.

@sorryusernameisalreadytaken

Actually, thanks to @JVaassen 's tip, that helped find the issue. See PR #3 for a nominal fix.

Can you show me your final sketch? This could help mse a lot.

@caternuson
Copy link
Author

No change needed to sketch. The fix is to the library code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants