Open-Smartwatch/open-smartwatch-os

Display won't come on/stay on after enablng SERVICE_BLE_COMPANION

Closed this issue · 7 comments

What is not working?

Enabling SERVICE_BLE_COMPANION in config.h results in display issues where the display briefly comes on but goes to black.

How to reproduce this

Steps to reproduce the behavior:

  1. uncomment and set SERVICE_BLE_COMPANION to '1' in config.h
  2. build and upload firmware to open smartwatch
  3. detach USB and touch reset button at least once to bring up watch
  4. observe brief display before going black again

What should happen instead?

Display should come on and remain on until timeout.

Environment

  • Light Edition
  • master branch of open-smartwatch-os, with config.h changed as usual

Additional context

none

I have this exact same problem. I'm attempting to debug it a bit but I've never done this before. When I enable SERVICE_BLE_COMPANION and then execute Project Task > LIGHT_EDITION_V3_3 > General > Upload and Monitor I get the following:

> Executing task: platformio run --target upload --target monitor --environment LIGHT_EDITION_V3_3 <

Processing LIGHT_EDITION_V3_3 (platform: espressif32; board: pico32; framework: arduino)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/pico32.html
PLATFORM: Espressif 32 (3.4.0) > ESP32 Pico Kit
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: 
 - framework-arduinoespressif32 3.10006.210326 (1.0.6) 
 - tool-esptoolpy 1.30100.210531 (3.1.0) 
 - tool-mkspiffs 2.230.0 (2.30) 
 - toolchain-xtensa32 2.50200.97 (5.2.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 45 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <BME280> 3.0.0
|   |-- <Wire> 1.0.1
|   |-- <SPI> 1.0
|-- <QMC5883LCompass> 1.1.1
|   |-- <Wire> 1.0.1
|-- <Adafruit Unified Sensor> 1.1.4
|-- <Adafruit BME280 Library> 2.2.1
|   |-- <Adafruit BusIO> 1.9.8
|   |   |-- <Wire> 1.0.1
|   |   |-- <SPI> 1.0
|   |-- <Wire> 1.0.1
|   |-- <SPI> 1.0
|   |-- <Adafruit Unified Sensor> 1.1.4
|-- <Adafruit BusIO> 1.9.8
|   |-- <Wire> 1.0.1
|   |-- <SPI> 1.0
|-- <RTC> 2.3.5
|   |-- <SPI> 1.0
|-- <ArduinoJson> 6.18.5
|-- <Lib Open-Smartwatch> 1.0.0
|   |-- <GFX Library for Arduino> 1.1.5
|   |   |-- <SPI> 1.0
|-- <mini-wifi> 2.0.1
|   |-- <HTTPClient> 1.2
|   |   |-- <WiFi> 1.0
|   |   |-- <WiFiClientSecure> 1.0
|   |   |   |-- <WiFi> 1.0
|   |-- <WiFi> 1.0
|-- <AnimatedGIF> 1.3.2
|-- <mini-iot-client> 1.0.3
|   |-- <HTTPClient> 1.2
|   |   |-- <WiFi> 1.0
|   |   |-- <WiFiClientSecure> 1.0
|   |   |   |-- <WiFi> 1.0
|   |-- <WiFi> 1.0
|-- <FS> 1.0
|-- <SD(esp32)> 1.0.5
|   |-- <FS> 1.0
|   |-- <SPI> 1.0
|-- <ESP32 BLE Keyboard> 0.2.2
|   |-- <ESP32 BLE Arduino> 1.0.1
|-- <BMA400-API>
|-- <GFX Library for Arduino> 1.1.5
|   |-- <SPI> 1.0
|-- <pngle>
|-- <NeoGPS> 4.2.9
|-- <SPI> 1.0
|-- <Wire> 1.0.1
|-- <Preferences> 1.0
|-- <LUA>
|-- <WebServer> 1.0
|   |-- <WiFi> 1.0
|   |-- <FS> 1.0
|-- <ESP32 BLE Arduino> 1.0.1
|-- <HTTPClient> 1.2
|   |-- <WiFi> 1.0
|   |-- <WiFiClientSecure> 1.0
|   |   |-- <WiFi> 1.0
|-- <Update> 1.0
|-- <ESPmDNS> 1.0
|   |-- <WiFi> 1.0
|-- <WiFi> 1.0
|-- <SPIFFS> 1.0
|   |-- <FS> 1.0
Building in release mode
Compiling .pio/build/LIGHT_EDITION_V3_3/src/services/OswServiceTaskWebserver.cpp.o
Linking .pio/build/LIGHT_EDITION_V3_3/firmware.elf
Retrieving maximum program size .pio/build/LIGHT_EDITION_V3_3/firmware.elf
Checking size .pio/build/LIGHT_EDITION_V3_3/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [==        ]  17.6% (used 57556 bytes from 327680 bytes)
Flash: [==========]  97.9% (used 1924040 bytes from 1966080 bytes)
Building .pio/build/LIGHT_EDITION_V3_3/firmware.bin
esptool.py v3.1
Merged 1 ELF section
Configuring upload protocol...
AVAILABLE: esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = esptool
Looking for upload port...
Auto-detected: /dev/ttyUSB0
Uploading .pio/build/LIGHT_EDITION_V3_3/firmware.bin
esptool.py v3.1
Serial port /dev/ttyUSB0
Connecting....
Chip is ESP32-PICO-D4 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, Embedded Flash, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 98:cd:ac:d0:81:1c
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Flash will be erased from 0x00001000 to 0x00005fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x001e5fff...
Compressed 17104 bytes to 11191...
Writing at 0x00001000... (100 %)
Wrote 17104 bytes (11191 compressed) at 0x00001000 in 0.5 seconds (effective 273.7 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 129...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (129 compressed) at 0x00008000 in 0.0 seconds (effective 499.5 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 693.0 kbit/s)...
Hash of data verified.
Compressed 1924288 bytes to 1189654...
Writing at 0x00010000... (1 %)
Writing at 0x0001484d... (2 %)
Writing at 0x00018b94... (4 %)
Writing at 0x0001cb8c... (5 %)
Writing at 0x00020b87... (6 %)
Writing at 0x00024b82... (8 %)
Writing at 0x00028b7d... (9 %)
Writing at 0x0002e05b... (10 %)
Writing at 0x00039b05... (12 %)
Writing at 0x00043d2c... (13 %)
Writing at 0x00051743... (15 %)
Writing at 0x0005c417... (16 %)
Writing at 0x00069d84... (17 %)
Writing at 0x00080254... (19 %)
Writing at 0x00085ba4... (20 %)
Writing at 0x0008ba10... (21 %)
Writing at 0x0009218c... (23 %)
Writing at 0x00097b83... (24 %)
Writing at 0x0009e1d8... (26 %)
Writing at 0x000a3f27... (27 %)
Writing at 0x000a950d... (28 %)
Writing at 0x000ae607... (30 %)
Writing at 0x000b3aa9... (31 %)
Writing at 0x000b8e0c... (32 %)
Writing at 0x000be356... (34 %)
Writing at 0x000c3b85... (35 %)
Writing at 0x000cdd5b... (36 %)
Writing at 0x000d4519... (38 %)
Writing at 0x000d9bd7... (39 %)
Writing at 0x000df466... (41 %)
Writing at 0x000e54ed... (42 %)
Writing at 0x000ebbdb... (43 %)
Writing at 0x000f28a7... (45 %)
Writing at 0x000f8813... (46 %)
Writing at 0x000fe6fd... (47 %)
Writing at 0x00104330... (49 %)
Writing at 0x0010b8af... (50 %)
Writing at 0x001116bf... (52 %)
Writing at 0x00117907... (53 %)
Writing at 0x0011d9a1... (54 %)
Writing at 0x001239ed... (56 %)
Writing at 0x00129ac2... (57 %)
Writing at 0x0012fc30... (58 %)
Writing at 0x0013581b... (60 %)
Writing at 0x0013b3f0... (61 %)
Writing at 0x0014166f... (63 %)
Writing at 0x00147839... (64 %)
Writing at 0x0014d57d... (65 %)
Writing at 0x00152e22... (67 %)
Writing at 0x00158785... (68 %)
Writing at 0x0015e2e9... (69 %)
Writing at 0x00163c38... (71 %)
Writing at 0x00169875... (72 %)
Writing at 0x0016f69c... (73 %)
Writing at 0x001758ea... (75 %)
Writing at 0x0017b926... (76 %)
Writing at 0x001812fe... (78 %)
Writing at 0x0018756f... (79 %)
Writing at 0x0018dceb... (80 %)
Writing at 0x00193a09... (82 %)
Writing at 0x00199e40... (83 %)
Writing at 0x0019ff9d... (84 %)
Writing at 0x001a5b2f... (86 %)
Writing at 0x001ab9d6... (87 %)
Writing at 0x001b12db... (89 %)
Writing at 0x001b7023... (90 %)
Writing at 0x001bd139... (91 %)
Writing at 0x001c3bf3... (93 %)
Writing at 0x001ca232... (94 %)
Writing at 0x001d08cc... (95 %)
Writing at 0x001d657e... (97 %)
Writing at 0x001dc088... (98 %)
Writing at 0x001e1bf0... (100 %)
Wrote 1924288 bytes (1189654 compressed) at 0x00010000 in 28.2 seconds (effective 545.9 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
========================================================================= [SUCCESS] Took 42.39 seconds =========================================================================
--- 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 /dev/ttyUSB0  115200,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ets Jun  8 2016 00:22:57
�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:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:10124
load:0x40080400,len:5828
entry 0x400806a8
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 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
include/osw_config.h: Accessing key id h
include/osw_config.h: Accessing key id g
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 s
Config loaded! Version? 2
Boot count? 826
include/osw_config.h: Accessing key id n
Guru Meditation Error: Core  0 panic'ed (StoreProhibited). Exception was unhandled.
Core 0 register dump:
PC      : 0x4000c46c  PS      : 0x00060c30  A0      : 0x80197038  A1      : 0x3fff7bb0  
A2      : 0x00000000  A3      : 0x00000000  A4      : 0x00000798  A5      : 0x00000000  
A6      : 0x00000001  A7      : 0x00000079  A8      : 0x800828b0  A9      : 0x3fff7b50  
A10     : 0x00000000  A11     : 0x00001800  A12     : 0x00000000  A13     : 0x00000003  
A14     : 0x00001800  A15     : 0x3ffc2568  SAR     : 0x00000010  EXCCAUSE: 0x0000001d  
EXCVADDR: 0x00000000  LBEG    : 0x4000c46c  LEND    : 0x4000c477  LCOUNT  : 0x00000078  

ELF file SHA256: 0000000000000000

Backtrace: 0x4000c46c:0x3fff7bb0 0x40197035:0x3fff7bc0 0x4017d147:0x3fff7be0 0x4014f99e:0x3fff7c00 0x4014f9db:0x3fff7c20 0x400917c2:0x3fff7c50

Rebooting...

--- exit ---

Environment         Status    Duration
------------------  --------  ------------
LIGHT_EDITION_V3_3  SUCCESS   00:00:42.394
========================================================================= 1 succeeded in 00:00:42.394 =========================================================================

Terminal will be reused by tasks, press any key to close it.

I tried using 3_2 env, the 3_3 env, and the 4_0 env. they all fail with an unhandled excepetion.

uvwxy commented

Short Answer: BLE does not work.
Long Answer:

The BLE companion was added without testing a while ago.

What I have mentioned a couple of times on discord: the OSW does not have enough RAM to run the BLE Companion and the Display with a full buffer.
BLE leaves 80kb RAM, but we need 120kb RAM for the display data.

You are most likely running into seg faults / memory exceptions.

This is not a bug. The BLE companion is a proof of concept that is still in the code or needs to be adapted, either by reducing the display performance, or new hardware...

Hey, I would leave this open as I plan to look further into it... 🥺

uvwxy commented

Hey, I would leave this open as I plan to look further into it... 🥺

In that case we'd need a full feature, not a bug ticket ;).

just to give you some more room to try this tech demo try calling hal->disableDisplayBuffer(); after hal->setup(...).

If this works you can watch how the watch face is drawn in slow motion and what ever the BLE companion does should do something.

the OSW does not have enough RAM to run the BLE Companion and the Display with a full buffer.
BLE leaves 80kb RAM, but we need 120kb RAM for the display data.

Is this the beginning of a solution? #202