-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Adding a single global variable causes uploaded binary to not run #547
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
Comments
please add #include <Arduino.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <SparkFunHTU21D.h>
HTU21D myHumidity;
void setup()
{
Serial.begin(115200);
Serial.setDebugOutput(true);
delay(1000);
Serial.println("\n\nOrientation Sensor Raw Data Test\n");
Serial.flush();
myHumidity.begin();
Serial.println("Setup done.\n");
Serial.flush();
}
void loop()
{
Serial.println("Loop.");
float temp = myHumidity.readTemperature();
float humd = myHumidity.readHumidity();
Serial.print("Temperature:");
Serial.print(temp, 1);
Serial.print("C");
Serial.print(" Humidity:");
Serial.print(humd, 1);
Serial.println("%");
delay(1000);
} |
The original intent of the if (first) clause was there was the setup() code was taking too long, and I wanted to move it into the loop(), thinking that perhaps the WTD did not fire there. I was, wrong, of course, so it could go back into setup() again. However, the code you pasted is not the same as the code I was running. In your code, the part that I have #if'd out is active; in mine, it is disabled, and yet its mere presence causes it to not compile the same. |
So it doesn't compile or doesn't run? |
It doesn't run. Adding setDebugOutput(true) doesn't change the behavior. Output:
|
Note once again that the code Links2004 posted is NOT equivalent to the code that I posted. |
the code you use has #include "Arduino.h"
void setup()
{
Serial.begin(115200);
Serial.println("\n\nOrientation Sensor Raw Data Test\n");
}
bool first = true;
void loop()
{
Serial.println("Loop.");
if (first) {
first = false;
delay(1000);
}
delay(1000);
} and the WDT fires? |
@Links2004, the code as you posted it just now does work as expected. |
Do you agree that your code and the effective code from the #if 0'd out lines should be identical? |
It's actually inconsistent what works and what does not. This is all using a bench power supply with an upper limit set to 1A. I've bumped the limit to 2A just in case I can't do math. Wether or not the code works seems to be dependent on something apparently random. If I flash the above code it works, and then the original works as well. If I flash a longer version (which has the same concept as the shorter version, but adds a gyroscopic sensor and starts to initialize WiFi, all #if'd out) -- it will not. And then, the shorter #if'd out part I originally posted will not work either. I think I need a young priest and an old priest. |
yes the precompiler will delete all the code inside the |
what version do you use? how do you flash? |
According to the board manager, I have "1.6.4-673-g8cd3697" installed. I've tried flashing both with the included esptool binary and the Python version. Prior to what appears to be a very recent update, the built-in esptool would not consistently flash, but the python version would. This version seems stable. I will try removing it, and flashing it again, just to see if that is an issue. |
Wiping the ~/Library/Arduino15 directory entirely and reinstalling still causes the same issue. The version installed matches from my previous comment. |
After tinkering for a bit, the code has morphed into what's shown below. Note that the effective code is still very similar, and yet does not run as expected. I'll paste both the current code and my "effective code" for comparison. This will not work. It loops with WTD resets with the message:
#include "Arduino.h"
#define USE_WIFI 0
#define USE_HUMIDITY 0
#define USE_GYRO 0
#if USE_GYRO || USE_HUMIDITY
#include <Wire.h>
#include <Adafruit_Sensor.h>
#endif
#if USE_GYRO
#include <Adafruit_BNO055.h>
#endif
#if USE_WIFI
#include <SPI.h>
#include <WiFi.h>
#endif
#define BNO055_SAMPLERATE_DELAY_MS (100)
#if USE_GYRO
#include <utility/imumaths.h>
Adafruit_BNO055 bno = Adafruit_BNO055(12345);
#endif
#if USE_HUMIDITY
#include <SparkFunHTU21D.h>
HTU21D myHumidity;
#endif
#if USE_WIFI
char ssid[] = "TechShop WiFi";
char pass[] = "xxxxxxxxx";
int status = WL_IDLE_STATUS;
#endif
void setup()
{
Serial.setDebugOutput(true);
Serial.begin(115200);
Serial.println("\n\nOrientation Sensor Raw Data Test\n");
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
delay(10);
digitalWrite(13, HIGH);
#if USE_GYRO || USE_HUMIDITY
Wire.setClock(200000UL);
Wire.begin(4, 5);
delay(100);
#endif
#if USE_GYRO
/* Initialise the BNO055 sensor */
while (!bno.begin(Adafruit_BNO055::OPERATION_MODE_NDOF, false)) {
/* There was a problem detecting the BNO055 ... check your connections */
Serial.println("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!");
yield();
}
#endif
#if USE_HUMIDITY
myHumidity.begin();
#endif
delay(1000);
#if USE_GYRO
/* Display the current temperature */
int8_t temp = bno.getTemp();
Serial.print("Current Temperature: ");
Serial.print(temp);
Serial.println(" C");
Serial.println("");
bno.setExtCrystalUse(true);
#endif
#if USE_WIFI
Serial.println("Configuring WiFi");
while (status != WL_CONNECTED) {
Serial.print("Attempting to connect to WPA SSID: ");
Serial.println(ssid);
status = WiFi.begin(ssid, pass);
delay(10000);
}
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
#endif
}
#if USE_GYRO
void print_plus(float x) {
if (x >= 0.0)
Serial.print("+");
}
#endif
void loop()
{
Serial.println("Loop.");
#if USE_GYRO
// Possible vector values can be:
// - VECTOR_ACCELEROMETER - m/s^2
// - VECTOR_MAGNETOMETER - uT
// - VECTOR_GYROSCOPE - rad/s
// - VECTOR_EULER - degrees
// - VECTOR_LINEARACCEL - m/s^2
// - VECTOR_GRAVITY - m/s^2
imu::Vector<3> euler = bno.getVector(Adafruit_BNO055::VECTOR_EULER);
Serial.print("X: ");
print_plus(euler.x());
Serial.print(euler.x());
Serial.print(" Y: ");
print_plus(euler.y());
Serial.print(euler.y());
Serial.print(" Z: ");
print_plus(euler.z());
Serial.print(euler.z());
Serial.print(" - ");
euler = bno.getVector(Adafruit_BNO055::VECTOR_LINEARACCEL);
Serial.print("X: ");
print_plus(euler.x());
Serial.print(euler.x());
Serial.print(" Y: ");
print_plus(euler.y());
Serial.print(euler.y());
Serial.print(" Z: ");
print_plus(euler.z());
Serial.print(euler.z());
Serial.print(" Mag:" );
Serial.print(sqrt(euler.x() * euler.x() + euler.y() * euler.y() + euler.z() * euler.z()));
#endif
#if USE_HUMIDITY
float temp = myHumidity.readTemperature();
float humd = myHumidity.readHumidity();
Serial.print(" Temperature:");
Serial.print(temp, 1);
Serial.print("C");
Serial.print(" Humidity:");
Serial.print(humd, 1);
Serial.print("%");
Serial.println();
#endif
delay(1000);
} Effective code (which runs): #include "Arduino.h"
void setup()
{
Serial.setDebugOutput(true);
Serial.begin(115200);
Serial.println("\n\nOrientation Sensor Raw Data Test\n");
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
delay(10);
digitalWrite(13, HIGH);
delay(1000);
}
void loop()
{
Serial.println("Loop.");
delay(1000);
} |
btw, the staging directory has these:
|
the version look good. Serial.println();
Serial.println();
Serial.println();
for(uint8_t t = 4; t > 0; t--) {
Serial.print(F("[SETUP] BOOT WAIT "));
Serial.print(t);
Serial.println(F("..."));
Serial.flush();
delay(1000);
}
Serial.print("[SETUP] Reset Info: ");
Serial.println(ESP.getResetInfo());
Serial.flush();
delay(1000); to the top of the |
There is no getResetInfo() on the ESP class. |
Regardless, the output is pretty much identical, using ESP.getBootMode() call which does exist. Nothing is printed from within the setup() method at all. |
ok its not in the release build the 1.6.4-673-g8cd3697 is from May 22, 2015. |
Can you give me a rundown or pointer on how to install the latest? I'm more than happy to track it from git, so long as my regular Arduino code continues working! |
hi Michael To install the latest IDE: git clone https://github.com/esp8266/Arduino.git Then unpack the built version as instructed by the ant script (a .xz in This will include the "arduino" script to run the IDE. It may also a good idea to start with a fresh set of preferences etc., e.g.: cd HTH, Hamish Cunningham |
@Links2004 cool, tnx (though I guess you don't actually save any time or space this way?) |
i never build the package :) i directly use the git files with symlinks in my arduino dir. |
ah, sneaky!
:-)
|
I'm happy to make those symlinks as well. I am a coder; this hardware stuff is for fun :) Running from my live build root does not frighten me at all. |
I followed those steps and pointed at localhost:8000, but now I get:
Let's go the symlink route if it's not too difficult. |
I'm just running the Arduino.app from the build directory, and it does work, including when I enable the i2c portion of the code. I've not tried the WiFi parts yet, but considering it works and this issue is resolved enough that I can continue the i2c issue in #526, I'll close this one with one final comment. For the good of all those others wanting to use the ESP8266, please release a new package for the board manager! It's night and day in terms of outcome. |
This code compiles, but does not run correctly on the device:
Removing all the parts that are already #ifdef'd out causes it to run properly. Something, somewhere, is insane.
The text was updated successfully, but these errors were encountered: