Add wifi debug code

This commit is contained in:
Theo Arends 2020-02-24 13:27:22 +01:00
parent cfc3db04ed
commit 94c9072815
2 changed files with 44 additions and 3 deletions

View File

@ -277,6 +277,23 @@ bool RtcRebootValid(void)
/*********************************************************************************************\
* Config - Flash
*
* Tasmota 1M flash usage
* 0x00000000 - Unzipped binary bootloader
* 0x00001000 - Unzipped binary code start
* ::::
* 0x000xxxxx - Unzipped binary code end
* 0x000x1000 - First page used by Core OTA
* ::::
* 0x000F3000 - Tasmota Quick Power Cycle counter (SETTINGS_LOCATION - CFG_ROTATES) - First four bytes only
* 0x000F4000 - First Tasmota rotating settings page
* ::::
* 0x000FA000 - Last Tasmota rotating settings page = Last page used by Core OTA
* 0x000FB000 - Core SPIFFS end = Core EEPROM = Tasmota settings page during OTA and when no flash rotation is active (SETTINGS_LOCATION)
* 0x000FC000 - SDK - Uses first 128 bytes for phy init data mirrored by Core in RAM. See core_esp8266_phy.cpp phy_init_data[128] = Core user_rf_cal_sector
* 0x000FD000 - SDK - Uses scattered bytes from 0x340 (iTead use as settings storage from 0x000FD000)
* 0x000FE000 - SDK - Uses scattered bytes from 0x340 (iTead use as mirrored settings storage from 0x000FE000)
* 0x000FF000 - SDK - Uses at least first 32 bytes of this page - Tasmota Zigbee persistence from 0x000FF800 to 0x000FFFFF
\*********************************************************************************************/
extern "C" {
@ -745,8 +762,17 @@ void SettingsErase(uint8_t type)
_sectorStart = SETTINGS_LOCATION - CFG_ROTATES; // Tasmota and SDK parameter area (0x0F3xxx - 0x0FFFFF)
_sectorEnd = ESP.getFlashChipSize() / SPI_FLASH_SEC_SIZE; // Flash size as seen by SDK
}
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_ERASE " %d " D_UNIT_SECTORS), _sectorEnd - _sectorStart);
#ifdef USE_WIFI_SDK_ERASE
else if (4 == type) {
_sectorStart = SETTINGS_LOCATION +1; // SDK phy area and Core calibration sector (0x0FC000)
_sectorEnd = _sectorStart +1; // SDK end of phy area and Core calibration sector (0x0FCFFF)
}
else if (5 == type) {
_sectorStart = (ESP.getFlashChipRealSize() / SPI_FLASH_SEC_SIZE) -4; // SDK phy area and Core calibration sector (0xxFC000)
_sectorEnd = _sectorStart +1; // SDK end of phy area and Core calibration sector (0xxFCFFF)
}
#endif // USE_WIFI_SDK_ERASE
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_ERASE " from 0x%08X to 0x%08X"), _sectorStart * SPI_FLASH_SEC_SIZE, (_sectorEnd * SPI_FLASH_SEC_SIZE) -1);
// EspErase(_sectorStart, _sectorEnd); // Arduino core and SDK - erases flash as seen by SDK
EsptoolErase(_sectorStart, _sectorEnd); // Esptool - erases flash completely
@ -755,11 +781,21 @@ void SettingsErase(uint8_t type)
void SettingsSdkErase(void)
{
WiFi.disconnect(true); // Delete SDK wifi config
WiFi.disconnect(false); // Delete SDK wifi config
SettingsErase(1);
delay(1000);
}
#ifdef USE_WIFI_SDK_ERASE
void SettingsSdkWifiErase(void)
{
WiFi.disconnect(false); // Delete SDK wifi config
SettingsErase(4);
SettingsErase(5);
delay(200);
}
#endif // USE_WIFI_SDK_ERASE
/********************************************************************************************/
void SettingsDefault(void)

View File

@ -620,12 +620,17 @@ void WifiConnect(void)
// Re-enabled from 6.3.0.7 with ESP.restart replaced by ESP.reset
void WifiDisconnect(void)
{
#ifdef USE_WIFI_SDK_ERASE // Do not enable with DeepSleep as it will wear out flash
SettingsSdkWifiErase();
#else
// Courtesy of EspEasy
WiFi.persistent(true); // use SDK storage of SSID/WPA parameters
ETS_UART_INTR_DISABLE();
wifi_station_disconnect(); // this will store empty ssid/wpa into sdk storage
ETS_UART_INTR_ENABLE();
WiFi.persistent(false); // Do not use SDK storage of SSID/WPA parameters
delay(100); // Flush anything in the network buffers.
#endif // USE_WIFI_SDK_ERASE
}
void WifiShutdown(void)