From 03259546494f8a280f52eab1b729cae0afbf4497 Mon Sep 17 00:00:00 2001 From: fvanroie Date: Thu, 29 Sep 2022 20:19:08 +0200 Subject: [PATCH] Add ESP32-S3 support --- src/dev/esp32/esp32.cpp | 20 +-- user_setups/esp32s3/_esp32s3.ini | 136 +++++++++++++++++++++ user_setups/esp32s3/esp32-s3-devkitc-1.ini | 41 +++++++ 3 files changed, 187 insertions(+), 10 deletions(-) create mode 100644 user_setups/esp32s3/_esp32s3.ini create mode 100644 user_setups/esp32s3/esp32-s3-devkitc-1.ini diff --git a/src/dev/esp32/esp32.cpp b/src/dev/esp32/esp32.cpp index f17748fa..aaaa3cb9 100644 --- a/src/dev/esp32/esp32.cpp +++ b/src/dev/esp32/esp32.cpp @@ -371,16 +371,16 @@ bool Esp32Device::is_system_pin(uint8_t pin) // SPIQ = IO13 or IO37 // SPIWP = IO14 or IO38 if((pin >= 33) && (pin <= 38)) return true; // SPI flash - - if(psramFound()) { - if((pin == 26)) return true; // PSRAM. IO26 = SPICS1, the rest are shared with the flash - } + if(psramFound() &&(pin == 26)) return true; // PSRAM. IO26 = SPICS1, the rest are shared with the flash +#elif defined(ESP32S3) + if((pin >= 22) && (pin <= 25)) return true; // unavailable + if((pin >= 26) && (pin <= 32)) return true; // integrated SPI flash + if((pin >= 33) && (pin <= 37)) return true; // octal flash or PSram #else - if((pin >= 6) && (pin <= 11)) return true; // integrated SPI flash - if((pin == 37) || (pin == 38)) return true; // unavailable - if(psramFound()) { - if((pin == 16) || (pin == 17)) return true; // PSRAM - } + if((pin >= 6) && (pin <= 11)) return true; // integrated SPI flash + if((pin == 37) || (pin == 38)) return true; // unavailable + if(psramFound() && ((pin == 16) || (pin == 17))) return true; // PSRAM + #endif return false; } @@ -443,7 +443,7 @@ long Esp32Device::get_uptime() // #warning Building for Lanbon L8 #include "dev/esp32/lanbonl8.h" #elif defined(M5STACK) - // #warning Building for M5Stack core2 + // #warning Building for M5Stack core2 #include "dev/esp32/m5stackcore2.h" #else dev::Esp32Device haspDevice; diff --git a/user_setups/esp32s3/_esp32s3.ini b/user_setups/esp32s3/_esp32s3.ini new file mode 100644 index 00000000..06f57f50 --- /dev/null +++ b/user_setups/esp32s3/_esp32s3.ini @@ -0,0 +1,136 @@ +; -- Platform specific build flags +[esp32s3] +; ----- debugger +check_tool = cppcheck +check_flags = --enable=all +debug_tool = esp-prog +debug_init_break = tbreak setup +board_build.embed_files = + data/edit.htm.gz + data/style.css.gz + data/script.js.gz + data/cert/x509_crt_bundle.bin + data/static/logo.svg.gz + data/static/ace.1.9.6.min.js.gz + data/static/petite-vue.hasp.js.gz + +build_flags = + ${env.build_flags} + -D HTTP_UPLOAD_BUFLEN=1024 ; lower http upload buffer + -D MQTT_MAX_PACKET_SIZE=2048 ; longer PubSubClient messages + -D HASP_CONSOLE_BUFFER=256 ; maximum length of a console/telnet command + -D NO_GLOBAL_HTTPUPDATE ; dont instantiate httpUpdate + ;-D CONFIG_NEWLIB_NANO_FORMAT +; -- lvgl build options ----------------------------- + -D LV_ATTRIBUTE_FAST_MEM=IRAM_ATTR + -D LV_ATTRIBUTE_TASK_HANDLER=IRAM_ATTR + -D LV_USE_FS_IF=0 + ;-D LV_FS_PC_PATH="//littlefs" ; this needs to match the vfs mount pount +; -- ArduinoJson build options ---------------------------- + -D ARDUINOJSON_ENABLE_PROGMEM=1 ; for PROGMEM arguments +; -- tft_espi build options ------------------------ + ;-D USE_DMA_TO_TFT +; -- openHASP build options ------------------------ + -D HASP_ATTRIBUTE_FAST_MEM=IRAM_ATTR + -D HASP_USE_TELNET=1 + ;-D HASP_USE_SPIFFS=1 + -D HASP_USE_LITTLEFS=1 + ;-D HASP_USE_EEPROM=1 + -D HASP_USE_CONFIG=1 ; Native application, not library + -D LV_LOG_TRACE_TIMER=1 + -D HASP_USE_PNGDECODE=1 + -D HASP_USE_BMPDECODE=1 + -D HASP_USE_JPGDECODE=0 + -D HASP_USE_GIFDECODE=0 +; -- LittleFS build options ------------------------ + ;-D CONFIG_LITTLEFS_FOR_IDF_3_2 ; obsolete in IDF 3.3 +; -- FreeType build options ------------------------ + -D LV_FREETYPE_SBIT_CACHE=1 ; use small bitmap cache + -D LV_FREETYPE_CACHE_SIZE=1 ; cache freetype font sizes + -D LV_USE_FT_CACHE_MANAGER=1 ; crashes without cache + -D LVGL_FREETYPE_MAX_FACES=16 ; max number of FreeType faces in cache + -D LVGL_FREETYPE_MAX_SIZES=16 ; max number of sizes in cache + -D LVGL_FREETYPE_MAX_BYTES=16384 ; max bytes in cache + -D LVGL_FREETYPE_MAX_BYTES_PSRAM=131072 ; max bytes in cache when using PSRAM +; -- SimpleFTpServer build options ----------------- + -D HASP_USE_FTP=1 + -D FTP_SERVER_DEBUG + -D FTP_SERVER_NETWORK_TYPE=4 ;// NETWORK_ESP32 + -D STORAGE_TYPE=6 ;// STORAGE_LITTLEFS + -D STORAGE_SD_FORCE_DISABLE + -D STORAGE_SPIFFS_FORCE_DISABLE + +lib_ignore = + GxTFT + XPT2046_Touchscreen + Adafruit BusIO + Adafruit GFX Library + ESP32 BLE Arduino + lv_drv_fsmc_ili9341 + lv_drivers + AXP192 + +lib_deps = + git+https://github.com/fvanroie/ConsoleInput.git#dev + bxparks/AceButton@^1.9.2 ; GPIO button library + bblanchon/StreamUtils@^1.6.3 ; for EEPromStream and BufferedTelnetClient + knolleary/PubSubClient@^2.8.0 ; MQTT client + +extra_scripts = + pre:tools/auto_firmware_version.py + tools/littlefsbuilder.py + tools/esp_merge_bin.py + tools/analyze_elf.py +; ${env.extra_scripts} +; tools/copy_partitions.py + +ps_ram = + -DBOARD_HAS_PSRAM + -mfix-esp32-psram-cache-issue ; uses 24kB + -D HASP_USE_FREETYPE=1 + -D LV_USE_FREETYPE=1 +no_ps_ram = + -D HASP_USE_FREETYPE=1 + -D LV_USE_FREETYPE=1 + +; -- The ESP32 has 2 SPI Hardware Busses available to use: +vspi = + -D TFT_MISO=19 + -D TFT_MOSI=23 + -D TFT_SCLK=18 +hspi = + -D TFT_MISO=12 + -D TFT_MOSI=13 + -D TFT_SCLK=14 + + +; -- The Arduino ESP32 v2.0.2 with 3 available flash sizes: +[arduino_esp32s3_v2] +framework = arduino +;platform = https://github.com/tasmota/platform-espressif32/releases/download/v2.0.5/platform-espressif32-2.0.5.zip +platform = espressif32 +board_build.filesystem = littlefs +; ----- crash reporter +monitor_filters = esp32_exception_decoder +extra_scripts = + ${esp32.extra_scripts} +lib_deps = +lib_ignore = LittleFS_esp32 ; for v2 + +[esp32s3_4mb_v2] +extends = esp32s3, arduino_esp32s3_v2 +board_upload.flash_size=4MB +board_upload.maximum_size = 4194304 +board_build.partitions = user_setups/esp32/partitions_4MB.csv + +[esp32s3_8mb_v2] +extends = esp32s3, arduino_esp32s3_v2 +board_upload.flash_size=8MB +board_upload.maximum_size = 8388608 +board_build.partitions = user_setups/esp32/partitions_8MB.csv + +[esp32s3_16mb_v2] +extends = esp32s3, arduino_esp32s3_v2 +board_upload.flash_size = 16MB +board_upload.maximum_size = 16777216 +board_build.partitions = user_setups/esp32/partitions_16MB.csv diff --git a/user_setups/esp32s3/esp32-s3-devkitc-1.ini b/user_setups/esp32s3/esp32-s3-devkitc-1.ini new file mode 100644 index 00000000..589cd9b5 --- /dev/null +++ b/user_setups/esp32s3/esp32-s3-devkitc-1.ini @@ -0,0 +1,41 @@ +;***************************************************; +; D1 Mini ESP32 with Lolin TFT 2.4" ; +; - D1-mini-esp32 board ; +; - ili9341 TFT ; +; - xpt2046 touch controller ; +;***************************************************; + +[env:esp32-s3-devkitc-1] +extends = esp32s3_8mb_v2 +;board = esp32-s3-devkitc-1 +board = esp32s3_opi + +build_flags = + ${env.build_flags} + ${esp32.build_flags} + ${esp32.no_ps_ram} + -D HASP_MODEL="ESP32 D1 Mini" + +;region -- TFT_eSPI build options ------------------------ + ${lcd.ili9341} + ${touch.xpt2046} + ${esp32.vspi} ; Use VSPI hardware SPI bus + -D TFT_DC=5 + -D TFT_CS=26 + -D TFT_RST=-1 ; RST + -D TFT_BCKL=-1 ; None, configurable via web UI (e.g. 21) + -D TOUCH_CS=17 ; (can also be 22 or 16) +;endregion + +;region -- Library options ------------------------------- +lib_deps = + ${env.lib_deps} + ${esp32.lib_deps} + ${arduino_esp32_v2.lib_deps} + ${tft_espi.lib_deps} + +lib_ignore = + ${env.lib_ignore} + ${esp32.lib_ignore} + ${arduino_esp32_v2.lib_ignore} +;endregion