adapt0 / smartplug

Alternative firmware for Etekcity's "Voltson Wi-Fi Smart Plug Mini Outlet" (ESW01-USA)
MIT License
31 stars 6 forks source link

user2.bin getting written but not activating #27

Closed brilthor closed 3 years ago

brilthor commented 3 years ago

I'm halfway through debugging an issue similar to the behaviour seen here: https://github.com/adapt0/smartplug/issues/4#issuecomment-577898643

Specifically that the image download finishes and then nothing seems to happen after that. Unlike the above mentioned comment though these switches are one of the original ones and contain a firmware version (1.89) that has been known to work previously.

Known relevant details:

Log from the hijack server:

$ node ./index.js -p <redacted>  
Using en0 192.168.88.254
Looking for local WiFi interface (use --ssid & --bssid to override)
Using SSID "<redacted> " (BSSID: <redacted> , Local IP: 192.168.88.254)
Starting web server on TCP port 17273
Listening for devices on UDP port 18266
Sending Smart Config...
Connected to device 192.168.88.253
<= {"uri":"/beginConfigRequest","wifiID":"<redacted> ","wifiBssid":"","wifiPassword":"<redacted> ","account":"0","key":1623597219849,"serverIP":"192.168.88.254"}
0000 257b22757269223a222f626567696e436f6e6669675265706c79222c22657272
0020 223a2230227d
Accepted WebSocket from ::ffff:192.168.88.253
{ account: '0',
  id: '01cb455a-4714-45e6-bc5b-<redacted> ',
  deviceName: 'vesync_wifi_outlet',
  deviceVersion: '1.5',
  deviceVersionCode: 5,
  type: 'wifi-switch',
  apptype: 'switch-measure',
  firmName: 'cosytek_firm_a',
  firmVersion: '1.89',
  firmVersionCode: 89,
  key: 2147483647,
  relay: 'open' }
Initiating device upgrade
::ffff:192.168.88.253 - - [13/Jun/2021:15:13:41 +0000] "HEAD /user2.bin HTTP/1.1"
::ffff:192.168.88.253 - - [13/Jun/2021:15:13:41 +0000] "HEAD /user2.bin HTTP/1.1" 200 332548 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36 "
::ffff:192.168.88.253 - - [13/Jun/2021:15:13:44 +0000] "GET /user2.bin HTTP/1.1"
::ffff:192.168.88.253 - - [13/Jun/2021:15:13:45 +0000] "GET /user2.bin HTTP/1.1" 200 332548 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36 "
{ account: '0',
  id: '01cb455a-4714-45e6-bc5b-<redacted> ',
  deviceName: 'vesync_wifi_outlet',
  deviceVersion: '1.5',
  deviceVersionCode: 5,
  type: 'wifi-switch',
  apptype: 'switch-measure',
  firmName: 'cosytek_firm_a',
  firmVersion: '1.89',
  firmVersionCode: 89,
  key: 0,
  relay: 'open' }
(node:44916) UnhandledPromiseRejectionWarning: undefined
(node:44916) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:44916) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
{ uri: '/report', e: '17', t: 'b7' }
{ uri: '/ka', rssi: -26 }
{ uri: '/report', e: '24', t: 'b6' }

Log from the serial interface:

scandone
SC_STATUS_FIND_CHANNEL
TYPE: ESPTOUCH
SC_STATUS_GETTING_SSID_PSWD
SC_TYPE:SC_TYPE_ESPTOUCH
F|pswd: <redacted>
F|ssid: <redacted>
SC_STATUS_LINK
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 2
cnt

connected with <redacted>, channel 1
dhcp client start...
event 0
connect to ssid <redacted>, channel 1
ip:192.168.88.253,mask:255.255.255.0,gw:192.168.88.1
event 3
ip:192.168.88.253,mask:255.255.255.0,gw:192.168.88.1
cs_wifi_on_station_connected, status:5
cs_wifi_on_station_connected, null callback
cs_configer_on_sniffer_completed, state:1
softap_tcp_server_listen
webserver_recv, length:163
found uri
uri value:/beginConfigRequest
wifiID:<redacted>
wifiBssid:
wifi password:<redacted>
account:0
key:2147483647
serverIP:192.168.88.254
cs_configer_on_app_begin_config
send_device_config_status_to_app
start dhcp
cs_switch_client_do_reconnect
cs_switch_client_do_reconnect, now connect to server
cs_switch_client_start ...
cs_switch_client_start ok

....

