RavenSystem / esp-homekit-devices

Advanced firmware to add native Apple HomeKit and custom configurations, compatible with any SoC based on ESP32, ESP32-S, ESP32-C and ESP8266 series. (Shelly, Sonoff, Electrodragon, Tuya...)
Other
2.73k stars 360 forks source link

OTA Updates broken vol2. - HTTP Headers Capitalisation #1655

Closed SyBeer closed 2 years ago

SyBeer commented 2 years ago

Hi,

After buying "HAA Manager" (iOS) I run autoupdate for my all devices One of them - "Sonoff SV" - won't finish update. I have yellow screen with HAA Installation

The procedure from issue #825 don't work (I use esptool.py for flashing)

_(...) 3. Enable flash mode in the device.

  1. Flash last haaboot.bin using this command: esptool.py -p /dev/ write_flash 0x2000 haaboot.bin
  2. Reboot your device._
(esp32-env) uEr@MBA ESP32 % esptool.py -p /dev/cu.usbserial-0001 write_flash 0x2000 /Users/uEr/Downloads/HAA/haaboot.bin
esptool.py v3.2
Serial port /dev/cu.usbserial-0001
Connecting...
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting...
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: a4:cf:12:d8:5b:02
Stub is already running. No upload is necessary.
Configuring flash size...
Flash will be erased from 0x00002000 to 0x00062fff...
Compressed 395472 bytes to 283558...
Wrote 395472 bytes (283558 compressed) at 0x00002000 in 31.1 seconds (effective 101.7 kbit/s)...
Hash of data verified.

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

I also try flash another firmware (tasmota) and it's work fine.

Logs from device look like this, and still there is "Content-Length: 2"

*** OTAMAIN installed

Restarting...
rm match
del if0
usl
sul 0 0

 ets Jan  8 2013,rst cause:4, boot mode:(3,7)

wdt reset
load 0x40100000, len 2292, room 16 
tail 4
chksum 0x57
load 0x3ffe8000, len 772, room 4 
tail 0
chksum 0x0b
csum 0x0b

rBoot v1.4.0 - richardaburton@gmail.com
Flash Size:   8 Mbit
Flash Mode:   DOUT
Flash Speed:  40 MHz
rBoot Option: Big flash
rBoot Option: RTC data

Booting temp rom.
Booting rom 1.

 ets Jan  8 2013,rst cause:4, boot mode:(3,7)

wdt reset
load 0x40100000, len 2292, room 16 
tail 4
chksum 0x57
load 0x3ffe8000, len 772, room 4 
tail 0
chksum 0x0b
csum 0x0b

rBoot v1.4.0 - richardaburton@gmail.com
Flash Size:   8 Mbit
Flash Mode:   DOUT
Flash Speed:  40 MHz
rBoot Option: Big flash
rBoot Option: RTC data

Booting rom 0.
pp_task_hdl : 3ffefac0, prio:14, stack:512
pm_task_hdl : 3ffef3b0, prio:1, stack:176
frc2_timer_task_hdl:0x3fff42c8, prio:12, stack:200

ESP-Open-SDK ver: 0.0.1 compiled @ Jan 28 2021 22:13:21
phy ver: 273, pp ver: 8.3

sleep disable

Sysparam OK

Wifi Init
mode : sta(a4:cf:12:d8:5b:02)
add if0
Saved BSSID: 382c4a68f238
Wifi Mode: Normal

HAA OTA - NORMAL MODE

scandone
add 0
aid 9
cnt 

connected with AS_WLAN, channel 8
dhcp client start...
ip:192.168.1.217,mask:255.255.255.0,gw:192.168.1.1

HAA Installer Version: 4.5.0

- Server: github.com/RavenSystem/haa/releases/latest/download
- Port:   443
- SSL:    yes

Current HAAMAIN version installed: 0.0.0

INIT
DNS check result  = OK

*** STARTING UPDATE PROCESS

Running HAABOOT

HomeKit data migration...
Data is already migrated

Get sign

DOWNLOADING FILE

Forwarding: github.com/RavenSystem/haa/releases/latest/download/otamain.bin.sec
-----
GET /RavenSystem/haa/releases/latest/download/otamain.bin.sec HTTP/1.1
Host: github.com
Range: bytes=0-1

-----

*** NEW CONNECTION
DNS..OK Socket..OK Connect..OK SSL..OK set_fd to github.com port 443..OK
sent OK
ret = 1024

HTTP/1.1 302 Found
Server: GitHub.com
Date: Sun, 28 Nov 2021 21:14:51 GMT
Content-Type: text/html; charset=utf-8
Vary: X-PJAX, X-PJAX-Container, Accept-Encoding, Accept, X-Requested-With
permissions-policy: interest-cohort=()
Location: https://github.com/RavenSystem/haa/releases/download/9.4.2/otamain.bin.sec
Cache-Control: no-cache
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
X-Frame-Options: deny
X-Content-Type-Options: nosniff
X-XSS-Protection: 0
Referrer-Policy: no-referrer-when-downgrade
Expect-CT: max-age=2592000, report-uri="https://api.github.com/_private/browser/errors"
Content-Security-Policy: default-src 'none'; base-uri 'self'; block-all-mixed-content; child-src github.com/assets-cdn/worker/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com objects-origin.githubusercontent.com www.githubstatus.com collector.githubapp.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-prod

HTTP returns 302

Forwarding: github.com/RavenSystem/haa/releases/download/9.4.2/otamain.bin.sec
-----
GET /RavenSystem/haa/releases/download/9.4.2/otamain.bin.sec HTTP/1.1
Host: github.com
Range: bytes=0-1

-----

*** NEW CONNECTION
DNS..OK Socket..OK Connect..OK SSL..OK set_fd to github.com port 443..OK
sent OK
ret = 1024

HTTP/1.1 302 Found
Server: GitHub.com
Date: Sun, 28 Nov 2021 21:14:52 GMT
Content-Type: text/html; charset=utf-8
Vary: X-PJAX, X-PJAX-Container, Accept-Encoding, Accept, X-Requested-With
permissions-policy: interest-cohort=()
Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/166993980/ed58cf82-936f-4ec4-a9ae-f1dfa5529a0f?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20211128%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20211128T211452Z&X-Amz-Expires=300&X-Amz-Signature=851b0e2769b124512666c519d9a8cc26280138cea5e8d9683995fa16e8b82fc5&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=166993980&response-content-disposition=attachment%3B%20filename%3Dotamain.bin.sec&response-content-type=application%2Foctet-stream
Cache-Control: no-cache
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
X-Frame-Options: deny
X-Content-Type-Options: nosniff
X-XSS-Protection: 0
Referrer-Policy: no-referrer-when-downgrade
Expect-CT: m

HTTP returns 302

Forwarding: objects.githubusercontent.com/github-production-release-asset-2e65be/166993980/ed58cf82-936f-4ec4-a9ae-f1dfa5529a0f?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20211128%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20211128T211452Z&X-Amz-Expires=300&X-Amz-Signature=851b0e2769b124512666c519d9a8cc26280138cea5e8d9683995fa16e8b82fc5&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=166993980&response-content-disposition=attachment%3B%20filename%3Dotamain.bin.sec&response-content-type=application%2Foctet-stream
-----
GET /github-production-release-asset-2e65be/166993980/ed58cf82-936f-4ec4-a9ae-f1dfa5529a0f?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20211128%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20211128T211452Z&X-Amz-Expires=300&X-Amz-Signature=851b0e2769b124512666c519d9a8cc26280138cea5e8d9683995fa16e8b82fc5&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=166993980&response-content-disposition=attachment%3B%20filename%3Dotamain.bin.sec&response-content-type=application%2Foctet-stream HTTP/1.1
Host: objects.githubusercontent.com
Range: bytes=0-1

-----

*** NEW CONNECTION
DNS..OK Socket..OK Connect..OK SSL..OK set_fd to objects.githubusercontent.com port 443..OK
sent OK
ret = 645

HTTP/1.1 206 Partial Content
Connection: keep-alive
Content-Length: 2
x-amz-id-2: xKB/7d8cvk6xa+vEz7h6NDVrqn/cRjO47m+cLCaKjR4K7MiMtTKzUuw3/R6A26NeI1LqMVRDXoI=
x-amz-request-id: 98W2BH4CXT2S0MKX
Last-Modified: Sun, 28 Nov 2021 13:32:33 GMT
ETag: "6213a36174a3ec54b7d7b24c698cfdb6"
Content-Disposition: attachment; filename=otamain.bin.sec
Content-Type: application/octet-stream
Server: AmazonS3
Fastly-Restarts: 1
Accept-Ranges: bytes
Age: 0
Content-Range: bytes 0-1/104
Date: Sun, 28 Nov 2021 21:15:57 GMT
Via: 1.1 varnish
X-Served-By: cache-fra19165-FRA
X-Cache: MISS
X-Cache-Hits: 0
X-Timer: S1638134157.943659,VS0,VE218

