From 72472e241c9d53c7f897c3e51180ef40ce3bf3f0 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 30 Aug 2024 18:36:26 +0200 Subject: [PATCH] Enable usage of PSRAM (#463) * PSRAM * Fix PSRAM --- .github/workflows/beta.yml | 7 +--- .github/workflows/build.yml | 7 +--- .github/workflows/nightly.yml | 7 +--- .github/workflows/release.yml | 7 +--- README.md | 45 ++++++++++++++++++++++ boards/nuki-esp32-s3-oct.json | 50 +++++++++++++++++++++++++ boards/nuki-esp32-s3.json | 2 +- pio_package_post.py | 2 + platformio.ini | 41 ++++++++++++++++++-- resources/how-to-flash.txt | 11 ++++++ sdkconfig.debug.defaults | 4 +- sdkconfig.defaults.esp32 | 6 +++ sdkconfig.defaults.esp32-s3 | 6 +++ sdkconfig.defaults.esp32-s3-oct | 7 ++++ sdkconfig.defaults.esp32-solo1 | 8 +++- src/Config.h | 17 ++++++++- src/WebCfgServer.cpp | 28 ++++++++++++-- src/main.cpp | 7 ++++ updater/pio_package_post.py | 2 + updater/platformio.ini | 10 +++++ updater/sdkconfig.defaults.esp32 | 6 +++ updater/sdkconfig.defaults.esp32-s3 | 6 +++ updater/sdkconfig.defaults.esp32-s3-oct | 7 ++++ updater/sdkconfig.defaults.esp32-solo1 | 8 +++- 24 files changed, 265 insertions(+), 36 deletions(-) create mode 100644 boards/nuki-esp32-s3-oct.json create mode 100644 sdkconfig.defaults.esp32 create mode 100644 sdkconfig.defaults.esp32-s3 create mode 100644 sdkconfig.defaults.esp32-s3-oct create mode 100644 updater/sdkconfig.defaults.esp32 create mode 100644 updater/sdkconfig.defaults.esp32-s3 create mode 100644 updater/sdkconfig.defaults.esp32-s3-oct diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml index 76ff2a9..491d865 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/beta.yml @@ -12,7 +12,7 @@ jobs: strategy: fail-fast: false matrix: - board: [esp32, esp32-s3, esp32-c3, esp32-c6, esp32-h2, esp32-solo1] + board: [esp32, esp32-s3, esp32-s3-oct, esp32-c3, esp32-c6, esp32-h2, esp32-solo1] build: [release, debug] env: BOARD: ${{ matrix.board }} @@ -62,11 +62,6 @@ jobs: run: | BOARD=`echo $BOARD | tr '[:lower:]' '[:upper:]'` - # fix for docs - if [ "$BOARD" = "ESP32DEV" ]; then - BOARD="ESP32" - fi - # look for documentation on flash and copy the command command=`sed -n '/^Howto flash (esptool)$/,$p' ${DOC} | sed -n '/^## '"${BOARD}"'$/,\${ n; n; p; }' | head -n1` diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f6ad16f..6305dc1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ jobs: strategy: fail-fast: false matrix: - board: [esp32, esp32-s3, esp32-c3, esp32-c6, esp32-h2, esp32-solo1] + board: [esp32, esp32-s3, esp32-s3-oct, esp32-c3, esp32-c6, esp32-h2, esp32-solo1] build: [release, debug] env: BOARD: ${{ matrix.board }} @@ -67,11 +67,6 @@ jobs: run: | BOARD=`echo $BOARD | tr '[:lower:]' '[:upper:]'` - # fix for docs - if [ "$BOARD" = "ESP32DEV" ]; then - BOARD="ESP32" - fi - # look for documentation on flash and copy the command command=`sed -n '/^Howto flash (esptool)$/,$p' ${DOC} | sed -n '/^## '"${BOARD}"'$/,\${ n; n; p; }' | head -n1` diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 4a00ebb..652ee9d 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -34,7 +34,7 @@ jobs: strategy: fail-fast: false matrix: - board: [esp32, esp32-s3, esp32-c3, esp32-c6, esp32-h2, esp32-solo1] + board: [esp32, esp32-s3, esp32-s3-oct, esp32-c3, esp32-c6, esp32-h2, esp32-solo1] build: [release, debug] env: BOARD: ${{ matrix.board }} @@ -84,11 +84,6 @@ jobs: run: | BOARD=`echo $BOARD | tr '[:lower:]' '[:upper:]'` - # fix for docs - if [ "$BOARD" = "ESP32DEV" ]; then - BOARD="ESP32" - fi - # look for documentation on flash and copy the command command=`sed -n '/^Howto flash (esptool)$/,$p' ${DOC} | sed -n '/^## '"${BOARD}"'$/,\${ n; n; p; }' | head -n1` diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b8a2eb1..d1765e0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,7 +12,7 @@ jobs: strategy: fail-fast: false matrix: - board: [esp32, esp32-s3, esp32-c3, esp32-c6, esp32-h2, esp32-solo1] + board: [esp32, esp32-s3, esp32-s3-oct, esp32-c3, esp32-c6, esp32-h2, esp32-solo1] build: [release, debug] env: BOARD: ${{ matrix.board }} @@ -61,11 +61,6 @@ jobs: run: | BOARD=`echo $BOARD | tr '[:lower:]' '[:upper:]'` - # fix for docs - if [ "$BOARD" = "ESP32DEV" ]; then - BOARD="ESP32" - fi - # look for documentation on flash and copy the command command=`sed -n '/^Howto flash (esptool)$/,$p' ${DOC} | sed -n '/^## '"${BOARD}"'$/,\${ n; n; p; }' | head -n1` diff --git a/README.md b/README.md index cd30f24..483d664 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,23 @@ As an alternative to Wi-Fi (which is available on any supported ESP32), the foll In principle all ESP32 (and variants) devices with built-in ethernet port are supported, but might require additional setup using the "Custom LAN setup" option. See the "[Connecting via Ethernet](#connecting-via-ethernet-optional)" section for more information. +## Recommended ESP32 devices + +- If WIFI6 is required: ESP32-C6 +- If PoE is required: Any of the above mentioned devices with PoE or any other ESP device in combination with a SPI Ethernet module ([W5500](https://www.aliexpress.com/w/wholesale-w5500.html)) and [PoE to Ethernet and USB type B/C splitter](https://aliexpress.com/w/wholesale-poe-splitter-usb-c.html) +- If you want maximum performance and intend to run any or multiple of the following: + - a Nuki Lock and Nuki Opener and/or + - MQTT SSL and/or + - HTTP SSL and/or + - large amounts of keypad codes, timecontrol or authorization entries + - Developing/debugging Nuki devices and/or Nuki Hub + + An ESP32-S3 with 2MB of PSRAM or more (look for an ESP32-S3 with the designation N>=4 and R>=2 such as an ESP32-S3 N16R8) + +- In general when buying a new device when size and a couple of dollars more or less are not an issue: An ESP32-S3 with 2MB of PSRAM or more.
+ +The ESP32-S3 is a dual-core CPU with many GPIO's, ability to enlarge RAM using PSRAM, ability to connect Ethernet modules over SPI and optionally power the device with a PoE splitter. The only functions missing from the ESP32-S3 as compared to other ESP devices is the ability to use some Ethernet modules only supported by the original ESP32 and the ability to connect over WIFI6 (C6) + ## Support Nuki Hub development If you haven't ordered your Nuki product yet, you can support me by using my referrer code when placing your order:
@@ -97,6 +114,34 @@ Enable "Register as app" before pairing to allow this. Otherwise the Bridge will Hybrid mode allows you to use the official Nuki MQTT implemenation on a Nuki Lock 3.0 Pro, Nuki Lock 4.0 or Nuki Lock 4.0 Pro in conjunction with Nuki Hub.
See [hybrid mode](/HYBRID.md) for more information. +## Memory constraints + +ESP32 devices have a limited amount of free RAM available.
+
+On version 9.01 of Nuki Hub with only a Nuki Lock connected the expected free amount of RAM/Heap available is around: +- ESP32: 60 kilobytes / 60.000 bytes +- Other variants (C3/S3/C6/H2): 90-120 kilobytes / 90.000-120.000 bytes + +This free amount of RAM can be reduced (temporarily) by certain actions (such as changing Nuki device config) or continuously when enabling the following: +- Connecting both a Nuki opener and a Nuki lock to Nuki Hub +- Enlarging stack sizes of the Nuki and Network task to accommodate large amounts of keypad codes, authorization entries or timecontrol entries +- MQTT SSL (Costs about 30k RAM) +- HTTP SSL (Costs about 30k RAM) +- Developing/debugging Nuki devices and/or Nuki Hub, using WebSerial (Costs about 30k RAM) + +The currently available RAM/Heap can be found on the info page of the Web configurator of Nuki Hub.
+
+When the ESP32 runs out of available RAM this device can crash or otherwise unexpected behaviour can occur.
+
+Nuki Hub does allow for the use of embedded PSRAM on the regular binaries whenever it is available.
+PSRAM is usually 2, 4 or 8MB in size and thus greatly enlarges the 320kb of internal RAM that is available.
+It is basically impossible to run out of RAM when PSRAM is available. +You can check on the info page of the Web configurator if PSRAM is available. + +Note that there are two build of Nuki Hub for the ESP32-S3 available.
+One for devices with no or Quad SPI PSRAM and one for devices with Octal SPI PSRAM.
+If your ESP32-S3 device has PSRAM but it is not detected please flash the other S3 binary. + ## Configuration In a browser navigate to the IP address assigned to the ESP32. diff --git a/boards/nuki-esp32-s3-oct.json b/boards/nuki-esp32-s3-oct.json new file mode 100644 index 0000000..1c52fbe --- /dev/null +++ b/boards/nuki-esp32-s3-oct.json @@ -0,0 +1,50 @@ +{ + "build": { + "arduino":{ + "ldscript": "esp32s3_out.ld" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_ESP32S3_DEV", + "-DARDUINO_USB_MODE=1", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [ + [ + "0x303A", + "0x1001" + ] + ], + "mcu": "esp32s3", + "variant": "esp32s3" + }, + "connectivity": [ + "bluetooth", + "wifi" + ], + "debug": { + "default_tool": "esp-builtin", + "onboard_tools": [ + "esp-builtin" + ], + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "ESP32-S3 (>=4 MB QD, OCTAL PSRAM)", + "upload": { + "flash_size": "4MB", + "maximum_ram_size": 327680, + "maximum_size": 4194304, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/user-guide-devkitc-1.html", + "vendor": "Espressif" +} diff --git a/boards/nuki-esp32-s3.json b/boards/nuki-esp32-s3.json index 9dd0cf6..a45a34d 100644 --- a/boards/nuki-esp32-s3.json +++ b/boards/nuki-esp32-s3.json @@ -37,7 +37,7 @@ "arduino", "espidf" ], - "name": "ESP32-S3 (4 MB QD, No PSRAM)", + "name": "ESP32-S3 (>=4 MB QD, QUAD OR NO PSRAM)", "upload": { "flash_size": "4MB", "maximum_ram_size": 327680, diff --git a/pio_package_post.py b/pio_package_post.py index 2e20791..b412cad 100644 --- a/pio_package_post.py +++ b/pio_package_post.py @@ -9,6 +9,8 @@ def get_board_name(env): if env.get('BOARD') == 'esp32-solo1': board = env.get('BOARD').replace('-', '') + elif env.get('BOARD') == 'nuki-esp32-s3-oct': + board = 'esp32s3oct' return board def create_target_dir(env): diff --git a/platformio.ini b/platformio.ini index 21d694f..abc8855 100644 --- a/platformio.ini +++ b/platformio.ini @@ -73,7 +73,7 @@ monitor_filters = [env:esp32] board = esp32dev board_build.cmake_extra_args = - -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.release.defaults" + -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.release.defaults;sdkconfig.defaults.esp32" extra_scripts = pre:pio_package_pre.py post:pio_package_post.py @@ -89,21 +89,33 @@ build_flags = [env:esp32-c3] extends = env:esp32 board = esp32-c3-devkitc-02 +board_build.cmake_extra_args = + -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.release.defaults" [env:esp32-s3] extends = env:esp32 board = nuki-esp32-s3 +board_build.cmake_extra_args = + -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.release.defaults;sdkconfig.defaults.esp32-s3" + +[env:esp32-s3-oct] +extends = env:esp32 +board = nuki-esp32-s3-oct +board_build.cmake_extra_args = + -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.release.defaults;sdkconfig.defaults.esp32-s3-oct" [env:esp32-c6] extends = env:esp32 board = esp32-c6-devkitm-1 +board_build.cmake_extra_args = + -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.release.defaults" [env:esp32-h2] extends = env:esp32 board = esp32-h2-devkitm-1 board_build.cmake_extra_args = -DNUKI_TARGET_H2=y - -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.debug.defaults" + -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.release.defaults" lib_ignore = BLE BluetoothSerial @@ -124,7 +136,7 @@ board_build.cmake_extra_args = extends = env:esp32 custom_build = debug board_build.cmake_extra_args = - -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.debug.defaults" + -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.debug.defaults;sdkconfig.defaults.esp32" build_flags = ${env.build_flags} -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG @@ -209,7 +221,28 @@ build_flags = extends = env:esp32-s3 custom_build = debug board_build.cmake_extra_args = - -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.debug.defaults" + -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.debug.defaults;sdkconfig.defaults.esp32-s3" +build_flags = + ${env.build_flags} + -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG + -DCONFIG_NIMBLE_CPP_LOG_LEVEL=0 + -DCONFIG_BT_NIMBLE_LOG_LEVEL=0 + -DDEBUG_NUKIHUB + -DDEBUG_SENSE_NUKI + -DDEBUG_NUKI_COMMAND + -DDEBUG_NUKI_CONNECT + -DDEBUG_NUKI_COMMUNICATION + ;-DDEBUG_NUKI_HEX_DATA + -DDEBUG_NUKI_READABLE_DATA + -DCONFIG_ASYNC_TCP_QUEUE_SIZE=128 + -DCONFIG_ASYNC_TCP_STACK_SIZE=8192 + -DWS_MAX_QUEUED_MESSAGES=512 + +[env:esp32-s3-oct_dbg] +extends = env:esp32-s3-oct +custom_build = debug +board_build.cmake_extra_args = + -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.debug.defaults;sdkconfig.defaults.esp32-s3-oct" build_flags = ${env.build_flags} -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG diff --git a/resources/how-to-flash.txt b/resources/how-to-flash.txt index 6d11dbe..fc2737d 100644 --- a/resources/how-to-flash.txt +++ b/resources/how-to-flash.txt @@ -36,6 +36,13 @@ e000 boot_app0.bin 10000 nuki_hub_esp32s3.bin 280000 nuki_hub_updater_esp32s3.bin +ESP32-S3-OCT +e000 boot_app0.bin +0 bootloader.bin +8000 nuki_hub.partitions.bin +10000 nuki_hub_esp32s3oct.bin +280000 nuki_hub_updater_esp32s3oct.bin + ESP32-C3 e000 boot_app0.bin 0 bootloader.bin @@ -84,6 +91,10 @@ esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset esptool.py --chip esp32s3 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x0 bootloader.bin 0x10000 nuki_hub_esp32s3.bin 0x280000 nuki_hub_updater_esp32s3.bin 0x8000 nuki_hub.partitions.bin +## ESP32-S3-OCT + +esptool.py --chip esp32s3 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x0 bootloader.bin 0x10000 nuki_hub_esp32s3oct.bin 0x280000 nuki_hub_updater_esp32s3oct.bin 0x8000 nuki_hub.partitions.bin + ## ESP32-C3 esptool.py --chip esp32c3 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x0 bootloader.bin 0x10000 nuki_hub_esp32c3.bin 0x280000 nuki_hub_updater_esp32c3.bin 0x8000 nuki_hub.partitions.bin diff --git a/sdkconfig.debug.defaults b/sdkconfig.debug.defaults index 19ac7c9..ee9344a 100644 --- a/sdkconfig.debug.defaults +++ b/sdkconfig.debug.defaults @@ -2,4 +2,6 @@ CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y CONFIG_LOG_DEFAULT_LEVEL=4 CONFIG_ESP_IPC_TASK_STACK_SIZE=8192 CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y -CONFIG_BOOTLOADER_LOG_LEVEL=1 \ No newline at end of file +CONFIG_BOOTLOADER_LOG_LEVEL=1 +CONFIG_FREERTOS_USE_TRACE_FACILITY=y +CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS=y \ No newline at end of file diff --git a/sdkconfig.defaults.esp32 b/sdkconfig.defaults.esp32 new file mode 100644 index 0000000..10a55c9 --- /dev/null +++ b/sdkconfig.defaults.esp32 @@ -0,0 +1,6 @@ +CONFIG_SPIRAM=y +CONFIG_SPIRAM_IGNORE_NOTFOUND=y +CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC=y +CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_DEFAULT=y +CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=4096 +CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=50768 \ No newline at end of file diff --git a/sdkconfig.defaults.esp32-s3 b/sdkconfig.defaults.esp32-s3 new file mode 100644 index 0000000..10a55c9 --- /dev/null +++ b/sdkconfig.defaults.esp32-s3 @@ -0,0 +1,6 @@ +CONFIG_SPIRAM=y +CONFIG_SPIRAM_IGNORE_NOTFOUND=y +CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC=y +CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_DEFAULT=y +CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=4096 +CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=50768 \ No newline at end of file diff --git a/sdkconfig.defaults.esp32-s3-oct b/sdkconfig.defaults.esp32-s3-oct new file mode 100644 index 0000000..103353e --- /dev/null +++ b/sdkconfig.defaults.esp32-s3-oct @@ -0,0 +1,7 @@ +CONFIG_SPIRAM=y +CONFIG_SPIRAM_IGNORE_NOTFOUND=y +CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC=y +CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_DEFAULT=y +CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=4096 +CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=50768 +CONFIG_SPIRAM_MODE_OCT=y \ No newline at end of file diff --git a/sdkconfig.defaults.esp32-solo1 b/sdkconfig.defaults.esp32-solo1 index 58ed5cc..2cb5c90 100644 --- a/sdkconfig.defaults.esp32-solo1 +++ b/sdkconfig.defaults.esp32-solo1 @@ -1 +1,7 @@ -CONFIG_FREERTOS_UNICORE=y \ No newline at end of file +CONFIG_FREERTOS_UNICORE=y +CONFIG_SPIRAM=y +CONFIG_SPIRAM_IGNORE_NOTFOUND=y +CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC=y +CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_DEFAULT=y +CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=4096 +CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=50768 \ No newline at end of file diff --git a/src/Config.h b/src/Config.h index d621c64..de1c633 100644 --- a/src/Config.h +++ b/src/Config.h @@ -4,7 +4,7 @@ #define NUKI_HUB_VERSION "9.01" #define NUKI_HUB_BUILD "unknownbuildnr" -#define NUKI_HUB_DATE "2024-08-18" +#define NUKI_HUB_DATE "unknownbuilddate" #define GITHUB_LATEST_RELEASE_URL (char*)"https://github.com/technyon/nuki_hub/releases/latest" #define GITHUB_OTA_MANIFEST_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/manifest.json" @@ -23,6 +23,20 @@ #define GITHUB_MASTER_RELEASE_BINARY_URL_DBG (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/debug/master/nuki_hub_esp32c3.bin" #define GITHUB_MASTER_UPDATER_BINARY_URL_DBG (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/debug/master/nuki_hub_updater_esp32c3.bin" #elif defined(CONFIG_IDF_TARGET_ESP32S3) +#if defined(CONFIG_SPIRAM_MODE_OCT) +#define GITHUB_LATEST_RELEASE_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/nuki_hub_esp32s3oct.bin" +#define GITHUB_LATEST_UPDATER_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/nuki_hub_updater_esp32s3oct.bin" +#define GITHUB_BETA_RELEASE_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/beta/nuki_hub_esp32s3oct.bin" +#define GITHUB_BETA_UPDATER_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/beta/nuki_hub_updater_esp32s3oct.bin" +#define GITHUB_MASTER_RELEASE_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/master/nuki_hub_esp32s3oct.bin" +#define GITHUB_MASTER_UPDATER_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/master/nuki_hub_updater_esp32s3oct.bin" +#define GITHUB_LATEST_RELEASE_BINARY_URL_DBG (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/debug/nuki_hub_esp32s3oct.bin" +#define GITHUB_LATEST_UPDATER_BINARY_URL_DBG (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/debug/nuki_hub_updater_esp32s3oct.bin" +#define GITHUB_BETA_RELEASE_BINARY_URL_DBG (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/debug/beta/nuki_hub_esp32s3oct.bin" +#define GITHUB_BETA_UPDATER_BINARY_URL_DBG (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/debug/beta/nuki_hub_updater_esp32s3oct.bin" +#define GITHUB_MASTER_RELEASE_BINARY_URL_DBG (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/debug/master/nuki_hub_esp32s3oct.bin" +#define GITHUB_MASTER_UPDATER_BINARY_URL_DBG (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/debug/master/nuki_hub_updater_esp32s3oct.bin" +#else #define GITHUB_LATEST_RELEASE_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/nuki_hub_esp32s3.bin" #define GITHUB_LATEST_UPDATER_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/nuki_hub_updater_esp32s3.bin" #define GITHUB_BETA_RELEASE_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/beta/nuki_hub_esp32s3.bin" @@ -35,6 +49,7 @@ #define GITHUB_BETA_UPDATER_BINARY_URL_DBG (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/debug/beta/nuki_hub_updater_esp32s3.bin" #define GITHUB_MASTER_RELEASE_BINARY_URL_DBG (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/debug/master/nuki_hub_esp32s3.bin" #define GITHUB_MASTER_UPDATER_BINARY_URL_DBG (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/debug/master/nuki_hub_updater_esp32s3.bin" +#endif #elif defined(CONFIG_IDF_TARGET_ESP32C6) #define GITHUB_LATEST_RELEASE_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/nuki_hub_esp32c6.bin" #define GITHUB_LATEST_UPDATER_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/nuki_hub_updater_esp32c6.bin" diff --git a/src/WebCfgServer.cpp b/src/WebCfgServer.cpp index a595508..0b0b8a4 100644 --- a/src/WebCfgServer.cpp +++ b/src/WebCfgServer.cpp @@ -4,6 +4,9 @@ #include "Logger.h" #include "RestartReason.h" #include +#ifdef CONFIG_SOC_SPIRAM_SUPPORTED +#include +#endif #ifndef CONFIG_IDF_TARGET_ESP32H2 #include #endif @@ -3071,7 +3074,6 @@ void WebCfgServer::buildAccLvlHtml(AsyncWebServerRequest *request) _response.concat("
"); _response.concat("
"); } - _response.concat(""); _response.concat(""); sendResponse(request); @@ -3203,8 +3205,28 @@ void WebCfgServer::buildInfoHtml(AsyncWebServerRequest *request) _response.concat(getRestartReason()); _response.concat("\nLast restart reason ESP: "); _response.concat(getEspRestartReason()); - _response.concat("\nFree heap: "); - _response.concat(esp_get_free_heap_size()); + _response.concat("\nFree internal heap: "); + _response.concat(ESP.getFreeHeap()); + _response.concat("\nTotal internal heap: "); + _response.concat(ESP.getHeapSize()); + #ifdef CONFIG_SOC_SPIRAM_SUPPORTED + if(esp_psram_get_size() > 0) + { + _response.concat("\nPSRAM Available: Yes"); + _response.concat("\nTotal PSRAM: "); + _response.concat(esp_psram_get_size()); + _response.concat("\nFree PSRAM: "); + _response.concat((esp_get_free_heap_size() - ESP.getFreeHeap())); + _response.concat("\nTotal free heap: "); + _response.concat(esp_get_free_heap_size()); + } + else + { + _response.concat("\nPSRAM Available: No"); + } + #else + _response.concat("\nPSRAM Available: No"); + #endif _response.concat("\nNetwork task stack high watermark: "); _response.concat(uxTaskGetStackHighWaterMark(networkTaskHandle)); _response.concat("\nNuki task stack high watermark: "); diff --git a/src/main.cpp b/src/main.cpp index e1ae161..47787e1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -514,6 +514,13 @@ void setup() if(doOta) setupTasks(true); else setupTasks(false); + + #ifdef DEBUG_NUKIHUB + Log->print("Task Name\tStatus\tPrio\tHWM\tTask\tAffinity\n"); + char stats_buffer[1024]; + vTaskList(stats_buffer); + Log->println(stats_buffer); + #endif } void loop() diff --git a/updater/pio_package_post.py b/updater/pio_package_post.py index 159f7c6..571b73f 100644 --- a/updater/pio_package_post.py +++ b/updater/pio_package_post.py @@ -8,6 +8,8 @@ def get_board_name(env): board = env.get('BOARD_MCU') if env.get('BOARD') == 'esp32-solo1': board = env.get('BOARD').replace('-', '') + elif env.get('BOARD') == 'nuki-esp32-s3-oct': + board = 'esp32s3oct' return board def create_target_dir(env): diff --git a/updater/platformio.ini b/updater/platformio.ini index 7bf7ec3..3cd6f2d 100644 --- a/updater/platformio.ini +++ b/updater/platformio.ini @@ -67,6 +67,8 @@ board = esp32dev extra_scripts = pre:pio_package_pre.py post:pio_package_post.py +board_build.cmake_extra_args = + -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.defaults.esp32" [env:updater_esp32-c3] extends = env:updater_esp32 @@ -75,6 +77,14 @@ board = esp32-c3-devkitc-02 [env:updater_esp32-s3] extends = env:updater_esp32 board = nuki-esp32-s3 +board_build.cmake_extra_args = + -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.defaults.esp32-s3" + +[env:updater_esp32-s3-oct] +extends = env:updater_esp32 +board = nuki-esp32-s3-oct +board_build.cmake_extra_args = + -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.defaults.esp32-s3-oct" [env:updater_esp32-c6] extends = env:updater_esp32 diff --git a/updater/sdkconfig.defaults.esp32 b/updater/sdkconfig.defaults.esp32 new file mode 100644 index 0000000..10a55c9 --- /dev/null +++ b/updater/sdkconfig.defaults.esp32 @@ -0,0 +1,6 @@ +CONFIG_SPIRAM=y +CONFIG_SPIRAM_IGNORE_NOTFOUND=y +CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC=y +CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_DEFAULT=y +CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=4096 +CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=50768 \ No newline at end of file diff --git a/updater/sdkconfig.defaults.esp32-s3 b/updater/sdkconfig.defaults.esp32-s3 new file mode 100644 index 0000000..10a55c9 --- /dev/null +++ b/updater/sdkconfig.defaults.esp32-s3 @@ -0,0 +1,6 @@ +CONFIG_SPIRAM=y +CONFIG_SPIRAM_IGNORE_NOTFOUND=y +CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC=y +CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_DEFAULT=y +CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=4096 +CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=50768 \ No newline at end of file diff --git a/updater/sdkconfig.defaults.esp32-s3-oct b/updater/sdkconfig.defaults.esp32-s3-oct new file mode 100644 index 0000000..103353e --- /dev/null +++ b/updater/sdkconfig.defaults.esp32-s3-oct @@ -0,0 +1,7 @@ +CONFIG_SPIRAM=y +CONFIG_SPIRAM_IGNORE_NOTFOUND=y +CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC=y +CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_DEFAULT=y +CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=4096 +CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=50768 +CONFIG_SPIRAM_MODE_OCT=y \ No newline at end of file diff --git a/updater/sdkconfig.defaults.esp32-solo1 b/updater/sdkconfig.defaults.esp32-solo1 index 58ed5cc..2cb5c90 100644 --- a/updater/sdkconfig.defaults.esp32-solo1 +++ b/updater/sdkconfig.defaults.esp32-solo1 @@ -1 +1,7 @@ -CONFIG_FREERTOS_UNICORE=y \ No newline at end of file +CONFIG_FREERTOS_UNICORE=y +CONFIG_SPIRAM=y +CONFIG_SPIRAM_IGNORE_NOTFOUND=y +CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC=y +CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_DEFAULT=y +CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=4096 +CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=50768 \ No newline at end of file