From f38196f4c996e897d0ed3032dd493be90bb809ac Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Wed, 22 Feb 2023 17:22:44 +0100 Subject: [PATCH] PICO board updates + fix for array overflow platformio.ini: buildenv updates for PICO board (reduced upload speed, added "V4" environment) wled.h: allow wifi sleep for PICO board (to reduce heat output) xml.cpp: increase buffer arrays to avoid array bounds violations (PM_NO_PIN = 255 i.e. 4 bytes per element needed) --- platformio.ini | 52 +++++++++++++++++++++++++++++++++++++++++--------- wled00/wled.h | 2 +- wled00/xml.cpp | 10 +++++----- 3 files changed, 49 insertions(+), 15 deletions(-) diff --git a/platformio.ini b/platformio.ini index ef88ffb0..56feed5a 100644 --- a/platformio.ini +++ b/platformio.ini @@ -48,8 +48,6 @@ default_envs = esp32_16MB_all esp8266_4MB_min esp8266_4MB_max - esp32_4MB_PSRAM_max - esp32S3_8MB_max wemos_shield_esp32_4MB_max wemos_shield_esp32_4MB_ICS4343x_max wemos_shield_esp32_4MB_SPM1423_max @@ -60,7 +58,12 @@ default_envs = wemos_shield_esp32_16MB_SPM1423_all wemos_shield_esp32_16MB_LineIn_max esp32_pico_4MB_max - esp32s2_tinyUF2_PSRAM_max + esp32_4MB_PSRAM_max + esp32S3_8MB_max + esp32s2_tinyUF2_PSRAM_max ;; experimental - only for adafruit -S2 boards with UF2 bootloader !!! + esp32c3dev_4MB_max ;; experimental + esp32_4MB_V4_min ;; experimental + esp32_16MB_V4_max ;; experimental esp8266pro_16MB_min esp01_1MB_min @@ -1404,6 +1407,9 @@ board_build.partitions = ${Board_ESP32_16MB.board_build.partitions} [env:esp32_pico_4MB_max] extends = esp32_4MB_max_base board = pico32 +board_build.flash_mode = dout ;; (dout = dual out; more compatible than qio = quad i/o) +upload_speed = 256000 ;; or 115200 ;; or 460800 ; or 921600 (slower speeds are better when flashing without a soldered connection) + build_flags = ${esp32_4MB_max_base.build_flags} -D WLED_RELEASE_NAME=esp32_pico_4MB_max -D WLED_DISABLE_BROWNOUT_DET @@ -1412,12 +1418,10 @@ build_flags = ${esp32_4MB_max_base.build_flags} ; -D WLED_DEBUG ; -D SR_DEBUG -D LEDPIN=2 - -D RLYPIN=-1 - -D BTNPIN=-1 - -D IRPIN=-1 + -D RLYPIN=-1 -D BTNPIN=-1 -D IRPIN=-1 -D HW_PIN_SCL=22 -D HW_PIN_SDA=21 -D SR_DMTYPE=1 -D I2S_SDPIN=25 -D I2S_WSPIN=15 -D I2S_CKPIN=14 - -D SR_SQUELCH=5 -D SR_GAIN=30 -D SR_FREQ_PROF=5 ; ICS-43434 specific + -D SR_SQUELCH=5 -D SR_GAIN=30 -D SR_FREQ_PROF=5 ; ICS-4343x specific ; -D MCLK_PIN=0 -D SR_ENABLE_DEFAULT ;; enable at first start - no need to manually set "enable", then reboot ; -D WLED_USE_MY_CONFIG @@ -1427,5 +1431,35 @@ build_flags = ${esp32_4MB_max_base.build_flags} ; -D WLED_DISABLE_MQTT ; -D WLED_DISABLE_INFRARED ; -D WLED_ENABLE_DMX -; RAM: [== ] 24.4% (used 79804 bytes from 327680 bytes) -; Flash: [========= ] 88.6% (used 1394241 bytes from 1572864 bytes) +; RAM: [== ] 24.4% (used 79812 bytes from 327680 bytes) +; Flash: [========= ] 90.4% (used 1422581 bytes from 1572864 bytes) + + +;; experimental +;; PICO environment with ESP-IDF v4.4.1 / arduino-esp32 v2.0.4 +[env:esp32_pico_4MB_V4_min] +extends = esp32_4MB_V4_min_base +board = pico32 +;platform = espressif32@~5.2.0 ;; alternative platform, might help in case you experience bootloops due to corrupted flash filesystem +;platform_packages = +upload_speed = 256000 ;; or 115200 ;; or 460800 ; or 921600 (slower speeds are better when flashing without a soldered connection) + +build_flags = ${esp32_4MB_V4_min_base.build_flags} + -D ARDUINO_USB_CDC_ON_BOOT=0 ; needed for arduino-esp32 >=2.0.4; avoids errors on startup + -D WLED_RELEASE_NAME=esp32_pico_4MB_V4_min + -D WLED_DISABLE_BROWNOUT_DET + -D SERVERNAME='"WLED-pico32-V4"' + -D WLED_WATCHDOG_TIMEOUT=0 + ; -D WLED_WATCHDOG_TIMEOUT=60 + ; -D WLED_DEBUG + ; -D SR_DEBUG + -D LEDPIN=2 + -D RLYPIN=-1 -D BTNPIN=-1 -D IRPIN=-1 + -D HW_PIN_SCL=22 -D HW_PIN_SDA=21 + -D SR_DMTYPE=1 -D I2S_SDPIN=25 -D I2S_WSPIN=15 -D I2S_CKPIN=14 + -D SR_SQUELCH=5 -D SR_GAIN=30 -D SR_FREQ_PROF=5 ; ICS-4343x specific + ; -D MCLK_PIN=0 + -D SR_ENABLE_DEFAULT ;; enable audioreactive at first start - no need to manually set "enable", then reboot + ; -D WLED_USE_MY_CONFIG +; RAM: [== ] 24.5% (used 80436 bytes from 327680 bytes) +; Flash: [========= ] 93.9% (used 1476341 bytes from 1572864 bytes) diff --git a/wled00/wled.h b/wled00/wled.h index cbf6895f..f5063644 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -290,7 +290,7 @@ WLED_GLOBAL byte apBehavior _INIT(AP_BEHAVIOR_BOOT_NO_CONN); // access poi WLED_GLOBAL IPAddress staticIP _INIT_N((( 0, 0, 0, 0))); // static IP of ESP WLED_GLOBAL IPAddress staticGateway _INIT_N((( 0, 0, 0, 0))); // gateway (router) IP WLED_GLOBAL IPAddress staticSubnet _INIT_N(((255, 255, 255, 0))); // most common subnet in home networks -#ifdef ARDUINO_ARCH_ESP32 +#if defined(ARDUINO_ARCH_ESP32) && !defined(ARDUINO_ESP32_PICO) WLED_GLOBAL bool noWifiSleep _INIT(true); // disabling modem sleep modes will increase heat output and power usage, but may help with connection issues #else WLED_GLOBAL bool noWifiSleep _INIT(false); diff --git a/wled00/xml.cpp b/wled00/xml.cpp index 5dc5e62a..5c5f5175 100644 --- a/wled00/xml.cpp +++ b/wled00/xml.cpp @@ -274,16 +274,16 @@ void appendGPIOinfo() { #endif oappend(SET_F(";")); - char dt_pins[48]; // fix warning: output 45 bytes into a destination of size 30 + char dt_pins[64] = { '\0' }; // fix warning: output 45 bytes into a destination of size 30 #if defined(ESP8266) && !defined(ARDUINO_ESP8266_ESP01) - sprintf(dt_pins, "d.dt_pins=[%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d];", D0, D1, D2, D3, D4, D5, D6, D7, D8, hardwareRX, hardwareTX); + snprintf(dt_pins, 64, "d.dt_pins=[%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d];", D0, D1, D2, D3, D4, D5, D6, D7, D8, hardwareRX, hardwareTX); #else - sprintf(dt_pins, "d.dt_pins=[%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d];", PM_NO_PIN, PM_NO_PIN, PM_NO_PIN, PM_NO_PIN, PM_NO_PIN, PM_NO_PIN, PM_NO_PIN, PM_NO_PIN, PM_NO_PIN, hardwareRX, hardwareTX); + snprintf(dt_pins, 64, "d.dt_pins=[%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d];", PM_NO_PIN, PM_NO_PIN, PM_NO_PIN, PM_NO_PIN, PM_NO_PIN, PM_NO_PIN, PM_NO_PIN, PM_NO_PIN, PM_NO_PIN, hardwareRX, hardwareTX); #endif oappend(dt_pins); - char a_pins[48]; // fix warning: output 45 bytes into a destination of size 30 - sprintf(a_pins, "d.a_pins=[%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d];", pinManager.getADCPin(PM_ADC1, 0), pinManager.getADCPin(PM_ADC1, 1), pinManager.getADCPin(PM_ADC1, 2), pinManager.getADCPin(PM_ADC1, 3), pinManager.getADCPin(PM_ADC1, 4), pinManager.getADCPin(PM_ADC1, 5), pinManager.getADCPin(PM_ADC1, 6), pinManager.getADCPin(PM_ADC1, 7), pinManager.getADCPin(PM_ADC1, 8), pinManager.getADCPin(PM_ADC1, 9), pinManager.getADCPin(PM_ADC1, 10)); + char a_pins[64] = { '\0' }; // fix warning: output 45 bytes into a destination of size 30 + snprintf(a_pins, 64, "d.a_pins=[%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d];", pinManager.getADCPin(PM_ADC1, 0), pinManager.getADCPin(PM_ADC1, 1), pinManager.getADCPin(PM_ADC1, 2), pinManager.getADCPin(PM_ADC1, 3), pinManager.getADCPin(PM_ADC1, 4), pinManager.getADCPin(PM_ADC1, 5), pinManager.getADCPin(PM_ADC1, 6), pinManager.getADCPin(PM_ADC1, 7), pinManager.getADCPin(PM_ADC1, 8), pinManager.getADCPin(PM_ADC1, 9), pinManager.getADCPin(PM_ADC1, 10)); oappend(a_pins); }