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

failed to load bootloader header! error with new esp32 lib/ide 1.8.2 #9

Open
mjs513 opened this issue Apr 28, 2017 · 36 comments
Open

Comments

@mjs513
Copy link
Contributor

mjs513 commented Apr 28, 2017

Getting error message using ide 1.8.2 and new version of esp32 library. Something about magic number. I reported under issue 334, espressif/arduino-esp32#334

ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0x00
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DOUT, clock div:1
load:0x3fff0008,len:8
load:0x3fff0010,len:2036
load:0x40078000,len:9988
load:0x40080000,len:252
entry 0x40080034
E (30) esp_image: image at 0x1000 has invalid magic byte
E (30) boot: failed to load bootloader header!
user code done
@mjs513 mjs513 closed this as completed Apr 28, 2017
@mjs513 mjs513 reopened this May 6, 2017
@mjs513
Copy link
Contributor Author

mjs513 commented May 6, 2017

Hi Kris,

Reopened since the new ESP32 core seems to be conflicting with the board. Its opened as Issue #342 on the ESP32 GitHub site. Not sure if you are seeing this same problem.

Mike

@mjs513
Copy link
Contributor Author

mjs513 commented Dec 19, 2017

Hi Kris,

Think this is now fixed, at least with the latest changes on GitHub. But I am running into another problem, not sure if it is associated with the bootloader. I press the boot button and press and then release the reset button. Everything seems to upload no errors. But when I press and release the rst button again to put in run mode the sketch doesn't seem to run. Tested it on my sketch, then the blink sketch with ledpin on 5 and a couple of others

Any idea?

@kriswiner
Copy link
Owner

kriswiner commented Dec 19, 2017 via email

@mjs513
Copy link
Contributor Author

mjs513 commented Dec 19, 2017

Did you choose 4 MByte flash, DOUT for flashing?

Thanks for reminding me about this. They added your board to dropdown list of boards in boards managed. So I went back in and checked to see the setup for the board. 4MB was correct, but it was set at DIO. I changed it DOUT and it reset into run mode and the blink sketch started working. Will give the other sketches a try to make sure they work and will let you know. I will post an issue on the esp32 GitHub so they get it fixed once I check it all out.

Thanks

_UPDATE (10:34pm EST):
Ok here we go.

  1. I ran the blink sketch and worked fine after I hit the rst button.
  2. I ran the i2cscanner.ino file that Paul S. put together. I hit rst before I opened the terminal window, but when I opened the terminal window nothing I had to hit rst to get anything out. Opening and closing after that had the sketching output fine.
  3. I used your MPU-9250 breakout board and the scanner identified 0x68 and 0x76 (accel/gyro and pressure sensor) but not the magnetometer.
  4. I loaded up your MPU9250_MS5637 sketch for the ESP32 and ran it. Had to hit rst after I opened the terminal window to get it to run. After I did that the whoami tests failed but it did identify the same i2c addresses (this worked in the past of course no problem). Here is a dump of the terminal window:
ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DOUT, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:812
load:0x40078000,len:0
load:0x40078000,len:11392
entry 0x40078a9c
Scanning...
I2C device found at address 0x68  !
I2C device found at address 0x76  !
done

MPU9250 9-axis motion sensor...
MPU9250 I AM FF I should be 71
Could not connect to MPU9250: 0xFF

Something is wrong but I am at a loss. I did measure the voltage on GPIO0 (SDA) and it was at 3.29v on my multimeter. Tried recycling power, hitting reset, redid the wiring. Everything is being powered off of the USB. The only thing I haven't tried is swapping the cable but it worked fine on the T3.5 tests. Any recommendations would be appreciated.

UPDATE:12/19/17
I attached a different 9250 breakout board from Diymall and same thing happened. I decided to test with a different i2c device - Adafruit BME280 - it worked fine, no issue. I have to set up a 5v supply for the 9250 just in case its a power issue.

No joy on the power - same thing is happening when I separately power the sensor.

Mike_

Note: I did test the MS5637 separately and it works fine. I2c scanner recognizes the 9250, but whoami fails. Also, if I bypass the whoami test the magnetometer is recognized as well as the pressure sensor. Accel and gyro shows zero.

@mjs513
Copy link
Contributor Author

mjs513 commented Dec 20, 2017

Hi Kris,

I am beginning to think that the issue is with I2C with the ESP32 Core. I extracted and ran the following code on a T3.5 and it worked fine. It identified the WhoIAm correctly. Same code on the ESP32 board failed WhoIAm test. I did a little digging and it is almost reminiscent of Issue #90 that you opened up on the Arduino-ESP32 core library. There was another issue with I2C but it was fixed - espressif/arduino-esp32#834

#include "Wire.h"   

#define MPU9250_ADDRESS 0x68  // Device address when ADO = 0
#define WHO_AM_I_MPU9250 0x75 // Should return 0x71


void setup() 
{
  Serial.begin(115200);
  delay(4000);

  Wire.begin(400000); //(SDA, SCL) (21,22) are default on ESP32, 400 kHz I2C clock
  delay(1000);

  // Set up the interrupt pin, its set as active high, push-pull
  pinMode(5, OUTPUT);
  digitalWrite(5, LOW);

  I2Cscan();// look for I2C devices on the bus
  delay(1000);

  // Read the WHO_AM_I register, this is a good test of communication
  Serial.println("MPU9250 9-axis motion sensor...");
  uint8_t c = readByte(MPU9250_ADDRESS, WHO_AM_I_MPU9250);  // Read WHO_AM_I register for MPU-9250
  Serial.print("MPU9250 "); Serial.print("I AM "); Serial.print(c, HEX); Serial.print(" I should be "); Serial.println(0x71, HEX);
  
}

void loop() {
  // put your main code here, to run repeatedly:

}

// simple function to scan for I2C devices on the bus
void I2Cscan() 
{
    // scan for i2c devices
  byte error, address;
  int nDevices;

  Serial.println("Scanning...");

  nDevices = 0;
  for(address = 1; address < 127; address++ ) 
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire.beginTransmission(address);
    error = Wire.endTransmission();

    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16) 
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");

      nDevices++;
    }
    else if (error==4) 
    {
      Serial.print("Unknown error at address 0x");
      if (address<16) 
        Serial.print("0");
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");
}

  uint8_t readByte(uint8_t address, uint8_t subAddress)
{
  uint8_t data = 0;                        // `data` will store the register data   
  Wire.beginTransmission(address);         // Initialize the Tx buffer
  Wire.write(subAddress);                  // Put slave register address in Tx buffer
  Wire.endTransmission(false);             // Send the Tx buffer, but send a restart to keep connection alive
  Wire.requestFrom(address, 1);  // Read two bytes from slave register address on MPU9250 
  data = Wire.read();                      // Fill Rx buffer with result
  return data;                             // Return data read from slave register
}

@kriswiner
Copy link
Owner

kriswiner commented Dec 20, 2017 via email

@mjs513
Copy link
Contributor Author

mjs513 commented Dec 20, 2017

I did that when I ran it on the ESP32. The code I posted was the T3.5 version. Sorry, should have been clearer.

@kriswiner
Copy link
Owner

kriswiner commented Dec 20, 2017 via email

@mjs513
Copy link
Contributor Author

mjs513 commented Dec 20, 2017

Yep. Just changed the board to the esp32 dev board so I could change the core debug level and here is the error for reading the whoiam register:

MPU9250 9-axis motion sensor...
[W][esp32-hal-i2c.c:235] i2cWrite(): Ack Error! Addr: 68
[W][esp32-hal-i2c.c:334] i2cRead(): Ack Error! Addr: 68
MPU9250 I AM FF I should be 71

@kriswiner
Copy link
Owner

kriswiner commented Dec 20, 2017 via email

@mjs513
Copy link
Contributor Author

mjs513 commented Dec 20, 2017

I am using a git pull from a few days ago but didn't see anything in the new commits that would affect I2C.

@kriswiner
Copy link
Owner

kriswiner commented Dec 20, 2017 via email

@mjs513
Copy link
Contributor Author

mjs513 commented Dec 20, 2017

Just as a FYI I just tested the BNO055 and that appears to work as well as the BME280. As for the pull - was looking for the link to latest release but for reason couldn't find it so I used the latest core pull.

@kriswiner
Copy link
Owner

kriswiner commented Dec 20, 2017 via email

@kriswiner
Copy link
Owner

kriswiner commented Dec 20, 2017 via email

@mjs513
Copy link
Contributor Author

mjs513 commented Dec 21, 2017

For your board no pullups (thought there were onboard 4.7k's), on the DIYMALL 9250 board there are 4.7k pullups on the sda/scl lines already. Both are behaving exactly the same.

@kriswiner
Copy link
Owner

kriswiner commented Dec 21, 2017 via email

@mjs513
Copy link
Contributor Author

mjs513 commented Dec 21, 2017

Tried both boards with a T3.5 and they worked - along with a couple different versions of a 9250 library. That's one of the first thing I tried. Going to add 4.7k's to your board and see what happens I have the mini version and it looks like I am suppose to solder the back side to activate the 4.7k's?

@kriswiner
Copy link
Owner

kriswiner commented Dec 21, 2017 via email

@mjs513
Copy link
Contributor Author

mjs513 commented Dec 21, 2017

You may want to check this issue out: espressif/arduino-esp32#834

Maybe makes more sense to you.

@kriswiner
Copy link
Owner

kriswiner commented Dec 21, 2017 via email

@mjs513
Copy link
Contributor Author

mjs513 commented Dec 21, 2017

Yeah, I know I saw you issue #90 for the ESP32. It looks like they changed the wire API about a month or so ago to try and resolve more issues, but looks like broke it at least for the 9250 or 6050 (will have to test it later). Think I read in the thread that they are saying that those boards are special cases :( - yeah I know. Think I should go ahead and generate an issue for them :)

Have to dig up my old version of the core - think I have it on a hard drive somewhere.

@kriswiner
Copy link
Owner

kriswiner commented Dec 21, 2017 via email

@mjs513
Copy link
Contributor Author

mjs513 commented Dec 21, 2017

Ok. Dug out my old copy from around Feb of this year works fine for the 9250.

@kriswiner
Copy link
Owner

kriswiner commented Dec 21, 2017 via email

@mjs513
Copy link
Contributor Author

mjs513 commented Dec 21, 2017

Planning on it. Was just waiting to here your opinion. :)

@mjs513
Copy link
Contributor Author

mjs513 commented Dec 21, 2017

Ok here is the issue I posted, if you want to add for it: espressif/arduino-esp32#937

@kriswiner
Copy link
Owner

kriswiner commented Dec 21, 2017 via email

@mjs513
Copy link
Contributor Author

mjs513 commented Dec 21, 2017

Hope me-no-dev works this. He seems to have a good handle on what's going on.

@kriswiner
Copy link
Owner

kriswiner commented Dec 21, 2017 via email

@mjs513
Copy link
Contributor Author

mjs513 commented Dec 22, 2017

Think I isolated to when the problem started - it was when they incorporated the commit for long I2C reads. I posted what I found so maybe that is a starting point for them.

@mjs513
Copy link
Contributor Author

mjs513 commented Dec 25, 2017

See issue 90 for problem and how to fix it. Have to read 2 bytes. Was your original issue back in Dec 2016.

Merry christmas.

@kriswiner
Copy link
Owner

kriswiner commented Dec 25, 2017 via email

@mjs513
Copy link
Contributor Author

mjs513 commented Dec 25, 2017

Kris. From what I can see it was fixed until they added support for long i2c addressimg. On a hunch I went ahead and tried the two byte read in issue 90 and it worked. There long addressing broke it. Now it's up to them to fix it I guess. Just wanted to let you know.

@kriswiner
Copy link
Owner

kriswiner commented Dec 25, 2017 via email

@mjs513
Copy link
Contributor Author

mjs513 commented Dec 25, 2017

Yes I did in the same issue that I opened up. I referenced issue 90 (even gave them the link) and mentioned that me-no-dev fixed it. They will get around to it eventually. Think they are working on a new i2c/wire wrapper - me-no-dev is involved with that one.

Can't wait for the ble support for the Arduino library. Like you said still immature in a lot of respects. Can't blame them - there's a lot there.

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

2 participants