Skip to content

All Wemos D1 mini code stopped working after esp8266 Boards upgrade from 2.5.2 to 3.0.2 #8475

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
TSBrownie opened this issue Feb 2, 2022 · 18 comments

Comments

@TSBrownie
Copy link

TSBrownie commented Feb 2, 2022

Basic Info

  • [x ] This issue complies with the issue POLICY doc.
  • [ x] I have read the documentation at readthedocs and the issue is not addressed there.
  • [ ?] I have tested that the issue is present in current master branch (aka latest git).
  • [ x] I have searched the issue tracker for a similar issue.
  • [ x] If there is a stack dump, I have decoded it.
  • [ x] I have filled out all fields below.

Platform

  • Hardware: Wemos D1 mini (reports: ESP8266EX) w/ RTC Shield/SD
  • Core Version: [latest git hash or date]
  • Development Env: 1.8.16
  • Operating System: Win 10

Settings in IDE

  • Module: Wemos D1 mini ESP8266 3.0.2 (from 2.5.2)
  • Flash Mode: qio
  • Flash Size: 4MB
  • lwip Variant: v2 lower mem
  • Reset Method: nodemcu, hard, power
  • Flash Frequency: ?? Mhz
  • CPU Frequency: Crystal is 26MHz
  • Upload Using: SERIAL
  • Upload Speed: 460800 (auto set)

Problem Description

Working code (plus 10 past versions) stopped working immediately after updating from Boards esp8266 by ESP8266 Community version 2.5.2 to 3.0.2.
Code still complies w/o error. (Takes take 3x longer.)
I have tried all the Wemos LOLIN boards on the 3.0.2, include generic esp8266. Similar chksum errors from all.

Output before:
========= 20220201,Tue,07:54:28
Device Altitude(abs): 6.00 meters AMSL
Temperature: 28.47C; 83.25F Falling
Barometric Pressure(abs): Rising-Fair Weather
955.597 hPa(mbar); 95559.720 Pa
950.916 hPa, Short Term Past Average
716.757 mmHg
0.943101 Atm
Barometric Pressure-Comp'ed To Sealevel
956.247 hPa(mbar); 95624.692 Pa
717.244 mmHg
0.943742 Atm

Output after:
ets Jan 8 2013,rst cause:4, boot mode:(3,6)
wdt reset
load 0x4010f000, len 3460, room 16
tail 4
chksum 0xcc
load 0x3fff20b8, len 40, room 4
tail 4
chksum 0xc9
csum 0xc9
v00055920
~ld

MCVE Sketch

One sample of previously working code here (compile info below):
https://github.com/TSBrownie/Arduino-Wemos-D1-Weather-Basic/tree/main/2022WeatherBMP280-04x

#include <Arduino.h>
void setup() {}
void loop() {}

Debug Messages

Executable segment sizes:
ICACHE : 32768           - flash instruction cache 
IROM   : 247428          - code in flash         (default or ICACHE_FLASH_ATTR) 
IRAM   : 27369   / 32768 - code in IRAM          (IRAM_ATTR, ISRs...) 
DATA   : 1520  )         - initialized variables (global, static) in RAM/HEAP 
RODATA : 1152  ) / 81920 - constants             (global, static) in RAM/HEAP 
BSS    : 26216 )         - zeroed variables      (global, static) in RAM/HEAP 
Sketch uses 277469 bytes (26%) of program storage space. Maximum is 1044464 bytes.
Global variables use 28888 bytes (35%) of dynamic memory, leaving 53032 bytes for local variables. Maximum is 81920 bytes.
esptool.py v3.0
Serial port COM4
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: e8:db:84:dc:c5:06
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 281616 bytes to 205845...
Writing at 0x00000000... (7 %)
Writing at 0x00004000... (15 %)
Writing at 0x00008000... (23 %)
Writing at 0x0000c000... (30 %)
Writing at 0x00010000... (38 %)
Writing at 0x00014000... (46 %)
Writing at 0x00018000... (53 %)
Writing at 0x0001c000... (61 %)
Writing at 0x00020000... (69 %)
Writing at 0x00024000... (76 %)
Writing at 0x00028000... (84 %)
Writing at 0x0002c000... (92 %)
Writing at 0x00030000... (100 %)
Wrote 281616 bytes (205845 compressed) at 0x00000000 in 4.6 seconds (effective 488.2 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

NOTE: Simple code such as the following still compiles / works, but only after initially reporting checksums:

//Arduino C.  Wemos D1R1 ESP8266Boards (2.5.2) Mini DS32 w/ Mini Shield.  
//Read Real Time Clock Module DS1307.  COM7.  VCC->5v, Gnd->Gnd, SDA (data)->A4, SCL (clk)->A5
//RTC Pinouts, I2C.  D1 = SCL, D2 = SDA
//20210323 - by TSBrownie.  Non-commercial use approved.
#include "Wire.h"                   //Include I2C library
#define DS1307 0x68                 //Default I2C Addr of 1307 0x68 Hex

String DoWList[] = {"Null"," Sun "," Mon "," Tue "," Wed "," Thr "," Fri "," Sat "}; //DOW from 1-7
byte second, minute, hour, DoW, Date, month, year;     //Btye variables for BCD time
int sec, mm, hh, dow, date, mnth, yy;                  //Decimal variables

byte BCD2DEC(byte val){             //Ex: 51 = 01010001 BCD.  01010001/16-->0101=5 then x10-->50.  
  return(((val/16)*10)+(val%16));}  //         01010001%16-->0001.  50+0001 = 51 DEC

void GetRTCTime(byte *second, byte *minute,byte *hour,byte *DoW,
                byte *Date,byte *month,byte *year){
  Wire.beginTransmission(DS1307);           //Open I2C to RTC
  Wire.write(0x00);                         //Write reg pointer to 0x00 Hex
  Wire.endTransmission();                   //End xmit to I2C.  Send requested data.
  Wire.requestFrom(DS1307, 7);              //Get 7 bytes from RTC buffer
  *second = BCD2DEC(Wire.read() & 0x7f);    //Set pntr to seconds remove hi order bit
  *minute = BCD2DEC(Wire.read());           //Set pointer to minutes
  *hour = BCD2DEC(Wire.read() & 0x3f);      //Set pntr to hour remove 2 hi order bits
  *DoW = BCD2DEC(Wire.read());              //Set pointer to day of week
  *Date = BCD2DEC(Wire.read());             //Set pointer to Date
  *month = BCD2DEC(Wire.read());            //Set pointer to month
  *year = BCD2DEC(Wire.read());             //Set pointer to year
}
void printTime(){                         //Read & print data from RTC
  GetRTCTime(&second, &minute, &hour, &DoW, &Date, &month, &year);  //Get RTC data
  Serial.print(2000+year, DEC);             //Print year 20xx
  Serial.print("/");
  if (month<10){Serial.print("0");}         //Print leading 0 if needed
  Serial.print(month, DEC);                 //Month as decimal
  Serial.print("/");
  if(Date<10){Serial.print("0");}           //Print leading 0 if needed
  Serial.print(Date, DEC);                  //Date (1-30)
  Serial.print(DoWList[DoW]);               //1Sun-7Sat (0=null)
  if (hour<10){Serial.print("0");}          //Print leading 0 if needed
  Serial.print(hour, DEC);                  //HH
  Serial.print(":");        
  if (minute<10){Serial.print("0");}        //Print leading 0 if needed
  Serial.print(minute, DEC);                //MM
  Serial.print(":");
  if (second<10){Serial.print("0");}        //Print leading 0 if needed
  Serial.println(second, DEC);              //SS
}
void setup(){                               //Setup function
  Wire.begin();                             //Join I2C bus as primary
  Serial.begin(74880);                      //Initialize serial com
  for(int i=1; i<5; i++){                   //Read RTC and print date/time for user verify
     printTime();                           //Output date/time to Serial Monitor
     delay(1000);                           //Delay output x seconds
  }
  Serial.println("If the above date and times are correct, the RTC is updated.");
}

void loop(){}                           //Just loops

OUTPUT:
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
load 0x4010f000, len 3460, room 16
tail 4
chksum 0xcc
load 0x3fff20b8, len 40, room 4
tail 4
chksum 0xc9
csum 0xc9
v00042ec0
~ld
2022/02/02 Wed 15:36:42
2022/02/02 Wed 15:36:43
2022/02/02 Wed 15:36:44
2022/02/02 Wed 15:36:45
If the above date and times are correct, the RTC is updated.

@TSBrownie
Copy link
Author

Another version of the same weather station code that was working, now does this:

--------------- CUT HERE FOR EXCEPTION DECODER ---------------
Exception (28):
epc1=0x40211734 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
>>>stack>>>
ctx: cont
sp: 3ffffd20 end: 3fffffc0 offset: 0190
3ffffeb0:  00000000 00000000 3ffeebd8 3fff0738  
3ffffec0:  3fff072c 00000003 3ffeea34 40201709  
3ffffed0:  00000000 00000000 3ffffef0 3ffeea9c  
3ffffee0:  3fffff08 3ffeea34 3fffff30 4021184c  
3ffffef0:  40210fa4 00000000 000003e8 40100cd4  
3fffff00:  00000000 00000000 00000000 40204d4c  
3fffff10:  00000000 00000000 3ffeebd8 4020c8d5  
3fffff20:  4020fddc 4020fdc8 3ffee9d8 40201860  
3fffff30:  3fff05b4 000c000f 80000000 4020c9d1  
3fffff40:  4020fddc 4020fdc8 3ffee9d8 40203d00  
3fffff50:  3fff069c 0037003f 80000000 00000000  
3fffff60:  40203488 00000000 4020fddc 4020fdc8  
3fffff70:  40203488 08080808 feefeffe feefeffe  
3fffff80:  00000000 feefeffe feefeffe feefeffe  
3fffff90:  feefeffe feefeffe feefeffe 3ffeeedc  
3fffffa0:  3fffdad0 00000000 3ffeeec8 4020d9c4  
3fffffb0:  feefeffe feefeffe 3ffe8688 40100f2d  
<<<stack<<<

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

THIS IS THE CODE throwing the above errors. This was working archival code:

//Add led on / off during file update if file corruption is issue during eject.
//Arduino Wemos D1R1 mini w/ RTC, SD Shield (ESP8266 Boards 2.5.2), WiFi Viewing
//RTC, SD File: Absolute Barometric Pressure (SL & Comp), Temp, no humidity
//Exponential Moving Average EMA improvement
//Wemos SDA(D2)-->BMP280 SDA pin; Wemos SCL(D1)-->BMP280 SCL
//Wemos 3v3-->BMP280 Vdd; Wemos GND-->BMP280 GND
//UNUSED: Wemos Vdd or GND-->BMP280=SDO (Address control)
//UNUSED: Wemos Vdd or GND-->BMP280=CSB (I2C select, GND=SPI)
//BMP280 Data is LSBMSB ijklmnopabcdefgh order (not abcdefghijklmnop)
//WeMos Micro SD Shield (uses HSPI(12-15) not (5-8), 3V3, G)
//GPIO12(D6)=MISO (main in, secondary out); GPIO13(D7)=MOSI (main out, secondary in) 
//GPIO14(D5)=CLK (Clock); GPIO15(D8)=CS (Chip select)
//SD library-->8.3 filenames (ABCDEFGH.txt = abcdefgh.txt)
//RTC DS1307. I2C--> SCL(clk)=D1, SDA(data)=D2 (Shared with BMP280)
//20220122 - TSBrownie.  Non-commercial use.
#include <SD.h>                      //SD card library
#include <SPI.h>                     //COM Serial Peripheral Interface bus for COMM, SD com

//WiFi Serving Def ===============================
#include <ESP8266WiFi.h>             //WiFi library
#include <WiFiClient.h>              //WiFi Client library
#include <ESP8266WebServer.h>        //Web Server library
#include <DNSServer.h>               //Domain Name Server
#include <ESP8266mDNS.h>             //ESP8266 mDNS specific
#include <EEPROM.h>                  //ESP eeprom library
#define DBG_OUTPUT_PORT Serial       //Direct debug to Serial
//Set to desired softAP credentials. NOT configurable at runtime
#ifndef APSSID                       //Prevents incursive lib inclusions
#define APSSID "FreeLocalWeather"    //USER SUPPLIED: SSID
#define APPSK  ""                    //#define APPSK  "12345678"
#endif                               //

const char *softAP_ssid = APSSID;    //Soft access point ssid (def above)
const char *softAP_password = APPSK; //Soft access point password (def above)
const char *myHostname = "FreeInfo"; //Hostname for multicast DNS. Works on win. Try http://esp8266.local
char ssid[32] = "";                  //Don't set this credential. Configured at runtime & stored on EEPROM
char password[32] = "";              //Don't set this credential. Configured at runtime & stored on EEPROM
const byte DNS_PORT = 53;            //DNS server.  Port 53 for UDP activities & as server port for TCP
DNSServer dnsServer;                 //DNS server.  Port 53 for UDP activities & as server port for TCP
ESP8266WebServer server(80);         //Port 80, standard internet
IPAddress apIP(8, 8, 8, 8);          //Soft AP network parameters 8888 for auto show
IPAddress netMsk(255, 255, 255, 0);  //Soft AP network parameters
const int msgLen = 57;               //Xfer client confirm message length
char msg[msgLen];                    //Final confirm msg to client.  2GB file limit
//End WiFi Serving Def ===========================
#include<Wire.h>                     //Wire library I2C
#define BMP280Addr 0x76              //BMP280 I2C 0x76(108), or 0x77
#define DS1307 0x68                  //I2C Addr of RTC1307 (Default=0x68 Hex)
#define S_prt Serial.print           //Short name for Serial.print
#define S_pln Serial.println         //Short name for Serial.println
File SDconFile;                      //SD File2 to keep connect info
File saveWeather;                    //SD file3 keep all weather data
File dataTemp;                       //SD file4 txt temp weather data to show
const char *FName2 = "Connect1.txt"; //USER: SD card file keep connect info
const char *FName3 = "20220122.txt"; //USER SUPPLIED: SD card file name (ANSI encoding is best)
String FName4 = "DataTemp.txt";      //USER: SD temp display data (not const char) 
String connectData;                  //Accumulate SD connect data
String outBuff;                      //Output to COM and SD file
String SDData;                       //Build data to write to SD "disk"
String timeString;                   //Build date time data
unsigned long time_last = 0;         //Last time data was updated for millis()
unsigned int time2update = 10000;    //USER SUPPLIED: Milliseconds between readings
double calib = 0;                    //USER SUPPLIED: Clock calibration
double TempCal = -5;                 //USER SUPPLIED: Temp C calibration factor
double Dh = 6.0;                     //USER SUPPLIED: Device height above sea level m
double P, p0;                        //P Uncomp Press at device alt, p0 Sea Level
double cTempLast = 0;                //Keep last temp for rising, falling, steady
double pLast = 0;                    //Keep last pressure for rising, falling, steady
unsigned int b1[24];                 //16 bit array 0-24 (2 bytes)
unsigned int data[8];                //16 bit Data array 0-8
unsigned int avgPTindx = 0;          //Index to avgPT
unsigned int con = 0;                //Number of user connects since startup 
const unsigned int avgPTsz = 10;     //USER SUPPLIED: # of past data to average,size of avgPT array
//const unsigned int Nreadings = 10; //USER SUPPLIED: # of data points to average,size of avgPT array
//float Kconst = 0.18181818;         //USER SUPPLIED K = 2 / (N+1) N=Number of readings stored
double avgPT[2][avgPTsz+1];          //Store past press & temp for averages
bool avgFlag = false;                //Suppress avg press until enough samples
byte second, minute, hour, DoW, Date, month, year;   //Btye variables for BCD time
const char *DoWList[]={"Null",",Sun,",",Mon,",",Tue,",",Wed,",",Thr,",",Fri,",",Sat,"}; //DOW from 1-7

int Compare(float f1, float f2, int ex1){                   //Compare(F1, F2, # decimal places)
  if (round(f1 * pow(10,ex1)) > (round(f2 * pow(10,ex1)))){ //Compare ex1 decimals           
     return(1);}
     else if (round(f1*pow(10,ex1)) < (round(f2*pow(10,ex1)))){  //Compare ex1 decimals
       return(-1);}
       else return(0);
}

void avgPTCalc(){                     //Calc all avgs
  avgPT[0][0] = 0;                    //Init Press accumulator
  avgPT[1][0] = 0;                    //Init Temp accumulator
  for(int k=1; k<=avgPTsz; k++){      //Loop thru avg readings
    avgPT[0][0] += avgPT[0][k];       //Add to accumulator for P
    avgPT[1][0] += avgPT[1][k];       //Add to accumulator for T
  }
  avgPT[0][0] = avgPT[0][0]/avgPTsz;  //Put average P at loc 0
  avgPT[1][0] = avgPT[1][0]/avgPTsz;  //Put average T at loc 0
}
/*
void EMACalcPT(){                     //Exp Moving Avg Calc
  //EMAcur = (ValueCur*(Smoothing/(1+days)))+EMAlast*(1-(Smoothing/(1+days)))
  //EMA=Value(t) × k + EMA(y) × (1 − k); where:t=today; y=yesterday; N=number of days in EMA; k=2÷(N+1)
  //Kconst
  //avgPT[0][0] = 0;                    //Init Press last
  //avgPT[1][0] = 0;                    //Init Temp last

  avgPT[0][0] = (avgPT[0][avgPTindx] * Kconst) + (avgPT[0][0] * (1 - Kconst)); //Kconst= 2/(N+1)
  S_pln(avgPT[0][avgPTindx] * Kconst + avgPT[0][0] * (1 - Kconst)); //Kconst= 2/(N+1)
  S_pln((avgPT[0][avgPTindx] * Kconst) + (avgPT[0][0] * (1 - Kconst))); //Kconst= 2/(N+1)
  
  
  for(int k=1; k<=avgPTsz; k++){      //Loop thru avg readings
    avgPT[0][0] = avgPT[0][k];       //Add to accumulator for P
    avgPT[1][0] = avgPT[1][k];       //Add to accumulator for T
  }
  avgPT[0][0] = avgPT[0][0]/avgPTsz;  //Put average P at loc 0
  avgPT[1][0] = avgPT[1][0]/avgPTsz;  //Put average T at loc 0
}
*/

//RTC FUNCTIONS =====================================
byte BCD2DEC(byte val){               //Ex: 51 = 01010001 BCD. 01010001/16-->0101=5 then x10-->50  
  return(((val/16)*10)+(val%16));}    //         01010001%16-->0001. 50+0001 = 51 DEC

void GetRTCTime(){                               //Routine read real time clock, format data
  byte second;byte minute;byte hour;byte DoW;byte Date;byte month;byte year;
  Wire.beginTransmission(DS1307);                //Open I2C to RTC DS1307
  Wire.write(0x00);                              //Write reg pointer to 0x00 Hex
  Wire.endTransmission();                        //End xmit to I2C.  Send requested data.
  Wire.requestFrom(DS1307, 7);                   //Get 7 bytes from RTC buffer
  second = BCD2DEC(Wire.read() & 0x7f);          //Seconds.  Remove hi order bit
  minute = BCD2DEC(Wire.read());                 //Minutes
  hour = BCD2DEC(Wire.read() & 0x3f);            //Hour.  Remove 2 hi order bits
  DoW = BCD2DEC(Wire.read());                    //Day of week
  Date = BCD2DEC(Wire.read());                   //Date
  month = BCD2DEC(Wire.read());                  //Month
  year = BCD2DEC(Wire.read());                   //Year
  timeString = 2000+year;                        //Build Date-Time data to write to SD
  if (month<10){timeString = timeString + '0';}  //Pad leading 0 if needed
  timeString = timeString + month;               //Month (1-12)  
  if(Date<10){timeString = timeString + '0';}    //Pad leading 0 if needed
  timeString = timeString + Date;                //Date (1-30)
  timeString = timeString + DoWList[DoW];        //1Sun-7Sat (0=null)
  if (hour<10){timeString = timeString + '0';}   //Pad leading 0 if needed
  timeString = timeString + hour + ':';          //HH (0-24)
  if (minute<10){timeString = timeString + '0';} //Pad leading 0 if needed
  timeString = timeString + minute + ':';        //MM (0-60)
  if (second<10){timeString = timeString + '0';} //Pad leading 0 if needed
  timeString = timeString + second;              //SS (0-60)
}

//SD CARD FUNCTIONS =================================
void openSD() {                          //Routine to open SD card
  S_pln(); S_pln("Open SD card");        //User message
  if (!SD.begin(15)) {                   //If not open, print message.
    S_pln("Open SD card failed");
    return;}
  S_pln("SD Card open");
}

//char openFile2(byte RW, String FN) {     //Open SD FName2 file. char RW. Only 1 at a time.
//  SDconFile.close();                     //Ensure file status, before re-opening
//  SDconFile = SD.open(FN, RW);}          //Open Read at end.  Open at EOF for write/append

char openFile3(byte RW, String FN) {     //Open SD FName3 file. char RW. Only 1 at a time.
  saveWeather.close();                   //Ensure file status, before re-opening
  saveWeather = SD.open(FN, RW);}        //Open Read at end.  Open at EOF for write/append

char openFile4(byte RW, String FN) {     //Open SD FName3 file. char RW. Only 1 at a time.
  dataTemp.close();                      //Ensure file status, before re-opening
  dataTemp = SD.open(FN, RW);            //Open Read at end.  Open at EOF for write/append
//  digitalWrite(LED_BUILTIN, LOW);        //D1 Mini: turns LED *on*. Eject SD if off
  }

/*void print2File(String C){               //Write connect data to SD file
  openFile2(FILE_WRITE, FName2);         //Open SD connect file Write
  if (SDconFile) {                       //If file there & opened --> write
    SDconFile.println(C);                //Write to SD
    SDconFile.close();                   //Close file, flush buffer (reliable but slow)
  } else {                               //File didn't open
    Serial.println("Error opening Connect file for write");
  }
}
*/

void print2File(String C){               //Write connect data to SD file
  SDconFile.close();                     //Ensure file status, before re-opening
  SDconFile = SD.open(FName2, FILE_WRITE); //Open Read at end.  Open at EOF for write/append
  if (SDconFile) {                       //If file there & opened --> write
    SDconFile.println(C);                //Write to SD
    SDconFile.close();                   //Close file, flush buffer (reliable but slow)
  } else {                               //File didn't open
    Serial.println("Error opening Connect file for write");
  }
}



void print3File(String tmp1) {         //Print data to SD file
  openFile3(FILE_WRITE,FName3);          //Open user SD file for write
  if (saveWeather) {                     //If file there & opened --> write
    saveWeather.println(tmp1);           //Print string to file
    saveWeather.close();                 //Close file, flush buffer (reliable but slower)
  } else {S_pln("Error opening saveWeather file for write");}   //File didn't open
}

void print4File(String tmp1) {         //Print data to SD file
  openFile4(FILE_WRITE,FName4);          //Open user SD file for write
  if (dataTemp) {                        //If file there & opened --> write
    dataTemp.println(tmp1);              //Print string to file
    dataTemp.close();                    //Close file, flush buffer (reliable but slower)
//    digitalWrite(LED_BUILTIN, HIGH);     //D1 Mini: turns LED *on*.Eject SD if off
  } else {S_pln("Error opening dataTemp file for write");}   //File didn't open
}

void initTempFile(){                     //Initialize SD card connect file
  SDconFile.close();                     //Ensure file is closed         
  SD.remove(FName4);                     //Delete connection info file
  SDconFile.close();                     //Ensure file status, before re-opening
  SDconFile = SD.open(FName4, FILE_WRITE); //Open Read at end.  Open at EOF for write/append
//  openFile2(FILE_WRITE, FName4);         //Open SD connect file Write
  SDconFile.close();                     //Close SD connect file
//  server.send(200, "text/html", "Connect Data File Initialized");
}
//End SD Card FUNCTIONS ====================
//Web Routines =============================
void handleRoot(){ 
  openFile4(FILE_READ, FName4);                                  //Open SD file for read
  int SDfileSz = dataTemp.size();                                //Get file size
  Serial.print("SDfileSz: ");  Serial.println(SDfileSz);         //Data file size
  server.sendHeader("Content-Length", (String)(SDfileSz));       //Header info
  server.sendHeader("Cache-Control", "max-age=2628000, public"); //Cache 30 days
  String dataType = "text/plain";
  if(FName4.endsWith("/")) FName4 += "index.htm";
  if(FName4.endsWith(".src")) FName4 = FName4.substring(0, FName4.lastIndexOf("."));
  else if(FName4.endsWith(".html")) dataType = "text/html";
  else if(FName4.endsWith(".mhtml")) dataType = "text/mhtml";
  else if(FName4.endsWith(".css")) dataType = "text/css";
  else if(FName4.endsWith(".js")) dataType = "application/javascript";
  else if(FName4.endsWith(".png")) dataType = "image/png";
  else if(FName4.endsWith(".gif")) dataType = "image/gif";
  else if(FName4.endsWith(".jpg")) dataType = "image/jpeg";
  else if(FName4.endsWith(".ico")) dataType = "image/x-icon";
  else if(FName4.endsWith(".xml")) dataType = "text/xml";
  else if(FName4.endsWith(".pdf")) dataType = "application/pdf";
  else if(FName4.endsWith(".zip")) dataType = "application/zip";
  size_t fsizeSent = server.streamFile(dataTemp, dataType);      //
  Serial.print("fsizeSent: "); Serial.println(fsizeSent);        //Size sent data
  dataTemp.close();                                              //Close SD file
  delay(100);                                        //File settling time

GetRTCTime();                                        //Get time from RTC
  connectData = String(timeString+','+con++);        //SD connects data
  Serial.println(connectData);                       //Print connect data to serial
  print2File(connectData);                           //Write connect data to SD
  delay(100);                                        //File settling time
}

void handleNotFound() {                              //Server Errors
  String message = F("File Not Found\n\n");
  message += F("URI: ");
  message += server.uri();
  message += F("\nMethod: ");
  message += (server.method() == HTTP_GET) ? "GET" : "POST";
  message += F("\nArguments: ");
  message += server.args();
  message += F("\n");
  for (uint8_t i = 0; i < server.args(); i++) {
    message += String(F(" ")) + server.argName(i) + F(": ") + server.arg(i) + F("\n");}
  server.sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
  server.sendHeader("Pragma", "no-cache");
  server.sendHeader("Expires", "-1");
  server.send(404, "text/plain", message);
}
//End Web Routines =========================
//SETUP ===============
void setup(){                            //SETUP()
//  pinMode(LED_BUILTIN, OUTPUT);          //Set pin D4 (GPIO2) for LED. Safe SD eject
  Wire.begin();                          //Init I2C com
  Serial.begin(115200);                  //Init Serial com
  delay(1000);                           //Allow serial to come online
  S_pln("Connecting to network ");       //User msg
  WiFi.softAPConfig(apIP, apIP, netMsk); //Soft access point set IP, mask
  WiFi.softAP(softAP_ssid, softAP_password);  //Remove password parameter for open AP
  delay(500);                            //500 Delay to avoid blank IP address
  Serial.print("AP IP address: ");
  Serial.println(WiFi.softAPIP());
  dnsServer.setErrorReplyCode(DNSReplyCode::NoError);  //Setup DNS server redirecting all the domains to apIP
  dnsServer.start(DNS_PORT, "*", apIP);  //Setup DNS server redirecting all the domains to apIP
  server.on("/", handleRoot);            //First web input
  server.on("/generate_204", handleRoot);//Android captive portal. Maybe not needed. Might be handled by notFound handler.
  server.on("/fwlink", handleRoot);      //Microsoft captive portal. Maybe not needed. Might be handled by notFound handler.
  server.on("/initfile", initTempFile);  //Data request
  server.onNotFound(handleNotFound);     //Handle not found error
  server.begin();                        //Start server
  Serial.println("HTTP Server Started"); //User info
  
  openSD();                              //Call open SD card routine
  GetRTCTime();                          //Get time from real time clock
  SDData = String("RecType,DeviceAlt,DateTime,DevicehPa,SeaLevel-hPa,TempC"); //File Header
  print3File(SDData);                    //Write string to SD file
  SDData = "C,"+timeString+calib;        //Prepare calibration string
  print3File(SDData);                    //Write string to SD file
//  outBuff = String("RecType,DeviceAlt,DateTime,DevicehPa,SeaLevel-hPa,TempC"); //File Header
//  print3File(outBuff);                   //Write string to SD file
//  outBuff = "C,"+timeString+calib;       //Prepare calibration string
//  print3File(outBuff);                   //Write string to SD file

}
//LOOP ===============
void loop(){                             //LOOP()
  dnsServer.processNextRequest();        //DNS NECESSARY
  server.handleClient();                 //Handle client calls
  for (int i = 0; i < 24; i++)  {        //Get data 1 reg (2 bytes, 16 bits) at a time
    Wire.beginTransmission(BMP280Addr);  //Begin I2C to BMx280
    Wire.write((136 + i));               //Data register 136-159 (0x88-0x9F)
    Wire.endTransmission();              //End I2C Transmission
    Wire.requestFrom(BMP280Addr, 1);     //Get BMx280 1 byte data in LSBMSB order
    if (Wire.available() == 1){          //If device available
      b1[i] = Wire.read();}              //Read reg, store in b1[0-23]
  }
  
  //Temperature coefficients (byte1: LSB<>MSB, bitwise & 11111111; byte 2 same+shift)
  unsigned int dig_T1=(b1[0] & 0xFF)+((b1[1] & 0xFF)*256); //0x88/0x89 
  int dig_T2 = b1[2] + (b1[3] * 256);    //0x8A/0x8B
  int dig_T3 = b1[4] + (b1[5] * 256);    //0x8C/0x8D

  //Pressure coefficients (byte1: LSB<>MSB, bitwise & 11111111; byte 2 same+shift)
  unsigned int dig_P1=(b1[6] & 0xFF)+((b1[7] & 0xFF)*256);//0x8E/0x8F
  int dig_P2 = b1[8] + (b1[9] * 256);    //0x90/0x91
  int dig_P3 = b1[10] + (b1[11] * 256);  //0x92/0x93
  int dig_P4 = b1[12] + (b1[13] * 256);  //0x94/0x95
  int dig_P5 = b1[14] + (b1[15] * 256);  //0x96/0x97
  int dig_P6 = b1[16] + (b1[17] * 256);  //0x98/0x99
  int dig_P7 = b1[18] + (b1[19] * 256);  //0x9A/0x9B
  int dig_P8 = b1[20] + (b1[21] * 256);  //0x9C/0x9D
  int dig_P9 = b1[22] + (b1[23] * 256);  //0x9E/0x9F

  Wire.beginTransmission(BMP280Addr);    //Start I2C Transmission BMx280
  Wire.write(0xF4);                      //Select control measurement register
  Wire.write(0x27);                      //Set normal mode, temp & press over-sampling rate = 1
  Wire.endTransmission();                //End I2C Transmission
  Wire.beginTransmission(BMP280Addr);    //Start I2C Transmission BMx280
  Wire.write(0xF5);                      //Select Config register
  Wire.write(0xA0);                      //Set stand_by time = 1000ms
  Wire.endTransmission();                //End I2C Transmission to get data
  for (int i = 0; i < 8; i++){           //Collect temp & press data
    Wire.beginTransmission(BMP280Addr);  //Start I2C Transmission BMx280
    Wire.write((247 + i));               //Select data register
    Wire.endTransmission();              //End I2C Transmission
    Wire.requestFrom(BMP280Addr, 1);     //Request 1 byte of data from BMx280
    if (Wire.available() == 1){          //If data
      data[i] = Wire.read();}            //Read & store 1 byte of data
  }

  //Convert pressure & temperature data to 19-bits
  long adc_p = (((long)(data[0] & 0xFF) * 65536) + ((long)(data[1] & 0xFF) * 256) + (long)(data[2] & 0xF0)) / 16;
  long adc_t = (((long)(data[3] & 0xFF) * 65536) + ((long)(data[4] & 0xFF) * 256) + (long)(data[5] & 0xF0)) / 16;

  //Temperature offset calculations (per Bosch)
  double var1 = (((double)adc_t) / 16384.0 - ((double)dig_T1) / 1024.0) * ((double)dig_T2);
  double var2 = ((((double)adc_t) / 131072.0 - ((double)dig_T1) / 8192.0) *
                 (((double)adc_t) / 131072.0 - ((double)dig_T1) / 8192.0)) * ((double)dig_T3);
  double t_fine = (long)(var1 + var2);              //
  double cTemp = ((var1 + var2) / 5120.0) + TempCal;//Calc C, add calibration factor
  double fTemp = cTemp * 1.8 + 32;                  //Convert C to F

  //Pressure offset calculations (per Bosch)
  var1 = ((double)t_fine / 2.0) - 64000.0;          //
  var2 = var1 * var1 * ((double)dig_P6) / 32768.0;  //
  var2 = var2 + var1 * ((double)dig_P5) * 2.0;      //
  var2 = (var2 / 4.0) + (((double)dig_P4) * 65536.0); //
  var1 = (((double) dig_P3) * var1 * var1 / 524288.0 + ((double) dig_P2) * var1) / 524288.0;
  var1 = (1.0 + var1 / 32768.0) * ((double)dig_P1); //
  double p = 1048576.0 - (double)adc_p;
  p = (p - (var2 / 4096.0)) * 6250.0 / var1;        //
  var1 = ((double) dig_P9) * p * p / 2147483648.0;  //
  var2 = p * ((double) dig_P8) / 32768.0;           //
  double pressure = (p + (var1 + var2 + ((double)dig_P7)) / 16.0) / 100; //hPa

  //OUTPUT TO SERIAL MONITOR + WiFi CONNECTIONS
  if(millis() >= time_last + time2update){          //Delay data update per user
    time_last += time2update;                       //Keep last time of update
    initTempFile();                                 //Reset the temp file, fill with current data
    p0 = ((pressure/100) * pow(1 - (0.0065 * Dh / (cTemp + 0.0065 * Dh + 273.15)), -5.257));
    avgPTCalc();                                    //Calculate averages
    outBuff = "========= " + String(timeString); 
    S_pln(outBuff);print4File(outBuff);
    outBuff = "Device Altitude(abs): "+ String(Dh)+" meters AMSL";
    S_pln(outBuff);print4File(outBuff);
//    outBuff = "Temperature: "+String(cTemp)+("°C; ")+String(fTemp)+"°F  ";
    outBuff = "Temperature: "+String(cTemp)+("C; ")+String(fTemp)+"F  ";
    if (Compare(cTemp,avgPT[1][0],1) == 1){         //Compare(F1,F2,# decimal places compared)
        S_pln(outBuff+"Rising");print4File(outBuff+"Rising");} //If temp is rising from prior
      else if(Compare(cTemp,avgPT[1][0],1) == -1){      
        S_pln(outBuff+"Falling");print4File(outBuff+"Falling");}      //If temp is falling from prior 
        else {S_pln(outBuff+"Steady");print4File(outBuff+"Steady");}  //Else steady
  
    outBuff = "Barometric Pressure(abs): ";
    if (Compare(pressure,avgPT[0][0],1) == 1){      //Compare(F1, F2, # decimal places compared)
      if(avgFlag){outBuff+="Rising-Fair Weather";}} //If press is rising from prior
      else if(Compare(pressure,avgPT[0][0],1) == -1){
        if(avgFlag){outBuff+="Falling-Stormy";}}    //If press is falling from prior
        else {if(avgFlag){outBuff+="Steady-No Change";}}   //Else steady
    S_pln(outBuff);print4File(outBuff);             //Output buffer string
      
    if(avgPTindx >= avgPTsz){                       //Circular index to averages
      avgPTindx = 1;                                //If too big-->reset to 1
      avgFlag = true;}                              //Display average press
      else {avgPTindx++;}                           //Increment index
    avgPT[0][avgPTindx] = pressure;                 //Save press to avg
    avgPT[1][avgPTindx] = cTemp;                    //Save temp to avg
  
    outBuff = "  "+String(pressure, 3)+" hPa(mbar); "+String(pressure * 100, 3)+" Pa"; //Print Pressure in Pa mbar
    S_pln(outBuff);print4File(outBuff);
    outBuff = "  "+String(avgPT[0][0], 3)+" hPa, Short Term Past Average "; //Avg Pressure
    if(avgFlag){S_pln(outBuff);print4File(outBuff);}                        //Avg Press if available
    outBuff = "  "+String(pressure * 0.750061683, 3)+" mmHg"; //Print Pressure in mmHg
    S_pln(outBuff);print4File(outBuff);
    outBuff = "  "+String(pressure * 0.000986923, 6)+" Atm ";//Print Pressure in atm
    S_pln(outBuff);print4File(outBuff);
    outBuff = "Barometric Pressure-Comp'ed To Sealevel";
    S_pln(outBuff);print4File(outBuff);
    outBuff = "  "+String(p0 * 100, 3)+" hPa(mbar); "+String(p0 * 10000, 3)+" Pa";//Comp'ed Pressure in Pa, mbar, hPa
    S_pln(outBuff);print4File(outBuff);
    outBuff = "  "+String(p0 * 075.0061683, 3)+" mmHg";       //Comp'ed Pressure in mmHg
    S_pln(outBuff);print4File(outBuff);
    outBuff = "  "+String(p0 * 000.0986923, 6)+" Atm ";      //Comp'ed Pressure in Atm
    S_pln(outBuff);print4File(outBuff);
   
    GetRTCTime();                                             //Get time from RTC
//    SDData = "D,"+String(Dh)+','+timeString+','+
//      String(pressure)+','+String(p0*100)+','+String(cTemp);  //Ongoing SD weather data
//    print3File(SDData);                                       //Write weather data to SD

    outBuff = "D,"+String(Dh)+','+timeString+','+
      String(pressure)+','+String(p0*100)+','+String(cTemp);  //Ongoing SD weather data
    print3File(outBuff);                                       //Write weather data to SD

  }                                                           //End: if(millis() >= time_last + time2update)
}                                                             //End: Loop()

@d-a-v
Copy link
Collaborator

d-a-v commented Feb 2, 2022

Thanks for the report.
Please use the exception decoder for your stack trace above.

@TSBrownie
Copy link
Author

I used github's code sample. Ran it. It blew up.
Copied the dump (below), but
IDE 1.8.16 does not have the ESP exception decoder.

ctx: cont
sp: 3ffffdf0 end: 3fffffc0 offset: 01a0
3fffff90:  3fffdad0 00000000 3ffee4f8 40201050  
3fffffa0:  feefeffe feefeffe 3ffee54c 40201894  
3fffffb0:  feefeffe feefeffe 3ffe85d8 40100b51  

I have been testing all my Wemos code from simple to 500 line programs
and none of it works; most of it produces chksums or such, some of it
produces Serial COM output, but anything that's not just text (ex: numbers)
is either junk, or wrong (probably from memory issues).

I used to write code for GE/Honeywell mainframes in the late 1970s, and
that's the last time I dug through a dump. Now I'm coding for fun,
but when all your code goes bad because of a board library change, that
sucks. Any suggestions on low power boards with solid support? (And RTCs, SD
cards, etc?)
Thanks.

@d-a-v
Copy link
Collaborator

d-a-v commented Feb 2, 2022

but IDE 1.8.16 does not have the ESP exception decoder.

You must install it as instructed in the documentation. No one except you can decode the stack trace.

I have been testing all my Wemos code from simple to 500 line programs
and none of it works

Did you try the erase "All flash" arduino IDE option ?

@Bighoneypot
Copy link
Contributor

@TSBrownie
Copy link
Author

but IDE 1.8.16 does not have the ESP exception decoder.

You must install it as instructed in the documentation. No one except you can decode the stack trace.

I have been testing all my Wemos code from simple to 500 line programs
and none of it works

Did you try the erase "All flash" arduino IDE option ?
Yes, I tried all 3 options. No difference.

EXCEPTION DECODER:
Decoding stack results
0x40201050: setup() at D:\Prgms\Arduino\ArduinoWemosD1\2022GithubExceptDecode01a/2022GithubExceptDecode01a.ino line 22
0x40201894: loop_wrapper() at C:\Users\Family\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_main.cpp line 198


--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Soft WDT reset

stack>>>

ctx: cont
sp: 3ffffdf0 end: 3fffffc0 offset: 01a0
3fffff90: 3fffdad0 00000000 3ffee4f8 40201050
3fffffa0: feefeffe feefeffe 3ffee54c 40201894
3fffffb0: feefeffe feefeffe 3ffe85d8 40100b51
<<<stack<<<

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

@TSBrownie
Copy link
Author

@TSBrownie

Try this tool

https://www.filemail.com/d/nzlpfgbjpananhv
Your user name is "Bighoneypot" and you are offering a link to an unknown source?
Hmmmmmmm.

@Bighoneypot
Copy link
Contributor

@TSBrownie
Copy link
Author

This is a video of Setting the Real Time Clock (code from above) showing it worked when it was compiled using Board 2.5.2.
https://www.youtube.com/watch?v=dAs0Xzp2GdQ

@TSBrownie TSBrownie changed the title All Wemos D1 mini code stopped working after Boards upgrade from 2.5.2 to 3.0.2 All Wemos D1 mini code stopped working after esp8266 Boards upgrade from 2.5.2 to 3.0.2 Feb 7, 2022
@mcspr
Copy link
Collaborator

mcspr commented Feb 7, 2022

Note that the code from #8475 (comment) cannot be built using 3.0.2 with warnings enabled

/home/builder/dev/arduino8475/src/main.ino: In function 'void avgPTCalc()':
/home/builder/dev/arduino8475/src/main.ino:92:17: warning: comparison of integer expressions of different signedness: 'int' and 'const unsigned int' [-Wsign-compare]
   92 |   for(int k=1; k<=avgPTsz; k++){      //Loop thru avg readings
      |                ~^~~~~~~~~
/home/builder/dev/arduino8475/src/main.ino: In function 'char openFile3(byte, String)':
/home/builder/dev/arduino8475/src/main.ino:167:33: error: no return statement in function returning non-void [-Werror=return-type]
  167 |   saveWeather = SD.open(FN, RW);}        //Open Read at end.  Open at EOF for write/append
      |                                 ^
/home/builder/dev/arduino8475/src/main.ino: In function 'char openFile4(byte, String)':
/home/builder/dev/arduino8475/src/main.ino:173:3: error: no return statement in function returning non-void [-Werror=return-type]
  173 |   }
      |

