Closed Devi416 closed 3 years ago
Hi @Devi416 ,
This looks like a hardware issue of some kind not a problem with esptool.
Is anything connected to your dev board? Try removing all connections. Especially anything connected to GPIOs 6-11, as these are shared with the internal flash chip and usually can't be used for other purposes.
If removing everything doesn't change the output then suggest looking at the troubleshooting steps for power here or try swapping USB cables, USB ports, etc.
I am also getting the same issue with my NodeMCU while uploading the code. But in my case, the simple example codes like Blink, etc. are uploading easily but as the code becomes bigger and complex, I receive the same error. The below is the list of things that I tried but didn't work:
My code looks like as below:
#include <MAX30100_PulseOximeter.h>
#include<FirebaseESP8266.h>
#include<ESP8266WiFi.h>
#include<Wire.h>
/////////////////////Define Pins Here///////////////
const int MPU6050pin=D0;
const int MAX30100pin=D3;
////////////////////////////////////////////////////
#define FIREBASE_HOST "//my host" // database URL
#define FIREBASE_AUTH "//my auth" // secret key
#define WIFI_SSID "//my ssd" //Wifi Name
#define WIFI_PASSWORD "//my wifi password" //Wifi Password
#define REPORTING_PERIOD_MS 1000
/////////////////////////////////////////////////////
/////////////////////Define Sensors Here//////////////
const int MPU_addr=0x68; // I2C address of the MPU-6050
//////////////////////////////////////////////////////
////////////////////Define Variables Here/////////////
float AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;
FirebaseData firebaseData;
int MPU6050state,MAX30100state;
boolean MPU6050flag,MAX30100flag;
PulseOximeter pox;
uint32_t tsLastReport = 0;
int MAX30100firstTime=0;
///////////////////////////////////////////////////////
void setup() {
Serial.begin(115200);
WiFi.begin(WIFI_SSID,WIFI_PASSWORD); //Connecting to Wifi Network
Firebase.begin(FIREBASE_HOST,FIREBASE_AUTH);
//////////////////Set Up Pins Here///////////////
pinMode(MPU6050pin,OUTPUT);
pinMode(MAX30100pin,OUTPUT);
/////////////////////////////////////////////////
/////////////////Initialize all Sensors to OFF///////
digitalWrite(MPU6050pin,LOW);
digitalWrite(MAX30100pin,LOW);
////////////////////////////////////////////////////
}
void onBeatDetected()
{
Serial.println("Beat!");
}
void UploadMPUToFirebase(){
Firebase.setFloat(firebaseData,"/Readings/MPU6050/RoomTemperature",(Tmp/340.00)+36.53);
Firebase.setFloat(firebaseData,"/Readings/MPU6050/Acceleration/0",AcX/16384);
Firebase.setFloat(firebaseData,"/Readings/MPU6050/Acceleration/1",AcY/16384);
Firebase.setFloat(firebaseData,"/Readings/MPU6050/Acceleration/2",AcZ/16384);
Firebase.setFloat(firebaseData,"/Readings/MPU6050/Gyro/0",GyX/131);
Firebase.setFloat(firebaseData,"/Readings/MPU6050/Gyro/1",GyY/131);
Firebase.setFloat(firebaseData,"/Readings/MPU6050/Gyro/2",GyZ/131);
}
void UploadMAXtoFirebase(){
}
void MPU6050Data(){
Wire.begin();
Wire.beginTransmission(MPU_addr);
Wire.write(0x6B); // PWR_MGMT_1 register
Wire.write(0); // set to zero (wakes up the MPU-6050)
Wire.endTransmission(true);
Wire.beginTransmission(MPU_addr);
Wire.write(0x3B); // starting with register 0x3B (ACCEL_XOUT_H)
Wire.endTransmission(false);
Wire.requestFrom(MPU_addr,14,true); // request a total of 14 registers
AcX=Wire.read()<<8|Wire.read(); // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)
AcY=Wire.read()<<8|Wire.read(); // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
AcZ=Wire.read()<<8|Wire.read(); // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)
Tmp=Wire.read()<<8|Wire.read(); // 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L)
GyX=Wire.read()<<8|Wire.read(); // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)
GyY=Wire.read()<<8|Wire.read(); // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L)
GyZ=Wire.read()<<8|Wire.read(); // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L)
}
void MAX30100DataSetup(){
Serial.print("Initializing pulse oximeter..");
if (!pox.begin()) {
Serial.println("FAILED");
for(;;);
} else {
Serial.println("SUCCESS");
}
pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA);
// Register a callback for the beat detection
pox.setOnBeatDetectedCallback(onBeatDetected);
MAX30100firstTime=1;
MAX30100DataLoop();
}
void MAX30100DataLoop(){
pox.update();
if (millis() - tsLastReport > REPORTING_PERIOD_MS) {
Serial.print("Heart rate:");
Serial.print(pox.getHeartRate());
Serial.print("bpm / SpO2:");
Serial.print(pox.getSpO2());
Serial.println("%");
tsLastReport = millis();
}
}
void TurnSensorsOnOff(){
if(MPU6050flag){
digitalWrite(MPU6050pin,HIGH);
MPU6050Data();
UploadMPUToFirebase();
}else{
digitalWrite(MPU6050pin,LOW);
}
if(MAX30100flag){
digitalWrite(MAX30100pin,HIGH);
if(MAX30100firstTime==0){
MAX30100DataSetup();
}else{
MAX30100DataLoop();
}
UploadMAXtoFirebase();
}else{
digitalWrite(MAX30100pin,LOW);
MAX30100firstTime=0;
}
}
void loop() {
if(Firebase.get(firebaseData, "/SensorState/switchGesture/switchGestureState"))
{
if(firebaseData.dataType() == "int"){
MPU6050state=firebaseData.intData();
Serial.println("MPU6050 = ");
Serial.print(MPU6050state);
}else{
Serial.println("MPU state is Not Retrieved");
MPU6050state=0;
}
if(MPU6050state==0){
MPU6050flag=false;
}else{
MPU6050flag=true;
}
}
if(Firebase.get(firebaseData, "/SensorState/switchOxygenHeartBeat/switchOxygenHeartBeatState"))
{
if(firebaseData.dataType() == "int"){
MAX30100state=firebaseData.intData();
Serial.println("MAX30100 = ");
Serial.print(MAX30100state);
}else{
Serial.println("MAX state is Not Retrieved");
MAX30100state=0;
}
if(MAX30100state==0){
MAX30100flag=false;
}else{
MAX30100flag=true;
}
}
/////////////////////////////////Add otherSensorStateCheakingHere
TurnSensorsOnOff();
}
And when I try to upload this code, I get the following error:
Executable segment sizes:
IROM : 451380 - code in flash (default or ICACHE_FLASH_ATTR)
IRAM : 28276 / 32768 - code in IRAM (ICACHE_RAM_ATTR, ISRs...)
DATA : 1344 ) - initialized variables (global, static) in RAM/HEAP
RODATA : 1936 ) / 81920 - constants (global, static) in RAM/HEAP
BSS : 27184 ) - zeroed variables (global, static) in RAM/HEAP
Sketch uses 482936 bytes (46%) of program storage space. Maximum is 1044464 bytes.
Global variables use 30464 bytes (37%) of dynamic memory, leaving 51456 bytes for local variables. Maximum is 81920 bytes.
esptool.py v2.8
Serial port COM8
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 2c:f4:32:20:7d:8e
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 487088 bytes to 354774...
Writing at 0x00000000... (4 %)
Writing at 0x00004000... (9 %)
Writing at 0x00008000... (13 %)
Writing at 0x0000c000... (18 %)
Writing at 0x00010000... (22 %)
Writing at 0x00014000... (27 %)
Writing at 0x00018000... (31 %)Traceback (most recent call last):
File "C:\Users\Prashang\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1/tools/upload.py", line 65, in <module>
esptool.main(cmdline)
File "C:/Users/Prashang/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.7.1/tools/esptool\esptool.py", line 2938, in main
operation_func(esp, args)
File "C:/Users/Prashang/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.7.1/tools/esptool\esptool.py", line 2374, in write_flash
esp.flash_defl_block(block, seq, timeout=DEFAULT_TIMEOUT * ratio * 2)
File "C:/Users/Prashang/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.7.1/tools/esptool\esptool.py", line 104, in inner
return func(*args, **kwargs)
File "C:/Users/Prashang/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.7.1/tools/esptool\esptool.py", line 672, in flash_defl_block
self.ESP_FLASH_DEFL_DATA, struct.pack('<IIII', len(data), seq, 0, 0) + data, self.checksum(data), timeout=timeout)
File "C:/Users/Prashang/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.7.1/tools/esptool\esptool.py", line 369, in check_command
val, data = self.command(op, data, chk, timeout=timeout)
File "C:/Users/Prashang/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.7.1/tools/esptool\esptool.py", line 347, in command
p = self.read()
File "C:/Users/Prashang/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.7.1/tools/esptool\esptool.py", line 292, in read
return next(self._slip_reader)
File "C:/Users/Prashang/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.7.1/tools/esptool\esptool.py", line 2045, in slip_reader
raise FatalError("Timed out waiting for packet %s" % waiting_for)
esptool.FatalError: Timed out waiting for packet header
esptool.FatalError: Timed out waiting for packet header
Please help me solve this issue. Thank you.
Hi @deepesh101 ,
I have a couple of questions to try and pin this down:
Thanks for your reply @projectgus NodeMCU does work for sometimes like I tried today (the same code as above) and it worked but soon the same errors started appearing. I tried changing the upload speed as well but that didn't work. And I am new to all this so I don't know how to get .bin file which you are requesting. So, please tell me how can I get that so that I can send it to you.
Hi @deepesh101 ,
Sorry I didn't see this question when you asked.
You can get the .bin file by choosing Sketch -> Export Compiled Binary in the Arduino IDE.
Angus
Hello @deepesh101,
have you been able to look into this?
Radim
I am closing this issue because it seems like it is not relevant anymore. Please reopen if you think further discussion is needed.
i would like to uploading a simple example code in my NODEMCU module but i got an error like :
TRACE +0.078 Read 1 bytes: c0 TRACE +0.000 Read 1 bytes: 01 TRACE +0.000 Read 8 bytes: 0702009401600000 TRACE +0.000 Read 1 bytes: 00 TRACE +0.000 Read 1 bytes: c0 Traceback (most recent call last): TRACE +0.000 Received full packet: 01070200940160000000 File "C:\Users\admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2/tools/upload.py", line 25, in
Running stub...
esptool.main(fakeargs)
TRACE +0.109 command op=0x06 data len=8 wait_response=1 timeout=0.050 data=0000000004e01040
File "C:/Users/admin/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/tools/esptool\esptool.py", line 2694, in main
TRACE +0.000 Write 18 bytes:
detect_flash_size(esp, args)
c000060800000000 000000000004e010 | ................
File "C:/Users/admin/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/tools/esptool\esptool.py", line 2073, in detect_flash_size
40c0 | @.
flash_id = esp.flash_id()
TRACE +0.000 Read 1 bytes: c0
File "C:/Users/admin/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/tools/esptool\esptool.py", line 567, in flash_id
TRACE +0.000 Read 1 bytes: 01
return self.run_spiflash_command(SPIFLASH_RDID, b"", 24)
TRACE +0.000 Read 10 bytes: 060200940160000000c0
File "C:/Users/admin/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/tools/esptool\esptool.py", line 812, in run_spiflash_command
TRACE +0.000 Received full packet: 01060200940160000000
old_spi_usr = self.read_reg(SPI_USR_REG)
TRACE +0.047 Read 6 bytes: c04f484149c0
File "C:/Users/admin/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/tools/esptool\esptool.py", line 475, in read_reg
TRACE +0.000 Received full packet: 4f484149
val, data = self.command(self.ESP_READ_REG, struct.pack('<I', addr))
Stub running...
File "C:/Users/admin/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/tools/esptool\esptool.py", line 332, in command
Configuring flash size...
p = self.read()
TRACE +0.000 command op=0x0a data len=4 wait_response=1 timeout=3.000 data=1c020060
File "C:/Users/admin/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/tools/esptool\esptool.py", line 277, in read
TRACE +0.000 Write 14 bytes: c0000a0400000000001c020060c0
return next(self._slip_reader)
TRACE +3.011 Timed out waiting for packet header
File "C:/Users/admin/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/tools/esptool\esptool.py", line 1877, in slip_reader
raise FatalError("Timed out waiting for packet %s" % waiting_for)
esptool.FatalError: Timed out waiting for packet header
esptool.FatalError: Timed out waiting for packet header