HomeACcessoryKid / life-cycle-manager

Initial install, WiFi settings and over the air firmware upgrades for any esp-open-rtos repository on GitHub
Apache License 2.0
60 stars 11 forks source link

No Update over OTA #12

Closed AchimPieters closed 5 years ago

AchimPieters commented 5 years ago

@HomeACcessoryKid at first great job on this LCM :+1:

But unfortunately I have a question about the update when releasing a new versions of my software. let's go step by step;

  1. esptool.py erase_flash
  2. esptool.py -p /dev/cu.usbserial-A50285BI --baud 115200 write_flash -fs 1MB -fm dout -ff 40m 0x0 rboot.bin 0x1000 blank_config.bin 0x2000 otaboot.bin
  3. Then I reset the ESP, hereafter the LCMXXX appears and try to connect, unfortunately the first time it never works? :hushed: 4.Reset the ESP again, connect to LCMXXX and now I can add the WIFI Password and the url to my git where the .bin is located. Everything runs well, after installing my bin file, I can connect My homekit device.

Now I have added the code necessary to update the firmware when I release a new one on my git(see code below).

#include <stdio.h>
#include <stdlib.h>
#include <espressif/esp_common.h>
#include "rboot-api.h" //LCM
#include <esp/uart.h>
#include <esp8266.h>
#include <FreeRTOS.h>
#include <task.h>

#include <homekit/homekit.h>
#include <homekit/characteristics.h>
#include <wifi_config.h>

#include "button.h"

// The GPIO pin that is connected to the relay on the Sonoff Basic.
const int relay_gpio = 12;
// The GPIO pin that is connected to the LED on the Sonoff Basic.
const int led_gpio = 2;
// The GPIO pin that is oconnected to the button on the Sonoff Basic.
const int BUTTON_GPIO = 4;

void switch_on_callback(homekit_characteristic_t *_ch, homekit_value_t on, void *context);

void relay_write(bool on) {
        gpio_write(relay_gpio, on ? 1 : 0);
}

void led_write(bool on) {
        gpio_write(led_gpio, on ? 0 : 1);
}

void device_restart_task() {
    vTaskDelay(5500 / portTICK_PERIOD_MS);

        wifi_config_reset();
        printf("Reset Wifi\n");
        vTaskDelay(200 / portTICK_PERIOD_MS);

        rboot_set_temp_rom(1);
        printf("set temp rom\n");
        vTaskDelay(150 / portTICK_PERIOD_MS);

    sdk_system_restart();

    vTaskDelete(NULL);
}

void device_restart() {
    printf("HomeKit Device > Restarting...\n");
    xTaskCreate(device_restart_task, "device_restart_task", configMINIMAL_STACK_SIZE, NULL, 1, NULL);
}

homekit_characteristic_t switch_on = HOMEKIT_CHARACTERISTIC_(
        ON, false, .callback=HOMEKIT_CHARACTERISTIC_CALLBACK(switch_on_callback)
        );

void gpio_init() {
        gpio_enable(led_gpio, GPIO_OUTPUT);
        led_write(false);
        gpio_enable(relay_gpio, GPIO_OUTPUT);
        relay_write(switch_on.value.bool_value);
}

void switch_on_callback(homekit_characteristic_t *_ch, homekit_value_t on, void *context) {
        relay_write(switch_on.value.bool_value);
}

void idle_task(void* arg) {
        while (true) {
                vTaskDelay(1000 / portTICK_PERIOD_MS);
        }

        vTaskDelete(NULL);
}

void button_callback(button_event_t event, void* context) {
        switch (event) {
        case button_event_single_press:
                printf("Toggling relay\n");
                switch_on.value.bool_value = !switch_on.value.bool_value;
                relay_write(switch_on.value.bool_value);
                homekit_characteristic_notify(&switch_on, switch_on.value);
                break;
        case button_event_long_press:
                device_restart();
                break;
        default:
                printf("Unknown button event: %d\n", event);
        }
}

void switch_identify_task(void *_args) {
        // We identify the Sonoff by Flashing it's LED.
        for (int i=0; i<3; i++) {
                for (int j=0; j<2; j++) {
                        led_write(true);
                        vTaskDelay(100 / portTICK_PERIOD_MS);
                        led_write(false);
                        vTaskDelay(100 / portTICK_PERIOD_MS);
                }

                vTaskDelay(250 / portTICK_PERIOD_MS);
        }

        led_write(false);

        vTaskDelete(NULL);
}

void switch_identify(homekit_value_t _value) {
        printf("Switch identify\n");
        xTaskCreate(switch_identify_task, "Switch identify", 128, NULL, 2, NULL);
}

homekit_characteristic_t name = HOMEKIT_CHARACTERISTIC_(NAME, "Switch");

homekit_accessory_t *accessories[] = {
        HOMEKIT_ACCESSORY(.id=1, .category=homekit_accessory_category_switch, .services=(homekit_service_t*[]){
                HOMEKIT_SERVICE(ACCESSORY_INFORMATION, .characteristics=(homekit_characteristic_t*[]){
                        &name,
                        HOMEKIT_CHARACTERISTIC(MANUFACTURER, "Nono"),
                        HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "037A2BABF19D"),
                        HOMEKIT_CHARACTERISTIC(MODEL, "Basic Switch"),
                        HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "0.1.6"),
                        HOMEKIT_CHARACTERISTIC(IDENTIFY, switch_identify),
                        NULL
                }),
                HOMEKIT_SERVICE(SWITCH, .primary=true, .characteristics=(homekit_characteristic_t*[]){
                        HOMEKIT_CHARACTERISTIC(NAME, "Switch"),
                        &switch_on,
                        NULL
                }),
                NULL
        }),
        NULL
};

homekit_server_config_t config = {
        .accessories = accessories,
        .password = "558-98-144",
        .setupId="7SW9",
};

void on_wifi_ready() {
        homekit_server_init(&config);
}

void create_accessory_name() {
        uint8_t macaddr[6];
        sdk_wifi_get_macaddr(STATION_IF, macaddr);

        int name_len = snprintf(NULL, 0, "Switch-%02X%02X%02X",
                                macaddr[3], macaddr[4], macaddr[5]);
        char *name_value = malloc(name_len+1);
        snprintf(name_value, name_len+1, "Switch-%02X%02X%02X",
                 macaddr[3], macaddr[4], macaddr[5]);

        name.value = HOMEKIT_STRING(name_value);
}

void user_init(void) {
        uart_set_baud(0, 115200);

        create_accessory_name();

        wifi_config_init("switch", NULL, on_wifi_ready);
        gpio_init();

        button_config_t button_config = BUTTON_CONFIG(
                .active_level=button_active_low,
                );

        int r = button_create(BUTTON_GPIO, button_config, button_callback, NULL);
        if (r) {
                printf("Failed to initalize button (code %d)\n", r);
        }

        printf("Button example\n");

        xTaskCreate(idle_task, "Idle task", 256, NULL, tskIDLE_PRIORITY, NULL);
}

The reset of the Wifi is going as it should. I can access LCMXXX to select my Wifi and add the Password. (monitor output: see below )

HomeKit Device > Restarting...
Reset Wifi
set temp rom
rm match
del if0
usl
sul 0 0
Task stack overflow (high water mark=0 name="device_restart_")
!!! HomeKit: [Client 6] Error reading data from socket (code 113). Disconnecting
!!! HomeKit: [Client 4] Error reading data from socket (code 113). Disconnecting
!!! HomeKit: [Client 5] Error reading data from socket (code 113). Disconnecting
>>> HomeKit: [Client 6] Closing client connection
>>> HomeKit: [Client 4] Closing client connection
>>> HomeKit: [Client 5] Closing client connection

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

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.
WA�l⸮⸮l⸮⸮⸮n⸮n⸮⸮<⸮n⸮⸮#⸮n⸮⸮!⸮8n⸮⸮⸮�⸮|⸮r⸮⸮⸮⸮⸮;r⸮�r⸮blrpp_task_hdl : 3ffefac8, prio:14, stack:512
pm_task_hdl : 3ffef530, prio:1, stack:176
frc2_timer_task_hdl:0x3fff4780, prio:12, stack:200

ESP-Open-SDK ver: 0.0.1 compiled @ Jan  5 2019 17:14:12
phy ver: 273, pp ver: 8.3

user-init-start
>>> wifi_config: Initializing WiFi config
>>> wifi_config: wifi_config_station_connect: No configuration found
user-init-done
mode : sta(5c:cf:7f:b8:d6:1d)
add if0

LifeCycleManager version 1.0.0
Will start Wifi AP for config if no input in 5 seconds
Press <enter> to begin
Too Late, Typo? Just restart
scandone
add 0
aid 3
cnt 

connected with AirPort Network, channel 1
dhcp client start...
ip:192.168.178.27,mask:255.255.255.0,gw:192.168.178.1
>>> wifi_config: wifi_config_station_connect: No configuration found
>>> wifi_config: Starting AP mode
mode : sta(5c:cf:7f:b8:d6:1d) + softAP(5e:cf:7f:b8:d6:1d)
add if1
bcn 100
Function called without core lock
>>> wifi_config: wifi_config_softap_start: Starting AP SSID=LCM-B8D61D
bcn 0
del if1
add if1
bcn 100
>>> wifi_config: Starting WiFi scan
>>> wifi_config: Starting DHCP server
>>> wifi_config: Starting DNS server
>>> wifi_config: Starting HTTP server

when this is done I can see this in the monitor:

connected with AirPort Network, channel 1
dhcp client start...
ip:192.168.178.27,mask:255.255.255.0,gw:192.168.178.1
>>> wifi_config: wifi_config_sta_connect_timeout_callback: Successfully connected
wifiready-done
--- ota_boot...1
OTAMAIN VERSION: 1.0.0
--- ota_init
userbeta='0' otabeta='0'
Function called without core lock
Function called without core lock
Function called without core lock
Function called without core lock
Function called without core lock
Function called without core lock
Function called without core lock
Function called without core lock
Function called without core lock
Function called without core lock
Function called without core lock
active_sector: 0xfa000
--- ota_set_verify...OFF
--- DNS: done!
active_cert_sector: 0xfa000
--- ota_get_pubkey
 04 94 30 cc 5c 4e 50 29 15 ff 3d 41 da e9 e5 e3 64 27 b3 96 07 61 36 a4 83 28 4d fd f9 05 4f 0d 82 fa 57 26 06 b7 e8 1f 22 2d 2b 8a d2 ff 6e ac 59 73 00 b5 e4 9c 5f 68 ab 31 d3 9f ad bb 3d c8 4f 6d 38 e6 6f b8 b3 f7 22 21 b7 f2 e4 b7 75 ed 09 2c 87 2b 00 56 5b 81 e8 64 5c 2c 84 85 c0 3c 34
ret: 0
--- ota_get_privkey
--- ota_boot...1
--- ota_load_user_app
user_repo='AchimPieters/ESP8266-Update' user_version='V0.0.1' user_file='main.bin'
--- ota_boot...1
--- entering the loop
>>> wifi_config: Stopping DNS server
--- ota_get_pubkey
 04 94 30 cc 5c 4e 50 29 15 ff 3d 41 da e9 e5 e3 64 27 b3 96 07 61 36 a4 83 28 4d fd f9 05 4f 0d 82 fa 57 26 06 b7 e8 1f 22 2d 2b 8a d2 ff 6e ac 59 73 00 b5 e4 9c 5f 68 ab 31 d3 9f ad bb 3d c8 4f 6d 38 e6 6f b8 b3 f7 22 21 b7 f2 e4 b7 75 ed 09 2c 87 2b 00 56 5b 81 e8 64 5c 2c 84 85 c0 3c 34
ret: 0
--- ota_set_verify...OFF
--- ota_get_version
--- ota_connect LocalPort=f603 DNS IP:140.82.118.3 local..OK remote..OK SSL..OK set_fd to github.com port 443..failed, return [-0x1]
wolfSSL_send error = -112
--- ota_boot...1
HomeACcessoryKid/life-cycle-manager@version:"Fatal exception (28): 
epc1=0x402c3940
epc2=0x00000000
epc3=0x4028f080
excvaddr=0x00000000
depc=0x00000000
excsave1=0x4029d921
Registers:
a0 4029d921 a1 3fffdd10 a2  00000000 a3  00000000
a4  ffffffff a5  401065b4 a6  3fffddc0 a7  0000002d
a8  3fffdda3 a9  000000b0 a10 402c4a27 a11 0000000a
a12 00000000 a13 3fff23dc SAR 00000010

Stack: SP=0x3fffdd10

Free Heap: 12468
_heap_start 0x3fff2600 brk 0x3fffffc8 supervisor sp 0x40000000 sp-brk 56 bytes
arena (total_size) 55752 fordblks (free_size) 12412 uordblocks (used_size) 43340

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

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 : 3ffeff50, prio:14, stack:512
pm_task_hdl : 3ffef840, prio:1, stack:176
frc2_timer_task_hdl:0x3fff3eb0, prio:12, stack:200

ESP-Open-SDK ver: 0.0.1 compiled @ Aug 11 2019 14:49:09
phy ver: 273, pp ver: 8.3

>>> wifi_config: Initializing WiFi config
>>> wifi_config: Found configuration, connecting to AirPort Network
Button example
mode : sta(5c:cf:7f:b8:d6:1d)
add if0
scandone
add 0
aid 3
cnt 

connected with AirPort Network, channel 1
dhcp client start...
ip:192.168.178.27,mask:255.255.255.0,gw:192.168.178.1
>>> wifi_config: wifi_config_sta_connect_timeout_callback: Successfully connected
>>> HomeKit: Starting server
>>> HomeKit: Using existing accessory ID: 28:D8:5F:2F:5A:52
>>> HomeKit: Found admin pairing with D8738893-A2E2-4AA2-8E70-AC3C7ED75F9D, disabling pair setup
>>> HomeKit: Configuring mDNS
mDNS announcement: Name=Switch-B8D61D-28D8 md=Basic Switchpv=1.0id=28:D8:5F:2F:5A:52c#=1s#=1ff=0sf=0ci=8sh=Mpl6YQ== Port=5556 TTL=4500

and I'm back where I started... :astonished:

I can't figure out what I'm doing wrong, can or would you help solving this puzzle please :pray:

HomeACcessoryKid commented 5 years ago

I highly suspect that using the V in the version is what is wrong. My code expects x.y.z and not Vx.y.z

Please try and see?

On 11 Aug 2019, at 18:09, Achim Pieters notifications@github.com wrote:

user_repo='AchimPieters/ESP8266-Update' user_version='V0.0.1' user_file='main.bin'

AchimPieters commented 5 years ago

@HomeACcessoryKid

Thank you for your quick reply!

