Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
mp-se committed Sep 3, 2023
2 parents 78ba958 + 7c0700e commit c76ca47
Show file tree
Hide file tree
Showing 13 changed files with 163 additions and 63 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
.vscode/*
example/test/__pycache__
# These files are under examples and should not be checked in.
script/*
src/demo*.*
platformio.ini
html/*
test/*
test/*
/diagram.json
/wokwi.toml
/partitions.csv
/output.map
21 changes: 21 additions & 0 deletions example/diagram.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"version": 1,
"author": "mp-se",
"editor": "wokwi",
"parts": [
{
"type": "wokwi-esp32-devkit-v1",
"id": "esp",
"top": 46.17,
"left": -11.69,
"rotate": 90,
"attrs": { "psramSize": "2", "firmwareOffset": "0" }
}
],
"connections": [
[ "esp:TX0", "$serialMonitor:RX", "", [] ],
[ "esp:RX0", "$serialMonitor:TX", "", [] ]
],
"serialMonitor": { "display": "always", "newline": "lf", "convertEol": false },
"dependencies": {}
}
7 changes: 7 additions & 0 deletions example/partitions.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Name,Type,SubType,Offset,Size,Flags
nvs,data,nvs,0x9000,0x5000
otadata,data,ota,0xe000,0x2000
app0,app,ota_0,0x10000,0x1c0000
app1,app,ota_1,0x1d0000,0x1c0000
spiffs,data,spiffs,0x390000,0x60000
coredump,data,coredump,0x3F0000,0x10000
108 changes: 55 additions & 53 deletions example/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,33 @@ build_flags =
-D PIO_FRAMEWORK_ARDUINO_ENABLE_EXCEPTIONS
lib_deps =
https://github.com/mp-se/Arduino-Log#1.1.1
https://github.com/mp-se/ArduinoJson#v6.18.5
https://github.com/mp-se/ArduinoJson#v6.21.3
https://github.com/mp-se/arduino-mqtt#v2.5.1
html_files =
html/upload.min.htm
html/config.min.htm
html/about.min.htm
html/index.min.htm
html/test.min.htm
html/ws.min.htm

[env:esplib-debug]
platform = espressif8266 @ 4.1.0
platform = espressif8266 @ 4.2.1
board = d1_mini
framework = arduino
board_build.filesystem = ${common_env_data.board_build.filesystem}
upload_speed = ${common_env_data.upload_speed}
monitor_speed = ${common_env_data.monitor_speed}
build_unflags = ${common_env_data.build_unflags}
build_flags =
${common_env_data.build_flags}
build_flags = ${common_env_data.build_flags}
lib_deps =
https://github.com/mp-se/incbin#v1.0.0
https://github.com/mp-se/incbin#v1.0.0
${common_env_data.lib_deps}
build_type = debug
monitor_filters = esp8266_exception_decoder

[env:esplibasync-debug]
platform = espressif8266 @ 4.1.0
platform = espressif8266 @ 4.2.1
board = d1_mini
framework = arduino
board_build.filesystem = ${common_env_data.board_build.filesystem}
Expand All @@ -57,17 +63,17 @@ build_unflags =
${common_env_data.build_unflags}
build_flags =
-D USE_ASYNC_WEB
${common_env_data.build_flags}
${common_env_data.build_flags}
lib_deps =
https://github.com/mp-se/incbin#v1.0.0
https://github.com/mp-se/incbin#v1.0.0
https://github.com/mp-se/ESPAsyncWebServer
https://github.com/mp-se/ESPAsyncTCP
${common_env_data.lib_deps}
build_type = release
monitor_filters = esp8266_exception_decoder

[env:esplib32-debug]
platform = espressif32 @ 5.3.0
platform = espressif32 @ 6.3.2
framework = arduino
board = featheresp32
board_build.filesystem = ${common_env_data.board_build.filesystem}
Expand All @@ -78,20 +84,13 @@ build_flags =
-D CORE_DEBUG_LEVEL=0
# -D USE_SERIAL_PINS
${common_env_data.build_flags}
lib_deps =
${common_env_data.lib_deps}
lib_deps = ${common_env_data.lib_deps}
build_type = debug
monitor_filters = esp32_exception_decoder
board_build.embed_txtfiles =
html/upload.min.htm
html/config.min.htm
html/about.min.htm
html/index.min.htm
html/test.min.htm
html/ws.min.htm
board_build.embed_txtfiles = ${common_env_data.html_files}

[env:esplib32-c3-debug]
platform = espressif32 @ 5.3.0
platform = espressif32 @ 6.3.2
framework = arduino
board = lolin_c3_mini
debug_tool = custom
Expand All @@ -107,68 +106,71 @@ monitor_speed = ${common_env_data.monitor_speed}
build_unflags = ${common_env_data.build_unflags}
build_flags =
-D CORE_DEBUG_LEVEL=0
-D ESP32C3
-D ESP32C3
-D ARDUINO_ESP32C3_DEV
-D USE_SERIAL_PINS
${common_env_data.build_flags}
lib_deps =
${common_env_data.lib_deps}
${common_env_data.build_flags}
lib_deps = ${common_env_data.lib_deps}
build_type = debug
board_build.embed_txtfiles =
html/upload.min.htm
html/config.min.htm
html/about.min.htm
html/index.min.htm
html/test.min.htm
html/ws.min.htm
board_build.embed_txtfiles = ${common_env_data.html_files}

[env:esplib32-s2-debug]
platform = espressif32 @ 5.3.0
platform = espressif32 @ 6.3.2
framework = arduino
board = lolin_s2_mini
board_build.filesystem = ${common_env_data.board_build.filesystem}
upload_speed = ${common_env_data.upload_speed}
monitor_speed = ${common_env_data.monitor_speed}
build_unflags = ${common_env_data.build_unflags}
build_flags =
-D ESP32S2
-D ESP32S2
-D ARDUINO_ESP32S2_DEV
#-D USE_SERIAL_PINS
${common_env_data.build_flags}
lib_deps =
${common_env_data.lib_deps}
${common_env_data.build_flags}
lib_deps = ${common_env_data.lib_deps}
build_type = debug
board_build.embed_txtfiles =
html/upload.min.htm
html/config.min.htm
html/about.min.htm
html/index.min.htm
html/test.min.htm
html/ws.min.htm
board_build.embed_txtfiles = ${common_env_data.html_files}

[env:esplib32async-s2-debug]
platform = espressif32 @ 5.3.0
platform = espressif32 @ 6.3.2
framework = arduino
board = lolin_s2_mini
board_build.filesystem = ${common_env_data.board_build.filesystem}
upload_speed = ${common_env_data.upload_speed}
monitor_speed = ${common_env_data.monitor_speed}
build_unflags = ${common_env_data.build_unflags}
build_flags =
-D ESP32S2
-D ESP32S2
-D ARDUINO_ESP32S2_DEV
#-D USE_SERIAL_PINS
${common_env_data.build_flags}
# -D USE_SERIAL_PINS
-D USE_ASYNC_WEB
${common_env_data.build_flags}
lib_deps =
https://github.com/mp-se/ESPAsyncWebServer
https://github.com/mp-se/AsyncTCP
${common_env_data.lib_deps}
build_type = debug
board_build.partitions = partitions.csv
board_build.embed_txtfiles = ${common_env_data.html_files}

[env:esplib32async-wokwi]
platform = espressif32 @ 6.3.2
framework = arduino
board = esp32dev
board_build.filesystem = ${common_env_data.board_build.filesystem}
upload_speed = ${common_env_data.upload_speed}
monitor_speed = ${common_env_data.monitor_speed}
build_unflags = ${common_env_data.build_unflags}
extra_scripts = script/merge_firmware.py
build_flags =
-D ESP32
-D USE_SERIAL_PINS
-D USE_ASYNC_WEB
${common_env_data.build_flags}
lib_deps =
https://github.com/mp-se/ESPAsyncWebServer
https://github.com/mp-se/AsyncTCP
${common_env_data.lib_deps}
build_type = debug
board_build.embed_txtfiles =
html/upload.min.htm
html/config.min.htm
html/about.min.htm
html/index.min.htm
html/test.min.htm
html/ws.min.htm
board_build.partitions = partitions.csv
board_build.embed_txtfiles = ${common_env_data.html_files}
40 changes: 40 additions & 0 deletions example/script/merge_firmware.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Import("env")

APP_BIN = "$BUILD_DIR/${PROGNAME}.bin"
MERGED_BIN = "$BUILD_DIR/${PROGNAME}_merged.bin"
BOARD_CONFIG = env.BoardConfig()


def merge_bin(source, target, env):
# The list contains all extra images (bootloader, partitions, eboot) and
# the final application binary
flash_images = env.Flatten(env.get("FLASH_EXTRA_IMAGES", [])) + ["$ESP32_APP_OFFSET", APP_BIN]

# Run esptool to merge images into a single binary
env.Execute(
" ".join(
[
"$PYTHONEXE",
"$OBJCOPY",
"--chip",
BOARD_CONFIG.get("build.mcu", "esp32"),
"merge_bin",
"--fill-flash-size",
BOARD_CONFIG.get("upload.flash_size", "4MB"),
"-o",
MERGED_BIN,
]
+ flash_images
)
)

# Add a post action that runs esptoolpy to merge available flash images
env.AddPostAction(APP_BIN , merge_bin)

# Patch the upload command to flash the merged binary at address 0x0
env.Replace(
UPLOADERFLAGS=[
]
+ ["0x0", MERGED_BIN],
UPLOADCMD='"$PYTHONEXE" "$UPLOADER" $UPLOADERFLAGS',
)
8 changes: 8 additions & 0 deletions example/wokwi.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[wokwi]
version = 1
firmware = '.pio/build/esplib32async-wokwi/firmware_merged.bin'
elf = '.pio/build/esplib32async-wokwi/firmware.elf'

[[net.forward]]
from = "localhost:8180"
to = "target:80"
2 changes: 1 addition & 1 deletion src/baseasyncwebhandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ SOFTWARE.
#define SRC_BASEASYNCWEBHANDLER_HPP_

#if defined(ESP32)
#include <FreeRTOS.h>
#include <freertos/FreeRTOS.h>
#endif

#if defined(ESP8266)
Expand Down
12 changes: 12 additions & 0 deletions src/baseconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,14 +287,26 @@ void BaseConfig::checkFileSystem() {
#if LOG_LEVEL == 6
Log.verbose(F("CFG : Checking if filesystem is valid." CR));
#endif
#ifdef ESP8266
if (LittleFS.begin()) {
#if LOG_LEVEL == 6
Log.verbose(F("CFG : Filesystem mounted." CR));
#endif
} else {
Log.error(F("CFG : Unable to mount file system, formatting..." CR));
LittleFS.format();
LittleFS.begin();
}
#else
if (LittleFS.begin(true)) {
#if LOG_LEVEL == 6
Log.verbose(F("CFG : Filesystem mounted." CR));
#endif
} else {
Log.error(F("CFG : Unable to mount/format file system..." CR));
}
#endif

}

// EOF
12 changes: 8 additions & 4 deletions src/espframework.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,18 @@ SOFTWARE.
#ifndef SRC_ESPFRAMEWORK_HPP_
#define SRC_ESPFRAMEWORK_HPP_

#define ESPFWK_VER "0.6.3"
#define ESPFWK_VER "0.6.4"

#if defined(ESP8266)
#define ESP_RESET ESP.reset
#define PIN_LED 2
#define ESP_RESET ESP.reset
#define PIN_LED 2
#elif defined(ESP32)
#define ESP_RESET ESP.restart
#define PIN_LED LED_BUILTIN
#if defined(LED_BUILTIN)
#define PIN_LED LED_BUILTIN
#else
#define PIN_LED 2
#endif
#endif

#endif // SRC_ESPFRAMEWORK_HPP_
Expand Down
3 changes: 2 additions & 1 deletion src/log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ SerialDebug::SerialDebug(const uint32_t serialSpeed) {
#elif defined(ESP8266)
EspSerial.begin(serialSpeed);
#elif defined(USE_SERIAL_PINS) && defined(ESP32C3)
EspSerial.begin(115200L, SERIAL_8N1, 20, 21);
//EspSerial.begin(115200L, SERIAL_8N1, 20, 21);
EspSerial.begin(115200L);
#elif defined(ESP32C3)
EspSerial.begin(115200L);
#elif defined(USE_SERIAL_PINS) && defined(ESP32S2)
Expand Down
2 changes: 1 addition & 1 deletion src/log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void writeErrorLog(const char* format, ...);
void dumpErrorLog1();
void dumpErrorLog2();

#if defined(USE_SERIAL_PINS) && defined(ESP32)
#if defined(USE_SERIAL_PINS) && defined(ESP32) && !defined(ARDUINO_USB_CDC_ON_BOOT)
#define EspSerial Serial0
#else
#define EspSerial Serial
Expand Down
2 changes: 1 addition & 1 deletion src/serialws.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ SOFTWARE.
#include <Print.h>

#if defined(ESP32)
#include <FreeRTOS.h>
#include <freertos/FreeRTOS.h>
#endif

#if defined(ESP8266)
Expand Down
2 changes: 1 addition & 1 deletion src/wificonnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ void WifiConnection::writeReset() {
}
}
bool WifiConnection::hasConfig() {
if (strlen(_wifiConfig->getWifiSSID(0))) return true;
if (_userSSID.length()) return true;
if (strlen(_wifiConfig->getWifiSSID(0))) return true;

// Check if there are stored WIFI Settings we can use
#if defined(ESP8266)
Expand Down

0 comments on commit c76ca47

Please sign in to comment.