-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
httpUpdateSigned don't work if used gzipped firmware #7570
Comments
Those debug messages don't really give much info. Can you bump up to full debug and re-run? Sign checks are done in Updater.cpp before a reboot, and it doesn't care/know if the blob is signed or raw bin. It just looks for the proper magic bytes at the end and a signed hash of the bits uploaded (i.e. you should first gzip, then sign the update...the other way won't work). The exact steps you used to make the signed binaries and a demo public/private keypar would be helpful, too. |
I use the public/private keypar included in the httpUpdateSigned example. I build it with Arduino IDE v1.8.11 on Windows and use Debian on Windows (WSL) and call
Debug Messages
|
Check Arduino/bootloaders/eboot/eboot.c Lines 236 to 238 in e636a65
So, I'm seeing no issue here. The new firmware was copied the it was loaded ( Make sure you're uploading the file you want and not another one (http cache or something weird like that). |
Also, if the original bootloader does not have GZIP support, you could end up having it write gzip'd data instead of opcodes when it copies the new app over. You need to ensure the bootloader has gzip support (i.e. upload one FW using uncompressed mode), and once that's up only then try and use gzip'd bins. The signing stuff should be orthogonal to any gzip support. Signing is just doing a signed hash compare over a set of bits, it doesn't care what those bits are. Once the signing is validated, it should be exactly the same as unsigned. |
Quick check of Update.cpp shows it might be getting the wrong bin size to copy, meaning the eboot gzip decompressor could abort because the len was invalid. Try this patch, at line Arduino/cores/esp8266/Updater.cpp Line 284 in e636a65
add
after the |
It works 👍 thanks for your help! |
The last 4 bytes of a GZIP file is the decompressed file length, and are used in eboot to do sanity checks and know when decompression is done. Updater was incorrectly telling eboot to look at "end-of-bin + sizeof(signing)", and when eboot did so it got an incorrect value causing either the update to be skipped or for only a portion of update to be completed. Fix by adjusting the size back to the end of binary. Fixes esp8266#7570
The last 4 bytes of a GZIP file is the decompressed file length, and are used in eboot to do sanity checks and know when decompression is done. Updater was incorrectly telling eboot to look at "end-of-bin + sizeof(signing)", and when eboot did so it got an incorrect value causing either the update to be skipped or for only a portion of update to be completed. Fix by adjusting the size back to the end of binary. Fixes #7570
The last 4 bytes of a GZIP file is the decompressed file length, and are used in eboot to do sanity checks and know when decompression is done. Updater was incorrectly telling eboot to look at "end-of-bin + sizeof(signing)", and when eboot did so it got an incorrect value causing either the update to be skipped or for only a portion of update to be completed. Fix by adjusting the size back to the end of binary. Fixes esp8266#7570
Basic Infos
Platform
Settings in IDE
Problem Description
Signed http update don't work correctly if using gzipped firmware. During update no error appears and the signature check worked. But the esp boots to the old firmware and when i reset the esp it hangs and cannot boot anymore.
I used the httpUpdateSigned example build it with Arduino IDE v1.8.11.
After compiling i gzipped the firmware.bin and signed it with the signing.py script according to the documentation.
An unsigned gzipped firmware works and signed unzipped firmware works also.
MCVE Sketch
Debug Messages
[SETUP] WAIT 4...
[SETUP] WAIT 3...
[SETUP] WAIT 2...
[SETUP] WAIT 1...
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
load 0x4010f000, len 3584, room 16
tail 0
chksum 0xb0
csum 0xb0
v2843a5ac
@cp:0
ld
[SETUP] WAIT 4...
[SETUP] WAIT 3...
[SETUP] WAIT 2...
[SETUP] WAIT 1...
The text was updated successfully, but these errors were encountered: