Skip to content

OTA update error : esp_image: image at 0x150000 has invalid magic byte after flash enctiption #3976

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
sboicu opened this issue May 7, 2020 · 8 comments
Labels
Status: Stale Issue is stale stage (outdated/stuck)

Comments

@sboicu
Copy link

sboicu commented May 7, 2020

Hi.

I have enabled flash encryption on my esp32 board in release mode.
Everything is working fine. I have also a script to have OTA updates. I compile everything with Arduino IDE.

Unfortunately at the end of the upload of the new .BIN file I get those errors :
esp_image: image at 0x150000 has invalid magic byte

E (91901) esp_image: image at 0x150000 has invalid magic byte
E (91902) boot_comm: image has invalid chip ID, expected at least 0, found 717
E (91904) boot_comm: image has invalid chip revision, expected at least 1, found 224
Could Not Activate The Firmware

Before flash encryption, everything was working just fine. Updates over OTA were working very well. After encryption not.

What I also did is to program another board with ESP IDF native ota example, and set the upload new bin file to the one I am trying to update on my ota http application. I flash board with native ota, and then native ota uploads the new code, but when I use my own ota page is not working.

What would be the cause?

Maybe it helps, I am using async wifi libraries.

Chip is ESP32D0WDQ5 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
MAC: fc:f5:c4:4a:5a:cc
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 8192 bytes to 47...

Partition settings :

Name | Type | SubType | Offset | Size | Flags

-- | -- | -- | -- | -- | --
nvs | data | nvs | 0x9000 | 0x5000 |  
otadata | data | ota | 0xe000 | 0x2000 |  
app0 | app | ota_0 | 0x10000 | 0x140000 |  
app1 | app | ota_1 | 0x150000 | 0x140000 |  
spiffs | data | spiffs | 0x290000 | 0x170000 |  

@robertpoll
Copy link
Contributor

The current Arduino OTA doesn’t support encrypted flash. There are two issues 1) the bootloader is pre-compiled and doesn’t have encryption support. You’ve worked around this one though by programming with ESP-IDF. For the second issue see my PR for details of the problem and a proposed fix. Let me know how you get on.

@sboicu
Copy link
Author

sboicu commented May 7, 2020

The current Arduino OTA doesn’t support encrypted flash. There are two issues 1) the bootloader is pre-compiled and doesn’t have encryption support. You’ve worked around this one though by programming with ESP-IDF. For the second issue see my PR for details of the problem and a proposed fix. Let me know how you get on.

Thanks for your reply. I am not quite sure I understand what I need to do.
Do I have to update the libraries for Arduino OTA?

@sboicu
Copy link
Author

sboicu commented May 7, 2020

1.I have updated: Esp.cpp, Esp.h, Update.h and Update.cpp as per instructions.

2.I exported my .ino project in the compiled bin with Arduino IDE

3.went to my app website and upload the new bin file. Unfortunately, I have the same error.

I still have the same result
E (81486) esp_image: image at 0x150000 has invalid magic byte
E (81486) boot_comm: image has invalid chip ID, expected at least 0, found 717
E (81487) boot_comm: image has invalid chip revision, expected at least 1, found 224
Could Not Activate The Firmware

@sboicu
Copy link
Author

sboicu commented May 7, 2020

Ok. this fixed my issue.

I have uploaded the new code to a new board, with flash encryption as well.

Everything is working fine now. My OTA is also working.

Thank you very much for your great support.

@stale
Copy link

stale bot commented Jul 6, 2020

[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Jul 6, 2020
@stale
Copy link

stale bot commented Jul 20, 2020

[STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions.

@LusterWong
Copy link

LusterWong commented Feb 23, 2021

Ok. this fixed my issue.

I have uploaded the new code to a new board, with flash encryption as well.

Everything is working fine now. My OTA is also working.

Thank you very much for your great support.

Hello, I also use Arduino development and Flash encryption, also encountered OTA errors
E (130773) esp_image: image at 0x1f0000 has invalid magic byte
E (130774) boot_comm: image has invalid chip ID, expected at least 0, found 51630
E (130775) boot_comm: image has invalid chip revision, expected at least 1, found 36
How to solve this problem?

@Dvl-s
Copy link

Dvl-s commented Mar 25, 2021

Ok. this fixed my issue.
I have uploaded the new code to a new board, with flash encryption as well.
Everything is working fine now. My OTA is also working.
Thank you very much for your great support.

Hello, I also use Arduino development and Flash encryption, also encountered OTA errors
E (130773) esp_image: image at 0x1f0000 has invalid magic byte
E (130774) boot_comm: image has invalid chip ID, expected at least 0, found 51630
E (130775) boot_comm: image has invalid chip revision, expected at least 1, found 36
How to solve this problem?

Hii Have you solved encryption + OTA + Arduino IDE ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Stale Issue is stale stage (outdated/stuck)
Projects
None yet
Development

No branches or pull requests

4 participants