Skip to content

Commit

Permalink
Merge pull request #26 from softhack007/esp32-S2_patch2
Browse files Browse the repository at this point in the history
Esp32 s2 patch2 - debug improvement, and starting to collect some esp32 tools
  • Loading branch information
ewoudwijma authored Jan 22, 2024
2 parents b7eef29 + 24f4863 commit f5bb75d
Show file tree
Hide file tree
Showing 5 changed files with 342 additions and 34 deletions.
10 changes: 8 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
;; framework = arduino
;; monitor_speed = 115200
;; upload_speed = 115200
;; build_type = debug
;; build_type = release

[starmod]
lib_deps =
Expand Down Expand Up @@ -79,20 +81,24 @@ lib_deps =

[env:lolin_s2_mini]
board = lolin_s2_mini ;https://github.com/platformio/platform-espressif32/blob/develop/boards/lolin_s2_mini.json
platform = [email protected]
;; platform = [email protected] ;; WLED default framework version
platform = [email protected] ;; this one behaves better for debugging
framework = arduino
upload_speed = 256000
monitor_speed = 115200
board_build.partitions = tools/WLED_ESP32_4MB_256KB_FS.csv ;; 1.8MB firmware, 256KB filesystem (esptool erase_flash needed when changing from "standard WLED" partitions)
monitor_filters = esp32_exception_decoder
board_build.filesystem = littlefs
build_unflags =
; -DARDUINO_USB_CDC_ON_BOOT=1 ;; un-comment if you want to use a "real" serial-to-USB moddule
build_flags =
-DCONFIG_IDF_TARGET_ESP32S2=1
-DCONFIG_ASYNC_TCP_USE_WDT=0
-DLFS_THREADSAFE ;; enables use of semaphores in LittleFS driver
-DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_DFU_ON_BOOT=1 -DARDUINO_USB_MSC_ON_BOOT=0 ;; for debugging over USB
; -DARDUINO_USB_CDC_ON_BOOT=0 -DARDUINO_USB_DFU_ON_BOOT=1 -DARDUINO_USB_MSC_ON_BOOT=0 ;; without USB debug (use in case your board hangs without USB connection)
; -DARDUINO_USB_CDC_ON_BOOT=0 -DARDUINO_USB_DFU_ON_BOOT=1 -DARDUINO_USB_MSC_ON_BOOT=0 ;; with serial-to-USB moddule (use in case your board hangs without USB connection)
-DARDUINO_USB_MODE=0 ;; Make sure that the right HardwareSerial driver is picked in arduino-esp32 (mandatory on -S2)
; -D DEBUG=1 -D CORE_DEBUG_LEVEL=1 -D ARDUINOJSON_DEBUG=1 ;; for more debug output
${appmod_leds.build_flags}
${usermod_e131.build_flags}
; ${usermod_ha.build_flags}
Expand Down
20 changes: 16 additions & 4 deletions src/Sys/SysModPrint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,24 @@
#include "SysModUI.h"
#include "SysModModel.h"
#include "SysModWeb.h"
#include "esp32Tools.h"