HTTP returns 206

FINAL location: objects.githubusercontent.com/github-production-release-asset-2e65be/166993980/ed58cf82-936f-4ec4-a9ae-f1dfa5529a0f?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20211128%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20211128T211452Z&X-Amz-Expires=300&X-Amz-Signature=851b0e2769b124512666c519d9a8cc26280138cea5e8d9683995fa16e8b82fc5&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=166993980&response-content-disposition=attachment%3B%20filename%3Dotamain.bin.sec&response-content-type=application%2Foctet-stream

*** NEW CONNECTION
DNS..OK Socket..OK Connect..OK SSL..OK set_fd to objects.githubusercontent.com port 443..OK
 Downloaded 104 Bytes

Get file from github.com/RavenSystem/haa/releases/latest/download

DOWNLOADING FILE

Forwarding: github.com/RavenSystem/haa/releases/latest/download/otamain.bin
-----
GET /RavenSystem/haa/releases/latest/download/otamain.bin HTTP/1.1
Host: github.com
Range: bytes=0-1

-----

*** NEW CONNECTION
DNS..OK Socket..OK Connect..OK SSL..OK set_fd to github.com port 443..OK
sent OK
ret = 1024

HTTP/1.1 302 Found
Server: GitHub.com
Date: Sun, 28 Nov 2021 21:14:57 GMT
Content-Type: text/html; charset=utf-8
Vary: X-PJAX, X-PJAX-Container, Accept-Encoding, Accept, X-Requested-With
permissions-policy: interest-cohort=()
Location: https://github.com/RavenSystem/haa/releases/download/9.4.2/otamain.bin
Cache-Control: no-cache
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
X-Frame-Options: deny
X-Content-Type-Options: nosniff
X-XSS-Protection: 0
Referrer-Policy: no-referrer-when-downgrade
Expect-CT: max-age=2592000, report-uri="https://api.github.com/_private/browser/errors"
Content-Security-Policy: default-src 'none'; base-uri 'self'; block-all-mixed-content; child-src github.com/assets-cdn/worker/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com objects-origin.githubusercontent.com www.githubstatus.com collector.githubapp.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-producti

HTTP returns 302

Forwarding: github.com/RavenSystem/haa/releases/download/9.4.2/otamain.bin
-----
GET /RavenSystem/haa/releases/download/9.4.2/otamain.bin HTTP/1.1
Host: github.com
Range: bytes=0-1

-----

*** NEW CONNECTION
DNS..OK Socket..OK Connect..OK SSL..OK set_fd to github.com port 443..OK
sent OK
ret = 1024

HTTP/1.1 302 Found
Server: GitHub.com
Date: Sun, 28 Nov 2021 21:15:32 GMT
Content-Type: text/html; charset=utf-8
Vary: X-PJAX, X-PJAX-Container, Accept-Encoding, Accept, X-Requested-With
permissions-policy: interest-cohort=()
Location: https://github-releases.githubusercontent.com/166993980/49d1da60-4fec-4eaa-97ee-9cc6fa060af2?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20211128%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20211128T211532Z&X-Amz-Expires=300&X-Amz-Signature=10b5869b7c94eb484f6415646dd7e318f75123ae4f3b5e6b0cae60f7e38fbc80&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=166993980&response-content-disposition=attachment%3B%20filename%3Dotamain.bin&response-content-type=application%2Foctet-stream
Cache-Control: no-cache
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
X-Frame-Options: deny
X-Content-Type-Options: nosniff
X-XSS-Protection: 0
Referrer-Policy: no-referrer-when-downgrade
Expect-CT: max-age=2592000, report-uri="https:/

HTTP returns 302