I suppose that is b/c you are using 'no-warnings' option?
Can you retry by either using void as return type for openFile3 and openFile4 or add return with some meaningful value?

@TSBrownie
Copy link
Author

Note that the code from #8475 (comment) cannot be built using 3.0.2 with warnings enabled

/home/builder/dev/arduino8475/src/main.ino: In function 'void avgPTCalc()':
/home/builder/dev/arduino8475/src/main.ino:92:17: warning: comparison of integer expressions of different signedness: 'int' and 'const unsigned int' [-Wsign-compare]
   92 |   for(int k=1; k<=avgPTsz; k++){      //Loop thru avg readings
      |                ~^~~~~~~~~
/home/builder/dev/arduino8475/src/main.ino: In function 'char openFile3(byte, String)':
/home/builder/dev/arduino8475/src/main.ino:167:33: error: no return statement in function returning non-void [-Werror=return-type]
  167 |   saveWeather = SD.open(FN, RW);}        //Open Read at end.  Open at EOF for write/append
      |                                 ^
/home/builder/dev/arduino8475/src/main.ino: In function 'char openFile4(byte, String)':
/home/builder/dev/arduino8475/src/main.ino:173:3: error: no return statement in function returning non-void [-Werror=return-type]
  173 |   }
      |

I suppose that is b/c you are using 'no-warnings' option? Can you retry by either using void as return type for openFile3 and openFile4 or add return with some meaningful value?

Do you mean Tools -->Debug Level: None??? or Exceptions: Disabled???

@mcspr
Copy link
Collaborator

mcspr commented Feb 7, 2022

Do you mean Tools -->Debug Level: None??? or Exceptions: Disabled???

Debug Level one

@TSBrownie
Copy link
Author

TSBrownie commented Feb 8, 2022

Uninstalled IDE 1.8.16, installed 1.8.19, and esp8266 by ESP8266 Community. Tried versions below on the weather program above (closed IDE between each upgrade + "Erase all flash content" + hardware reset of Wemos).
2.5.2 --> Compiles. Runs correctly.
2.6.2 --> Compiles. Runs correctly.
2.7.2 --> Compiles. Runs correctly.
2.74 --> Compiles. Runs correctly.
3.0.0 --> Compiles, but gives similar runtime error as above
3.0.1 --> Compiles, but gives similar runtime error as above
3.0.2 --> Compiles, but gives the runtime errors shown above

Then I tried a simple program that reads the Wemos D1 mini SD card/RTC shield's clock (per above).
2.5.2 --> Compiles. Runs correctly.
2.6.2 --> Compiles. Runs correctly.
2.7.2 --> Compiles. Runs correctly.
2.7.4 --> Compiles. Runs correctly, but prints out the following line mid-output.
"SDK:2.2.2-dev(38a443e)/Core:2.7.3-3-g2843a5ac=20703003/lwIP:STABLE-2_1_2_RELEASE/glue:1.2-30-g92add50/BearSSL:5c771be"

3.0.0 --> Compiles, Runs correctly.
3.0.1 --> Compiles, Runs correctly.
3.0.2 --> Compiles, Runs correctly but prints out the following line mid-output
"SDK:2.2.2-dev(38a443e)/Core:3.0.2=30002000/lwIP:STABLE-2_1_2_RELEASE/glue:1.2-48-g7421258/BearSSL:6105635"

@TSBrownie
Copy link
Author

Note that the code from #8475 (comment) cannot be built using 3.0.2 with warnings enabled

/home/builder/dev/arduino8475/src/main.ino: In function 'void avgPTCalc()':
/home/builder/dev/arduino8475/src/main.ino:92:17: warning: comparison of integer expressions of different signedness: 'int' and 'const unsigned int' [-Wsign-compare]
   92 |   for(int k=1; k<=avgPTsz; k++){      //Loop thru avg readings
      |                ~^~~~~~~~~
/home/builder/dev/arduino8475/src/main.ino: In function 'char openFile3(byte, String)':
/home/builder/dev/arduino8475/src/main.ino:167:33: error: no return statement in function returning non-void [-Werror=return-type]
  167 |   saveWeather = SD.open(FN, RW);}        //Open Read at end.  Open at EOF for write/append
      |                                 ^
/home/builder/dev/arduino8475/src/main.ino: In function 'char openFile4(byte, String)':
/home/builder/dev/arduino8475/src/main.ino:173:3: error: no return statement in function returning non-void [-Werror=return-type]
  173 |   }
      |