cs_timer_schedule_timer_today
start_time has passed
end_time has passed too
cs_timer_schedule end, valid timer:2, sch-ing timer:0, sch-new timer:0
cs_switch_on_login_completed, err:0
cs_set_last_error, error:0
cs_configer_on_login_ok
cs_switch_client_recv_cb
re-start beacon timer:180000
ws got text msg
cs_server_handler_on_message, data length:74
found uri
uri value:/upgrade
execute_upgrade_command
upgrade url:http://192.168.88.254:17273
upgrade newVersion:2.00
system_upgrade_start
upgrade_connect 39752
upgrade_connect_cb
pusrdata = HTTP/1.1 200 OK
Content-Length: 332548
Date: Sun, 13 Jun 2021 15:13:41 GMT
Connection: close

sumlength = 332548
sec_block 82
..................................................................................pusrdata = HTTP/1.1 400 Bad Request
Connection: close

server do not support HEAD method now send GET message
upgrade_get_sum_disconcb 36096
erase sector=129 ok
erase sector=130 ok
erase sector=131 ok
erase sector=132 ok
erase sector=133 ok

...

erase sector=194 ok
erase sector=195 ok
erase sector=196 ok
erase sector=197 ok
erase sector=198 ok
erase sector=199 ok
erase sector=200 ok
cs_timer_schedule_timer_today
start_time has passed
end_time has passed too
cs_timer_schedule_timer_today
start_time has passed
end_time has passed too
cs_timer_schedule end, valid timer:2, sch-ing timer:0, sch-new timer:0
erase sector=201 ok
erase sector=202 ok
erase sector=203 ok
erase sector=204 ok
erase sector=205 ok
erase sector=206 ok
erase sector=207 ok
erase sector=208 ok
erase sector=209 ok
erase sector=210 ok

ALL=82 sectors erase ok!
upgrade_connect_cb
sumlength = 332548
upgrade file download start.
totallen = 2816
totallen = 4276
totallen = 5736
totallen = 7196
totallen = 8656
totallen = 10116
totallen = 11576

...

totallen = 324016
totallen = 325476
totallen = 326936
totallen = 328396
totallen = 329856
cs_timer_schedule_timer_today
start_time has passed
end_time has passed too
cs_timer_schedule_timer_today
start_time has passed
end_time has passed too
cs_timer_schedule end, valid timer:2, sch-ing timer:0, sch-new timer:0
totallen = 331316
totallen = 332548
upgrade file download finished.
flash_crc = 2746132336
img_crc = 1548834960
upgrade_check
cs_switch_on_upgrade_completed, result:1
register device info json length:291
cs_switch_client_send, WSPacket length is:299
re-start beacon timer:180000
cs_switch_client_sent_cb
free sent buffer
cs_switch_client_recv_cb
re-start beacon timer:180000
ws got text msg
cs_server_handler_on_message, data length:116
found uri
uri value:/loginReply
on_login_reply
error:0

build log:

bootstrap-firmware <redacted>$ ~/.platformio/penv/bin/pio run
Processing app (platform: espressif8266; board: esp12e; framework: esp8266-rtos-sdk)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Platform Manager: Installing espressif8266
Platform Manager: espressif8266 @ 3.0.0 has been installed!
The platform 'espressif8266' has been successfully installed!
The rest of the packages will be installed later depending on your build environment.                                                                                                                       
Tool Manager: Installing platformio/toolchain-xtensa @ ~1.40802.0
Downloading  [####################################]  100%          
Unpacking  [####################################]  100%          
Tool Manager: toolchain-xtensa @ 1.40802.0 has been installed!
Tool Manager: Installing platformio/framework-esp8266-rtos-sdk @ >=1.5.0-beta
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Tool Manager: framework-esp8266-rtos-sdk @ 1.5.0-beta.5 has been installed!
Tool Manager: Installing platformio/tool-esptool @ <2
Tool Manager: tool-esptool @ 1.413.0 has been installed!
Tool Manager: Installing platformio/tool-esptoolpy @ ~1.30000.0
Downloading  [####################################]  100%
Tool Manager: tool-esptoolpy @ 1.30000.201119 has been installed!
Tool Manager: Installing platformio/tool-scons @ ~4.40100.2
Tool Manager: tool-scons @ 4.40100.2 has been installed!
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/esp12e.html
PLATFORM: Espressif 8266 (3.0.0) > Espressif ESP8266 ESP-12E
HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
PACKAGES: 
 - framework-esp8266-rtos-sdk 1.5.0-beta.5 
 - tool-esptool 1.413.0 (4.13) 
 - tool-esptoolpy 1.30000.201119 (3.0.0) 
 - toolchain-xtensa 1.40802.0 (4.8.2)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio/build/app/src/http_connection.o
Compiling .pio/build/app/src/task_blink.o
Compiling .pio/build/app/src/task_connect.o
Compiling .pio/build/app/src/task_upgrade.o
Compiling .pio/build/app/src/user_main.o
Compiling /Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/lib/driver/driver/gpio.o
Compiling /Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/lib/driver/driver/hw_timer.o
Compiling /Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/lib/driver/driver/i2c_master.o
Compiling /Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/lib/driver/driver/spi_interface.o
Compiling /Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/lib/driver/driver/uart.o
In file included from /Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/lwip/ip_addr.h:38:0,
                 from /Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/lwip/netbuf.h:37,                                                                                           
                 from /Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/lwip/api.h:41,                                                                                              
                 from src/net_conn.h:16,                                                                                                                                                                    
                 from src/http_connection.h:12,                                                                                                                                                             
                 from src/http_connection.cpp:10:                                                                                                                                                           
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv4/lwip/ip4_addr.h:213:23: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F,             \                                                                                                                                   
                       ^                                                                                                                                                                                    
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv4/lwip/ip4_addr.h:213:31: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F,             \                                                                                                                                   
                               ^                                                                                                                                                                            
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv4/lwip/ip4_addr.h:213:40: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F,             \                                                                                                                                   
                                        ^                                                                                                                                                                   
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv4/lwip/ip4_addr.h:213:49: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F,             \                                                                                                                                   
                                                 ^                                                                                                                                                          
In file included from /Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/lwip/ip_addr.h:39:0,                                                                                        
                 from /Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/lwip/netbuf.h:37,                                                                                           
                 from /Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/lwip/api.h:41,                                                                                              
                 from src/net_conn.h:16,                                                                                                                                                                    
                 from src/http_connection.h:12,                                                                                                                                                             
                 from src/http_connection.cpp:10:                                                                                                                                                           
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv6/lwip/ip6_addr.h:263:23: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \                                                                                                           
                       ^                                                                                                                                                                                    
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv6/lwip/ip6_addr.h:263:31: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \                                                                                                           
                               ^                                                                                                                                                                            
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv6/lwip/ip6_addr.h:263:40: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \                                                                                                           
                                        ^                                                                                                                                                                   
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv6/lwip/ip6_addr.h:263:49: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \                                                                                                           
                                                 ^                                                                                                                                                          
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv6/lwip/ip6_addr.h:263:58: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \                                                                                                           
                                                          ^                                                                                                                                                 
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv6/lwip/ip6_addr.h:263:67: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \                                                                                                           
                                                                   ^                                                                                                                                        
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv6/lwip/ip6_addr.h:263:76: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \                                                                                                           
                                                                            ^                                                                                                                               
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv6/lwip/ip6_addr.h:263:85: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \                                                                                                           
                                                                                     ^                                                                                                                      
In file included from /Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/lwip/ip_addr.h:38:0,                                                                                        
                 from /Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/espressif/esp_misc.h:28,                                                                                         
                 from /Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/espressif/esp_common.h:96,                                                                                       
                 from src/task_connect.h:13,                                                                                                                                                                
                 from src/task_connect.cpp:10:                                                                                                                                                              
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv4/lwip/ip4_addr.h:213:23: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F,             \                                                                                                                                   
                       ^                                                                                                                                                                                    
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv4/lwip/ip4_addr.h:213:31: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F,             \                                                                                                                                   
                               ^                                                                                                                                                                            
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv4/lwip/ip4_addr.h:213:40: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F,             \                                                                                                                                   
                                        ^                                                                                                                                                                   
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv4/lwip/ip4_addr.h:213:49: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F,             \                                                                                                                                   
                                                 ^                                                                                                                                                          
In file included from /Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/lwip/ip_addr.h:38:0,                                                                                        
                 from /Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/espressif/esp_misc.h:28,                                                                                         
                 from /Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/espressif/esp_common.h:96,                                                                                       
                 from src/user_main.cpp:12:                                                                                                                                                                 
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv4/lwip/ip4_addr.h:213:23: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F,             \                                                                                                                                   
                       ^                                                                                                                                                                                    
In file included from /Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/lwip/ip_addr.h:39:0,                                                                                        
                 from /Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/espressif/esp_misc.h:28,                                                                                         
                 from /Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/espressif/esp_common.h:96,                                                                                       
                 from src/task_connect.h:13,                                                                                                                                                                
                 from src/task_connect.cpp:10:                                                                                                                                                              
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv6/lwip/ip6_addr.h:263:23: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \                                                                                                           
                       ^                                                                                                                                                                                    
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv6/lwip/ip6_addr.h:263:31: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \                                                                                                           
                               ^                                                                                                                                                                            
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv4/lwip/ip4_addr.h:213:31: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F,             \                                                                                                                                   
                               ^                                                                                                                                                                            
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv6/lwip/ip6_addr.h:263:40: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \                                                                                                           
                                        ^                                                                                                                                                                   
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv6/lwip/ip6_addr.h:263:49: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \                                                                                                           
                                                 ^                                                                                                                                                          
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv4/lwip/ip4_addr.h:213:40: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F,             \                                                                                                                                   
                                        ^                                                                                                                                                                   
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv6/lwip/ip6_addr.h:263:58: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \                                                                                                           
                                                          ^                                                                                                                                                 
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv4/lwip/ip4_addr.h:213:49: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F,             \                                                                                                                                   
                                                 ^                                                                                                                                                          
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv6/lwip/ip6_addr.h:263:67: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \                                                                                                           
                                                                   ^                                                                                                                                        
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv6/lwip/ip6_addr.h:263:76: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \                                                                                                           
                                                                            ^                                                                                                                               
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv6/lwip/ip6_addr.h:263:85: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \                                                                                                           
                                                                                     ^                                                                                                                      
In file included from /Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/lwip/ip_addr.h:38:0,                                                                                        
                 from /Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/espressif/esp_misc.h:28,                                                                                         
                 from /Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/espressif/esp_common.h:96,                                                                                       
                 from src/task_connect.h:13,                                                                                                                                                                
                 from src/task_upgrade.cpp:11:                                                                                                                                                              
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv4/lwip/ip4_addr.h:213:23: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F,             \                                                                                                                                   
                       ^                                                                                                                                                                                    
In file included from /Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/lwip/ip_addr.h:39:0,                                                                                        
                 from /Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/espressif/esp_misc.h:28,                                                                                         
                 from /Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/espressif/esp_common.h:96,                                                                                       
                 from src/user_main.cpp:12:                                                                                                                                                                 
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv6/lwip/ip6_addr.h:263:23: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \                                                                                                           
                       ^                                                                                                                                                                                    
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv6/lwip/ip6_addr.h:263:31: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \                                                                                                           
                               ^                                                                                                                                                                            
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv4/lwip/ip4_addr.h:213:31: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F,             \                                                                                                                                   
                               ^                                                                                                                                                                            
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv6/lwip/ip6_addr.h:263:40: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \                                                                                                           
                                        ^                                                                                                                                                                   
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv4/lwip/ip4_addr.h:213:40: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F,             \                                                                                                                                   
                                        ^                                                                                                                                                                   
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv6/lwip/ip6_addr.h:263:49: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \                                                                                                           
                                                 ^                                                                                                                                                          
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv4/lwip/ip4_addr.h:213:49: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F,             \                                                                                                                                   
                                                 ^                                                                                                                                                          
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv6/lwip/ip6_addr.h:263:58: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \                                                                                                           
                                                          ^                                                                                                                                                 
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv6/lwip/ip6_addr.h:263:67: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \                                                                                                           
                                                                   ^                                                                                                                                        
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv6/lwip/ip6_addr.h:263:76: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \                                                                                                           
                                                                            ^                                                                                                                               
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv6/lwip/ip6_addr.h:263:85: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \                                                                                                           
                                                                                     ^                                                                                                                      
In file included from /Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/lwip/ip_addr.h:39:0,                                                                                        
                 from /Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/espressif/esp_misc.h:28,                                                                                         
                 from /Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/espressif/esp_common.h:96,                                                                                       
                 from src/task_connect.h:13,                                                                                                                                                                
                 from src/task_upgrade.cpp:11:                                                                                                                                                              
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv6/lwip/ip6_addr.h:263:23: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \                                                                                                           
                       ^                                                                                                                                                                                    
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv6/lwip/ip6_addr.h:263:31: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \                                                                                                           
                               ^                                                                                                                                                                            
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv6/lwip/ip6_addr.h:263:40: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \                                                                                                           
                                        ^                                                                                                                                                                   
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv6/lwip/ip6_addr.h:263:49: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \                                                                                                           
                                                 ^                                                                                                                                                          
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv6/lwip/ip6_addr.h:263:58: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \                                                                                                           
                                                          ^                                                                                                                                                 
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv6/lwip/ip6_addr.h:263:67: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \                                                                                                           
                                                                   ^                                                                                                                                        
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv6/lwip/ip6_addr.h:263:76: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \                                                                                                           
                                                                            ^                                                                                                                               
/Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/include/lwip/ipv6/lwip/ip6_addr.h:263:85: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                                                                                                                                                                                                     
   LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \                                                                                                           
                                                                                     ^                                                                                                                      
cc1: warning: command line option '-fno-threadsafe-statics' is valid for C++/ObjC++ but not for C [enabled by default]                                                                                      
cc1: warning: command line option '-fno-threadsafe-statics' is valid for C++/ObjC++ but not for C [enabled by default]                                                                                      
cc1: warning: command line option '-fno-threadsafe-statics' is valid for C++/ObjC++ but not for C [enabled by default]                                                                                      
cc1: warning: command line option '-fno-threadsafe-statics' is valid for C++/ObjC++ but not for C [enabled by default]                                                                                      
cc1: warning: command line option '-fno-threadsafe-statics' is valid for C++/ObjC++ but not for C [enabled by default]                                                                                      
Archiving /Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/lib/libdriver.a
Indexing /Users/<redacted>/.platformio/packages/framework-esp8266-rtos-sdk/lib/libdriver.a
Linking .pio/build/app/firmware.elf
Linking .pio/build/app/user1.elf
Linking .pio/build/app/user2.elf
elf_to_user_bin([".pio/build/app/user1.elf"], [".pio/build/app/src/http_connection.o", ".pio/build/app/src/task_blink.o", ".pio/build/app/src/task_connect.o", ".pio/build/app/src/task_upgrade.o", ".pio/build/app/src/user_main.o"])
elf_to_user_bin([".pio/build/app/user2.elf"], [".pio/build/app/src/http_connection.o", ".pio/build/app/src/task_blink.o", ".pio/build/app/src/task_connect.o", ".pio/build/app/src/task_upgrade.o", ".pio/build/app/src/user_main.o"])
======================================================================================= [SUCCESS] Took 20.95 seconds =======================================================================================
hijacking-server <redacted>$ npm install
npm WARN vesync-ws@1.0.0 No description
npm WARN vesync-ws@1.0.0 No repository field.

added 143 packages from 144 contributors and audited 143 packages in 1.946s
found 9 vulnerabilities (5 low, 1 moderate, 3 high)
  run `npm audit fix` to fix them, or `npm audit` for details

cp ../bootstrap-firmware/.pio/build/app/user*.bin assets/
brilthor commented 3 years ago

tried building under a linux environment and got identical binaries:

[<redacted>@<redacted> bootstrap-firmware]$ md5sum .pio/build/app/*
1788b814616db014e04a148e09258c04  .pio/build/app/firmware.elf
md5sum: .pio/build/app/src: Is a directory
2cf8620c715fd44ee4ac6afaf3ece17d  .pio/build/app/user1.bin
1788b814616db014e04a148e09258c04  .pio/build/app/user1.elf
89d9279b199f20c57b6f5f874247e9d9  .pio/build/app/user2.bin
1788b814616db014e04a148e09258c04  .pio/build/app/user2.elf
adapt0 commented 3 years ago

Thanks. Took a look and the image's CRC aren't matching up:

flash_crc = 2746132336
img_crc = 1548834960
upgrade_check
cs_switch_on_upgrade_completed, result:1

These should match.

I'm also able to reproduce this locally; where new build today have a mismatched CRC, so it seems likely that my original images got "lucky" with the CRC calc. Just had another look at the ESP8266's SDK and tweaked the CRC algorithm accordingly (SDK's is framework-esp8266-rtos-sdk/tools/gen_appbin.py) to get them to match up.

Unfortunately this just raises a second more severe problem where the device hangs after jumping into the new bootstrap image. Let me debug that a bit more before pushing the CRC stuff. I'm guessing the layout has probably been changed with the latest SDKs.

adapt0 commented 3 years ago

Ah, pio won't let me inject the linker script via LDSCRIPT_PATH any more, so added a quick hack to user_bins.py to replaces the linker scripts. This results in the bootstrap firmware being built with the correct memory addresses. Also added a couple of asserts in the script in case this happens again.

Have pushed these changes (CRC + linker script + other tweaks) to master and I'm now able to hijack my ESP8266 1.89 FW in either user1 or user2.

brilthor commented 3 years ago

rebuilt with updates and that did it for me, thanks for the fix!