Open-Smartwatch / open-smartwatch-os

The Open-Smartwatch Operating System.
https://open-smartwatch.github.io
GNU General Public License v3.0
993 stars 162 forks source link

Attempting to connect WiFi crashes smartwatch. #260

Closed FranseFrikandel closed 2 years ago

FranseFrikandel commented 2 years ago

What is not working?

Watch crashes when attempting to connect to WiFi.

How to reproduce this

With the watch connected to the PC, platform.io serial monitor running, following steps:

At this point, the watch appears to reset and dumps me back at the watchface. The platform.io serial monitor also crashes. The full log from the serial monitor after following these steps:

--- Available filters and text transformations: colorize, debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at https://bit.ly/pio-monitor-filters
--- Miniterm on COM4  115200,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 188777542, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:12784
load:0x40080400,len:3032
entry 0x400805e4
Welcome to the OSW-OS! This build is based on commit e350e3c from dev. Compiled at Jul 10 2022 20:08:18 for platform LIGHT_EDITION_V3_3.
include/osw_config.h: Accessing key id k
include/osw_config.h: Accessing key id l
include/osw_config.h: Accessing key id s2
include/osw_config.h: Accessing key id s1
include/osw_config.h: Accessing key id s3
include/osw_config.h: Accessing key id s4
include/osw_config.h: Accessing key id h2
include/osw_config.h: Accessing key id g1
include/osw_config.h: Accessing key id m
include/osw_config.h: Accessing key id s5
include/osw_config.h: Accessing key id s6
include/osw_config.h: Accessing key id s8
include/osw_config.h: Accessing key id s7
include/osw_config.h: Accessing key id f
[    83][E][Preferences.cpp:503] getBytesLength(): nvs_get_blob len fail: f NOT_FOUND
include/osw_config.h: Accessing key id h
include/osw_config.h: Accessing key id h1
include/osw_config.h: Accessing key id g
include/osw_config.h: Accessing key id r
include/osw_config.h: Accessing key id c1
include/osw_config.h: Accessing key id c8
include/osw_config.h: Accessing key id c2
include/osw_config.h: Accessing key id c9
include/osw_config.h: Accessing key id c3
include/osw_config.h: Accessing key id c4
include/osw_config.h: Accessing key id c5
include/osw_config.h: Accessing key id c6
include/osw_config.h: Accessing key id c7
include/osw_config.h: Accessing key id f4
include/osw_config.h: Accessing key id f5
include/osw_config.h: Accessing key id f1
include/osw_config.h: Accessing key id f2
include/osw_config.h: Accessing key id f3
include/osw_config.h: Accessing key id o
Config loaded! Version? 2
Boot count? 136
include/osw_config.h: Accessing key id n
[   173][E][Preferences.cpp:483] getString(): nvs_get_str len fail: n NOT_FOUND
src/hal/environment.cpp: Current step history (day 0, today 15167, sum 7) is: {[0], 0, 0, 0, 0, 0, 7}
src/services/OswServiceTaskWiFi.cpp: [Mode] Off
src/services/OswServiceTaskWiFi.cpp: [Station] Disabled.
Setup Done
========= Memory Monitor =========
core 0 (high):  8192B of 8192B
core 1 (high):  1900B of 8192B
heap (high):    274180B of 274180B
heap (curr):    164492B of 274180B
src/services/OswServiceManager.cpp: Background worker started.
src/services/OswServiceTaskWiFi.cpp: [Mode] Off
========= Memory Monitor =========
core 0 (high):  1476B of 8192B
core 1 (high):  1900B of 8192B
heap (high):    205356B of 274180B
heap (curr):    164492B of 274180B
src/services/OswServiceTaskWiFi.cpp: [Mode] Off
include/osw_config.h: Accessing key id i
[ 10914][E][Preferences.cpp:483] getString(): nvs_get_str len fail: i NOT_FOUND
Exception in thread rx:
Traceback (most recent call last):
  File "C:\Users\CRGam\.platformio\python3\lib\threading.py", line 973, in _bootstrap_inner
    self.run()
  File "C:\Users\CRGam\.platformio\python3\lib\threading.py", line 910, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\CRGam\.platformio\penv\lib\site-packages\serial\tools\miniterm.py", line 499, in reader
    data = self.serial.read(self.serial.in_waiting or 1)
  File "C:\Users\CRGam\.platformio\penv\lib\site-packages\serial\serialwin32.py", line 295, in read
    raise SerialException("GetOverlappedResult failed ({!r})".format(ctypes.WinError()))
serial.serialutil.SerialException: GetOverlappedResult failed (PermissionError(13, 'Toegang geweigerd.', None, 5))

What should happen instead?

The WiFi to connect.

Environment

Additional context

Initial discussion in Discord: https://discord.com/channels/673521025593638932/701410676031225957/995727928635699200

FranseFrikandel commented 2 years ago

Looking at the errors that occur in serial monitor:

[    83][E][Preferences.cpp:503] getBytesLength(): nvs_get_blob len fail: f NOT_FOUND
[   173][E][Preferences.cpp:483] getString(): nvs_get_str len fail: n NOT_FOUND
[ 10914][E][Preferences.cpp:483] getString(): nvs_get_str len fail: i NOT_FOUND

These ID's appear to match ID's that are set in src/osw_config_keys.cpp

ID "f" is on line 75, "n" on line 44, "i" on line 23. Each of these seem like they should be set equal to config variables when looking into osw_config_keys.cpp. I believe these variables are also all configurable via the WiFi interface, and so presumably saved in flash memory. Is something going wrong here causing the variables to not exist yet in flash storage and thus causing them to not be found?

FranseFrikandel commented 2 years ago

According to @simonmicro, errors are not related to the watch crashing, and this is simply insufficient power delivery causing the watch to crash as documented in https://open-smartwatch.github.io/resources/hardware/ under known problems.