I suppose that is b/c you are using 'no-warnings' option? Can you retry by either using void as return type for openFile3 and openFile4 or add return with some meaningful value?

Do you mean Tools -->Debug Level: None??? or Exceptions: Disabled???

I did one better and integrated those into the only routine that called them. (The program is 4 programs I cobbled together, so I'm now removing redundancy and such.) The results are the same.

`//SD CARD FUNCTIONS =================================
void openSD() { //Routine to open SD card
S_pln(); S_pln("Open SD card"); //User message
if (!SD.begin(15)) { //If not open, print message.
S_pln("Open SD card failed");
return;}
S_pln("SD Card open");
}

void print2File(String B){ //Write connect data to SD file
SDconFile.close(); //Ensure file status, before re-opening
SDconFile = SD.open(FName2, FILE_WRITE); //Open Read at end. Open at EOF for write/append
if (SDconFile) { //If file there & opened --> write
SDconFile.println(B); //Write to SD
SDconFile.close();} //Close file, flush buffer (reliable but slow)
else {S_pln("Error opening Connect file for write");} //File didn't open
}

void print3File(String B) { //Print data to SD file
saveWeather.close(); //Ensure file status, before re-opening
saveWeather = SD.open(FName3, FILE_WRITE); //Open Read at end. Open at EOF for write/append
if (saveWeather) { //If file there & opened --> write
saveWeather.println(B); //Print string to file
saveWeather.close(); //Close file, flush buffer (reliable but slower)
} else {S_pln("Error opening saveWeather file for write");} //File didn't open
}

char openFile4(byte RW, String FN) { //Open SD FName3 file. char RW. Only 1 at a time.
dataTemp.close(); //Ensure file status, before re-opening
dataTemp = SD.open(FN, RW); //Open Read at end. Open at EOF for write/append
// digitalWrite(LED_BUILTIN, LOW); //D1 Mini: turns LED on. Eject SD if off
}

void print4File(String B) { //Print data to SD file
openFile4(FILE_WRITE,FName4); //Open user SD file for write
if (dataTemp) { //If file there & opened --> write
dataTemp.println(B); //Print string to file
dataTemp.close(); //Close file, flush buffer (reliable but slower)
// digitalWrite(LED_BUILTIN, HIGH); //D1 Mini: turns LED on.Eject SD if off
} else {S_pln("Error opening dataTemp file for write");} //File didn't open
}

void initTempFile(){ //Initialize SD card connect file
SDconFile.close(); //Ensure file is closed
SD.remove(FName4); //Delete connection info file
SDconFile.close(); //Ensure file status, before re-opening
SDconFile = SD.open(FName4, FILE_WRITE); //Open Read at end. Open at EOF for write/append
SDconFile.close(); //Close SD connect file
// server.send(200, "text/html", "Connect Data File Initialized");
}`

@mcspr
Copy link
Collaborator

mcspr commented Feb 8, 2022

My mistake, I was referring to the Arduino IDE preferences 'Compiler warnings'
(see File > Preferences, at least that's what it is called on the 2.0.0rc version I have locally. PIO has slightly different naming, but it's not a hidden setting but something we set explicitly)

The code cannot omit return statement if the function was declared as something other than void, openfile4 function above still does not have it. We can't exactly force this setting though, due to the fact -w overrides the -Werror=...

int something() { 
}

void setup() {
  something();
}

void loop() {
}
C:\Users\test\AppData\Local\Temp\.arduinoIDE-unsaved202218-9456-1ebm4ou.xdoe\sketch_feb8a\sketch_feb8a.ino: In function 'int something()':
C:\Users\test\AppData\Local\Temp\.arduinoIDE-unsaved202218-9456-1ebm4ou.xdoe\sketch_feb8a\sketch_feb8a.ino:8:1: error: no return statement in function returning non-void [-Werror=return-type]
    2 | }
      | ^

