diff --git a/boards/adafruit_matrixportal_esp32s3.json b/boards/adafruit_matrixportal_esp32s3.json new file mode 100644 index 0000000000..df10505ad4 --- /dev/null +++ b/boards/adafruit_matrixportal_esp32s3.json @@ -0,0 +1,66 @@ +{ + "build": { + "arduino":{ + "ldscript": "esp32s3_out.ld", + "partitions": "partitions-8MB-tinyuf2.csv" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_ADAFRUIT_MATRIXPORTAL_ESP32S3", + "-DARDUINO_USB_CDC_ON_BOOT=1", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1", + "-DBOARD_HAS_PSRAM" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [ + [ + "0x239A", + "0x8125" + ], + [ + "0x239A", + "0x0125" + ], + [ + "0x239A", + "0x8126" + ] + ], + "mcu": "esp32s3", + "variant": "adafruit_matrixportal_esp32s3" + }, + "connectivity": [ + "bluetooth", + "wifi" + ], + "debug": { + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "Adafruit MatrixPortal ESP32-S3", + "upload": { + "arduino": { + "flash_extra_images": [ + [ + "0x410000", + "variants/adafruit_matrixportal_esp32s3/tinyuf2.bin" + ] + ] + }, + "flash_size": "8MB", + "maximum_ram_size": 327680, + "maximum_size": 8388608, + "use_1200bps_touch": true, + "wait_for_upload_port": true, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://www.adafruit.com/product/5778", + "vendor": "Adafruit" +} diff --git a/platformio.ini b/platformio.ini index de02535d69..711514bb83 100644 --- a/platformio.ini +++ b/platformio.ini @@ -26,6 +26,7 @@ default_envs = nodemcuv2 lolin_s2_mini esp32c3dev esp32c3dev_qio + esp32S3_wroom2 esp32s3dev_16MB_opi esp32s3dev_8MB_opi esp32s3_4M_qspi @@ -561,9 +562,9 @@ upload_speed = 921600 custom_usermods = audioreactive build_unflags = ${common.build_unflags} build_flags = ${common.build_flags} ${esp32s3.build_flags} -D WLED_RELEASE_NAME=\"ESP32-S3_16MB_opi\" - -D CONFIG_LITTLEFS_FOR_IDF_3_2 -D WLED_WATCHDOG_TIMEOUT=0 + -D WLED_WATCHDOG_TIMEOUT=0 ;-D ARDUINO_USB_CDC_ON_BOOT=0 ;; -D ARDUINO_USB_MODE=1 ;; for boards with serial-to-USB chip - -D ARDUINO_USB_CDC_ON_BOOT=1 -D ARDUINO_USB_MODE=1 ;; for boards with USB-OTG connector only (USBCDC or "TinyUSB") + -D ARDUINO_USB_CDC_ON_BOOT=1 ;; -D ARDUINO_USB_MODE=1 ;; for boards with USB-OTG connector only (USBCDC or "TinyUSB") -DBOARD_HAS_PSRAM lib_deps = ${esp32s3.lib_deps} board_build.partitions = ${esp32.extreme_partitions} @@ -583,9 +584,9 @@ upload_speed = 921600 custom_usermods = audioreactive build_unflags = ${common.build_unflags} build_flags = ${common.build_flags} ${esp32s3.build_flags} -D WLED_RELEASE_NAME=\"ESP32-S3_8MB_opi\" - -D CONFIG_LITTLEFS_FOR_IDF_3_2 -D WLED_WATCHDOG_TIMEOUT=0 + -D WLED_WATCHDOG_TIMEOUT=0 ;-D ARDUINO_USB_CDC_ON_BOOT=0 ;; -D ARDUINO_USB_MODE=1 ;; for boards with serial-to-USB chip - -D ARDUINO_USB_CDC_ON_BOOT=1 -D ARDUINO_USB_MODE=1 ;; for boards with USB-OTG connector only (USBCDC or "TinyUSB") + -D ARDUINO_USB_CDC_ON_BOOT=1 ;; -D ARDUINO_USB_MODE=1 ;; for boards with USB-OTG connector only (USBCDC or "TinyUSB") -DBOARD_HAS_PSRAM lib_deps = ${esp32s3.lib_deps} board_build.partitions = ${esp32.large_partitions} @@ -604,13 +605,13 @@ upload_speed = 921600 custom_usermods = audioreactive build_unflags = ${common.build_unflags} build_flags = ${common.build_flags} ${esp32s3.build_flags} -D WLED_RELEASE_NAME=\"ESP32-S3_WROOM-2\" - -D CONFIG_LITTLEFS_FOR_IDF_3_2 -D WLED_WATCHDOG_TIMEOUT=0 + -D WLED_WATCHDOG_TIMEOUT=0 -D ARDUINO_USB_CDC_ON_BOOT=0 ;; -D ARDUINO_USB_MODE=1 ;; for boards with serial-to-USB chip - ;; -D ARDUINO_USB_CDC_ON_BOOT=1 -D ARDUINO_USB_MODE=1 ;; for boards with USB-OTG connector only (USBCDC or "TinyUSB") + ;; -D ARDUINO_USB_CDC_ON_BOOT=1 ;; -D ARDUINO_USB_MODE=1 ;; for boards with USB-OTG connector only (USBCDC or "TinyUSB") -DBOARD_HAS_PSRAM -D LEDPIN=38 -D DATA_PINS=38 ;; buildin WS2812b LED -D BTNPIN=0 -D RLYPIN=16 -D IRPIN=17 -D AUDIOPIN=-1 - -D WLED_DEBUG + ;;-D WLED_DEBUG -D SR_DMTYPE=1 -D I2S_SDPIN=13 -D I2S_CKPIN=14 -D I2S_WSPIN=15 -D MCLK_PIN=4 ;; I2S mic lib_deps = ${esp32s3.lib_deps} @@ -619,6 +620,23 @@ board_upload.flash_size = 16MB board_upload.maximum_size = 16777216 monitor_filters = esp32_exception_decoder +[env:esp32S3_wroom2_32MB] +;; For ESP32-S3 WROOM-2 with 32MB Flash, and >= 8MB PSRAM (memory_type: opi_opi) +extends = env:esp32S3_wroom2 +build_flags = ${common.build_flags} ${esp32s3.build_flags} -D WLED_RELEASE_NAME=\"ESP32-S3_WROOM-2_32MB\" + -D WLED_WATCHDOG_TIMEOUT=0 + -D ARDUINO_USB_CDC_ON_BOOT=0 ;; -D ARDUINO_USB_MODE=1 ;; for boards with serial-to-USB chip + ;; -D ARDUINO_USB_CDC_ON_BOOT=1 ;; -D ARDUINO_USB_MODE=1 ;; for boards with USB-OTG connector only (USBCDC or "TinyUSB") + -DBOARD_HAS_PSRAM + -D LEDPIN=38 -D DATA_PINS=38 ;; buildin WS2812b LED + -D BTNPIN=0 -D RLYPIN=16 -D IRPIN=17 -D AUDIOPIN=-1 + ;;-D WLED_DEBUG + -D SR_DMTYPE=1 -D I2S_SDPIN=13 -D I2S_CKPIN=14 -D I2S_WSPIN=15 -D MCLK_PIN=4 ;; I2S mic +board_build.partitions = tools/WLED_ESP32_32MB.csv +board_upload.flash_size = 32MB +board_upload.maximum_size = 33554432 +monitor_filters = esp32_exception_decoder + [env:esp32s3_4M_qspi] ;; ESP32-S3, with 4MB FLASH and <= 4MB PSRAM (memory_type: qio_qspi) board = lolin_s3_mini ;; -S3 mini, 4MB flash 2MB PSRAM @@ -628,7 +646,7 @@ upload_speed = 921600 custom_usermods = audioreactive build_unflags = ${common.build_unflags} build_flags = ${common.build_flags} ${esp32s3.build_flags} -D WLED_RELEASE_NAME=\"ESP32-S3_4M_qspi\" - -DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_MODE=1 ;; for boards with USB-OTG connector only (USBCDC or "TinyUSB") + -DARDUINO_USB_CDC_ON_BOOT=1 ;; -DARDUINO_USB_MODE=1 ;; for boards with USB-OTG connector only (USBCDC or "TinyUSB") -DBOARD_HAS_PSRAM -DLOLIN_WIFI_FIX ; seems to work much better with this -D WLED_WATCHDOG_TIMEOUT=0 diff --git a/platformio_override.sample.ini b/platformio_override.sample.ini index 249b101059..45ae87d91d 100644 --- a/platformio_override.sample.ini +++ b/platformio_override.sample.ini @@ -191,6 +191,22 @@ build_flags = ${common.build_flags} ${esp8266.build_flags} ; -D HW_PIN_MISOSPI=9 +# ------------------------------------------------------------------------------ +# Optional: build flags for speed, instead of optimising for size. +# Example of usage: see [env:esp32S3_PSRAM_HUB75] +# ------------------------------------------------------------------------------ + +[Speed_Flags] +build_unflags = -Os ;; to disable standard optimization for small size +build_flags = + -O2 ;; optimize for speed + -free -fipa-pta ;; very useful, too + ;;-fsingle-precision-constant ;; makes all floating point literals "float" (default is "double") + ;;-funsafe-math-optimizations ;; less dangerous than -ffast-math; still allows the compiler to exploit FMA and reciprocals (up to 10% faster on -S3) + # Important: we need to explicitly switch off some "-O2" optimizations + -fno-jump-tables -fno-tree-switch-conversion ;; needed - firmware may crash otherwise + -freorder-blocks -Wwrite-strings -fstrict-volatile-bitfields ;; needed - recommended by espressif + # ------------------------------------------------------------------------------ # PRE-CONFIGURED DEVELOPMENT BOARDS AND CONTROLLERS @@ -541,7 +557,7 @@ build_flags = ${common.build_flags} -D WLED_ENABLE_HUB75MATRIX -D NO_GFX -D WLED_DEBUG_BUS ; -D WLED_DEBUG - -D SR_DMTYPE=-1 -D I2S_SDPIN=-1 -D I2S_CKPIN=-1 -D I2S_WSPIN=-1 -D MCLK_PIN=-1 ;; Disable to prevent pin clash + -D SR_DMTYPE=1 -D I2S_SDPIN=-1 -D I2S_CKPIN=-1 -D I2S_WSPIN=-1 -D MCLK_PIN=-1 ;; Disable to prevent pin clash lib_deps = ${esp32_idf_V4.lib_deps} https://github.com/mrfaptastic/ESP32-HUB75-MatrixPanel-DMA.git#3.0.11 @@ -558,19 +574,22 @@ build_flags = ${common.build_flags} -D WLED_ENABLE_HUB75MATRIX -D NO_GFX -D ESP32_FORUM_PINOUT ;; enable for SmartMatrix default pins -D WLED_DEBUG_BUS - -D SR_DMTYPE=-1 -D I2S_SDPIN=-1 -D I2S_CKPIN=-1 -D I2S_WSPIN=-1 -D MCLK_PIN=-1 ;; Disable to prevent pin clash + -D SR_DMTYPE=1 -D I2S_SDPIN=-1 -D I2S_CKPIN=-1 -D I2S_WSPIN=-1 -D MCLK_PIN=-1 ;; Disable to prevent pin clash ; -D WLED_DEBUG [env:adafruit_matrixportal_esp32s3] ; ESP32-S3 processor, 8 MB flash, 2 MB of PSRAM, dedicated driver pins for HUB75 board = adafruit_matrixportal_esp32s3 +;; adafruit recommends to use arduino-esp32 2.0.14 +;;platform = espressif32@ ~6.5.0 +;;platform_packages = platformio/framework-arduinoespressif32 @ 3.20014.231204 ;; arduino-esp32 2.0.14 platform = ${esp32s3.platform} platform_packages = upload_speed = 921600 build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} ${esp32s3.build_flags} -D WLED_RELEASE_NAME=\"ESP32-S3_4M_qspi\" - -DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_MODE=1 ;; for boards with USB-OTG connector only (USBCDC or "TinyUSB") +build_flags = ${common.build_flags} ${esp32s3.build_flags} -D WLED_RELEASE_NAME=\"ESP32-S3_8M_qspi\" + -DARDUINO_USB_CDC_ON_BOOT=1 ;; -DARDUINO_USB_MODE=1 ;; for boards with USB-OTG connector only (USBCDC or "TinyUSB") -DBOARD_HAS_PSRAM -DLOLIN_WIFI_FIX ; seems to work much better with this -D WLED_WATCHDOG_TIMEOUT=0 @@ -578,27 +597,30 @@ build_flags = ${common.build_flags} ${esp32s3.build_flags} -D WLED_RELEASE_NAME= -D S3_LCD_DIV_NUM=20 ;; Attempt to fix wifi performance issue when panel active with S3 chips -D ARDUINO_ADAFRUIT_MATRIXPORTAL_ESP32S3 -D WLED_DEBUG_BUS - -D SR_DMTYPE=-1 -D I2S_SDPIN=-1 -D I2S_CKPIN=-1 -D I2S_WSPIN=-1 -D MCLK_PIN=-1 ;; Disable to prevent pin clash + -D SR_DMTYPE=1 -D I2S_SDPIN=-1 -D I2S_CKPIN=-1 -D I2S_WSPIN=-1 -D MCLK_PIN=-1 ;; Disable to prevent pin clash lib_deps = ${esp32s3.lib_deps} https://github.com/mrfaptastic/ESP32-HUB75-MatrixPanel-DMA.git#aa28e2a ;; S3_LCD_DIV_NUM fix -board_build.partitions = ${esp32.default_partitions} +board_build.partitions = ${esp32.large_partitions} ;; standard bootloader and 8MB Flash partitions +;; board_build.partitions = tools/partitions-8MB_spiffs-tinyuf2.csv ;; supports adafruit UF2 bootloader board_build.f_flash = 80000000L board_build.flash_mode = qio monitor_filters = esp32_exception_decoder custom_usermods = audioreactive [env:esp32S3_PSRAM_HUB75] -;; MOONHUB HUB75 adapter board +;; MOONHUB HUB75 adapter board (lilygo T7-S3 with 16MB flash and PSRAM) board = lilygo-t7-s3 platform = ${esp32s3.platform} platform_packages = upload_speed = 921600 build_unflags = ${common.build_unflags} + ${Speed_Flags.build_unflags} ;; optional: removes "-Os" so we can override with "-O2" in build_flags build_flags = ${common.build_flags} ${esp32s3.build_flags} -D WLED_RELEASE_NAME=\"esp32S3_16MB_PSRAM_HUB75\" - -DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_MODE=1 ;; for boards with USB-OTG connector only (USBCDC or "TinyUSB") + ${Speed_Flags.build_flags} ;; optional: -O2 -> optimize for speed instead of size + -DARDUINO_USB_CDC_ON_BOOT=1 ;; -DARDUINO_USB_MODE=1 ;; for boards with USB-OTG connector only (USBCDC or "TinyUSB") -DBOARD_HAS_PSRAM -DLOLIN_WIFI_FIX ; seems to work much better with this -D WLED_WATCHDOG_TIMEOUT=0 @@ -612,7 +634,8 @@ build_flags = ${common.build_flags} ${esp32s3.build_flags} -D WLED_RELEASE_NAME= lib_deps = ${esp32s3.lib_deps} https://github.com/mrfaptastic/ESP32-HUB75-MatrixPanel-DMA.git#aa28e2a ;; S3_LCD_DIV_NUM fix -board_build.partitions = ${esp32.default_partitions} +;;board_build.partitions = ${esp32.large_partitions} ;; for 8MB flash +board_build.partitions = ${esp32.extreme_partitions} ;; for 16MB flash board_build.f_flash = 80000000L board_build.flash_mode = qio monitor_filters = esp32_exception_decoder diff --git a/tools/WLED_ESP32_32MB.csv b/tools/WLED_ESP32_32MB.csv new file mode 100644 index 0000000000..2aa06e6f29 --- /dev/null +++ b/tools/WLED_ESP32_32MB.csv @@ -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, 0x300000, +app1, app, ota_1, 0x310000,0x300000, +spiffs, data, spiffs, 0x610000,0x19E0000, +coredump, data, coredump,,64K diff --git a/wled00/util.cpp b/wled00/util.cpp index 717264752e..cfaea2f0af 100644 --- a/wled00/util.cpp +++ b/wled00/util.cpp @@ -636,10 +636,12 @@ int32_t hw_random(int32_t lowerlimit, int32_t upperlimit) { #if defined(IDF_TARGET_ESP32C3) || defined(ESP8266) #error "ESP32-C3 and ESP8266 with PSRAM is not supported, please remove BOARD_HAS_PSRAM definition" #else - // BOARD_HAS_PSRAM also means that compiler flag "-mfix-esp32-psram-cache-issue" has to be used + #if defined(ARDUINO_ARCH_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32S3) // PSRAM fix only needed for classic esp32 + // BOARD_HAS_PSRAM also means that compiler flag "-mfix-esp32-psram-cache-issue" has to be used for old "rev.1" esp32 #warning "BOARD_HAS_PSRAM defined, make sure to use -mfix-esp32-psram-cache-issue to prevent issues on rev.1 ESP32 boards \ see https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-guides/external-ram.html#esp32-rev-v1-0" #endif + #endif #else #if !defined(IDF_TARGET_ESP32C3) && !defined(ESP8266) #pragma message("BOARD_HAS_PSRAM not defined, not using PSRAM.")