Skip to content

Commit

Permalink
brownout countermeasures, working coredump
Browse files Browse the repository at this point in the history
  • Loading branch information
Szybet committed Jul 1, 2024
1 parent 2520331 commit 5244f13
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
10 changes: 3 additions & 7 deletions resources/tools/other/debug/getCoreDump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

# This sometimes may not work, try a few times but:

# for sure you need to edit the library
# in /home/szybet/.espressif/python_env/idf5.2_py3.12_env/lib/python3.12/site-packages/esp_coredump/corefile/loader.py
# (your path may be different)
# remove these lines:

# if core_sha_trimmed != app_sha_trimmed:
Expand All @@ -16,17 +14,15 @@
# 'Invalid application image for coredump: coredump SHA256 version({}) != app SHA256 version({}).'
# .format(coredump_sha256.ver, self.version))

# this is only supported on arch linux esp-idf aur package
# In /workspaces/InkWatchy/.esp-idf/espressif/python_env/idf5.1_py3.12_env/lib64/python3.12/site-packages/esp_coredump/corefile/loader.py
# Change ESP_COREDUMP_PART_TABLE_OFF to 0x19000
# And part_table_offset too

source ../../globalFunctions.sh
source ~/.platformio/packages/framework-espidf/export.sh

pio_env=$(get_pio_env ../../../../.vscode/launch.json)

#/root/.platformio/penv/bin/python -m pip install --break-system-packages setuptools

. /workspaces/InkWatchy/.esp-idf/esp-idf/export.sh

#esp-coredump info_corefile ../../../../.pio/build/$pio_env/firmware.elf
#./esp-coredump info_corefile /workspaces/InkWatchy/.pio/build/Watchy_2/firmware.elf
espcoredump.py --chip esp32 info_corefile /workspaces/InkWatchy/.pio/build/Watchy_2/firmware.elf
6 changes: 6 additions & 0 deletions src/hardware/hardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,10 @@ cpuSpeed getCpuSpeed()
void restoreCpuSpeed()
{
setCpuSpeed(savedCpuSpeed);
}

void softStartDelay() {
#if SOFT_START_THINGS
delayTask(SOFT_START_DELAY_MS);
#endif
}
2 changes: 2 additions & 0 deletions src/hardware/hardware.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ cpuSpeed getCpuSpeed();
void restoreCpuSpeed();
String resetReasonToString(esp_reset_reason_t reason);

void softStartDelay();

#if DEBUG
void initHardwareDebug();
void loopHardwareDebug();
Expand Down
5 changes: 4 additions & 1 deletion src/network/wifi/wifiLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ RTC_DATA_ATTR long lastTryUnix = 0;

void wifiSyncModules()
{
softStartDelay();
syncWeather();
#if BITCOIN_MODULE
softStartDelay();
bitcoinSync(1);
#endif
}
Expand Down Expand Up @@ -40,7 +42,8 @@ void wifiPersistent()
}
}

void wifiKindOfPersistent() {
void wifiKindOfPersistent()
{
debugLog("Launching");
syncNtp(false); // Because we are connected to usb for some time now so the drift drifted too much in a bad way
wifiSyncModules();
Expand Down
7 changes: 6 additions & 1 deletion src/network/wifi/wifiTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,17 @@ void turnOnWifiTask(void *parameter)
// Won't work, fuck IDF for forcing that. We need a NVS partition
// https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-guides/partition-tables.html
// 0x3000 bytes we need
softStartDelay();
WiFi.mode(WIFI_STA);
softStartDelay();

debugLog("Wifi sleep mode: " + String(WiFi.getSleep()));

WiFi.setAutoReconnect(true);
initWifi();
softStartDelay();
wifiMulti.run(WIFI_MULTI_SYNC_TIME);
softStartDelay();

if (WiFi.status() == WL_CONNECTED)
{
Expand All @@ -71,6 +75,7 @@ void turnOnWifiTask(void *parameter)
delayTask(WIFI_MULTI_ERROR_TIME);
}
}
softStartDelay();
if (WiFi.status() == WL_CONNECTED)
{
debugLog("Wifi sleep mode: " + String(WiFi.getSleep()));
Expand Down Expand Up @@ -134,7 +139,7 @@ void initWifi()
{
if (initWifiMultiDone == true)
{
return void();
return;
}
if (strlen(WIFI_SSID1) != 0 && strlen(WIFI_PASS1) != 0)
{
Expand Down

0 comments on commit 5244f13

Please sign in to comment.