From 8f05054f55e27b52e27179633e19055965800728 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Sun, 20 Aug 2017 00:36:09 +0200 Subject: [PATCH] More information about the flash layout on boot log --- code/esp8266.flash.1m0.ld | 2 +- code/espurna/config/general.h | 1 + code/espurna/espurna.ino | 38 ++++++++++++++++++++++++++--------- code/espurna/ota.ino | 4 ++-- code/espurna/settings.ino | 7 +++++++ code/espurna/wifi.ino | 2 +- 6 files changed, 40 insertions(+), 14 deletions(-) diff --git a/code/esp8266.flash.1m0.ld b/code/esp8266.flash.1m0.ld index 1f9b56a8..46a16e17 100644 --- a/code/esp8266.flash.1m0.ld +++ b/code/esp8266.flash.1m0.ld @@ -1,5 +1,5 @@ /* Flash Split for 1M chips */ -/* sketch 999KB */ +/* sketch 1004KB */ /* eeprom 20KB */ MEMORY diff --git a/code/espurna/config/general.h b/code/espurna/config/general.h index bb9334f2..725e733a 100644 --- a/code/espurna/config/general.h +++ b/code/espurna/config/general.h @@ -55,6 +55,7 @@ // EEPROM //------------------------------------------------------------------------------ +#define EEPROM_SIZE 4096 // EEPROM size in bytes #define EEPROM_RELAY_STATUS 0 // Address for the relay status (1 byte) #define EEPROM_ENERGY_COUNT 1 // Address for the energy counter (4 bytes) #define EEPROM_CUSTOM_RESET 5 // Address for the reset reason (1 byte) diff --git a/code/espurna/espurna.ino b/code/espurna/espurna.ino index acaec099..fd8ee64d 100644 --- a/code/espurna/espurna.ino +++ b/code/espurna/espurna.ino @@ -119,9 +119,9 @@ unsigned char customReset() { void hardwareSetup() { - EEPROM.begin(4096); + EEPROM.begin(EEPROM_SIZE); - #ifdef DEBUG_PORT + #if ENABLE_SERIAL_DEBUG DEBUG_PORT.begin(SERIAL_BAUDRATE); if (customReset() == CUSTOM_RESET_HARDWARE) { DEBUG_PORT.setDebugOutput(true); @@ -151,13 +151,35 @@ void hardwareLoop() { // BOOTING // ----------------------------------------------------------------------------- +unsigned int sectors(size_t size) { + return (int) (size + SPI_FLASH_SEC_SIZE - 1) / SPI_FLASH_SEC_SIZE; +} + void welcome() { + DEBUG_MSG_P(PSTR("\n\n")); DEBUG_MSG_P(PSTR("%s %s\n"), (char *) APP_NAME, (char *) APP_VERSION); DEBUG_MSG_P(PSTR("%s\n%s\n\n"), (char *) APP_AUTHOR, (char *) APP_WEBSITE); - DEBUG_MSG_P(PSTR("ChipID: %06X\n"), ESP.getChipId()); + DEBUG_MSG_P(PSTR("CPU chip ID: 0x%06X\n"), ESP.getChipId()); DEBUG_MSG_P(PSTR("CPU frequency: %d MHz\n"), ESP.getCpuFreqMHz()); - + DEBUG_MSG_P(PSTR("SDK version: %s\n"), ESP.getSdkVersion()); + DEBUG_MSG_P(PSTR("Core version: %s\n"), ESP.getCoreVersion().c_str()); + + DEBUG_MSG_P(PSTR("\n")); + FlashMode_t mode = ESP.getFlashChipMode(); + DEBUG_MSG_P(PSTR("Flash chip ID: 0x%06X\n"), ESP.getFlashChipId()); + DEBUG_MSG_P(PSTR("Flash speed: %u Hz\n"), ESP.getFlashChipSpeed()); + DEBUG_MSG_P(PSTR("Flash mode: %s\n"), mode == FM_QIO ? "QIO" : mode == FM_QOUT ? "QOUT" : mode == FM_DIO ? "DIO" : mode == FM_DOUT ? "DOUT" : "UNKNOWN"); + DEBUG_MSG_P(PSTR("\n")); + DEBUG_MSG_P(PSTR("Flash sector size: %8u bytes\n"), SPI_FLASH_SEC_SIZE); + DEBUG_MSG_P(PSTR("Flash size (SDK): %8u bytes\n"), ESP.getFlashChipSize()); + DEBUG_MSG_P(PSTR("Flash size (CHIP): %8u bytes / %4d sectors\n"), ESP.getFlashChipRealSize(), sectors(ESP.getFlashChipRealSize())); + DEBUG_MSG_P(PSTR("Firmware size: %8u bytes / %4d sectors\n"), ESP.getSketchSize(), sectors(ESP.getSketchSize())); + DEBUG_MSG_P(PSTR("OTA size: %8u bytes / %4d sectors\n"), ESP.getFreeSketchSpace(), sectors(ESP.getFreeSketchSpace())); + DEBUG_MSG_P(PSTR("EEPROM size: %8u bytes / %4d sectors\n"), settingsMaxSize(), sectors(settingsMaxSize())); + DEBUG_MSG_P(PSTR("Empty space: %8u bytes / 4 sectors\n"), 4 * SPI_FLASH_SEC_SIZE); + + DEBUG_MSG_P(PSTR("\n")); unsigned char custom_reset = customReset(); if (custom_reset > 0) { char buffer[32]; @@ -166,16 +188,12 @@ void welcome() { } else { DEBUG_MSG_P(PSTR("Last reset reason: %s\n"), (char *) ESP.getResetReason().c_str()); } - - DEBUG_MSG_P(PSTR("Memory size (SDK): %d bytes\n"), ESP.getFlashChipSize()); - DEBUG_MSG_P(PSTR("Memory size (CHIP): %d bytes\n"), ESP.getFlashChipRealSize()); - DEBUG_MSG_P(PSTR("Free heap: %d bytes\n"), ESP.getFreeHeap()); - DEBUG_MSG_P(PSTR("Firmware size: %d bytes\n"), ESP.getSketchSize()); - DEBUG_MSG_P(PSTR("Free firmware space: %d bytes\n"), ESP.getFreeSketchSpace()); + DEBUG_MSG_P(PSTR("Free heap: %u bytes\n"), ESP.getFreeHeap()); #if ENABLE_SPIFFS FSInfo fs_info; if (SPIFFS.info(fs_info)) { + DEBUG_MSG_P(PSTR("\n")); DEBUG_MSG_P(PSTR("File system total size: %d bytes\n"), fs_info.totalBytes); DEBUG_MSG_P(PSTR(" used size : %d bytes\n"), fs_info.usedBytes); DEBUG_MSG_P(PSTR(" block size: %d bytes\n"), fs_info.blockSize); diff --git a/code/espurna/ota.ino b/code/espurna/ota.ino index b780a329..38bb64a5 100644 --- a/code/espurna/ota.ino +++ b/code/espurna/ota.ino @@ -39,8 +39,8 @@ void otaSetup() { }); ArduinoOTA.onError([](ota_error_t error) { - #if DEBUG_PORT - DEBUG_MSG_P(PSTR("\n[OTA] Error[%u]: "), error); + #if ENABLE_SERIAL_DEBUG || ENABLE_UDP_DEBUG + DEBUG_MSG_P(PSTR("\n[OTA] Error #%u: "), error); if (error == OTA_AUTH_ERROR) DEBUG_MSG_P(PSTR("Auth Failed\n")); else if (error == OTA_BEGIN_ERROR) DEBUG_MSG_P(PSTR("Begin Failed\n")); else if (error == OTA_CONNECT_ERROR) DEBUG_MSG_P(PSTR("Connect Failed\n")); diff --git a/code/espurna/settings.ino b/code/espurna/settings.ino index 240a76fb..0167b1ab 100644 --- a/code/espurna/settings.ino +++ b/code/espurna/settings.ino @@ -23,6 +23,13 @@ Embedis embedis(Serial); // Settings // ----------------------------------------------------------------------------- +size_t settingsMaxSize() { + size_t size = EEPROM_SIZE; + if (size > SPI_FLASH_SEC_SIZE) size = SPI_FLASH_SEC_SIZE; + size = (size + 3) & (~3); + return size; +} + unsigned long settingsSize() { unsigned pos = SPI_FLASH_SEC_SIZE - 1; while (size_t len = EEPROM.read(pos)) { diff --git a/code/espurna/wifi.ino b/code/espurna/wifi.ino index d841cd05..ff01b85a 100644 --- a/code/espurna/wifi.ino +++ b/code/espurna/wifi.ino @@ -123,7 +123,7 @@ void wifiSetup() { // Message callbacks jw.onMessage([](justwifi_messages_t code, char * parameter) { - #ifdef DEBUG_PORT + #if ENABLE_SERIAL_DEBUG || ENABLE_UDP_DEBUG if (code == MESSAGE_SCANNING) { DEBUG_MSG_P(PSTR("[WIFI] Scanning\n"));