I have changed my git .bin versions numbers from v0.0.1 to 0.0.1( see my git here: https://github.com/AchimPieters/ESP8266-Update/releases) Then to be sure I starten the whole process from he beginning as described above. Unfortnally it wasn't the fix..

HomeKit Device > Restarting...
Reset Wifi
set temp rom
rm match
del if0
usl
sul 0 0
!!! HomeKit: [Client 4] Error reading data from socket (code 113). Disconnecting
>>> HomeKit: [Client 4] Closing client connection

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

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.
WA⸮l|⸮⸮⸮l⸮⸮⸮n⸮n⸮⸮<⸮n⸮⸮#⸮n⸮⸮!⸮8n⸮⸮⸮⸮|⸮r⸮⸮⸮⸮⸮;r⸮r⸮blrpp_task_hdl : 3ffefac8, prio:14, stack:512
pm_task_hdl : 3ffef530, prio:1, stack:176
frc2_timer_task_hdl:0x3fff4780, prio:12, stack:200

ESP-Open-SDK ver: 0.0.1 compiled @ Jan  5 2019 17:14:12
phy ver: 273, pp ver: 8.3

user-init-start
>>> wifi_config: Initializing WiFi config
>>> wifi_config: wifi_config_station_connect: No configuration found
user-init-done
mode : sta(5c:cf:7f:b8:d6:1d)
add if0

LifeCycleManager version 1.0.0
Will start Wifi AP for config if no input in 5 seconds
Press <enter> to begin
Too Late, Typo? Just restart
scandone
add 0
aid 3
cnt 

connected with AirPort Network, channel 1
dhcp client start...
ip:192.168.178.27,mask:255.255.255.0,gw:192.168.178.1
>>> wifi_config: wifi_config_station_connect: No configuration found
>>> wifi_config: Starting AP mode
mode : sta(5c:cf:7f:b8:d6:1d) + softAP(5e:cf:7f:b8:d6:1d)
add if1
bcn 100
Function called without core lock
>>> wifi_config: wifi_config_softap_start: Starting AP SSID=LCM-B8D61D
bcn 0
del if1
add if1
bcn 100
>>> wifi_config: Starting WiFi scan
>>> wifi_config: Starting DHCP server
>>> wifi_config: Starting DNS server
>>> wifi_config: Starting HTTP server
scandone
beacon timeout
rm match
scandone
add 0
aid 1
cnt 

connected with AirPort Network, channel 11
dhcp client start...
ip:192.168.178.27,mask:255.255.255.0,gw:192.168.178.1
add 1
aid 1
station: 3c:15:c2:bd:6f:9e join, AID = 1
>>> wifi_config: http_task: Got 64 incoming data
!!! wifi_config: Unknown endpoint: GET /hotspot-detect.html
>>> wifi_config: http_task: Got 64 incoming data
>>> wifi_config: http_task: Got 4 incoming data
>>> wifi_config: wifi_config_server_on_message_complete: Unknown endpoint
>>> wifi_config: client_send_redirect: Redirecting to http://192.168.4.1/settings
>>> wifi_config: Client disconnected
>>> wifi_config: http_task: Got 64 incoming data
>>> wifi_config: http_task: Got 51 incoming data
>>> wifi_config: Client disconnected
>>> wifi_config: http_task: Got 64 incoming data
!!! wifi_config: Unknown endpoint: GET /hotspot-detect.html
>>> wifi_config: http_task: Got 64 incoming data
>>> wifi_config: http_task: Got 64 incoming data
>>> wifi_config: http_task: Got 64 incoming data
>>> wifi_config: http_task: Got 64 incoming data
>>> wifi_config: http_task: Got 27 incoming data
>>> wifi_config: wifi_config_server_on_message_complete: Unknown endpoint
>>> wifi_config: client_send_redirect: Redirecting to http://192.168.4.1/settings
>>> wifi_config: Client disconnected
>>> wifi_config: http_task: Got 64 incoming data
>>> wifi_config: http_task: Got 64 incoming data
>>> wifi_config: http_task: Got 64 incoming data
>>> wifi_config: http_task: Got 64 incoming data
>>> wifi_config: http_task: Got 64 incoming data
>>> wifi_config: http_task: Got 10 incoming data
scandone
>>> wifi_config: Client disconnected
>>> wifi_config: http_task: Got 64 incoming data
!!! wifi_config: Unknown endpoint: GET /hotspot-detect.html
>>> wifi_config: http_task: Got 64 incoming data
>>> wifi_config: http_task: Got 4 incoming data
>>> wifi_config: wifi_config_server_on_message_complete: Unknown endpoint
>>> wifi_config: client_send_redirect: Redirecting to http://192.168.4.1/settings
>>> wifi_config: Client disconnected
>>> wifi_config: http_task: Got 64 incoming data
>>> wifi_config: http_task: Got 51 incoming data
>>> wifi_config: Client disconnected
scandone
>>> wifi_config: http_task: Got 64 incoming data
>>> wifi_config: http_task: Got 64 incoming data
>>> wifi_config: http_task: Got 64 incoming data
>>> wifi_config: http_task: Got 64 incoming data
>>> wifi_config: http_task: Got 64 incoming data
>>> wifi_config: http_task: Got 64 incoming data
>>> wifi_config: http_task: Got 64 incoming data
>>> wifi_config: http_task: Got 62 incoming data
>>> wifi_config: wifi_config_server_on_settings_update: Update settings, body = ssid=AirPort+Network&password=XXXXXXXXXXXX
>>> wifi_config: Found configuration, connecting to AirPort Network
station: 3c:15:c2:bd:6f:9e leave, AID = 1
rm match
bcn 0
del if1
mode : sta(5c:cf:7f:b8:d6:1d)
Function called without core lock
scandone
reconnect
rm match
scandone
beacon timeout
scandone
add 0
aid 3
cnt 

connected with AirPort Network, channel 1
dhcp client start...
ip:192.168.178.27,mask:255.255.255.0,gw:192.168.178.1
>>> wifi_config: wifi_config_sta_connect_timeout_callback: Successfully connected
wifiready-done
--- ota_boot...1
OTAMAIN VERSION: 1.0.0
--- ota_init
userbeta='0' otabeta='0'
Function called without core lock
Function called without core lock
Function called without core lock
Function called without core lock
Function called without core lock
Function called without core lock
Function called without core lock
Function called without core lock
Function called without core lock
Function called without core lock
Function called without core lock
active_sector: 0xfa000
--- ota_set_verify...OFF
--- DNS: done!
active_cert_sector: 0xfa000
--- ota_get_pubkey
 04 94 30 cc 5c 4e 50 29 15 ff 3d 41 da e9 e5 e3 64 27 b3 96 07 61 36 a4 83 28 4d fd f9 05 4f 0d 82 fa 57 26 06 b7 e8 1f 22 2d 2b 8a d2 ff 6e ac 59 73 00 b5 e4 9c 5f 68 ab 31 d3 9f ad bb 3d c8 4f 6d 38 e6 6f b8 b3 f7 22 21 b7 f2 e4 b7 75 ed 09 2c 87 2b 00 56 5b 81 e8 64 5c 2c 84 85 c0 3c 34
ret: 0
--- ota_get_privkey
--- ota_boot...1
--- ota_load_user_app
user_repo='AchimPieters/ESP8266-Update' user_version='V0.0.1' user_file='main.bin'
--- ota_boot...1
--- entering the loop
--- ota_get_pubkey
 04 94 30 cc 5c 4e 50 29 15 ff 3d 41 da e9 e5 e3 64 27 b3 96 07 61 36 a4 83 28 4d fd f9 05 4f 0d 82 fa 57 26 06 b7 e8 1f 22 2d 2b 8a d2 ff 6e ac 59 73 00 b5 e4 9c 5f 68 ab 31 d3 9f ad bb 3d c8 4f 6d 38 e6 6f b8 b3 f7 22 21 b7 f2 e4 b7 75 ed 09 2c 87 2b 00 56 5b 81 e8 64 5c 2c 84 85 c0 3c 34
ret: 0
--- ota_set_verify...OFF
--- ota_get_version
--- ota_connect LocalPort=f271 DNS IP:140.82.118.4 local..OK remote..OK SSL..OK set_fd to github.com port 443..failed, return [-0x1]
wolfSSL_send error = -112
--- ota_boot...1
HomeACcessoryKid/life-cycle-manager@version:"Fatal exception (28): 
epc1=0x402c3940
epc2=0x00000000
epc3=0x402d0da8
excvaddr=0x00000000
depc=0x00000000
excsave1=0x4029d921
Registers:
a0 4029d921 a1 3fffdf90 a2  00000000 a3  00000000
a4  ffffffff a5  401065b4 a6  3fffe040 a7  0000002d
a8  3fffe023 a9  000000b0 a10 402c4a27 a11 0000000a
a12 00000000 a13 3fff23dc SAR 00000019

Stack: SP=0x3fffdf90

Free Heap: 12528
_heap_start 0x3fff2600 brk 0x3fffffc0 supervisor sp 0x40000000 sp-brk 64 bytes
arena (total_size) 55744 fordblks (free_size) 12464 uordblocks (used_size) 43280

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

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 : 3ffeff50, prio:14, stack:512
pm_task_hdl : 3ffef840, prio:1, stack:176
frc2_timer_task_hdl:0x3fff3eb0, prio:12, stack:200

ESP-Open-SDK ver: 0.0.1 compiled @ Aug 11 2019 14:49:09
phy ver: 273, pp ver: 8.3

>>> wifi_config: Initializing WiFi config
>>> wifi_config: Found configuration, connecting to AirPort Network
Button example
mode : sta(5c:cf:7f:b8:d6:1d)
add if0
scandone
add 0
aid 3
cnt 

connected with AirPort Network, channel 1
dhcp client start...
ip:192.168.178.27,mask:255.255.255.0,gw:192.168.178.1
>>> wifi_config: wifi_config_sta_connect_timeout_callback: Successfully connected
>>> HomeKit: Starting server
>>> HomeKit: Using existing accessory ID: C8:34:82:BD:F0:61
>>> HomeKit: Found admin pairing with D8738893-A2E2-4AA2-8E70-AC3C7ED75F9D, disabling pair setup
>>> HomeKit: Configuring mDNS
mDNS announcement: Name=Switch-B8D61D-C834 md=Basic Switchpv=1.0id=C8:34:82:BD:F0:61c#=1s#=1ff=0sf=0ci=8sh=lkk02g== Port=5556 TTL=4500

Any other suggestions :neutral_face:

HomeACcessoryKid commented 5 years ago

The issue concentrates on this part

--- ota_get_version --- ota_connect LocalPort=f271 DNS IP:140.82.118.4 local..OK remote..OK SSL..OK set_fd to github.com http://github.com/ port 443..failed, return [-0x1] wolfSSL_send error = -112 --- ota_boot...1 HomeACcessoryKid/life-cycle-manager@version:"Fatal exception (28):

ota_get_version calls ota_connect and because ota_connect did not deliver a ota_version the next step

"if (ota_boot() && ota_compare(version,OTAVERSION)<0) { //this acts when setting up a new version”

is going to have a NULL version pointer but ota_boot prevents ota_compare to happen but next

"UDPLGP("%s@version:\"%s\"\n",repo,version); “ will crash on that