Forwarding: github-releases.githubusercontent.com/166993980/49d1da60-4fec-4eaa-97ee-9cc6fa060af2?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20211128%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20211128T211532Z&X-Amz-Expires=300&X-Amz-Signature=10b5869b7c94eb484f6415646dd7e318f75123ae4f3b5e6b0cae60f7e38fbc80&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=166993980&response-content-disposition=attachment%3B%20filename%3Dotamain.bin&response-content-type=application%2Foctet-stream
-----
GET /166993980/49d1da60-4fec-4eaa-97ee-9cc6fa060af2?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20211128%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20211128T211532Z&X-Amz-Expires=300&X-Amz-Signature=10b5869b7c94eb484f6415646dd7e318f75123ae4f3b5e6b0cae60f7e38fbc80&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=166993980&response-content-disposition=attachment%3B%20filename%3Dotamain.bin&response-content-type=application%2Foctet-stream HTTP/1.1
Host: github-releases.githubusercontent.com
Range: bytes=0-1

-----

*** NEW CONNECTION
DNS..OK Socket..OK Connect..OK SSL..OK set_fd to github-releases.githubusercontent.com port 443..OK
sent OK
ret = 734

HTTP/1.1 206 Partial Content
Connection: keep-alive
Content-Length: 2
x-amz-id-2: H3PikKobHURaC/qyOTxSn22/HjqikE+SEgrQU8YjH8tZO+UMS+bslbk2KShN8WzDF8DKwuS086g=
x-amz-request-id: EZEX2GYJWRC8AF5K
Last-Modified: Sun, 28 Nov 2021 13:32:32 GMT
ETag: "132a10493022df38afcde09cd754c42c"
Content-Disposition: attachment; filename=otamain.bin
Content-Type: application/octet-stream
Server: AmazonS3
Via: 1.1 varnish, 1.1 varnish
Accept-Ranges: bytes
Age: 0
Content-Range: bytes 0-1/395200
Date: Sun, 28 Nov 2021 21:16:02 GMT
X-Served-By: cache-dca12920-DCA, cache-fra19173-FRA
X-Cache: HIT, MISS
X-Cache-Hits: 1, 0
Strict-Transport-Security: max-age=31536000
X-Fastly-Request-ID: d5cb7c4267e46113e882fd7e6c2d2774caa5424a

HTTP returns 206

FINAL location: github-releases.githubusercontent.com/166993980/49d1da60-4fec-4eaa-97ee-9cc6fa060af2?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20211128%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20211128T211532Z&X-Amz-Expires=300&X-Amz-Signature=10b5869b7c94eb484f6415646dd7e318f75123ae4f3b5e6b0cae60f7e38fbc80&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=166993980&response-content-disposition=attachment%3B%20filename%3Dotamain.bin&response-content-type=application%2Foctet-stream