SysModPrint::SysModPrint() :SysModule("Print") {
// print("%s %s\n", __PRETTY_FUNCTION__, name);

#if ARDUINO_USB_CDC_ON_BOOT || !defined(CONFIG_IDF_TARGET_ESP32S2)
Serial.begin(115200);
#else
Serial.begin(115200, SERIAL_8N1, RX, TX); // workaround for Lolin S2 mini - this board uses non-standard pins for RX and TX
#endif
delay(500);
// un-comment the next lines for redirecting kernel error messages to Serial
// #if ARDUINO_USB_CDC_ON_BOOT
// Serial0.setDebugOutput(false);
// #endif
// Serial.setDebugOutput(true);
#if CORE_DEBUG_LEVEL
#if ARDUINO_USB_CDC_ON_BOOT
Serial0.setDebugOutput(false);
#endif
Serial.setDebugOutput(true);
#endif

// softhack007: USB CDC needs a bit more time to initialize
#if ARDUINO_USB_CDC_ON_BOOT || ARDUINO_USB_MODE
Expand All @@ -36,6 +43,11 @@ SysModPrint::SysModPrint() :SysModule("Print") {
delay(3000); // this extra delay avoids repeating disconnects on -s2 "Disconnected (ClearCommError failed"
Serial.println(" **** COMMODORE BASIC V2 **** ");
#endif
if (!sysTools_normal_startup() && Serial) { // only print if Serial is connected, and startup was not normal
Serial.print("\nWARNING - possible crash: ");
Serial.println(sysTools_getRestartReason());
Serial.println("");
}
Serial.println("Ready.\n");
if (Serial) Serial.flush(); // drain output buffer

Expand Down
65 changes: 37 additions & 28 deletions src/Sys/SysModSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "SysModUI.h"
#include "SysModWeb.h"
#include "SysModModel.h"
#include "esp32Tools.h"

// #include <Esp.h>
#include <rom/rtc.h>
Expand Down Expand Up @@ -140,36 +141,44 @@ void SysModSystem::loop10s() {

//replace code by sentence as soon it occurs, so we know what will happen and what not
void SysModSystem::addResetReasonsSelect(JsonArray select) {
select.add("NO_MEAN"); // 0,
select.add("Vbat power on reset");//POWERON_RESET"); // 1, /**<1, */
select.add("SW_RESET (2)"); // 2, /**<3, Software reset digital core*/
select.add("SW_RESET (3)"); // 3, /**<3, Software reset digital core*/
select.add("OWDT_RESET"); // 4, /**<4, Legacy watch dog reset digital core*/
select.add("DEEPSLEEP_RESET"); // 5, /**<3, Deep Sleep reset digital core*/
select.add("SDIO_RESET"); // 6, /**<6, Reset by SLC module, reset digital core*/
select.add("TG0WDT_SYS_RESET"); // 7, /**<7, Timer Group0 Watch dog reset digital core*/
select.add("TG1WDT_SYS_RESET"); // 8, /**<8, Timer Group1 Watch dog reset digital core*/
select.add("RTCWDT_SYS_RESET"); // 9, /**<9, RTC Watch dog Reset digital core*/
select.add("INTRUSION_RESET"); //10, /**<10, Instrusion tested to reset CPU*/
select.add("TGWDT_CPU_RESET"); //11, /**<11, Time Group reset CPU*/
select.add("SW reset CPU (12)");//SW_CPU_RESET"); //12, /**<12, */
select.add("RTCWDT_CPU_RESET"); //13, /**<13, RTC Watch dog Reset CPU*/
select.add("for APP CPU, reset by PRO CPU");//EXT_CPU_RESET"); //14, /**<14, */
select.add("RTCWDT_BROWN_OUT_RESET"); //15, /**<15, Reset when the vdd voltage is not stable*/
select.add("RTCWDT_RTC_RESET"); //16 /**<16, RTC Watch dog reset digital core and rtc module*/
select.add(String("NO_MEAN (0)")); // 0,
select.add(sysTools_reset2String( 1)); //POWERON_RESET"); // 1, /**<1, */
select.add(sysTools_reset2String( 2)); // 2, /**<3, Software reset digital core*/
select.add(sysTools_reset2String( 3)); // 3, /**<3, Software reset digital core*/
select.add(sysTools_reset2String( 4)); // 4, /**<4, Legacy watch dog reset digital core*/
select.add(sysTools_reset2String( 5)); // 5, /**<3, Deep Sleep reset digital core*/
select.add(sysTools_reset2String( 6)); // 6, /**<6, Reset by SLC module, reset digital core*/
select.add(sysTools_reset2String( 7)); // 7, /**<7, Timer Group0 Watch dog reset digital core*/
select.add(sysTools_reset2String( 8)); // 8, /**<8, Timer Group1 Watch dog reset digital core*/
select.add(sysTools_reset2String( 9)); // 9, /**<9, RTC Watch dog Reset digital core*/
select.add(sysTools_reset2String(10)); //10, /**<10, Instrusion tested to reset CPU*/
select.add(sysTools_reset2String(11)); //11, /**<11, Time Group reset CPU*/
select.add(sysTools_reset2String(12)); //SW_CPU_RESET"); //12, /**<12, */
select.add(sysTools_reset2String(13)); //13, /**<13, RTC Watch dog Reset CPU*/
select.add(sysTools_reset2String(14)); //EXT_CPU_RESET"); //14, /**<14, */
select.add(sysTools_reset2String(15)); //15, /**<15, Reset when the vdd voltage is not stable*/
select.add(sysTools_reset2String(16)); //16 /**<16, RTC Watch dog reset digital core and rtc module*/
// codes below are only used on -S3/-S2/-C3
select.add(sysTools_reset2String(17)); //17 /* Time Group1 reset CPU */
select.add(sysTools_reset2String(18)); //18 /* super watchdog reset digital core and rtc module */
select.add(sysTools_reset2String(19)); //19 /* glitch reset digital core and rtc module */
select.add(sysTools_reset2String(20)); //20 /* efuse reset digital core */
select.add(sysTools_reset2String(21)); //21 /* usb uart reset digital core */
select.add(sysTools_reset2String(22)); //22 /* usb jtag reset digital core */
select.add(sysTools_reset2String(23)); //23 /* power glitch reset digital core and rtc module */
}

//replace code by sentence as soon it occurs, so we know what will happen and what not
void SysModSystem::addRestartReasonsSelect(JsonArray select) {
select.add("ESP_RST_UNKNOWN");// //!< Reset reason can not be determined
select.add("Reset due to power-on event");//ESP_RST_POWERON");// //!<
select.add("ESP_RST_EXT");// //!< Reset by external pin (not applicable for ESP32)
select.add("Software reset via esp_restart (3)");//ESP_RST_SW");// //!< Software reset via esp_restart
select.add("SW reset due to exception/panic (4)");//ESP_RST_PANIC");// //!<
select.add("ESP_RST_INT_WDT");// //!< Reset (software or hardware) due to interrupt watchdog
select.add("ESP_RST_TASK_WDT");// //!< Reset due to task watchdog
select.add("ESP_RST_WDT");// //!< Reset due to other watchdogs
select.add("ESP_RST_DEEPSLEEP");////!< Reset after exiting deep sleep mode
select.add("ESP_RST_BROWNOUT");// //!< Brownout reset (software or hardware)
select.add("ESP_RST_SDIO");// //!< Reset over SDIO
select.add(String("(0) ESP_RST_UNKNOWN"));// //!< Reset reason can not be determined
select.add(sysTools_restart2String( 1)); // ESP_RST_POWERON");// //!<
select.add(sysTools_restart2String( 2)); // !< Reset by external pin (not applicable for ESP32)
select.add(sysTools_restart2String( 3)); // ESP_RST_SW");// //!< Software reset via esp_restart
select.add(sysTools_restart2String( 4)); //ESP_RST_PANIC");// //!<
select.add(sysTools_restart2String( 5)); // //!< Reset (software or hardware) due to interrupt watchdog
select.add(sysTools_restart2String( 6)); // //!< Reset due to task watchdog
select.add(sysTools_restart2String( 7)); // //!< Reset due to other watchdogs
select.add(sysTools_restart2String( 8)); ////!< Reset after exiting deep sleep mode
select.add(sysTools_restart2String( 9)); // //!< Brownout reset (software or hardware)
select.add(sysTools_restart2String(10)); // //!< Reset over SDIO
}
Loading

0 comments on commit f5bb75d

Please sign in to comment.