Now the question is what makes this error -112 happen?

The wolfssl error given is this: -112 mp_exptmod error state

Can you indicate since when you have this, how often you could reproduce it, over which amount of time etc…

I actually had an issue where “it” all didn’t work and then 3 hours laters, no more issue Maybe Github servers are having a bad day...

Another line of brainstorming is that I never actually tried to do what you seem to do which is to combine the Wifi setup with the OTAMAIN running from boot1. Maybe there is some memory issue which otherwise never occurs. This is what I have for now. What do you say?

HomeACcessoryKid commented 5 years ago

for the record, your 0.0.2 version is still pre-release so the test is not a new test but then, the issue is not there ;-)

AchimPieters commented 5 years ago

@HomeACcessoryKid

okay let's sum it up:

  1. Can you indicate since when you have this, how often you could reproduce it, over which amount of time etc… I can reproduce it every time, over and over again.

  2. I actually had an issue where “it” all didn’t work and then 3 hours laters, no more issue Maybe Github servers are having a bad day... I'll gonna try tomorrow evening after work, to see if anything has changed.

  3. Another line of brainstorming is that I never actually tried to do what you seem to do which is to combine the Wifi setup with the OTAMAIN running from boot1. Maybe there is some memory issue which otherwise never occurs. _So if I understand right, your advise is to remove #include <wifi_config.h> and try again, to see if anything changes?_

  4. your 0.0.2 version is still pre-release. Yes, I changed that for testing purpose. :grin:

So I'm going to test some of these options tomorrow, I'll keep you updated! giphy

AchimPieters commented 5 years ago

@HomeACcessoryKid

  1. Okay I have tried to update de firmware that I made yesterday, but it still doesn't work.
  2. does't work either?

Let's refraise my question: how would you do it in the code above? :flushed:

HomeACcessoryKid commented 5 years ago

Just for completeness: In one2one contact it was revealed that the source of the issue was based on missing instructions how to apply this in a esp-homekit repository.

I have created a folder with such instructions which led to the closure of the issue... enjoy