*** NEW CONNECTION
DNS..OK Socket..OK Connect..OK SSL..OK set_fd to github-releases.githubusercontent.com port 443..OK
Sector 0x90000  Downloaded 4096 Bytes
Sector 0x91000  Downloaded 8192 Bytes
Sector 0x92000  Downloaded 12288 Bytes
Sector 0x93000  Downloaded 16384 Bytes
Sector 0x94000  Downloaded 20480 Bytes
Sector 0x95000  Downloaded 24576 Bytes
Sector 0x96000  Downloaded 28672 Bytes
Sector 0x97000  Downloaded 32768 Bytes
Sector 0x98000  Downloaded 36864 Bytes
Sector 0x99000  Downloaded 40960 Bytes
Sector 0x9a000  Downloaded 45056 Bytes
Sector 0x9b000  Downloaded 49152 Bytes
Sector 0x9c000  Downloaded 53248 Bytes
Sector 0x9d000  Downloaded 57344 Bytes
Sector 0x9e000  Downloaded 61440 Bytes
Sector 0x9f000  Downloaded 65536 Bytes
Sector 0xa0000  Downloaded 69632 Bytes
Sector 0xa1000  Downloaded 73728 Bytes
Sector 0xa2000  Downloaded 77824 Bytes
Sector 0xa3000  Downloaded 81920 Bytes
Sector 0xa4000  Downloaded 86016 Bytes
Sector 0xa5000  Downloaded 90112 Bytes
Sector 0xa6000  Downloaded 94208 Bytes
Sector 0xa7000  Downloaded 98304 Bytes
Sector 0xa8000  Downloaded 102400 Bytes
Sector 0xa9000  Downloaded 106496 Bytes
Sector 0xaa000  Downloaded 110592 Bytes
Sector 0xab000  Downloaded 114688 Bytes
Sector 0xac000  Downloaded 118784 Bytes
Sector 0xad000  Downloaded 122880 Bytes
Sector 0xae000  Downloaded 126976 Bytes
Sector 0xaf000  Downloaded 131072 Bytes
Sector 0xb0000  Downloaded 135168 Bytes
Sector 0xb1000  Downloaded 139264 Bytes
Sector 0xb2000  Downloaded 143360 Bytes
Sector 0xb3000  Downloaded 147456 Bytes
Sector 0xb4000  Downloaded 151552 Bytes
Sector 0xb5000  Downloaded 155648 Bytes
Sector 0xb6000  Downloaded 159744 Bytes
Sector 0xb7000  Downloaded 163840 Bytes
Sector 0xb8000  Downloaded 167936 Bytes
Sector 0xb9000  Downloaded 172032 Bytes
Sector 0xba000  Downloaded 176128 Bytes
Sector 0xbb000  Downloaded 180224 Bytes
Sector 0xbc000  Downloaded 184320 Bytes
Sector 0xbd000  Downloaded 188416 Bytes
Sector 0xbe000  Downloaded 192512 Bytes
Sector 0xbf000  Downloaded 196608 Bytes
Sector 0xc0000  Downloaded 200704 Bytes
Sector 0xc1000  Downloaded 204800 Bytes
Sector 0xc2000  Downloaded 208896 Bytes
Sector 0xc3000  Downloaded 212992 Bytes
Sector 0xc4000  Downloaded 217088 Bytes
Sector 0xc5000  Downloaded 221184 Bytes
Sector 0xc6000  Downloaded 225280 Bytes
Sector 0xc7000  Downloaded 229376 Bytes
Sector 0xc8000  Downloaded 233472 Bytes
Sector 0xc9000  Downloaded 237568 Bytes
Sector 0xca000  Downloaded 241664 Bytes
Sector 0xcb000  Downloaded 245760 Bytes
Sector 0xcc000  Downloaded 249856 Bytes
Sector 0xcd000  Downloaded 253952 Bytes
Sector 0xce000  Downloaded 258048 Bytes
Sector 0xcf000  Downloaded 262144 Bytes
Sector 0xd0000  Downloaded 266240 Bytes
Sector 0xd1000  Downloaded 270336 Bytes
Sector 0xd2000  Downloaded 274432 Bytes
Sector 0xd3000  Downloaded 278528 Bytes
Sector 0xd4000  Downloaded 282624 Bytes
Sector 0xd5000  Downloaded 286720 Bytes
Sector 0xd6000  Downloaded 290816 Bytes
Sector 0xd7000  Downloaded 294912 Bytes
Sector 0xd8000  Downloaded 299008 Bytes
Sector 0xd9000  Downloaded 303104 Bytes
Sector 0xda000  Downloaded 307200 Bytes
Sector 0xdb000  Downloaded 311296 Bytes
Sector 0xdc000  Downloaded 315392 Bytes
Sector 0xdd000  Downloaded 319488 Bytes
Sector 0xde000  Downloaded 323584 Bytes
Sector 0xdf000  Downloaded 327680 Bytes
Sector 0xe0000  Downloaded 331776 Bytes
Sector 0xe1000  Downloaded 335872 Bytes
Sector 0xe2000  Downloaded 339968 Bytes
Sector 0xe3000  Downloaded 344064 Bytes
Sector 0xe4000  Downloaded 348160 Bytes
Sector 0xe5000  Downloaded 352256 Bytes
Sector 0xe6000  Downloaded 356352 Bytes
Sector 0xe7000  Downloaded 360448 Bytes
Sector 0xe8000  Downloaded 364544 Bytes
Sector 0xe9000  Downloaded 368640 Bytes
Sector 0xea000  Downloaded 372736 Bytes
Sector 0xeb000  Downloaded 376832 Bytes
Sector 0xec000  Downloaded 380928 Bytes
Sector 0xed000  Downloaded 385024 Bytes
Sector 0xee000  Downloaded 389120 Bytes
Sector 0xef000  Downloaded 393216 Bytes
Sector 0xf0000  Downloaded 395200 Bytes

Verifying sign...
Sign result: OK (1)
Finalize file

*** OTAMAIN installed
RavenSystem commented 2 years ago

You are using an old version of fullhaaboot.bin file. Please, use last version from here: https://github.com/RavenSystem/esp-homekit-devices/wiki/Installation