earlephilhower added a commit to earlephilhower/Arduino that referenced this issue Feb 21, 2022
Fixes esp8266#8475

We disable all errors for `None` mode, so manually re-enable the return-type
check as an error (because the code behavior is undefined and will crash
the core).
earlephilhower added a commit to earlephilhower/Arduino that referenced this issue Feb 21, 2022
Fixes esp8266#8475

We disable all errors for `None` mode, so manually re-enable the return-type
check as an error (because the code behavior is undefined and will crash
the core).
mcspr added a commit that referenced this issue Feb 22, 2022
per #8421 and #8475
after checking HW, suggest to check SW as well by at least by enabling some or all compiler warnings
(and also note of the IDE weirdest defaults causing issues we expected to stay solved)
@mcspr
Copy link
Collaborator

mcspr commented Feb 22, 2022

Assuming this was eventually solved
#8492 adds documentation entry in the crash FAQ about compiler warnings and their possible impact on the resulting program

@mcspr mcspr closed this as completed Feb 22, 2022
@TSBrownie
Copy link
Author

No, it was not resolved. I went back to pre-3.xx board manager. 3.xx still does not work.

@TSBrownie
Copy link
Author

TSBrownie commented Feb 22, 2022 via email

hasenradball pushed a commit to hasenradball/Arduino that referenced this issue Nov 18, 2024
per esp8266#8421 and esp8266#8475
after checking HW, suggest to check SW as well by at least by enabling some or all compiler warnings
(and also note of the IDE weirdest defaults causing issues we expected to stay solved)
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

No branches or pull requests

4 participants