From 5711fcafa4670fc5e238132bd063f986fdfd1e12 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 9 Mar 2025 18:19:26 +0100 Subject: [PATCH 01/60] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 42f6463d3..3867dcc4f 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ ESP32 is a series of low-cost, low-power system on a chip microcontrollers with ## IDE Preparation -- [Download and install official Microsoft Visual Studio Code](https://code.visualstudio.com/). pioarduino IDE is built on top of it. +- [Download and install Microsoft Visual Studio Code](https://code.visualstudio.com/). pioarduino IDE is on top of it. - Open the extension manager. - Search for the `pioarduino ide` extension. - Install pioarduino IDE extension. From 6fa2efbb2b847d655ff4c8703ce484f91d7e98a9 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 9 Mar 2025 18:43:45 +0100 Subject: [PATCH 02/60] Update IDF 5.4.0.250303 --- platform.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform.json b/platform.json index 3bb195d1f..e252251c7 100644 --- a/platform.json +++ b/platform.json @@ -51,7 +51,7 @@ "type": "framework", "optional": true, "owner": "pioarduino", - "version": "https://github.com/pioarduino/esp-idf/releases/download/v5.4.0.250221/esp-idf-v5.4.0.zip" + "version": "https://github.com/pioarduino/esp-idf/releases/download/v5.4.0.250303/esp-idf-v5.4.0.zip" }, "toolchain-xtensa-esp-elf": { "type": "toolchain", From aa5a97e52d54f9bc133a697ab1b176c7d3ff1f25 Mon Sep 17 00:00:00 2001 From: Unexpected Maker Date: Mon, 10 Mar 2025 21:35:13 +1100 Subject: [PATCH 03/60] Added missing UM boards and fixed TinyS3 product URL. (#122) * Added missing UM boards and fixed TinyS3 product URL. Signed-off-by: Seon Rozenblum * More modifications for UM boards. Signed-off-by: Seon Rozenblum --------- Signed-off-by: Seon Rozenblum Co-authored-by: Seon Rozenblum --- boards/um_bling.json | 51 ++++++++++++++++++++++++++++++++++++ boards/um_feathers3.json | 2 +- boards/um_feathers3_neo.json | 51 ++++++++++++++++++++++++++++++++++++ boards/um_nanos3.json | 2 +- boards/um_omgs3.json | 51 ++++++++++++++++++++++++++++++++++++ boards/um_pros3.json | 2 +- boards/um_tinyc6.json | 38 +++++++++++++++++++++++++++ boards/um_tinys2.json | 3 ++- boards/um_tinys3.json | 4 +-- 9 files changed, 198 insertions(+), 6 deletions(-) create mode 100644 boards/um_bling.json create mode 100644 boards/um_feathers3_neo.json create mode 100644 boards/um_omgs3.json create mode 100644 boards/um_tinyc6.json diff --git a/boards/um_bling.json b/boards/um_bling.json new file mode 100644 index 000000000..aeeabadfe --- /dev/null +++ b/boards/um_bling.json @@ -0,0 +1,51 @@ +{ + "build": { + "arduino":{ + "partitions": "default_8MB.csv", + "memory_type": "qio_qspi" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_BLING", + "-DBOARD_HAS_PSRAM", + "-DARDUINO_USB_CDC_ON_BOOT=1", + "-DARDUINO_USB_MODE=1", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [ + [ + "0X303A", + "0x817F" + ] + ], + "mcu": "esp32s3", + "variant": "um_bling" + }, + "connectivity": [ + "bluetooth", + "wifi" + ], + "debug": { + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "Unexpected Maker BLING!", + "upload": { + "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://unexpectedmaker.com/shop/bling", + "vendor": "Unexpected Maker" +} diff --git a/boards/um_feathers3.json b/boards/um_feathers3.json index 1a851fab5..9c39ea916 100644 --- a/boards/um_feathers3.json +++ b/boards/um_feathers3.json @@ -1,7 +1,6 @@ { "build": { "arduino":{ - "ldscript": "esp32s3_out.ld", "partitions": "default_16MB.csv", "memory_type": "qio_qspi" }, @@ -10,6 +9,7 @@ "-DARDUINO_FEATHERS3", "-DBOARD_HAS_PSRAM", "-DARDUINO_USB_CDC_ON_BOOT=1", + "-DARDUINO_USB_MODE=1", "-DARDUINO_RUNNING_CORE=1", "-DARDUINO_EVENT_RUNNING_CORE=1" ], diff --git a/boards/um_feathers3_neo.json b/boards/um_feathers3_neo.json new file mode 100644 index 000000000..0849ee390 --- /dev/null +++ b/boards/um_feathers3_neo.json @@ -0,0 +1,51 @@ +{ + "build": { + "arduino":{ + "partitions": "default_8MB.csv", + "memory_type": "qio_qspi" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_FEATHERS3NEO", + "-DBOARD_HAS_PSRAM", + "-DARDUINO_USB_CDC_ON_BOOT=1", + "-DARDUINO_USB_MODE=1", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [ + [ + "0X303A", + "0x81FB" + ] + ], + "mcu": "esp32s3", + "variant": "um_feathers3neo" + }, + "connectivity": [ + "bluetooth", + "wifi" + ], + "debug": { + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "Unexpected Maker FeatherS3 Neo", + "upload": { + "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://unexpectedmaker.com/shop/feathers3neo", + "vendor": "Unexpected Maker" +} diff --git a/boards/um_nanos3.json b/boards/um_nanos3.json index 921a36e3f..742c0ac7d 100644 --- a/boards/um_nanos3.json +++ b/boards/um_nanos3.json @@ -1,7 +1,6 @@ { "build": { "arduino": { - "ldscript": "esp32s3_out.ld", "partitions": "default_8MB.csv", "memory_type": "qio_qspi" }, @@ -10,6 +9,7 @@ "-DBOARD_HAS_PSRAM", "-DARDUINO_NANOS3", "-DARDUINO_USB_CDC_ON_BOOT=1", + "-DARDUINO_USB_MODE=1", "-DARDUINO_RUNNING_CORE=1", "-DARDUINO_EVENT_RUNNING_CORE=1" ], diff --git a/boards/um_omgs3.json b/boards/um_omgs3.json new file mode 100644 index 000000000..55994d4a1 --- /dev/null +++ b/boards/um_omgs3.json @@ -0,0 +1,51 @@ +{ + "build": { + "arduino":{ + "partitions": "default_8MB.csv", + "memory_type": "qio_qspi" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_OMGS3", + "-DBOARD_HAS_PSRAM", + "-DARDUINO_USB_CDC_ON_BOOT=1", + "-DARDUINO_USB_MODE=1", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [ + [ + "0X303A", + "0x8224" + ] + ], + "mcu": "esp32s3", + "variant": "um_omgs3" + }, + "connectivity": [ + "bluetooth", + "wifi" + ], + "debug": { + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "Unexpected Maker OMGS3", + "upload": { + "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://unexpectedmaker.com/shop/omgs3", + "vendor": "Unexpected Maker" +} diff --git a/boards/um_pros3.json b/boards/um_pros3.json index 8edcefac3..484c0247b 100644 --- a/boards/um_pros3.json +++ b/boards/um_pros3.json @@ -1,7 +1,6 @@ { "build": { "arduino": { - "ldscript": "esp32s3_out.ld", "partitions": "default_16MB.csv", "memory_type": "qio_qspi" }, @@ -10,6 +9,7 @@ "-DARDUINO_PROS3", "-DBOARD_HAS_PSRAM", "-DARDUINO_USB_CDC_ON_BOOT=1", + "-DARDUINO_USB_MODE=1", "-DARDUINO_RUNNING_CORE=1", "-DARDUINO_EVENT_RUNNING_CORE=1" ], diff --git a/boards/um_tinyc6.json b/boards/um_tinyc6.json new file mode 100644 index 000000000..f34eee9cd --- /dev/null +++ b/boards/um_tinyc6.json @@ -0,0 +1,38 @@ +{ + "build": { + "arduino":{ + "partitions": "default_8MB.csv", + "memory_type": "qio_qspi" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_TINYC6" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "mcu": "esp32c6", + "variant": "um_tinyc6" + }, + "connectivity": [ + "bluetooth", + "wifi" + ], + "debug": { + "openocd_target": "esp32c6.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "Unexpected Maker TinyC6", + "upload": { + "flash_size": "8MB", + "maximum_ram_size": 327680, + "maximum_size": 8388608, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://unexpectedmaker.com/shop/tinyc6", + "vendor": "Unexpected Maker" +} diff --git a/boards/um_tinys2.json b/boards/um_tinys2.json index 8a57216ac..7ca5ca4b4 100644 --- a/boards/um_tinys2.json +++ b/boards/um_tinys2.json @@ -1,7 +1,8 @@ { "build": { "arduino": { - "ldscript": "esp32s2_out.ld" + "partitions": "default_4MB.csv", + "memory_type": "qio_qspi" }, "core": "esp32", "extra_flags": [ diff --git a/boards/um_tinys3.json b/boards/um_tinys3.json index ed7b2a028..cac1514fe 100644 --- a/boards/um_tinys3.json +++ b/boards/um_tinys3.json @@ -1,7 +1,6 @@ { "build": { "arduino":{ - "ldscript": "esp32s3_out.ld", "partitions": "default_8MB.csv", "memory_type": "qio_qspi" }, @@ -10,6 +9,7 @@ "-DARDUINO_TINYS3", "-DBOARD_HAS_PSRAM", "-DARDUINO_USB_CDC_ON_BOOT=1", + "-DARDUINO_USB_MODE=1", "-DARDUINO_RUNNING_CORE=1", "-DARDUINO_EVENT_RUNNING_CORE=1" ], @@ -46,6 +46,6 @@ "require_upload_port": true, "speed": 460800 }, - "url": "https://unexpectedmaker.com/shop/ttinys3-esp32s3", + "url": "https://unexpectedmaker.com/shop/tinys3", "vendor": "Unexpected Maker" } From e247f2ed0c2df6453d9618d514841c2d75cafede Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 19 Mar 2025 16:52:12 +0100 Subject: [PATCH 04/60] boards update taken from https://github.com/sivar2311/platformio_boards Thx @sivar2311 --- boards/bpi-centi-s3.json | 52 ++++++++++++++++++++++++ boards/esp32-s3-devkitc1-n16r16.json | 55 +++++++++++++++++++++++++ boards/esp32-s3-devkitc1-n16r2.json | 55 +++++++++++++++++++++++++ boards/esp32-s3-devkitc1-n16r8.json | 55 +++++++++++++++++++++++++ boards/esp32-s3-devkitc1-n4r2.json | 55 +++++++++++++++++++++++++ boards/esp32-s3-devkitc1-n4r8.json | 55 +++++++++++++++++++++++++ boards/esp32-s3-devkitc1-n8r2.json | 55 +++++++++++++++++++++++++ boards/esp32-s3-devkitc1-n8r8.json | 55 +++++++++++++++++++++++++ boards/esp32-s3-fh4r2.json | 56 ++++++++++++++++++++++++++ boards/feenove-esp32-s3-n8r8.json | 55 +++++++++++++++++++++++++ boards/nologo_esp32c3_super_mini.json | 32 +++++++++++++++ boards/sparkfun_pro_micro_esp32c3.json | 36 +++++++++++++++++ 12 files changed, 616 insertions(+) create mode 100644 boards/bpi-centi-s3.json create mode 100644 boards/esp32-s3-devkitc1-n16r16.json create mode 100644 boards/esp32-s3-devkitc1-n16r2.json create mode 100644 boards/esp32-s3-devkitc1-n16r8.json create mode 100644 boards/esp32-s3-devkitc1-n4r2.json create mode 100644 boards/esp32-s3-devkitc1-n4r8.json create mode 100644 boards/esp32-s3-devkitc1-n8r2.json create mode 100644 boards/esp32-s3-devkitc1-n8r8.json create mode 100644 boards/esp32-s3-fh4r2.json create mode 100644 boards/feenove-esp32-s3-n8r8.json create mode 100644 boards/nologo_esp32c3_super_mini.json create mode 100644 boards/sparkfun_pro_micro_esp32c3.json diff --git a/boards/bpi-centi-s3.json b/boards/bpi-centi-s3.json new file mode 100644 index 000000000..01c9509e2 --- /dev/null +++ b/boards/bpi-centi-s3.json @@ -0,0 +1,52 @@ +{ + "build": { + "arduino": { + "partitions": "default_8MB.csv", + "memory_type": "qio_qspi" + }, + "core": "esp32", + "extra_flags": [ + "-DBOARD_HAS_PSRAM", + "-DARDUINO_BPI_CENTI_S3", + "-DARDUINO_USB_MODE=1", + "-DARDUINO_USB_CDC_ON_BOOT=1" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [ + [ + "0x303A", + "0x80DF" + ] + ], + "mcu": "esp32s3", + "variant": "bpi_leaf_s3" + }, + "connectivity": [ + "bluetooth", + "wifi" + ], + "debug": { + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "platforms" : [ + "espressif32" + ], + "name": "BPI-Centi-S3", + "upload": { + "flash_size": "8MB", + "maximum_ram_size": 327680, + "maximum_size": 8388608, + "use_1200bps_touch": true, + "wait_for_upload_port": true, + "require_upload_port": true, + "speed": 921600 + }, + "url": "https://wiki.banana-pi.org/BPI-Leaf-S3", + "vendor": "BPI Tech" +} diff --git a/boards/esp32-s3-devkitc1-n16r16.json b/boards/esp32-s3-devkitc1-n16r16.json new file mode 100644 index 000000000..99c71136d --- /dev/null +++ b/boards/esp32-s3-devkitc1-n16r16.json @@ -0,0 +1,55 @@ +{ + "build": { + "arduino": { + "partitions": "default_16MB.csv", + "memory_type": "qio_opi" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_ESP32S3_DEV", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1", + "-DBOARD_HAS_PSRAM" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "psram_type": "opi", + "hwids": [ + [ + "0x303A", + "0x1001" + ] + ], + "mcu": "esp32s3", + "variant": "esp32s3" + }, + "connectivity": [ + "wifi", + "bluetooth" + ], + "debug": { + "default_tool": "esp-builtin", + "onboard_tools": [ + "esp-builtin" + ], + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "platforms": [ + "espressif32" + ], + "name": "Espressif ESP32-S3-DevKitC-1-N16R8V (16 MB Flash Quad, 16 MB PSRAM Octal)", + "upload": { + "flash_size": "16MB", + "maximum_ram_size": 327680, + "maximum_size": 16777216, + "require_upload_port": true, + "speed": 921600 + }, + "url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/user-guide-devkitc-1.html", + "vendor": "Espressif" +} \ No newline at end of file diff --git a/boards/esp32-s3-devkitc1-n16r2.json b/boards/esp32-s3-devkitc1-n16r2.json new file mode 100644 index 000000000..08968e5c8 --- /dev/null +++ b/boards/esp32-s3-devkitc1-n16r2.json @@ -0,0 +1,55 @@ +{ + "build": { + "arduino": { + "partitions": "default_16MB.csv", + "memory_type": "qio_qspi" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_ESP32S3_DEV", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1", + "-DBOARD_HAS_PSRAM" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "psram_type": "qio", + "hwids": [ + [ + "0x303A", + "0x1001" + ] + ], + "mcu": "esp32s3", + "variant": "esp32s3" + }, + "connectivity": [ + "wifi", + "bluetooth" + ], + "debug": { + "default_tool": "esp-builtin", + "onboard_tools": [ + "esp-builtin" + ], + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "platforms": [ + "espressif32" + ], + "name": "Espressif ESP32-S3-DevKitC-1-N8R8 (16 MB Flash Quad, 2 MB PSRAM Quad)", + "upload": { + "flash_size": "8MB", + "maximum_ram_size": 327680, + "maximum_size": 16777216, + "require_upload_port": true, + "speed": 921600 + }, + "url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/user-guide-devkitc-1.html", + "vendor": "Espressif" +} \ No newline at end of file diff --git a/boards/esp32-s3-devkitc1-n16r8.json b/boards/esp32-s3-devkitc1-n16r8.json new file mode 100644 index 000000000..1c7e5d635 --- /dev/null +++ b/boards/esp32-s3-devkitc1-n16r8.json @@ -0,0 +1,55 @@ +{ + "build": { + "arduino": { + "partitions": "default_16MB.csv", + "memory_type": "qio_opi" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_ESP32S3_DEV", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1", + "-DBOARD_HAS_PSRAM" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "psram_type": "opi", + "hwids": [ + [ + "0x303A", + "0x1001" + ] + ], + "mcu": "esp32s3", + "variant": "esp32s3" + }, + "connectivity": [ + "wifi", + "bluetooth" + ], + "debug": { + "default_tool": "esp-builtin", + "onboard_tools": [ + "esp-builtin" + ], + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "platforms": [ + "espressif32" + ], + "name": "Espressif ESP32-S3-DevKitC-1-N16R8V (16 MB Flash Quad, 8 MB PSRAM Octal)", + "upload": { + "flash_size": "16MB", + "maximum_ram_size": 327680, + "maximum_size": 16777216, + "require_upload_port": true, + "speed": 921600 + }, + "url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/user-guide-devkitc-1.html", + "vendor": "Espressif" +} \ No newline at end of file diff --git a/boards/esp32-s3-devkitc1-n4r2.json b/boards/esp32-s3-devkitc1-n4r2.json new file mode 100644 index 000000000..1ed4a3321 --- /dev/null +++ b/boards/esp32-s3-devkitc1-n4r2.json @@ -0,0 +1,55 @@ +{ + "build": { + "arduino": { + "partitions": "default_4MB.csv", + "memory_type": "qio_qspi" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_ESP32S3_DEV", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1", + "-DBOARD_HAS_PSRAM" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "psram_type": "qio", + "hwids": [ + [ + "0x303A", + "0x1001" + ] + ], + "mcu": "esp32s3", + "variant": "esp32s3" + }, + "connectivity": [ + "wifi", + "bluetooth" + ], + "debug": { + "default_tool": "esp-builtin", + "onboard_tools": [ + "esp-builtin" + ], + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "platforms": [ + "espressif32" + ], + "name": "Espressif ESP32-S3-DevKitC-1-N8R8 (4 MB Flash Quad, 2 MB PSRAM Quad)", + "upload": { + "flash_size": "8MB", + "maximum_ram_size": 327680, + "maximum_size": 4194304, + "require_upload_port": true, + "speed": 921600 + }, + "url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/user-guide-devkitc-1.html", + "vendor": "Espressif" +} \ No newline at end of file diff --git a/boards/esp32-s3-devkitc1-n4r8.json b/boards/esp32-s3-devkitc1-n4r8.json new file mode 100644 index 000000000..338fee270 --- /dev/null +++ b/boards/esp32-s3-devkitc1-n4r8.json @@ -0,0 +1,55 @@ +{ + "build": { + "arduino": { + "partitions": "default_4MB.csv", + "memory_type": "qio_opi" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_ESP32S3_DEV", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1", + "-DBOARD_HAS_PSRAM" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "psram_type": "opi", + "hwids": [ + [ + "0x303A", + "0x1001" + ] + ], + "mcu": "esp32s3", + "variant": "esp32s3" + }, + "connectivity": [ + "wifi", + "bluetooth" + ], + "debug": { + "default_tool": "esp-builtin", + "onboard_tools": [ + "esp-builtin" + ], + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "platforms": [ + "espressif32" + ], + "name": "Espressif ESP32-S3-DevKitC-1-N8R8 (4 MB Flash Quad, 8 MB PSRAM Octal)", + "upload": { + "flash_size": "8MB", + "maximum_ram_size": 327680, + "maximum_size": 4194304, + "require_upload_port": true, + "speed": 921600 + }, + "url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/user-guide-devkitc-1.html", + "vendor": "Espressif" +} \ No newline at end of file diff --git a/boards/esp32-s3-devkitc1-n8r2.json b/boards/esp32-s3-devkitc1-n8r2.json new file mode 100644 index 000000000..46e2a89b5 --- /dev/null +++ b/boards/esp32-s3-devkitc1-n8r2.json @@ -0,0 +1,55 @@ +{ + "build": { + "arduino": { + "partitions": "default_8MB.csv", + "memory_type": "qio_qspi" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_ESP32S3_DEV", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1", + "-DBOARD_HAS_PSRAM" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "psram_type": "qio", + "hwids": [ + [ + "0x303A", + "0x1001" + ] + ], + "mcu": "esp32s3", + "variant": "esp32s3" + }, + "connectivity": [ + "wifi", + "bluetooth" + ], + "debug": { + "default_tool": "esp-builtin", + "onboard_tools": [ + "esp-builtin" + ], + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "platforms": [ + "espressif32" + ], + "name": "Espressif ESP32-S3-DevKitC-1-N8R8 (8 MB Flash Quad, 2 MB PSRAM quad)", + "upload": { + "flash_size": "8MB", + "maximum_ram_size": 327680, + "maximum_size": 8388608, + "require_upload_port": true, + "speed": 921600 + }, + "url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/user-guide-devkitc-1.html", + "vendor": "Espressif" +} \ No newline at end of file diff --git a/boards/esp32-s3-devkitc1-n8r8.json b/boards/esp32-s3-devkitc1-n8r8.json new file mode 100644 index 000000000..6284c7c63 --- /dev/null +++ b/boards/esp32-s3-devkitc1-n8r8.json @@ -0,0 +1,55 @@ +{ + "build": { + "arduino": { + "partitions": "default_8MB.csv", + "memory_type": "qio_opi" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_ESP32S3_DEV", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1", + "-DBOARD_HAS_PSRAM" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "psram_type": "opi", + "hwids": [ + [ + "0x303A", + "0x1001" + ] + ], + "mcu": "esp32s3", + "variant": "esp32s3" + }, + "connectivity": [ + "wifi", + "bluetooth" + ], + "debug": { + "default_tool": "esp-builtin", + "onboard_tools": [ + "esp-builtin" + ], + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "platforms": [ + "espressif32" + ], + "name": "Espressif ESP32-S3-DevKitC-1-N8R8 (8 MB Flash Quad, 8 MB PSRAM Octal)", + "upload": { + "flash_size": "8MB", + "maximum_ram_size": 327680, + "maximum_size": 8388608, + "require_upload_port": true, + "speed": 921600 + }, + "url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/user-guide-devkitc-1.html", + "vendor": "Espressif" +} \ No newline at end of file diff --git a/boards/esp32-s3-fh4r2.json b/boards/esp32-s3-fh4r2.json new file mode 100644 index 000000000..1333a31d6 --- /dev/null +++ b/boards/esp32-s3-fh4r2.json @@ -0,0 +1,56 @@ +{ + "build": { + "arduino":{ + "partitions": "default.csv", + "memory_type": "qio_qspi" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_ESP32S3_DEV", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1", + "-DARDUINO_USB_CDC_ON_BOOT=1", + "-DBOARD_HAS_PSRAM" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "psram_type": "qio", + "hwids": [ + [ + "0x303A", + "0x1001" + ] + ], + "mcu": "esp32s3", + "variant": "esp32s3" + }, + "connectivity": [ + "wifi", + "bluetooth" + ], + "debug": { + "default_tool": "esp-builtin", + "onboard_tools": [ + "esp-builtin" + ], + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "platforms" : [ + "espressif32" + ], + "name": "Espressif ESP32-S3-FH4R2 (4 MB QD, 2MB PSRAM)", + "upload": { + "flash_size": "4MB", + "maximum_ram_size": 327680, + "maximum_size": 4194304, + "require_upload_port": true, + "speed": 921600 + }, + "url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/user-guide-devkitc-1.html", + "vendor": "Espressif" + } \ No newline at end of file diff --git a/boards/feenove-esp32-s3-n8r8.json b/boards/feenove-esp32-s3-n8r8.json new file mode 100644 index 000000000..0c508d5a7 --- /dev/null +++ b/boards/feenove-esp32-s3-n8r8.json @@ -0,0 +1,55 @@ +{ + "build": { + "arduino": { + "partitions": "default_8MB.csv", + "memory_type": "dio_opi" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_ESP32S3_DEV", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1", + "-DBOARD_HAS_PSRAM" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "dio", + "psram_type": "opi", + "hwids": [ + [ + "0X303A", + "0x1001" + ] + ], + "mcu": "esp32s3", + "variant": "esp32s3" + }, + "connectivity": [ + "wifi", + "bluetooth" + ], + "debug": { + "default_tool": "esp-builtin", + "onboard_tools": [ + "esp-builtin" + ], + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "platforms" : [ + "espressif32" + ], + "name": "Freenove ESP32-S3 WROOM N8R8 (8MB Flash / 8MB PSRAM)", + "upload": { + "flash_size": "8MB", + "maximum_ram_size": 327680, + "maximum_size": 8388608, + "require_upload_port": true, + "speed": 921600 + }, + "url": "https://github.com/Freenove/Freenove_ESP32_S3_WROOM_Board", + "vendor": "Freenove" +} diff --git a/boards/nologo_esp32c3_super_mini.json b/boards/nologo_esp32c3_super_mini.json new file mode 100644 index 000000000..e8e302c43 --- /dev/null +++ b/boards/nologo_esp32c3_super_mini.json @@ -0,0 +1,32 @@ +{ + "build": { + "core": "esp32", + "f_cpu": "160000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "extra_flags": "-DARDUINO_ESP32C3_DEV -DARDUINO_USB_MODE=1 -DARDUINO_USB_CDC_ON_BOOT=1", + "mcu": "esp32c3", + "variant": "nologo_esp32c3_super_mini" + }, + "connectivity": [ + "wifi", + "bluetooth" + ], + "debug": { + "openocd_target": "esp32c3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "Nologo ESP32C3 SuperMini", + "upload": { + "flash_size": "4MB", + "maximum_ram_size": 327680, + "maximum_size": 4194304, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://www.nologo.tech/product/esp32/esp32c3/esp32c3supermini/esp32C3SuperMini.html", + "vendor": "Nologo" +} \ No newline at end of file diff --git a/boards/sparkfun_pro_micro_esp32c3.json b/boards/sparkfun_pro_micro_esp32c3.json new file mode 100644 index 000000000..e31d53fc7 --- /dev/null +++ b/boards/sparkfun_pro_micro_esp32c3.json @@ -0,0 +1,36 @@ +{ + "build": { + "core": "esp32", + "f_cpu": "160000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "extra_flags": [ + "-DSPARKFUN_PRO_MICRO_ESP32C3", + "-DARDUINO_USB_MODE=1", + "-DARDUINO_USB_CDC_ON_BOOT=1" + ], + "mcu": "esp32c3", + "variant": "sparkfun_pro_micro_esp32c3" + }, + "connectivity": [ + "wifi", + "bluetooth" + ], + "debug": { + "openocd_target": "esp32c3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "SparkFun Pro Micro ESP32-C3", + "upload": { + "flash_size": "4MB", + "maximum_ram_size": 327680, + "maximum_size": 4194304, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://www.sparkfun.com/sparkfun-pro-micro-esp32-c3.html", + "vendor": "Sparkfun" +} \ No newline at end of file From 832a1953cf9de217ee667d80cb7d514db5979d76 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 19 Mar 2025 17:25:35 +0100 Subject: [PATCH 05/60] pioarduino core 6.1.18 --- .github/workflows/examples.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index eef99c0b2..c77c2082d 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -50,7 +50,7 @@ jobs: run: | python -m pip install --upgrade pip pip install wheel - pip install -U https://github.com/pioarduino/platformio-core/archive/refs/tags/v6.1.17.zip + pip install -U https://github.com/pioarduino/platformio-core/archive/refs/tags/v6.1.18.zip pio pkg install --global --platform file://. - name: git clone Tasmota and add to examples run: | From cac1250f4001e54aabc4443b4960bccca5189be0 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 19 Mar 2025 17:41:05 +0100 Subject: [PATCH 06/60] Update IDF 5.4.0.250314 --- platform.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform.json b/platform.json index e252251c7..6c3b54408 100644 --- a/platform.json +++ b/platform.json @@ -51,7 +51,7 @@ "type": "framework", "optional": true, "owner": "pioarduino", - "version": "https://github.com/pioarduino/esp-idf/releases/download/v5.4.0.250303/esp-idf-v5.4.0.zip" + "version": "https://github.com/pioarduino/esp-idf/releases/download/v5.4.0.250314/esp-idf-v5.4.0.zip" }, "toolchain-xtensa-esp-elf": { "type": "toolchain", From 60b296341d54672ec4c3d06cdf50e61ce24ad4f9 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 20 Mar 2025 16:34:39 +0100 Subject: [PATCH 07/60] Create esp32-s3-devkitc-1-n32r8v.json --- boards/esp32-s3-devkitc-1-n32r8v.json | 52 +++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 boards/esp32-s3-devkitc-1-n32r8v.json diff --git a/boards/esp32-s3-devkitc-1-n32r8v.json b/boards/esp32-s3-devkitc-1-n32r8v.json new file mode 100644 index 000000000..39d725adf --- /dev/null +++ b/boards/esp32-s3-devkitc-1-n32r8v.json @@ -0,0 +1,52 @@ +{ + "build": { + "arduino":{ + "partitions": "default_32MB.csv", + "memory_type": "opi_opi" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_ESP32S3_DEV", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1", + "-DBOARD_HAS_PSRAM" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "opi", + "psram_type": "opi", + "hwids": [ + [ + "0x303A", + "0x1001" + ] + ], + "mcu": "esp32s3", + "variant": "esp32s3" + }, + "connectivity": [ + "wifi", + "bluetooth" + ], + "debug": { + "default_tool": "esp-builtin", + "onboard_tools": [ + "esp-builtin" + ], + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "Espressif ESP32-S3-DevKitC-1-N32R8V (32 MB Flash Octal, 8 MB PSRAM Octal)", + "upload": { + "flash_size": "32MB", + "maximum_ram_size": 327680, + "maximum_size": 33554432, + "require_upload_port": true, + "speed": 921600 + }, + "url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/user-guide-devkitc-1.html", + "vendor": "Espressif" +} From b2c4121858d5f800bb8de740e027f4f489168f90 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 21 Mar 2025 12:26:43 +0100 Subject: [PATCH 08/60] Board Arduino Nano: standard no remapping causes more issues than it solves. --- boards/arduino_nano_esp32.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boards/arduino_nano_esp32.json b/boards/arduino_nano_esp32.json index e1bf757d5..1bec89121 100644 --- a/boards/arduino_nano_esp32.json +++ b/boards/arduino_nano_esp32.json @@ -8,7 +8,7 @@ "core": "esp32", "extra_flags": [ "-DARDUINO_NANO_ESP32", - "-DBOARD_HAS_PIN_REMAP", + "-DBOARD_USES_HW_GPIO_NUMBERS", "-DBOARD_HAS_PSRAM", "-DUSB_MANUFACTURER=\\\"Arduino\\\"", "-DUSB_PRODUCT=\\\"NanoESP32\\\"", From 0a48460db9d434e47df077d60811f35be16d4fc5 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 21 Mar 2025 12:27:10 +0100 Subject: [PATCH 09/60] Update arduino_nano_esp32.json --- boards/arduino_nano_esp32.json | 1 - 1 file changed, 1 deletion(-) diff --git a/boards/arduino_nano_esp32.json b/boards/arduino_nano_esp32.json index 1bec89121..737d194af 100644 --- a/boards/arduino_nano_esp32.json +++ b/boards/arduino_nano_esp32.json @@ -1,7 +1,6 @@ { "build": { "arduino":{ - "ldscript": "esp32s3_out.ld", "partitions": "app3M_fat9M_fact512k_16MB.csv", "memory_type": "qio_opi" }, From 3d5ca253cae2c7472571e8cc3101f59de1644679 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 21 Mar 2025 12:55:44 +0100 Subject: [PATCH 10/60] add arduino_nano_esp32 board to Arduino Blink example --- examples/arduino-blink/platformio.ini | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/examples/arduino-blink/platformio.ini b/examples/arduino-blink/platformio.ini index 26bd6f1b8..a6f61969b 100644 --- a/examples/arduino-blink/platformio.ini +++ b/examples/arduino-blink/platformio.ini @@ -44,6 +44,25 @@ custom_component_remove = espressif/esp_hosted espressif/esp_rainmaker espressif/rmaker_common +[env:esp32-s3-arduino_nano_esp32] +platform = espressif32 +framework = arduino +board = arduino_nano_esp32 +build_flags = -DLED_BUILTIN=48 +monitor_speed = 115200 +custom_component_remove = espressif/esp_hosted + espressif/esp_wifi_remote + espressif/esp-dsp + espressif/esp32-camera + espressif/libsodium + espressif/esp-modbus + espressif/qrcode + espressif/esp_insights + espressif/esp_diag_data_store + espressif/esp_diagnostics + espressif/esp_rainmaker + espressif/rmaker_common + [env:esp32s3-qio_opi_per] ; OPI Performance settings -> Display use platform = espressif32 From 2fa97a5f95524b787c4142b85e301508b1c10bc2 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 21 Mar 2025 13:13:56 +0100 Subject: [PATCH 11/60] remove already defined --- examples/arduino-blink/platformio.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/arduino-blink/platformio.ini b/examples/arduino-blink/platformio.ini index a6f61969b..8fe2201b7 100644 --- a/examples/arduino-blink/platformio.ini +++ b/examples/arduino-blink/platformio.ini @@ -48,7 +48,6 @@ custom_component_remove = espressif/esp_hosted platform = espressif32 framework = arduino board = arduino_nano_esp32 -build_flags = -DLED_BUILTIN=48 monitor_speed = 115200 custom_component_remove = espressif/esp_hosted espressif/esp_wifi_remote From 9c5cf8becd14e864b183aa82cd8f1b172a0a3725 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 24 Mar 2025 11:56:21 +0100 Subject: [PATCH 12/60] no Arduino Nora Nano support --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3867dcc4f..e5515135e 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ ESP32 is a series of low-cost, low-power system on a chip microcontrollers with integrated Wi-Fi and Bluetooth. ESP32 integrates an antenna switch, RF balun, power amplifier, low-noise receive amplifier, filters, and power management modules. * Issues with boards (wrong / missing). All issues caused from boards will not be fixed from the maintainer(s). A PR needs to be provided against branch `develop` to solve. - +* No support for the Arduino Nora Nano board, issues needs to be solved by the community ## IDE Preparation - [Download and install Microsoft Visual Studio Code](https://code.visualstudio.com/). pioarduino IDE is on top of it. From 10aa2177010c048096437cbba829a42f9c4a50bc Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 24 Mar 2025 12:42:38 +0100 Subject: [PATCH 13/60] arduino_nano_esp32.json: flash recovery image --- boards/arduino_nano_esp32.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/boards/arduino_nano_esp32.json b/boards/arduino_nano_esp32.json index 737d194af..4d7267937 100644 --- a/boards/arduino_nano_esp32.json +++ b/boards/arduino_nano_esp32.json @@ -41,6 +41,14 @@ ], "name": "Arduino Nano ESP32", "upload": { + "arduino": { + "flash_extra_images": [ + [ + "0xf70000", + "variants/arduino_nano_nora/extra/nora_recovery/nora_recovery.ino.bin" + ] + ] + }, "flash_size": "16MB", "maximum_ram_size": 327680, "maximum_size": 16777216, From fafc70033433f62870b22eb0896e95a53939875c Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 1 Apr 2025 16:32:22 +0200 Subject: [PATCH 14/60] Update esptoolpy v4.8.9 --- platform.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform.json b/platform.json index 6c3b54408..bb71f4dea 100644 --- a/platform.json +++ b/platform.json @@ -86,7 +86,7 @@ "tool-esptoolpy": { "type": "uploader", "owner": "pioarduino", - "version": "https://github.com/pioarduino/esptool/releases/download/v4.8.8/esptool.zip" + "version": "https://github.com/pioarduino/esptool/releases/download/v4.8.9/esptool.zip" }, "tool-dfuutil-arduino": { "type": "uploader", From 6899b83dd40210caa66a5dbc4f9da8c468e674ac Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 2 Apr 2025 12:57:55 +0200 Subject: [PATCH 15/60] Create Bug_report.md --- .github/ISSUE_TEMPLATE/Bug_report.md | 41 ++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/Bug_report.md diff --git a/.github/ISSUE_TEMPLATE/Bug_report.md b/.github/ISSUE_TEMPLATE/Bug_report.md new file mode 100644 index 000000000..f8e4ada0a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Bug_report.md @@ -0,0 +1,41 @@ +--- +name: Problem Report +about: Create a Report to help us improve +--- + + + +### PROBLEM DESCRIPTION +_A clear and concise description of what the problem is._ + + +### TO REPRODUCE +_Steps to reproduce the behavior:_ + + +### EXPECTED BEHAVIOUR +_A clear and concise description of what you expected to happen._ + + +### SCREENSHOTS +_If applicable, add screenshots to help explain your problem._ + + +### ADDITIONAL CONTEXT +_Add any other context about the problem here._ + + +**(Please, remember to close the issue when the problem has been addressed)** From 63fc1b3ba9eb892f095de90945f652f3ebb6f170 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 2 Apr 2025 13:00:58 +0200 Subject: [PATCH 16/60] Create config.yml --- .github/ISSUE_TEMPLATE/config.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/config.yml diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 000000000..828634eb6 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: + - name: pioarduino Users Chat + url: https://discord.gg/Nutz9crnZr + about: Chat for feedback, questions and troubleshooting. From 8eec5f03f89c283112062d46e72b03269050acd8 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 2 Apr 2025 13:18:13 +0200 Subject: [PATCH 17/60] add PR template --- .github/FUNDING.yml | 1 - .github/ISSUE_TEMPLATE/Bug_report.md | 4 +- .github/PULL_REQUEST_TEMPLATE.md | 9 ++ .github/config.yml | 11 +++ CONTRIBUTING.md | 111 ++++++++++++++++++++++ code_of_conduct.md | 134 +++++++++++++++++++++++++++ 6 files changed, 267 insertions(+), 3 deletions(-) delete mode 100644 .github/FUNDING.yml create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/config.yml create mode 100644 CONTRIBUTING.md create mode 100644 code_of_conduct.md diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index 6f70f7e98..000000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1 +0,0 @@ -custom: https://platformio.org/donate diff --git a/.github/ISSUE_TEMPLATE/Bug_report.md b/.github/ISSUE_TEMPLATE/Bug_report.md index f8e4ada0a..189906050 100644 --- a/.github/ISSUE_TEMPLATE/Bug_report.md +++ b/.github/ISSUE_TEMPLATE/Bug_report.md @@ -8,9 +8,9 @@ about: Create a Report to help us improve This issue template is meant to REPORT pioarduino caused PROBLEMS ONLY Please DO NOT OPEN AN ISSUE: - - If your problem is caused by a wrong or missing boards manifest, ask for help in [pioarduin Support Chat](https://discord.gg/Nutz9crnZr) and provide a PR to solve + - If your problem is caused by a wrong or missing boards manifest, ask for help in [pioarduin Support Chat](https://discord.gg/Nutz9crnZr) and please provide a PR to solve - If your pioarduino version is not the latest , please update, your issue might be fixed already - - If you have a problems or a general questions with Arduino core, please address it to the [Arduino Support Chat](https://discord.gg/8xY6e9crwv) + - If you have problems or general questions about the Arduino core, please address it to the [Arduino Support Chat](https://discord.gg/8xY6e9crwv) - If your issue is a flashing issue, please address it to the [pioarduin Support Chat](https://discord.gg/Nutz9crnZr) - If your issue is a compilation problem, please address it to the [pioarduino Support Chat](https://discord.gg/Nutz9crnZr) - If your issue has been addressed before (i.e., duplicated issue), please ask in the original issue diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..8438f074e --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,9 @@ +## Description: + +**Related issue (if applicable):** fixes # + +## Checklist: + - [ ] The pull request is done against the latest develop branch + - [ ] Only relevant files were touched + - [ ] Only one feature/fix was added per PR, more changes are allowed when changing boards.json + - [ ] I accept the [CLA](https://github.com/pioarduino/platform-espressif32/blob/main/CONTRIBUTING.md#contributor-license-agreement-cla) diff --git a/.github/config.yml b/.github/config.yml new file mode 100644 index 000000000..3397d6b43 --- /dev/null +++ b/.github/config.yml @@ -0,0 +1,11 @@ +# Configuration for sentiment-bot - https://github.com/behaviorbot/sentiment-bot + +# *Required* toxicity threshold between 0 and .99 with the higher numbers being the most toxic +# Anything higher than this threshold will be marked as toxic and commented on +sentimentBotToxicityThreshold: .7 + +# *Required* Comment to reply with +sentimentBotReplyComment: > + Please be sure to review the code of conduct and be respectful of other users. + +# Note: the bot will only work if your repository has a Code of Conduct diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..03a725f57 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,111 @@ +# Contributing + +**Any contribution helps our team and makes pioarduino better for the entire community!** + +Everybody is welcome and invited to contribute to pioarduino Project by: + +* Testing newly released features and reporting issues. +* Providing Pull Requests (Features, Proof of Concepts or Fixes) +* Contributing missing documentation for features in our (not yet existing ;-)) documentation + +This document describes rules that are in effect for this repository, meant for handling issues by contributors in the issue tracker and PRs. + +## Opening New Issues + +**Issue tracker is NOT a general discussion forum!** +1. Opening an issue means that a problem exists in the code and should be addressed by the project contributors. +2. When opening an issue, provide as much as possible infos. The information is important! With insufficient info about the provided issue, the issue may be closed. +3. Questions of type "How do I..." or "Can you please help me with..." WILL NOT be handled here. Such questions should be directed to pioarduino Support Chat. All issues of this type will be closed with a simple reference to this contributing policy. +4. Issues about topics already handled in the documentation will be closed in a similar manner. +5. Issues for unmerged PRs will be closed. If there is an issue with a PR, the explanation should be added to the PR itself. +6. Issues with accompanied investigation that shows the root of the problem should be given priority. +7. Duplicate issues will be closed. + +## Triaging of Issues/PR's + +1. Any contributor to the project can participate in the triaging process, if he/she/them chooses to do so. +2. An issue that needs to be closed, either due to not complying with this policy, or for other reasons, should be closed by a contributor. +3. Issues that are accepted should be marked with appropriate labels. +4. Issues that could impact functionality for many users should be considered severe. +5. Issues with feature requests should be discussed for viability/desirability. +6. Feature requests or changes that are meant to address a very specific/limited use case, may be denied, or may be required to be redesigned, generalized, or simplified. +7. Feature requests that are not accompanied by a PR: + * could be closed immediately (denied). + * could be closed after some predetermined period of time (left as candidate for somebody to pick up). +8. In some cases, feedback may be requested from the issue reporter, either as additional info for clarification, additional testing, or other. If no feedback is provided, the issue may be closed by a contributor or after 30 days by the STALE bot. + +## Pull requests + +A Pull Request (PR) is the process where code modifications are managed in GitHub. + +The process is straight-forward. + + - Read [How to get faster PR reviews](https://github.com/kubernetes/community/blob/master/contributors/guide/pull-requests.md#best-practices-for-faster-reviews) by Kubernetes (but skip step 0) + - Fork the pioarduino platform-espressif32 Repository [git repository](https://github.com/pioarduino/platform-espressif32). + - Write/Change the code in your Fork for a new feature, bug fix, optimization, etc. + - Ensure tests work. + - Create a Pull Request against the [**develop**](https://github.com/pioarduino/platform-espressif32/tree/develop) branch of pioarduino. + +1. All pull requests must be done against the develop branch. +2. Only relevant files should be touched (Also beware if your editor has auto-formatting feature enabled). +3. Only one feature/fix should be added per PR. A PR for mass changes in boards manifest is allowed. +4. PRs that don't compile (fail in CI Tests) or cause coding errors will not be merged. Please fix the issue. Same goes for PRs that are raised against older commit in develop - you might need to rebase and resolve conflicts. +5. All pull requests should undergo peer review by at least one contributor other than the creator, excepts for the owner. +6. All pull requests should consider updates to the documentation. +7. Pull requests that address an outstanding issue, particularly an issue deemed to be severe, should be given priority. +8. If a PR is accepted, then it should undergo review and updated based on the feedback provided, then merged. +9. By submitting a PR, it is needed to use the provided PR template and check all boxes, performing the required tasks and accepting the CLA. +10. Pull requests that don't meet the above will be denied and closed. + +-------------------------------------- + +## Contributor License Agreement (CLA) + +``` +By making a contribution to this project, I certify that: + +(a) The contribution was created in whole or in part by me and I + have the right to submit it under the GPL-3.0 license; or + +(b) The contribution is based upon previous work that, to the best + of my knowledge, is covered under an appropriate open source + license and I have the right under that license to submit that + work with modifications, whether created in whole or in part + by me, under the GPL-3.0 license; or + +(c) The contribution was provided directly to me by some other + person who certified (a), (b) or (c) and I have not modified + it. + +(d) I understand and agree that this project and the contribution + are public and that a record of the contribution (including all + personal information I submit with it) is maintained indefinitely + and may be redistributed consistent with this project or the open + source license(s) involved. +``` + +This Contributor License Agreement (CLA) was adopted on April 1st, 2019. + +The text of this license is available under the [Creative Commons Attribution-ShareAlike 3.0 Unported License](http://creativecommons.org/licenses/by-sa/3.0/). It is based on the Linux [Developer Certificate Of Origin](http://elinux.org/Developer_Certificate_Of_Origin), but is modified to explicitly use the GPL-3.0 license and not mention sign-off (due to GitHub.com keeps an historial, with your user name, of PRs' commits and all editions on PR's comments). + +To accept the CLA it is required to put a x between [ ] on `[ ] I accept the CLA` in the PR template when submitting it. The [ ] is an opt-in box, so you have to manually accept it. + +**Why a CLA ?** + +_"A Contributor License Agreement (CLA) is strongly recommended when accepting third party contributions to an open development project, such as an open source software project. In order to redistribute contributions, it is necessary to ensure that the project has the necessary rights to do so. A Contributor License Agreement is a lightweight agreement, signed by the copyright holder, that grants the necessary rights for the contribution to be redistributed as part of the project."_ [OSS Watch](http://oss-watch.ac.uk/resources/cla) + +A CLA is a legal document in which you state _you are entitled to contribute the code/documentation/translation to the project_ you’re contributing to and that _you are willing to have it used in distributions and derivative works_. This means that should there be any kind of legal issue in the future as to the origins and ownership of any particular piece of code, then that project has the necessary forms on file from the contributor(s) saying they were permitted to make this contribution. + +CLA is a safety because it also ensures that once you have provided a contribution, you cannot try to withdraw permission for its use at a later date. People can therefore use that software, confident that they will not be asked to stop using pieces of the code at a later date. + +A __license__ grants "outbound" rights to the user of project. + +A __CLA__ enables a contributor to grant "inbound" rights to a project. + + + + + + + + diff --git a/code_of_conduct.md b/code_of_conduct.md new file mode 100644 index 000000000..d12204350 --- /dev/null +++ b/code_of_conduct.md @@ -0,0 +1,134 @@ + +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall + community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or advances of + any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email address, + without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official email address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +[pioarduino](https://github.com/pioarduino/platform-espressif32/issues/new/choose). +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at +[https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations + From a7fab1278460bb03eb8dd0d0dce5c63933ae43a8 Mon Sep 17 00:00:00 2001 From: ikorman Date: Wed, 2 Apr 2025 14:55:38 +0200 Subject: [PATCH 18/60] Update esp32-s3-devkitc1-n16r16.json (#136) Changed wrong board name Espressif ESP32-S3-DevKitC-1-N16R8V (16 MB Flash Quad, 16 MB PSRAM Octal) --- boards/esp32-s3-devkitc1-n16r16.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/boards/esp32-s3-devkitc1-n16r16.json b/boards/esp32-s3-devkitc1-n16r16.json index 99c71136d..c2bf0cd33 100644 --- a/boards/esp32-s3-devkitc1-n16r16.json +++ b/boards/esp32-s3-devkitc1-n16r16.json @@ -42,7 +42,7 @@ "platforms": [ "espressif32" ], - "name": "Espressif ESP32-S3-DevKitC-1-N16R8V (16 MB Flash Quad, 16 MB PSRAM Octal)", + "name": "Espressif ESP32-S3-DevKitC-1-N16R16V (16 MB Flash Quad, 16 MB PSRAM Octal)", "upload": { "flash_size": "16MB", "maximum_ram_size": 327680, @@ -52,4 +52,4 @@ }, "url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/user-guide-devkitc-1.html", "vendor": "Espressif" -} \ No newline at end of file +} From 714989f13c8a821054bb33efbc3fdc33109f038e Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 2 Apr 2025 16:23:01 +0200 Subject: [PATCH 19/60] Ignore not used libs in example "Tasmota" --- examples/tasmota_platformio_override.ini | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/examples/tasmota_platformio_override.ini b/examples/tasmota_platformio_override.ini index 3c13dfc37..cb7be7b3d 100644 --- a/examples/tasmota_platformio_override.ini +++ b/examples/tasmota_platformio_override.ini @@ -13,6 +13,21 @@ build_flags = ${env:tasmota32_base.build_flags} lib_ignore = ${env:tasmota32_base.lib_ignore} Micro-RTSP epdiy + BLE + BluetoothSerial + SimpleBLE + WiFiProv + ESP_I2S + ESP_NOW + ESP_SR + Insights + Matter + OpenThread + RainMaker + SPIFFS + USB + NetworkClientSecure + Zigbee custom_sdkconfig = https://raw.githubusercontent.com/pioarduino/sdkconfig/refs/heads/main/sdkconfig_tasmota_esp32 '# CONFIG_ETH_USE_ESP32_EMAC is not set' '# CONFIG_ETH_PHY_INTERFACE_RMII is not set' From 441f2b9f58c2f219f5e0dd9653a8e974760ba7f3 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 3 Apr 2025 16:04:05 +0200 Subject: [PATCH 20/60] Disable BLE (sdkconfig) in CI Tasmota example --- examples/tasmota_platformio_override.ini | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/tasmota_platformio_override.ini b/examples/tasmota_platformio_override.ini index cb7be7b3d..ba1a5b608 100644 --- a/examples/tasmota_platformio_override.ini +++ b/examples/tasmota_platformio_override.ini @@ -29,6 +29,10 @@ lib_ignore = ${env:tasmota32_base.lib_ignore} NetworkClientSecure Zigbee custom_sdkconfig = https://raw.githubusercontent.com/pioarduino/sdkconfig/refs/heads/main/sdkconfig_tasmota_esp32 + '# CONFIG_BT_ENABLED is not set' + '# CONFIG_BT_NIMBLE_ENABLED is not set' + '# CONFIG_BT_CONTROLLER_ENABLED is not set' + CONFIG_BT_CONTROLLER_DISABLED=y '# CONFIG_ETH_USE_ESP32_EMAC is not set' '# CONFIG_ETH_PHY_INTERFACE_RMII is not set' '# CONFIG_ETH_RMII_CLK_INPUT is not set' From 80cbecac5b5638370aea120a119257a454e1e885 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 7 Apr 2025 14:56:29 +0200 Subject: [PATCH 21/60] set lib_archive=False as default to make weak defines in Arduino Core possible --- builder/main.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/builder/main.py b/builder/main.py index 4c770f0c9..d38aa65f7 100644 --- a/builder/main.py +++ b/builder/main.py @@ -279,6 +279,8 @@ def __fetch_fs_size(target, source, env): ], ERASECMD='"$PYTHONEXE" "$OBJCOPY" $ERASEFLAGS erase_flash', + lib_archive=False, + # mkspiffs package contains two different binaries for IDF and Arduino MKFSTOOL="mk%s" % filesystem + ( From a13d5f5791e951cf45ce8207110dd2fa192d2061 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 7 Apr 2025 15:01:57 +0200 Subject: [PATCH 22/60] revert c --- builder/main.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/builder/main.py b/builder/main.py index d38aa65f7..4c770f0c9 100644 --- a/builder/main.py +++ b/builder/main.py @@ -279,8 +279,6 @@ def __fetch_fs_size(target, source, env): ], ERASECMD='"$PYTHONEXE" "$OBJCOPY" $ERASEFLAGS erase_flash', - lib_archive=False, - # mkspiffs package contains two different binaries for IDF and Arduino MKFSTOOL="mk%s" % filesystem + ( From 9c7f8b8cb1858cc3fa3e908a4a27f538d2b2d324 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 7 Apr 2025 18:13:00 +0200 Subject: [PATCH 23/60] Set lib_archive to False as default --- builder/main.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/builder/main.py b/builder/main.py index 4c770f0c9..0c371fed1 100644 --- a/builder/main.py +++ b/builder/main.py @@ -24,6 +24,7 @@ env = DefaultEnvironment() platform = env.PioPlatform() +projectconfig = env.GetProjectConfig() # # Helpers @@ -305,6 +306,9 @@ def __fetch_fs_size(target, source, env): PROGSUFFIX=".elf" ) +# Set lib_archive to False for all envs to avoid issues with weak defs in framework and libs +projectconfig.set("env:" + env["PIOENV"], "lib_archive", "False") + # Allow user to override via pre:script if env.get("PROGNAME", "program") == "program": env.Replace(PROGNAME="firmware") From 4eee52dd89bb796d507716b6b7be90eac3bf1573 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 7 Apr 2025 21:20:11 +0200 Subject: [PATCH 24/60] Update main.py --- builder/main.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/builder/main.py b/builder/main.py index 0c371fed1..e4fad6f1d 100644 --- a/builder/main.py +++ b/builder/main.py @@ -306,8 +306,20 @@ def __fetch_fs_size(target, source, env): PROGSUFFIX=".elf" ) -# Set lib_archive to False for all envs to avoid issues with weak defs in framework and libs -projectconfig.set("env:" + env["PIOENV"], "lib_archive", "False") +# Check if lib_archive is set in platformio.ini and set it to False +# if not found. This makes weak defs in framework and libs possible. +def check_lib_archive_exists(): + for section in projectconfig.sections(): + if "lib_archive" in projectconfig.options(section): + #print(f"lib_archive in [{section}] found with value: {projectconfig.get(section, 'lib_archive')}") + return True + #print("lib_archive was not found in platformio.ini") + return False + +if not check_lib_archive_exists(): + env_section = "env:" + env["PIOENV"] + projectconfig.set(env_section, "lib_archive", "False") + #print(f"lib_archive is set to False in [{env_section}]") # Allow user to override via pre:script if env.get("PROGNAME", "program") == "program": From eb125676d44f9192dcc7b33fd26c3b1256b597ba Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 13 Apr 2025 19:58:35 +0200 Subject: [PATCH 25/60] Update IDF 5.4.1.250407 --- platform.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform.json b/platform.json index bb71f4dea..e6004dc35 100644 --- a/platform.json +++ b/platform.json @@ -51,7 +51,7 @@ "type": "framework", "optional": true, "owner": "pioarduino", - "version": "https://github.com/pioarduino/esp-idf/releases/download/v5.4.0.250314/esp-idf-v5.4.0.zip" + "version": "https://github.com/pioarduino/esp-idf/releases/download/v5.4.1.250407/esp-idf-v5.4.1.zip" }, "toolchain-xtensa-esp-elf": { "type": "toolchain", From ba2dae67502f6b49a39ddb9508e25ace812e2fb1 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 13 Apr 2025 20:02:57 +0200 Subject: [PATCH 26/60] Update platform.json --- platform.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/platform.json b/platform.json index e6004dc35..9b8ca8b83 100644 --- a/platform.json +++ b/platform.json @@ -136,6 +136,11 @@ "optional": true, "owner": "platformio", "version": "~3.30.2" + }, + "tool-esp-rom-elfs": { + "optional": true, + "owner": "platformio", + "version": "0.0.1+20241011" }, "tool-ninja": { "optional": true, From fa7beedc50f18da9241a9e100ef7ba7bc0b87e6c Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 13 Apr 2025 20:07:10 +0200 Subject: [PATCH 27/60] add esp-rom-elfs --- platform.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/platform.py b/platform.py index 58e1b536d..d77410530 100644 --- a/platform.py +++ b/platform.py @@ -102,7 +102,12 @@ def configure_default_packages(self, variables, targets): if "espidf" in frameworks: self.packages["toolchain-esp32ulp"]["optional"] = False for p in self.packages: - if p in ("tool-scons", "tool-cmake", "tool-ninja"): + if p in ( + "tool-scons", + "tool-cmake", + "tool-ninja", + "tool-esp-rom-elfs", + ): self.packages[p]["optional"] = False # elif p in ("tool-mconf", "tool-idf") and IS_WINDOWS: # self.packages[p]["optional"] = False From 6e848c3f780120264a1667686931b2cfc3d987b4 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 13 Apr 2025 20:27:58 +0200 Subject: [PATCH 28/60] Use actual develop 5.4. libs --- platform.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/platform.py b/platform.py index d77410530..9c5dccb8e 100644 --- a/platform.py +++ b/platform.py @@ -46,10 +46,12 @@ def configure_default_packages(self, variables, targets): if "arduino" in frameworks: self.packages["framework-arduinoespressif32"]["optional"] = False self.packages["framework-arduinoespressif32-libs"]["optional"] = False - # use latest espressif Arduino libs - URL = "https://raw.githubusercontent.com/espressif/arduino-esp32/master/package/package_esp32_index.template.json" - packjdata = requests.get(URL).json() - dyn_lib_url = packjdata['packages'][0]['tools'][0]['systems'][0]['url'] + # use matching espressif Arduino libs + #URL = "https://raw.githubusercontent.com/espressif/arduino-esp32/master/package/package_esp32_index.template.json" + #packjdata = requests.get(URL).json() + #dyn_lib_url = packjdata['packages'][0]['tools'][0]['systems'][0]['url'] + # use newer libs as linked in package_esp32_index.template.json is too old + dyn_lib_url = "https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.4/esp32-arduino-libs-idf-release_v5.4-6897a7bf-v1.zip" self.packages["framework-arduinoespressif32-libs"]["version"] = dyn_lib_url if variables.get("custom_sdkconfig") is not None or len(str(board_sdkconfig)) > 3: From f0bb1b844ed63e525c9a54750427b7b5ac92dccf Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 13 Apr 2025 20:49:49 +0200 Subject: [PATCH 29/60] Update pip dependencies --- builder/frameworks/espidf.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/builder/frameworks/espidf.py b/builder/frameworks/espidf.py index b77b73305..db5162048 100644 --- a/builder/frameworks/espidf.py +++ b/builder/frameworks/espidf.py @@ -1531,11 +1531,10 @@ def _get_installed_pip_packages(python_exe_path): # https://github.com/platformio/platformio-core/issues/4614 "urllib3": "<2", # https://github.com/platformio/platform-espressif32/issues/635 - "cryptography": "~=41.0.1", - "future": ">=0.18.3", + "cryptography": "~=44.0.0", "pyparsing": ">=3.1.0,<4", "idf-component-manager": "~=2.0.1", - "esp-idf-kconfig": ">=2.5.0" + "esp-idf-kconfig": "~=2.5.0" } if sys_platform.system() == "Darwin" and "arm" in sys_platform.machine().lower(): From 9530453b524d9615cbf5b0c2c2ef125b57709ee9 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 14 Apr 2025 20:53:18 +0200 Subject: [PATCH 30/60] Update espidf.py --- builder/frameworks/espidf.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/builder/frameworks/espidf.py b/builder/frameworks/espidf.py index db5162048..b73a875ba 100644 --- a/builder/frameworks/espidf.py +++ b/builder/frameworks/espidf.py @@ -536,6 +536,8 @@ def populate_idf_env_vars(idf_env): if "IDF_TOOLS_PATH" in idf_env: del idf_env["IDF_TOOLS_PATH"] + idf_env["ESP_ROM_ELF_DIR"] = platform.get_package_dir("tool-esp-rom-elfs") + def get_target_config(project_configs, target_index, cmake_api_reply_dir): target_json = project_configs.get("targets")[target_index].get("jsonFile", "") From 88fbdafc0554437a8f7ed644ae0632147973d66a Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 14 Apr 2025 20:54:29 +0200 Subject: [PATCH 31/60] Update IDF v5.4.1.250411 --- platform.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform.json b/platform.json index 9b8ca8b83..89a2d2f93 100644 --- a/platform.json +++ b/platform.json @@ -51,7 +51,7 @@ "type": "framework", "optional": true, "owner": "pioarduino", - "version": "https://github.com/pioarduino/esp-idf/releases/download/v5.4.1.250407/esp-idf-v5.4.1.zip" + "version": "https://github.com/pioarduino/esp-idf/releases/download/v5.4.1.250411/esp-idf-v5.4.1.zip" }, "toolchain-xtensa-esp-elf": { "type": "toolchain", From 3a85a8bb307f2eafa7d32eb458762537c096d7ff Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 16 Apr 2025 14:05:56 +0200 Subject: [PATCH 32/60] remove old (not anymore working) way of setting start address of firmware --- builder/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builder/main.py b/builder/main.py index e4fad6f1d..4b40d7d78 100644 --- a/builder/main.py +++ b/builder/main.py @@ -132,7 +132,7 @@ def _parse_partitions(env): result = [] next_offset = 0 - app_offset = int(board.get("upload.offset_address", "0x10000"), 16) # default 0x10000 + app_offset = 0x10000 # default address for firmware with open(partitions_csv) as fp: for line in fp.readlines(): line = line.strip() From 729d6014fa61a306e8c64449aedb3c6091810cd5 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 16 Apr 2025 16:03:35 +0200 Subject: [PATCH 33/60] Update README.md --- examples/espidf-arduino-matter-light/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/espidf-arduino-matter-light/README.md b/examples/espidf-arduino-matter-light/README.md index 7d8768865..d4072af5c 100644 --- a/examples/espidf-arduino-matter-light/README.md +++ b/examples/espidf-arduino-matter-light/README.md @@ -53,8 +53,7 @@ Holding the BOOT button pressed for more than 10 seconds and then releasing it w ## Building the Application using WiFi and Matter -Use ESP-IDF 5.1.4 from https://github.com/espressif/esp-idf/tree/release/v5.1 -This example has been tested with Arduino Core 3.0.4 +This example has been tested with Arduino Core 3.0.4. It should work with newer versions too. There is a configuration file for these SoC: esp32s3, esp32c3, esp32c6. Those are the tested devices that have a WS2812 RGB LED and can run BLE, WiFi and Matter. From 7da09cf8d6e8de78747279ede2e98f21afc82d5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20BOU=C3=89?= Date: Wed, 16 Apr 2025 18:08:08 +0200 Subject: [PATCH 34/60] Update README.md to fix typos (#139) * Update README.md to fix typo * Update README.md --- examples/espidf-arduino-matter-light/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/espidf-arduino-matter-light/README.md b/examples/espidf-arduino-matter-light/README.md index d4072af5c..215d7a9a9 100644 --- a/examples/espidf-arduino-matter-light/README.md +++ b/examples/espidf-arduino-matter-light/README.md @@ -63,5 +63,5 @@ In case it is necessary to change the Button Pin or the REG LED Pin, please use ## Using OpenThread with Matter This is possible with the ESP32-C6. -It is neessasy to have a Thread Border Routed in the Matter Environment. Check you matter hardware provider. +It is necessary to have a Thread Border Router in the Matter Environment. Check your Matter hardware provider. From d47f924d4c6d8fd2181532121531796ed115e8d2 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sat, 19 Apr 2025 12:36:33 +0200 Subject: [PATCH 35/60] remove generated old sdkconfig leftover --- builder/frameworks/arduino.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/builder/frameworks/arduino.py b/builder/frameworks/arduino.py index 4c2bd9306..ef75059cf 100644 --- a/builder/frameworks/arduino.py +++ b/builder/frameworks/arduino.py @@ -28,7 +28,7 @@ import os import sys import shutil -from os.path import join +from os.path import join, exists from SCons.Script import COMMAND_LINE_TARGETS, DefaultEnvironment, SConscript from platformio import fs @@ -240,6 +240,11 @@ def call_compile_libs(): SConscript("espidf.py") if check_reinstall_frwrk() == True: + envs = [section.replace("env:", "") for section in config.sections() if section.startswith("env:")] + for env_name in envs: + file_path = join(env.subst("$PROJECT_DIR"), f"sdkconfig.{env_name}") + if exists(file_path): + os.remove(file_path) print("*** Reinstall Arduino framework ***") shutil.rmtree(platform.get_package_dir("framework-arduinoespressif32")) shutil.rmtree(platform.get_package_dir("framework-arduinoespressif32-libs")) From b07c7388c2dfd2253c37b41c88b22d212a25f333 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 20 Apr 2025 18:23:40 +0200 Subject: [PATCH 36/60] Fix Arduino as an component of IDF compile for the C2 --- builder/frameworks/arduino.py | 14 ++++++++++++++ builder/frameworks/espidf.py | 14 +++++++++----- examples/espidf-arduino-littlefs/platformio.ini | 10 +++++----- examples/tasmota_platformio_override.ini | 3 +-- 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/builder/frameworks/arduino.py b/builder/frameworks/arduino.py index ef75059cf..228367821 100644 --- a/builder/frameworks/arduino.py +++ b/builder/frameworks/arduino.py @@ -230,6 +230,20 @@ def shorthen_includes(env, node): + shortened_includes, ) +# Check if framework = arduino, espidf is set -> compile Arduino as an component of IDF +# using platformio.ini entry since we modify the framework env var for Hybrid Compile! +def get_frameworks_in_current_env(): + current_env_section = "env:" + env["PIOENV"] + if "framework" in config.options(current_env_section): + frameworks = config.get(current_env_section, "framework", "") + return frameworks + return [] + +current_env_frameworks = get_frameworks_in_current_env() +if "arduino" in current_env_frameworks and "espidf" in current_env_frameworks: + # Arduino as component is set, switch off Hybrid compile + flag_custom_sdkconfig = False + def call_compile_libs(): if mcu == "esp32c2": ARDUINO_FRMWRK_C2_LIB_DIR = join(platform.get_package_dir("framework-arduinoespressif32-libs"),mcu) diff --git a/builder/frameworks/espidf.py b/builder/frameworks/espidf.py index b73a875ba..42fd2ade3 100644 --- a/builder/frameworks/espidf.py +++ b/builder/frameworks/espidf.py @@ -155,10 +155,14 @@ def _get_installed_standard_pip_packages(): ): print("Warning! Debugging an IDF project requires PlatformIO Core >= 6.1.11!") -# Arduino framework as a component is not compatible with ESP-IDF >5.3 if "arduino" in env.subst("$PIOFRAMEWORK"): ARDUINO_FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoespressif32") ARDUINO_FRMWRK_LIB_DIR = platform.get_package_dir("framework-arduinoespressif32-libs") + if mcu == "esp32c2": + ARDUINO_FRMWRK_C2_LIB_DIR = join(platform.get_package_dir("framework-arduinoespressif32-libs"),mcu) + if not os.path.exists(ARDUINO_FRMWRK_C2_LIB_DIR): + ARDUINO_C2_DIR = join(platform.get_package_dir("framework-arduino-c2-skeleton-lib"),mcu) + shutil.copytree(ARDUINO_C2_DIR, ARDUINO_FRMWRK_C2_LIB_DIR, dirs_exist_ok=True) # Possible package names in 'package@version' format is not compatible with CMake if "@" in os.path.basename(ARDUINO_FRAMEWORK_DIR): new_path = os.path.join( @@ -296,7 +300,7 @@ def HandleCOMPONENTsettings(env): if flag_custom_component_add == True or flag_custom_component_remove == True: # todo remove duplicated import yaml from yaml import SafeLoader - print("*** \"custom_component\" is used to select managed idf components ***") + print("*** \"custom_component\" is used to (de)select managed idf components ***") if flag_custom_component_remove == True: idf_custom_component_remove = env.GetProjectOption("custom_component_remove").splitlines() else: @@ -365,7 +369,7 @@ def HandleCOMPONENTsettings(env): if flag_custom_component_add == True or flag_custom_component_remove == True: HandleCOMPONENTsettings(env) -if flag_custom_sdkonfig == True and "arduino" in env.subst("$PIOFRAMEWORK"): +if flag_custom_sdkonfig == True and "arduino" in env.subst("$PIOFRAMEWORK") and "espidf" not in env.subst("$PIOFRAMEWORK"): HandleArduinoIDFsettings(env) LIB_SOURCE = os.path.join(ProjectConfig.get_instance().get("platformio", "platforms_dir"), "espressif32", "builder", "build_lib") if not bool(os.path.exists(os.path.join(PROJECT_DIR, ".dummy"))): @@ -2092,7 +2096,7 @@ def _skip_prj_source_files(node): # Compile Arduino IDF sources # -if "arduino" in env.get("PIOFRAMEWORK") and "espidf" not in env.get("PIOFRAMEWORK"): +if ("arduino" in env.subst("$PIOFRAMEWORK")) and ("espidf" not in env.subst("$PIOFRAMEWORK")): def idf_lib_copy(source, target, env): env_build = join(env["PROJECT_BUILD_DIR"],env["PIOENV"]) sdkconfig_h_path = join(env_build,"config","sdkconfig.h") @@ -2150,7 +2154,7 @@ def idf_lib_copy(source, target, env): print("*** Original Arduino \"idf_component.yml\" couldnt be restored ***") env.AddPostAction("checkprogsize", idf_lib_copy) -if "espidf" in env.get("PIOFRAMEWORK") and (flag_custom_component_add == True or flag_custom_component_remove == True): +if "espidf" in env.subst("$PIOFRAMEWORK") and (flag_custom_component_add == True or flag_custom_component_remove == True): def idf_custom_component(source, target, env): try: shutil.copy(join(ARDUINO_FRAMEWORK_DIR,"idf_component.yml.orig"),join(ARDUINO_FRAMEWORK_DIR,"idf_component.yml")) diff --git a/examples/espidf-arduino-littlefs/platformio.ini b/examples/espidf-arduino-littlefs/platformio.ini index d0c70385c..0ae6edc07 100644 --- a/examples/espidf-arduino-littlefs/platformio.ini +++ b/examples/espidf-arduino-littlefs/platformio.ini @@ -11,14 +11,14 @@ [env] platform = espressif32 framework = arduino, espidf +board_build.filesystem = littlefs +board_build.partitions = partitions_custom.csv monitor_speed = 115200 + +[env:esp32dev] +board = esp32dev board_build.embed_txtfiles = managed_components/espressif__esp_insights/server_certs/https_server.crt managed_components/espressif__esp_rainmaker/server_certs/rmaker_mqtt_server.crt managed_components/espressif__esp_rainmaker/server_certs/rmaker_claim_service_server.crt managed_components/espressif__esp_rainmaker/server_certs/rmaker_ota_server.crt - -[env:esp32dev] -board = esp32dev -board_build.filesystem = littlefs -board_build.partitions = partitions_custom.csv diff --git a/examples/tasmota_platformio_override.ini b/examples/tasmota_platformio_override.ini index ba1a5b608..8b477e297 100644 --- a/examples/tasmota_platformio_override.ini +++ b/examples/tasmota_platformio_override.ini @@ -37,8 +37,7 @@ custom_sdkconfig = https://raw.githubusercontent.com/pioarduino/sdkconfig '# CONFIG_ETH_PHY_INTERFACE_RMII is not set' '# CONFIG_ETH_RMII_CLK_INPUT is not set' '# CONFIG_ETH_RMII_CLK_IN_GPIO is not set' -custom_component_remove = espressif/esp_hosted - espressif/esp_wifi_remote +custom_component_remove = espressif/esp-dsp espressif/network_provisioning espressif/esp-zboss-lib From 43ef94a787b7d3166a5b0277aac27eb633d61420 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 23 Apr 2025 18:57:59 +0200 Subject: [PATCH 37/60] change example `custom_component_add` --- examples/arduino-blink/platformio.ini | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/arduino-blink/platformio.ini b/examples/arduino-blink/platformio.ini index 8fe2201b7..e6c37cb53 100644 --- a/examples/arduino-blink/platformio.ini +++ b/examples/arduino-blink/platformio.ini @@ -43,6 +43,8 @@ custom_component_remove = espressif/esp_hosted espressif/esp_diagnostics espressif/esp_rainmaker espressif/rmaker_common +custom_component_add = + espressif/cmake_utilities @ 0.* [env:esp32-s3-arduino_nano_esp32] platform = espressif32 @@ -87,7 +89,6 @@ custom_component_remove = espressif/esp_hosted espressif/esp_diagnostics espressif/esp_rainmaker espressif/rmaker_common -custom_component_add = lvgl/lvgl @ ^9.2.2 [env:esp32-c6-devkitc-1] platform = espressif32 From d81abd0f45d60251f14154ed9afd1db89a93c484 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 23 Apr 2025 19:23:14 +0200 Subject: [PATCH 38/60] Use Arduino libs idf-release_v5.4-3ad36321 --- platform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform.py b/platform.py index 9c5dccb8e..d27a32b6e 100644 --- a/platform.py +++ b/platform.py @@ -51,7 +51,7 @@ def configure_default_packages(self, variables, targets): #packjdata = requests.get(URL).json() #dyn_lib_url = packjdata['packages'][0]['tools'][0]['systems'][0]['url'] # use newer libs as linked in package_esp32_index.template.json is too old - dyn_lib_url = "https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.4/esp32-arduino-libs-idf-release_v5.4-6897a7bf-v1.zip" + dyn_lib_url = "https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.4/esp32-arduino-libs-idf-release_v5.4-3ad36321-v1.zip" self.packages["framework-arduinoespressif32-libs"]["version"] = dyn_lib_url if variables.get("custom_sdkconfig") is not None or len(str(board_sdkconfig)) > 3: From b4d0e71e7ac9b10cf17ef2abe6b14980316656df Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 25 Apr 2025 13:53:23 +0200 Subject: [PATCH 39/60] Esp32ExceptionDecoder: decode stack overflow backtraces --- monitor/filter_exception_decoder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monitor/filter_exception_decoder.py b/monitor/filter_exception_decoder.py index d0f4a39b3..9c4df9e83 100644 --- a/monitor/filter_exception_decoder.py +++ b/monitor/filter_exception_decoder.py @@ -32,7 +32,7 @@ class Esp32ExceptionDecoder(DeviceMonitorFilterBase): NAME = "esp32_exception_decoder" - ADDR_PATTERN = re.compile(r"((?:0x[0-9a-fA-F]{8}[: ]?)+)\s?$") + ADDR_PATTERN = re.compile(r"((?:0x[0-9a-fA-F]{8}[: ]?)+)") ADDR_SPLIT = re.compile(r"[ :]") PREFIX_RE = re.compile(r"^ *") From 044dd0e970faf89d83eebb0a4600e0897f3cc50a Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 25 Apr 2025 19:43:28 +0200 Subject: [PATCH 40/60] Fix Matter Arduino as an component of IDF example --- .../CMakeLists.txt | 15 +- .../main/Kconfig.projbuild | 96 +--- .../main/builtinLED.cpp | 338 +++++++------- .../main/builtinLED.h | 76 +-- .../main/idf_component.yml | 2 +- .../main/matter_accessory_driver.cpp | 132 +++--- .../main/matter_accessory_driver.h | 28 +- .../main/matter_light.cpp | 437 ++++++++---------- .../platformio.ini | 10 +- .../sdkconfig.defaults | 54 ++- .../sdkconfig.defaults.c6_thread | 5 +- .../sdkconfig.defaults.esp32c3 | 64 --- .../sdkconfig.defaults.esp32c6 | 63 --- .../sdkconfig.defaults.esp32s3 | 64 --- 14 files changed, 556 insertions(+), 828 deletions(-) delete mode 100644 examples/espidf-arduino-matter-light/sdkconfig.defaults.esp32c3 delete mode 100644 examples/espidf-arduino-matter-light/sdkconfig.defaults.esp32s3 diff --git a/examples/espidf-arduino-matter-light/CMakeLists.txt b/examples/espidf-arduino-matter-light/CMakeLists.txt index 4a9c0c2e8..1430df8ff 100644 --- a/examples/espidf-arduino-matter-light/CMakeLists.txt +++ b/examples/espidf-arduino-matter-light/CMakeLists.txt @@ -1,10 +1,15 @@ -cmake_minimum_required(VERSION 3.16.0) -include($ENV{IDF_PATH}/tools/cmake/project.cmake) +# The following lines of boilerplate have to be in your project's +# CMakeLists in this exact order for cmake to work correctly +cmake_minimum_required(VERSION 3.5) + set(PROJECT_VER "1.0") set(PROJECT_VER_NUMBER 1) -project(matter-light) +# This should be done before using the IDF_TARGET variable. +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +idf_build_set_property(MINIMAL_BUILD ON) +project(arduino_managed_component_light) # WARNING: This is just an example for using key for decrypting the encrypted OTA image # Please do not use it as is. @@ -16,8 +21,8 @@ if(CONFIG_IDF_TARGET_ESP32C2) include(relinker) endif() -idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++17;-Os;-DCHIP_HAVE_CONFIG_H" APPEND) +idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++2a;-Os;-DCHIP_HAVE_CONFIG_H" APPEND) idf_build_set_property(C_COMPILE_OPTIONS "-Os" APPEND) # For RISCV chips, project_include.cmake sets -Wno-format, but does not clear various # flags that depend on -Wformat -idf_build_set_property(COMPILE_OPTIONS "-Wno-format-nonliteral;-Wno-format-security" APPEND) \ No newline at end of file +idf_build_set_property(COMPILE_OPTIONS "-Wno-format-nonliteral;-Wno-format-security" APPEND) diff --git a/examples/espidf-arduino-matter-light/main/Kconfig.projbuild b/examples/espidf-arduino-matter-light/main/Kconfig.projbuild index 50e8914f0..91ee5e89b 100644 --- a/examples/espidf-arduino-matter-light/main/Kconfig.projbuild +++ b/examples/espidf-arduino-matter-light/main/Kconfig.projbuild @@ -3,100 +3,40 @@ menu "Light Matter Accessory" config BUTTON_PIN int prompt "Button 1 GPIO" - default ENV_GPIO_BOOT_BUTTON + default 9 if IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32C6 + default 0 range -1 ENV_GPIO_IN_RANGE_MAX help The GPIO pin for button that will be used to turn on/off the Matter Light. It shall be connected to a push button. It can use the BOOT button of the development board. endmenu - menu "LEDs" config WS2812_PIN int prompt "WS2812 RGB LED GPIO" - default ENV_GPIO_RGB_LED + default 8 if IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32C6 + default 48 range -1 ENV_GPIO_OUT_RANGE_MAX help The GPIO pin for the Matter Light that will be driven by RMT. It shall be connected to one single WS2812 RGB LED. endmenu - # TARGET CONFIGURATION - if IDF_TARGET_ESP32C3 - config ENV_GPIO_RANGE_MIN - int - default 0 - - config ENV_GPIO_RANGE_MAX - int - default 19 - # GPIOs 20/21 are always used by UART in examples - - config ENV_GPIO_IN_RANGE_MAX - int - default ENV_GPIO_RANGE_MAX - - config ENV_GPIO_OUT_RANGE_MAX - int - default ENV_GPIO_RANGE_MAX - - config ENV_GPIO_BOOT_BUTTON - int - default 9 - - config ENV_GPIO_RGB_LED - int - default 8 - endif - if IDF_TARGET_ESP32C6 - config ENV_GPIO_RANGE_MIN - int - default 0 + config ENV_GPIO_RANGE_MIN + int + default 0 - config ENV_GPIO_RANGE_MAX - int - default 30 - # GPIOs 16/17 are always used by UART in examples + config ENV_GPIO_RANGE_MAX + int + default 19 if IDF_TARGET_ESP32C3 + default 30 if IDF_TARGET_ESP32C6 + default 48 - config ENV_GPIO_IN_RANGE_MAX - int - default ENV_GPIO_RANGE_MAX + config ENV_GPIO_IN_RANGE_MAX + int + default ENV_GPIO_RANGE_MAX - config ENV_GPIO_OUT_RANGE_MAX - int - default ENV_GPIO_RANGE_MAX - - config ENV_GPIO_BOOT_BUTTON - int - default 9 - - config ENV_GPIO_RGB_LED - int - default 8 - endif - if IDF_TARGET_ESP32S3 - config ENV_GPIO_RANGE_MIN - int - default 0 - - config ENV_GPIO_RANGE_MAX - int - default 48 - - config ENV_GPIO_IN_RANGE_MAX - int - default ENV_GPIO_RANGE_MAX - - config ENV_GPIO_OUT_RANGE_MAX - int - default ENV_GPIO_RANGE_MAX - - config ENV_GPIO_BOOT_BUTTON - int - default 0 - - config ENV_GPIO_RGB_LED - int - default 48 - endif + config ENV_GPIO_OUT_RANGE_MAX + int + default ENV_GPIO_RANGE_MAX endmenu diff --git a/examples/espidf-arduino-matter-light/main/builtinLED.cpp b/examples/espidf-arduino-matter-light/main/builtinLED.cpp index 9f2695b89..8795dde27 100644 --- a/examples/espidf-arduino-matter-light/main/builtinLED.cpp +++ b/examples/espidf-arduino-matter-light/main/builtinLED.cpp @@ -13,235 +13,225 @@ #include "builtinLED.h" typedef struct { - uint16_t hue; - uint8_t saturation; + uint16_t hue; + uint8_t saturation; } HS_color_t; static const HS_color_t temperatureTable[] = { - {4, 100}, {8, 100}, {11, 100}, {14, 100}, {16, 100}, {18, 100}, {20, 100}, {22, 100}, {24, 100}, {25, 100}, - {27, 100}, {28, 100}, {30, 100}, {31, 100}, {31, 95}, {30, 89}, {30, 85}, {29, 80}, {29, 76}, {29, 73}, - {29, 69}, {28, 66}, {28, 63}, {28, 60}, {28, 57}, {28, 54}, {28, 52}, {27, 49}, {27, 47}, {27, 45}, - {27, 43}, {27, 41}, {27, 39}, {27, 37}, {27, 35}, {27, 33}, {27, 31}, {27, 30}, {27, 28}, {27, 26}, - {27, 25}, {27, 23}, {27, 22}, {27, 21}, {27, 19}, {27, 18}, {27, 17}, {27, 15}, {28, 14}, {28, 13}, - {28, 12}, {29, 10}, {29, 9}, {30, 8}, {31, 7}, {32, 6}, {34, 5}, {36, 4}, {41, 3}, {49, 2}, - {0, 0}, {294, 2}, {265, 3}, {251, 4}, {242, 5}, {237, 6}, {233, 7}, {231, 8}, {229, 9}, {228, 10}, - {227, 11}, {226, 11}, {226, 12}, {225, 13}, {225, 13}, {224, 14}, {224, 14}, {224, 15}, {224, 15}, {223, 16}, - {223, 16}, {223, 17}, {223, 17}, {223, 17}, {222, 18}, {222, 18}, {222, 19}, {222, 19}, {222, 19}, {222, 19}, - {222, 20}, {222, 20}, {222, 20}, {222, 21}, {222, 21} + {4, 100}, {8, 100}, {11, 100}, {14, 100}, {16, 100}, {18, 100}, {20, 100}, {22, 100}, {24, 100}, {25, 100}, {27, 100}, {28, 100}, {30, 100}, {31, 100}, + {31, 95}, {30, 89}, {30, 85}, {29, 80}, {29, 76}, {29, 73}, {29, 69}, {28, 66}, {28, 63}, {28, 60}, {28, 57}, {28, 54}, {28, 52}, {27, 49}, + {27, 47}, {27, 45}, {27, 43}, {27, 41}, {27, 39}, {27, 37}, {27, 35}, {27, 33}, {27, 31}, {27, 30}, {27, 28}, {27, 26}, {27, 25}, {27, 23}, + {27, 22}, {27, 21}, {27, 19}, {27, 18}, {27, 17}, {27, 15}, {28, 14}, {28, 13}, {28, 12}, {29, 10}, {29, 9}, {30, 8}, {31, 7}, {32, 6}, + {34, 5}, {36, 4}, {41, 3}, {49, 2}, {0, 0}, {294, 2}, {265, 3}, {251, 4}, {242, 5}, {237, 6}, {233, 7}, {231, 8}, {229, 9}, {228, 10}, + {227, 11}, {226, 11}, {226, 12}, {225, 13}, {225, 13}, {224, 14}, {224, 14}, {224, 15}, {224, 15}, {223, 16}, {223, 16}, {223, 17}, {223, 17}, {223, 17}, + {222, 18}, {222, 18}, {222, 19}, {222, 19}, {222, 19}, {222, 19}, {222, 20}, {222, 20}, {222, 20}, {222, 21}, {222, 21} }; /* step brightness table: gamma = 2.3 */ static const uint8_t gamma_table[MAX_PROGRESS] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, - 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, - 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, - 10, 10, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16, 17, - 17, 18, 18, 19, 19, 20, 20, 21, 22, 22, 23, 23, 24, 25, 25, 26, - 26, 27, 28, 28, 29, 30, 30, 31, 32, 33, 33, 34, 35, 36, 36, 37, - 38, 39, 40, 40, 41, 42, 43, 44, 45, 45, 46, 47, 48, 49, 50, 51, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 74, 75, 76, 77, 78, 79, 81, 82, 83, 84, 86, - 87, 88, 89, 91, 92, 93, 95, 96, 97, 99, 100, 101, 103, 104, 105, 107, - 108, 110, 111, 112, 114, 115, 117, 118, 120, 121, 123, 124, 126, 128, 129, 131, - 132, 134, 135, 137, 139, 140, 142, 144, 145, 147, 149, 150, 152, 154, 156, 157, - 159, 161, 163, 164, 166, 168, 170, 172, 174, 175, 177, 179, 181, 183, 185, 187, - 189, 191, 193, 195, 197, 199, 201, 203, 205, 207, 209, 211, 213, 215, 217, 219, - 221, 223, 226, 228, 230, 232, 234, 236, 239, 241, 243, 245, 248, 250, 252, 255, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, + 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, + 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, + 21, 22, 22, 23, 23, 24, 25, 25, 26, 26, 27, 28, 28, 29, 30, 30, 31, 32, 33, 33, 34, 35, 36, 36, 37, 38, 39, 40, 40, + 41, 42, 43, 44, 45, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 72, 74, 75, 76, 77, 78, 79, 81, 82, 83, 84, 86, 87, 88, 89, 91, 92, 93, 95, 96, 97, 99, 100, 101, 103, 104, + 105, 107, 108, 110, 111, 112, 114, 115, 117, 118, 120, 121, 123, 124, 126, 128, 129, 131, 132, 134, 135, 137, 139, 140, 142, 144, 145, 147, 149, + 150, 152, 154, 156, 157, 159, 161, 163, 164, 166, 168, 170, 172, 174, 175, 177, 179, 181, 183, 185, 187, 189, 191, 193, 195, 197, 199, 201, 203, + 205, 207, 209, 211, 213, 215, 217, 219, 221, 223, 226, 228, 230, 232, 234, 236, 239, 241, 243, 245, 248, 250, 252, 255, }; BuiltInLED::BuiltInLED() { - pin_number = (uint8_t) -1; // no pin number - state = false; // LED is off - hsv_color.value = 0; // black color + pin_number = (uint8_t)-1; // no pin number + state = false; // LED is off + hsv_color.value = 0; // black color } -BuiltInLED::~BuiltInLED(){ - end(); +BuiltInLED::~BuiltInLED() { + end(); } led_indicator_color_hsv_t BuiltInLED::rgb2hsv(led_indicator_color_rgb_t rgb) { - led_indicator_color_hsv_t hsv; - uint8_t minRGB, maxRGB; - uint8_t delta; - - minRGB = rgb.r < rgb.g ? (rgb.r < rgb.b ? rgb.r : rgb.b) : (rgb.g < rgb.b ? rgb.g : rgb.b); - maxRGB = rgb.r > rgb.g ? (rgb.r > rgb.b ? rgb.r : rgb.b) : (rgb.g > rgb.b ? rgb.g : rgb.b); - hsv.value = 0; - hsv.v = maxRGB; - delta = maxRGB - minRGB; - - if (delta == 0) { - hsv.h = 0; - hsv.s = 0; + led_indicator_color_hsv_t hsv; + uint8_t minRGB, maxRGB; + uint8_t delta; + + minRGB = rgb.r < rgb.g ? (rgb.r < rgb.b ? rgb.r : rgb.b) : (rgb.g < rgb.b ? rgb.g : rgb.b); + maxRGB = rgb.r > rgb.g ? (rgb.r > rgb.b ? rgb.r : rgb.b) : (rgb.g > rgb.b ? rgb.g : rgb.b); + hsv.value = 0; + hsv.v = maxRGB; + delta = maxRGB - minRGB; + + if (delta == 0) { + hsv.h = 0; + hsv.s = 0; + } else { + hsv.s = delta * 255 / maxRGB; + + if (rgb.r == maxRGB) { + hsv.h = (60 * (rgb.g - rgb.b) / delta + 360) % 360; + } else if (rgb.g == maxRGB) { + hsv.h = (60 * (rgb.b - rgb.r) / delta + 120); } else { - hsv.s = delta * 255 / maxRGB; - - if (rgb.r == maxRGB) { - hsv.h = (60 * (rgb.g - rgb.b) / delta + 360) % 360; - } else if (rgb.g == maxRGB) { - hsv.h = (60 * (rgb.b - rgb.r) / delta + 120); - } else { - hsv.h = (60 * (rgb.r - rgb.g) / delta + 240); - } + hsv.h = (60 * (rgb.r - rgb.g) / delta + 240); } - return hsv; + } + return hsv; } led_indicator_color_rgb_t BuiltInLED::hsv2rgb(led_indicator_color_hsv_t hsv) { - led_indicator_color_rgb_t rgb; - uint8_t rgb_max = hsv.v; - uint8_t rgb_min = rgb_max * (255 - hsv.s) / 255.0f; + led_indicator_color_rgb_t rgb; + uint8_t rgb_max = hsv.v; + uint8_t rgb_min = rgb_max * (255 - hsv.s) / 255.0f; - uint8_t i = hsv.h / 60; - uint8_t diff = hsv.h % 60; + uint8_t i = hsv.h / 60; + uint8_t diff = hsv.h % 60; - // RGB adjustment amount by hue - uint8_t rgb_adj = (rgb_max - rgb_min) * diff / 60; - rgb.value = 0; - switch (i) { + // RGB adjustment amount by hue + uint8_t rgb_adj = (rgb_max - rgb_min) * diff / 60; + rgb.value = 0; + switch (i) { case 0: - rgb.r = rgb_max; - rgb.g = rgb_min + rgb_adj; - rgb.b = rgb_min; - break; + rgb.r = rgb_max; + rgb.g = rgb_min + rgb_adj; + rgb.b = rgb_min; + break; case 1: - rgb.r = rgb_max - rgb_adj; - rgb.g = rgb_max; - rgb.b = rgb_min; - break; + rgb.r = rgb_max - rgb_adj; + rgb.g = rgb_max; + rgb.b = rgb_min; + break; case 2: - rgb.r = rgb_min; - rgb.g = rgb_max; - rgb.b = rgb_min + rgb_adj; - break; + rgb.r = rgb_min; + rgb.g = rgb_max; + rgb.b = rgb_min + rgb_adj; + break; case 3: - rgb.r = rgb_min; - rgb.g = rgb_max - rgb_adj; - rgb.b = rgb_max; - break; + rgb.r = rgb_min; + rgb.g = rgb_max - rgb_adj; + rgb.b = rgb_max; + break; case 4: - rgb.r = rgb_min + rgb_adj; - rgb.g = rgb_min; - rgb.b = rgb_max; - break; + rgb.r = rgb_min + rgb_adj; + rgb.g = rgb_min; + rgb.b = rgb_max; + break; default: - rgb.r = rgb_max; - rgb.g = rgb_min; - rgb.b = rgb_max - rgb_adj; - break; + rgb.r = rgb_max; + rgb.g = rgb_min; + rgb.b = rgb_max - rgb_adj; + break; + } + + // gamma correction + rgb.r = gamma_table[rgb.r]; + rgb.g = gamma_table[rgb.g]; + rgb.b = gamma_table[rgb.b]; + return rgb; +} + +void BuiltInLED::begin(uint8_t pin) { + if (pin < NUM_DIGITAL_PINS) { + pin_number = pin; + log_i("Initializing pin %d", pin); + } else { + log_e("Invalid pin (%d) number", pin); + } +} +void BuiltInLED::end() { + state = false; + write(); // turn off the LED + if (pin_number < NUM_DIGITAL_PINS) { + if (!rmtDeinit(pin_number)) { + log_e("Failed to deinitialize RMT"); } - - // gamma correction - rgb.r = gamma_table[rgb.r]; - rgb.g = gamma_table[rgb.g]; - rgb.b = gamma_table[rgb.b]; - return rgb; + } } -void BuiltInLED::begin(uint8_t pin){ - if (pin < NUM_DIGITAL_PINS) { - pin_number = pin; - log_i("Initializing pin %d", pin); - } else { - log_e("Invalid pin (%d) number", pin); - } -} -void BuiltInLED::end(){ - state = false; - write(); // turn off the LED - if (pin_number < NUM_DIGITAL_PINS) { - if (!rmtDeinit(pin_number)) { - log_e("Failed to deinitialize RMT"); - } - } +void BuiltInLED::on() { + state = true; } -void BuiltInLED::on(){ - state = true; +void BuiltInLED::off() { + state = false; } -void BuiltInLED::off(){ - state = false; +void BuiltInLED::toggle() { + state = !state; } -void BuiltInLED::toggle(){ - state = !state; +bool BuiltInLED::getState() { + return state; } -bool BuiltInLED::getState(){ - return state; -} - -bool BuiltInLED::write(){ - led_indicator_color_rgb_t rgb_color = getRGB(); - log_d("Writing to pin %d with state = %s", pin_number, state ? "ON" : "OFF"); - log_d("HSV: %d, %d, %d", hsv_color.h, hsv_color.s, hsv_color.v); - log_d("RGB: %d, %d, %d", rgb_color.r, rgb_color.g, rgb_color.b); - if(pin_number < NUM_DIGITAL_PINS){ - if (state) { - rgbLedWrite(pin_number, rgb_color.r, rgb_color.g, rgb_color.b); - } else { - rgbLedWrite(pin_number, 0, 0, 0); - } - return true; +bool BuiltInLED::write() { + led_indicator_color_rgb_t rgb_color = getRGB(); + log_d("Writing to pin %d with state = %s", pin_number, state ? "ON" : "OFF"); + log_d("HSV: %d, %d, %d", hsv_color.h, hsv_color.s, hsv_color.v); + log_d("RGB: %d, %d, %d", rgb_color.r, rgb_color.g, rgb_color.b); + if (pin_number < NUM_DIGITAL_PINS) { + if (state) { + rgbLedWrite(pin_number, rgb_color.r, rgb_color.g, rgb_color.b); } else { - log_e("Invalid pin (%d) number", pin_number); - return false; + rgbLedWrite(pin_number, 0, 0, 0); } + return true; + } else { + log_e("Invalid pin (%d) number", pin_number); + return false; + } } -void BuiltInLED::setBrightness(uint8_t brightness){ - hsv_color.v = brightness; +void BuiltInLED::setBrightness(uint8_t brightness) { + hsv_color.v = brightness; } -uint8_t BuiltInLED::getBrightness(){ - return hsv_color.v; +uint8_t BuiltInLED::getBrightness() { + return hsv_color.v; } -void BuiltInLED::setHSV(led_indicator_color_hsv_t hsv){ - if (hsv.h > MAX_HUE) { - hsv.h = MAX_HUE; - } - hsv_color.value = hsv.value; +void BuiltInLED::setHSV(led_indicator_color_hsv_t hsv) { + if (hsv.h > MAX_HUE) { + hsv.h = MAX_HUE; + } + hsv_color.value = hsv.value; } -led_indicator_color_hsv_t BuiltInLED::getHSV(){ - return hsv_color; +led_indicator_color_hsv_t BuiltInLED::getHSV() { + return hsv_color; } -void BuiltInLED::setRGB(led_indicator_color_rgb_t rgb_color){ - hsv_color = rgb2hsv(rgb_color); +void BuiltInLED::setRGB(led_indicator_color_rgb_t rgb_color) { + hsv_color = rgb2hsv(rgb_color); } -led_indicator_color_rgb_t BuiltInLED::getRGB(){ - return hsv2rgb(hsv_color); +led_indicator_color_rgb_t BuiltInLED::getRGB() { + return hsv2rgb(hsv_color); } -void BuiltInLED::setTemperature(uint32_t temperature){ - uint16_t hue; - uint8_t saturation; +void BuiltInLED::setTemperature(uint32_t temperature) { + uint16_t hue; + uint8_t saturation; - log_d("Requested Temperature: %ld", temperature); - //hsv_color.v = gamma_table[((temperature >> 25) & 0x7F)]; - temperature &= 0xFFFFFF; - if (temperature < 600) { - hue = 0; - saturation = 100; + log_d("Requested Temperature: %ld", temperature); + //hsv_color.v = gamma_table[((temperature >> 25) & 0x7F)]; + temperature &= 0xFFFFFF; + if (temperature < 600) { + hue = 0; + saturation = 100; + } else { + if (temperature > 10000) { + hue = 222; + saturation = 21 + (temperature - 10000) * 41 / 990000; } else { - if (temperature > 10000) { - hue = 222; - saturation = 21 + (temperature - 10000) * 41 / 990000; - } else { - temperature -= 600; - temperature /= 100; - hue = temperatureTable[temperature].hue; - saturation = temperatureTable[temperature].saturation; - } + temperature -= 600; + temperature /= 100; + hue = temperatureTable[temperature].hue; + saturation = temperatureTable[temperature].saturation; } - saturation = (saturation * 255) / 100; - // brightness is not changed - hsv_color.h = hue; - hsv_color.s = saturation; - log_d("Calculated Temperature: %ld, Hue: %d, Saturation: %d, Brightness: %d", temperature, hue, saturation, hsv_color.v); -} \ No newline at end of file + } + saturation = (saturation * 255) / 100; + // brightness is not changed + hsv_color.h = hue; + hsv_color.s = saturation; + log_d("Calculated Temperature: %ld, Hue: %d, Saturation: %d, Brightness: %d", temperature, hue, saturation, hsv_color.v); +} diff --git a/examples/espidf-arduino-matter-light/main/builtinLED.h b/examples/espidf-arduino-matter-light/main/builtinLED.h index 7a2f2ec5d..1ca8c9355 100644 --- a/examples/espidf-arduino-matter-light/main/builtinLED.h +++ b/examples/espidf-arduino-matter-light/main/builtinLED.h @@ -14,61 +14,61 @@ #include -#define MAX_HUE 360 +#define MAX_HUE 360 #define MAX_SATURATION 255 #define MAX_BRIGHTNESS 255 -#define MAX_PROGRESS 256 +#define MAX_PROGRESS 256 typedef struct { - union { - struct { - uint32_t v: 8; /*!< Brightness/Value of the LED. 0-255 */ - uint32_t s: 8; /*!< Saturation of the LED. 0-255 */ - uint32_t h: 9; /*!< Hue of the LED. 0-360 */ - }; - uint32_t value; /*!< IHSV value of the LED. */ + union { + struct { + uint32_t v : 8; /*!< Brightness/Value of the LED. 0-255 */ + uint32_t s : 8; /*!< Saturation of the LED. 0-255 */ + uint32_t h : 9; /*!< Hue of the LED. 0-360 */ }; + uint32_t value; /*!< IHSV value of the LED. */ + }; } led_indicator_color_hsv_t; typedef struct { - union { - struct { - uint32_t r: 8; /*!< Red component of the LED color. Range: 0-255. */ - uint32_t g: 8; /*!< Green component of the LED color. Range: 0-255. */ - uint32_t b: 8; /*!< Blue component of the LED color. Range: 0-255. */ - }; - uint32_t value; /*!< Combined RGB value of the LED color. */ + union { + struct { + uint32_t r : 8; /*!< Red component of the LED color. Range: 0-255. */ + uint32_t g : 8; /*!< Green component of the LED color. Range: 0-255. */ + uint32_t b : 8; /*!< Blue component of the LED color. Range: 0-255. */ }; + uint32_t value; /*!< Combined RGB value of the LED color. */ + }; } led_indicator_color_rgb_t; class BuiltInLED { private: - uint8_t pin_number; - bool state; - led_indicator_color_hsv_t hsv_color; + uint8_t pin_number; + bool state; + led_indicator_color_hsv_t hsv_color; public: - BuiltInLED(); - ~BuiltInLED(); + BuiltInLED(); + ~BuiltInLED(); - static led_indicator_color_hsv_t rgb2hsv(led_indicator_color_rgb_t rgb_value); - static led_indicator_color_rgb_t hsv2rgb(led_indicator_color_hsv_t hsv); + static led_indicator_color_hsv_t rgb2hsv(led_indicator_color_rgb_t rgb_value); + static led_indicator_color_rgb_t hsv2rgb(led_indicator_color_hsv_t hsv); - void begin(uint8_t pin); - void end(); + void begin(uint8_t pin); + void end(); - void on(); - void off(); - void toggle(); - bool getState(); + void on(); + void off(); + void toggle(); + bool getState(); - bool write(); + bool write(); - void setBrightness(uint8_t brightness); - uint8_t getBrightness(); - void setHSV(led_indicator_color_hsv_t hsv); - led_indicator_color_hsv_t getHSV(); - void setRGB(led_indicator_color_rgb_t color); - led_indicator_color_rgb_t getRGB(); - void setTemperature(uint32_t temperature); -}; \ No newline at end of file + void setBrightness(uint8_t brightness); + uint8_t getBrightness(); + void setHSV(led_indicator_color_hsv_t hsv); + led_indicator_color_hsv_t getHSV(); + void setRGB(led_indicator_color_rgb_t color); + led_indicator_color_rgb_t getRGB(); + void setTemperature(uint32_t temperature); +}; diff --git a/examples/espidf-arduino-matter-light/main/idf_component.yml b/examples/espidf-arduino-matter-light/main/idf_component.yml index 0caf8ffa0..a0c5e72e5 100644 --- a/examples/espidf-arduino-matter-light/main/idf_component.yml +++ b/examples/espidf-arduino-matter-light/main/idf_component.yml @@ -1,6 +1,6 @@ dependencies: espressif/esp_matter: - version: "^1.3.0" + version: ">=1.4.0" espressif/cmake_utilities: version: "0.*" rules: diff --git a/examples/espidf-arduino-matter-light/main/matter_accessory_driver.cpp b/examples/espidf-arduino-matter-light/main/matter_accessory_driver.cpp index 8e3cc7ec4..523c38e68 100644 --- a/examples/espidf-arduino-matter-light/main/matter_accessory_driver.cpp +++ b/examples/espidf-arduino-matter-light/main/matter_accessory_driver.cpp @@ -11,85 +11,79 @@ #include "matter_accessory_driver.h" /* Do any conversions/remapping for the actual value here */ -esp_err_t light_accessory_set_power(void *led, uint8_t val) -{ - BuiltInLED *builtinLED = (BuiltInLED *) led; - esp_err_t err = ESP_OK; - if (val) { - builtinLED->on(); - } else { - builtinLED->off(); - } - if (!builtinLED->write()) { - err = ESP_FAIL; - } - log_i("LED set power: %d", val); - return err; +esp_err_t light_accessory_set_power(void *led, uint8_t val) { + BuiltInLED *builtinLED = (BuiltInLED *)led; + esp_err_t err = ESP_OK; + if (val) { + builtinLED->on(); + } else { + builtinLED->off(); + } + if (!builtinLED->write()) { + err = ESP_FAIL; + } + log_i("LED set power: %d", val); + return err; } -esp_err_t light_accessory_set_brightness(void *led, uint8_t val) -{ - esp_err_t err = ESP_OK; - BuiltInLED *builtinLED = (BuiltInLED *) led; - int value = REMAP_TO_RANGE(val, MATTER_BRIGHTNESS, STANDARD_BRIGHTNESS); +esp_err_t light_accessory_set_brightness(void *led, uint8_t val) { + esp_err_t err = ESP_OK; + BuiltInLED *builtinLED = (BuiltInLED *)led; + int value = REMAP_TO_RANGE(val, MATTER_BRIGHTNESS, STANDARD_BRIGHTNESS); - builtinLED->setBrightness(value); - if (!builtinLED->write()) { - err = ESP_FAIL; - } - log_i("LED set brightness: %d", value); - return err; + builtinLED->setBrightness(value); + if (!builtinLED->write()) { + err = ESP_FAIL; + } + log_i("LED set brightness: %d", value); + return err; } -esp_err_t light_accessory_set_hue(void *led, uint8_t val) -{ - esp_err_t err = ESP_OK; - BuiltInLED *builtinLED = (BuiltInLED *) led; - int value = REMAP_TO_RANGE(val, MATTER_HUE, STANDARD_HUE); - led_indicator_color_hsv_t hsv = builtinLED->getHSV(); - hsv.h = value; - builtinLED->setHSV(hsv); - if (!builtinLED->write()) { - err = ESP_FAIL; - } - log_i("LED set hue: %d", value); - return err; +esp_err_t light_accessory_set_hue(void *led, uint8_t val) { + esp_err_t err = ESP_OK; + BuiltInLED *builtinLED = (BuiltInLED *)led; + int value = REMAP_TO_RANGE(val, MATTER_HUE, STANDARD_HUE); + led_indicator_color_hsv_t hsv = builtinLED->getHSV(); + hsv.h = value; + builtinLED->setHSV(hsv); + if (!builtinLED->write()) { + err = ESP_FAIL; + } + log_i("LED set hue: %d", value); + return err; } -esp_err_t light_accessory_set_saturation(void *led, uint8_t val) -{ - esp_err_t err = ESP_OK; - BuiltInLED *builtinLED = (BuiltInLED *) led; - int value = REMAP_TO_RANGE(val, MATTER_SATURATION, STANDARD_SATURATION); - led_indicator_color_hsv_t hsv = builtinLED->getHSV(); - hsv.s = value; - builtinLED->setHSV(hsv); - if (!builtinLED->write()) { - err = ESP_FAIL; - } - log_i("LED set saturation: %d", value); - return err; +esp_err_t light_accessory_set_saturation(void *led, uint8_t val) { + esp_err_t err = ESP_OK; + BuiltInLED *builtinLED = (BuiltInLED *)led; + int value = REMAP_TO_RANGE(val, MATTER_SATURATION, STANDARD_SATURATION); + led_indicator_color_hsv_t hsv = builtinLED->getHSV(); + hsv.s = value; + builtinLED->setHSV(hsv); + if (!builtinLED->write()) { + err = ESP_FAIL; + } + log_i("LED set saturation: %d", value); + return err; } -esp_err_t light_accessory_set_temperature(void *led, uint16_t val) -{ - esp_err_t err = ESP_OK; - BuiltInLED *builtinLED = (BuiltInLED *) led; - uint32_t value = REMAP_TO_RANGE_INVERSE(val, STANDARD_TEMPERATURE_FACTOR); - builtinLED->setTemperature(value); - if (!builtinLED->write()) { - err = ESP_FAIL; - } - log_i("LED set temperature: %ld", value); - return err; +esp_err_t light_accessory_set_temperature(void *led, uint16_t val) { + esp_err_t err = ESP_OK; + BuiltInLED *builtinLED = (BuiltInLED *)led; + uint32_t value = REMAP_TO_RANGE_INVERSE(val, STANDARD_TEMPERATURE_FACTOR); + builtinLED->setTemperature(value); + if (!builtinLED->write()) { + err = ESP_FAIL; + } + log_i("LED set temperature: %ld", value); + return err; } -app_driver_handle_t light_accessory_init() -{ - /* Initialize led */ - static BuiltInLED builtinLED; +app_driver_handle_t light_accessory_init() { + /* Initialize led */ + static BuiltInLED builtinLED; - const uint8_t pin = WS2812_PIN; // set your board WS2812b pin here - builtinLED.begin(pin); - return (app_driver_handle_t) &builtinLED; + const uint8_t pin = WS2812_PIN; // set your board WS2812b pin here + builtinLED.begin(pin); + return (app_driver_handle_t)&builtinLED; } diff --git a/examples/espidf-arduino-matter-light/main/matter_accessory_driver.h b/examples/espidf-arduino-matter-light/main/matter_accessory_driver.h index 8d816c799..3bf6655ab 100644 --- a/examples/espidf-arduino-matter-light/main/matter_accessory_driver.h +++ b/examples/espidf-arduino-matter-light/main/matter_accessory_driver.h @@ -3,9 +3,9 @@ // set your board WS2812b pin here (e.g. 48 is the default pin for the ESP32-S3 devkit) #ifndef CONFIG_WS2812_PIN -#define WS2812_PIN 48 // ESP32-S3 DevKitC built-in LED +#define WS2812_PIN 48 // ESP32-S3 DevKitC built-in LED #else -#define WS2812_PIN CONFIG_WS2812_PIN // From sdkconfig.defaults. +#define WS2812_PIN CONFIG_WS2812_PIN // From sdkconfig.defaults. #endif #ifndef RGB_BUILTIN @@ -14,34 +14,34 @@ // Set your board button pin here (e.g. 0 is the default pin for the ESP32-S3 devkit) #ifndef CONFIG_BUTTON_PIN -#define BUTTON_PIN 0 // ESP32-S3 DevKitC built-in button +#define BUTTON_PIN 0 // ESP32-S3 DevKitC built-in button #else -#define BUTTON_PIN CONFIG_BUTTON_PIN // From sdkconfig.defaults. +#define BUTTON_PIN CONFIG_BUTTON_PIN // From sdkconfig.defaults. #endif /** Standard max values (used for remapping attributes) */ -#define STANDARD_BRIGHTNESS 255 -#define STANDARD_HUE 360 -#define STANDARD_SATURATION 255 +#define STANDARD_BRIGHTNESS 255 +#define STANDARD_HUE 360 +#define STANDARD_SATURATION 255 #define STANDARD_TEMPERATURE_FACTOR 1000000 /** Matter max values (used for remapping attributes) */ -#define MATTER_BRIGHTNESS 254 -#define MATTER_HUE 254 -#define MATTER_SATURATION 254 +#define MATTER_BRIGHTNESS 254 +#define MATTER_HUE 254 +#define MATTER_SATURATION 254 #define MATTER_TEMPERATURE_FACTOR 1000000 /** Default attribute values used during initialization */ -#define DEFAULT_POWER true +#define DEFAULT_POWER true #define DEFAULT_BRIGHTNESS 64 -#define DEFAULT_HUE 128 +#define DEFAULT_HUE 128 #define DEFAULT_SATURATION 254 typedef void *app_driver_handle_t; -esp_err_t light_accessory_set_power(void *led, uint8_t val); +esp_err_t light_accessory_set_power(void *led, uint8_t val); esp_err_t light_accessory_set_brightness(void *led, uint8_t val); esp_err_t light_accessory_set_hue(void *led, uint8_t val); esp_err_t light_accessory_set_saturation(void *led, uint8_t val); esp_err_t light_accessory_set_temperature(void *led, uint16_t val); -app_driver_handle_t light_accessory_init(); \ No newline at end of file +app_driver_handle_t light_accessory_init(); diff --git a/examples/espidf-arduino-matter-light/main/matter_light.cpp b/examples/espidf-arduino-matter-light/main/matter_light.cpp index 5f3898e84..6079ce46a 100644 --- a/examples/espidf-arduino-matter-light/main/matter_light.cpp +++ b/examples/espidf-arduino-matter-light/main/matter_light.cpp @@ -20,24 +20,18 @@ #include #include "esp_openthread_types.h" -#define ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG() \ - { \ - .radio_mode = RADIO_MODE_NATIVE, \ - } +#define ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG() \ + { .radio_mode = RADIO_MODE_NATIVE, } -#define ESP_OPENTHREAD_DEFAULT_HOST_CONFIG() \ - { \ - .host_connection_mode = HOST_CONNECTION_MODE_NONE, \ - } +#define ESP_OPENTHREAD_DEFAULT_HOST_CONFIG() \ + { .host_connection_mode = HOST_CONNECTION_MODE_NONE, } -#define ESP_OPENTHREAD_DEFAULT_PORT_CONFIG() \ - { \ - .storage_partition_name = "nvs", .netif_queue_size = 10, .task_queue_size = 10, \ - } +#define ESP_OPENTHREAD_DEFAULT_PORT_CONFIG() \ + { .storage_partition_name = "nvs", .netif_queue_size = 10, .task_queue_size = 10, } #endif // set your board button pin here -const uint8_t button_gpio = BUTTON_PIN; // GPIO BOOT Button +const uint8_t button_gpio = BUTTON_PIN; // GPIO BOOT Button uint16_t light_endpoint_id = 0; @@ -54,290 +48,259 @@ extern const char decryption_key_end[] asm("_binary_esp_image_encryption_key_pem static const char *s_decryption_key = decryption_key_start; static const uint16_t s_decryption_key_len = decryption_key_end - decryption_key_start; -#endif // CONFIG_ENABLE_ENCRYPTED_OTA +#endif // CONFIG_ENABLE_ENCRYPTED_OTA bool isAccessoryCommissioned() { - return chip::Server::GetInstance().GetFabricTable().FabricCount() > 0; + return chip::Server::GetInstance().GetFabricTable().FabricCount() > 0; } #if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION bool isWifiConnected() { - return chip::DeviceLayer::ConnectivityMgr().IsWiFiStationConnected(); + return chip::DeviceLayer::ConnectivityMgr().IsWiFiStationConnected(); } #endif #if CHIP_DEVICE_CONFIG_ENABLE_THREAD bool isThreadConnected() { - return chip::DeviceLayer::ConnectivityMgr().IsThreadAttached(); + return chip::DeviceLayer::ConnectivityMgr().IsThreadAttached(); } #endif -static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg) -{ - switch (event->Type) { +static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg) { + switch (event->Type) { case chip::DeviceLayer::DeviceEventType::kInterfaceIpAddressChanged: - log_i("Interface %s Address changed", - event->InterfaceIpAddressChanged.Type == chip::DeviceLayer::InterfaceIpChangeType::kIpV4_Assigned ? - "IPv4" : "IPV6" ); - break; + log_i( + "Interface %s Address changed", event->InterfaceIpAddressChanged.Type == chip::DeviceLayer::InterfaceIpChangeType::kIpV4_Assigned ? "IPv4" : "IPV6" + ); + break; - case chip::DeviceLayer::DeviceEventType::kCommissioningComplete: - log_i("Commissioning complete"); - break; + case chip::DeviceLayer::DeviceEventType::kCommissioningComplete: log_i("Commissioning complete"); break; - case chip::DeviceLayer::DeviceEventType::kFailSafeTimerExpired: - log_i("Commissioning failed, fail safe timer expired"); - break; + case chip::DeviceLayer::DeviceEventType::kFailSafeTimerExpired: log_i("Commissioning failed, fail safe timer expired"); break; - case chip::DeviceLayer::DeviceEventType::kCommissioningSessionStarted: - log_i("Commissioning session started"); - break; + case chip::DeviceLayer::DeviceEventType::kCommissioningSessionStarted: log_i("Commissioning session started"); break; - case chip::DeviceLayer::DeviceEventType::kCommissioningSessionStopped: - log_i("Commissioning session stopped"); - break; + case chip::DeviceLayer::DeviceEventType::kCommissioningSessionStopped: log_i("Commissioning session stopped"); break; - case chip::DeviceLayer::DeviceEventType::kCommissioningWindowOpened: - log_i("Commissioning window opened"); - break; + case chip::DeviceLayer::DeviceEventType::kCommissioningWindowOpened: log_i("Commissioning window opened"); break; - case chip::DeviceLayer::DeviceEventType::kCommissioningWindowClosed: - log_i("Commissioning window closed"); - break; + case chip::DeviceLayer::DeviceEventType::kCommissioningWindowClosed: log_i("Commissioning window closed"); break; case chip::DeviceLayer::DeviceEventType::kFabricRemoved: - { - log_i("Fabric removed successfully"); - if (chip::Server::GetInstance().GetFabricTable().FabricCount() == 0) - { - chip::CommissioningWindowManager & commissionMgr = chip::Server::GetInstance().GetCommissioningWindowManager(); - constexpr auto kTimeoutSeconds = chip::System::Clock::Seconds16(k_timeout_seconds); - if (!commissionMgr.IsCommissioningWindowOpen()) - { - /* After removing last fabric, this example does not remove the Wi-Fi credentials + { + log_i("Fabric removed successfully"); + if (chip::Server::GetInstance().GetFabricTable().FabricCount() == 0) { + chip::CommissioningWindowManager &commissionMgr = chip::Server::GetInstance().GetCommissioningWindowManager(); + constexpr auto kTimeoutSeconds = chip::System::Clock::Seconds16(k_timeout_seconds); + if (!commissionMgr.IsCommissioningWindowOpen()) { + /* After removing last fabric, this example does not remove the Wi-Fi credentials * and still has IP connectivity so, only advertising on DNS-SD. */ - CHIP_ERROR err = commissionMgr.OpenBasicCommissioningWindow(kTimeoutSeconds, - chip::CommissioningWindowAdvertisement::kDnssdOnly); - if (err != CHIP_NO_ERROR) - { - log_e("Failed to open commissioning window, err:%" CHIP_ERROR_FORMAT, err.Format()); - } - } - } - break; + CHIP_ERROR err = commissionMgr.OpenBasicCommissioningWindow(kTimeoutSeconds, chip::CommissioningWindowAdvertisement::kDnssdOnly); + if (err != CHIP_NO_ERROR) { + log_e("Failed to open commissioning window, err:%" CHIP_ERROR_FORMAT, err.Format()); + } } + } + break; + } - case chip::DeviceLayer::DeviceEventType::kFabricWillBeRemoved: - log_i("Fabric will be removed"); - break; + case chip::DeviceLayer::DeviceEventType::kFabricWillBeRemoved: log_i("Fabric will be removed"); break; - case chip::DeviceLayer::DeviceEventType::kFabricUpdated: - log_i("Fabric is updated"); - break; + case chip::DeviceLayer::DeviceEventType::kFabricUpdated: log_i("Fabric is updated"); break; - case chip::DeviceLayer::DeviceEventType::kFabricCommitted: - log_i("Fabric is committed"); - break; + case chip::DeviceLayer::DeviceEventType::kFabricCommitted: log_i("Fabric is committed"); break; - case chip::DeviceLayer::DeviceEventType::kBLEDeinitialized: - log_i("BLE deinitialized and memory reclaimed"); - break; + case chip::DeviceLayer::DeviceEventType::kBLEDeinitialized: log_i("BLE deinitialized and memory reclaimed"); break; - default: - break; - } + default: break; + } } -esp_err_t matter_light_attribute_update(app_driver_handle_t driver_handle, uint16_t endpoint_id, uint32_t cluster_id, - uint32_t attribute_id, esp_matter_attr_val_t *val) -{ - esp_err_t err = ESP_OK; - if (endpoint_id == light_endpoint_id) { - void *led = (void *)driver_handle; - if (cluster_id == OnOff::Id) { - if (attribute_id == OnOff::Attributes::OnOff::Id) { - err = light_accessory_set_power(led, val->val.b); - } - } else if (cluster_id == LevelControl::Id) { - if (attribute_id == LevelControl::Attributes::CurrentLevel::Id) { - err = light_accessory_set_brightness(led, val->val.u8); - } - } else if (cluster_id == ColorControl::Id) { - if (attribute_id == ColorControl::Attributes::CurrentHue::Id) { - err = light_accessory_set_hue(led, val->val.u8); - } else if (attribute_id == ColorControl::Attributes::CurrentSaturation::Id) { - err = light_accessory_set_saturation(led, val->val.u8); - } else if (attribute_id == ColorControl::Attributes::ColorTemperatureMireds::Id) { - err = light_accessory_set_temperature(led, val->val.u16); - } - } +esp_err_t matter_light_attribute_update( + app_driver_handle_t driver_handle, uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val +) { + esp_err_t err = ESP_OK; + if (endpoint_id == light_endpoint_id) { + void *led = (void *)driver_handle; + if (cluster_id == OnOff::Id) { + if (attribute_id == OnOff::Attributes::OnOff::Id) { + err = light_accessory_set_power(led, val->val.b); + } + } else if (cluster_id == LevelControl::Id) { + if (attribute_id == LevelControl::Attributes::CurrentLevel::Id) { + err = light_accessory_set_brightness(led, val->val.u8); + } + } else if (cluster_id == ColorControl::Id) { + if (attribute_id == ColorControl::Attributes::CurrentHue::Id) { + err = light_accessory_set_hue(led, val->val.u8); + } else if (attribute_id == ColorControl::Attributes::CurrentSaturation::Id) { + err = light_accessory_set_saturation(led, val->val.u8); + } else if (attribute_id == ColorControl::Attributes::ColorTemperatureMireds::Id) { + err = light_accessory_set_temperature(led, val->val.u16); + } } - return err; + } + return err; } -esp_err_t matter_light_set_defaults(uint16_t endpoint_id) -{ - esp_err_t err = ESP_OK; - - void *led = endpoint::get_priv_data(endpoint_id); - node_t *node = node::get(); - endpoint_t *endpoint = endpoint::get(node, endpoint_id); - cluster_t *cluster = NULL; - attribute_t *attribute = NULL; - esp_matter_attr_val_t val = esp_matter_invalid(NULL); - - /* Setting brightness */ - cluster = cluster::get(endpoint, LevelControl::Id); - attribute = attribute::get(cluster, LevelControl::Attributes::CurrentLevel::Id); +esp_err_t matter_light_set_defaults(uint16_t endpoint_id) { + esp_err_t err = ESP_OK; + + void *led = endpoint::get_priv_data(endpoint_id); + node_t *node = node::get(); + endpoint_t *endpoint = endpoint::get(node, endpoint_id); + cluster_t *cluster = NULL; + attribute_t *attribute = NULL; + esp_matter_attr_val_t val = esp_matter_invalid(NULL); + + /* Setting brightness */ + cluster = cluster::get(endpoint, LevelControl::Id); + attribute = attribute::get(cluster, LevelControl::Attributes::CurrentLevel::Id); + attribute::get_val(attribute, &val); + err |= light_accessory_set_brightness(led, val.val.u8); + + /* Setting color */ + cluster = cluster::get(endpoint, ColorControl::Id); + attribute = attribute::get(cluster, ColorControl::Attributes::ColorMode::Id); + attribute::get_val(attribute, &val); + if (val.val.u8 == (uint8_t)ColorControl::ColorMode::kCurrentHueAndCurrentSaturation) { + /* Setting hue */ + attribute = attribute::get(cluster, ColorControl::Attributes::CurrentHue::Id); attribute::get_val(attribute, &val); - err |= light_accessory_set_brightness(led, val.val.u8); - - /* Setting color */ - cluster = cluster::get(endpoint, ColorControl::Id); - attribute = attribute::get(cluster, ColorControl::Attributes::ColorMode::Id); + err |= light_accessory_set_hue(led, val.val.u8); + /* Setting saturation */ + attribute = attribute::get(cluster, ColorControl::Attributes::CurrentSaturation::Id); attribute::get_val(attribute, &val); - if (val.val.u8 == (uint8_t)ColorControl::ColorMode::kCurrentHueAndCurrentSaturation) { - /* Setting hue */ - attribute = attribute::get(cluster, ColorControl::Attributes::CurrentHue::Id); - attribute::get_val(attribute, &val); - err |= light_accessory_set_hue(led, val.val.u8); - /* Setting saturation */ - attribute = attribute::get(cluster, ColorControl::Attributes::CurrentSaturation::Id); - attribute::get_val(attribute, &val); - err |= light_accessory_set_saturation(led, val.val.u8); - } else if (val.val.u8 == (uint8_t)ColorControl::ColorMode::kColorTemperature) { - /* Setting temperature */ - attribute = attribute::get(cluster, ColorControl::Attributes::ColorTemperatureMireds::Id); - attribute::get_val(attribute, &val); - err |= light_accessory_set_temperature(led, val.val.u16); - } else { - log_e("Color mode not supported"); - } - - /* Setting power */ - cluster = cluster::get(endpoint, OnOff::Id); - attribute = attribute::get(cluster, OnOff::Attributes::OnOff::Id); + err |= light_accessory_set_saturation(led, val.val.u8); + } else if (val.val.u8 == (uint8_t)ColorControl::ColorMode::kColorTemperature) { + /* Setting temperature */ + attribute = attribute::get(cluster, ColorControl::Attributes::ColorTemperatureMireds::Id); attribute::get_val(attribute, &val); - err |= light_accessory_set_power(led, val.val.b); + err |= light_accessory_set_temperature(led, val.val.u16); + } else { + log_e("Color mode not supported"); + } - return err; + /* Setting power */ + cluster = cluster::get(endpoint, OnOff::Id); + attribute = attribute::get(cluster, OnOff::Attributes::OnOff::Id); + attribute::get_val(attribute, &val); + err |= light_accessory_set_power(led, val.val.b); + + return err; } -void button_driver_init() -{ - /* Initialize button */ - pinMode(button_gpio, INPUT_PULLUP); +void button_driver_init() { + /* Initialize button */ + pinMode(button_gpio, INPUT_PULLUP); } // This callback is called for every attribute update. The callback implementation shall // handle the desired attributes and return an appropriate error code. If the attribute // is not of your interest, please do not return an error code and strictly return ESP_OK. -static esp_err_t app_attribute_update_cb(attribute::callback_type_t type, uint16_t endpoint_id, uint32_t cluster_id, - uint32_t attribute_id, esp_matter_attr_val_t *val, void *priv_data) -{ - esp_err_t err = ESP_OK; - - if (type == PRE_UPDATE) { - /* Driver update */ - app_driver_handle_t driver_handle = (app_driver_handle_t)priv_data; - err = matter_light_attribute_update(driver_handle, endpoint_id, cluster_id, attribute_id, val); - } +static esp_err_t app_attribute_update_cb( + attribute::callback_type_t type, uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val, void *priv_data +) { + esp_err_t err = ESP_OK; + + if (type == PRE_UPDATE) { + /* Driver update */ + app_driver_handle_t driver_handle = (app_driver_handle_t)priv_data; + err = matter_light_attribute_update(driver_handle, endpoint_id, cluster_id, attribute_id, val); + } - return err; + return err; } // This callback is invoked when clients interact with the Identify Cluster. // In the callback implementation, an endpoint can identify itself. (e.g., by flashing an LED or light). -static esp_err_t app_identification_cb(identification::callback_type_t type, uint16_t endpoint_id, uint8_t effect_id, - uint8_t effect_variant, void *priv_data) -{ - log_i("Identification callback: type: %u, effect: %u, variant: %u", type, effect_id, effect_variant); - return ESP_OK; +static esp_err_t app_identification_cb(identification::callback_type_t type, uint16_t endpoint_id, uint8_t effect_id, uint8_t effect_variant, void *priv_data) { + log_i("Identification callback: type: %u, effect: %u, variant: %u", type, effect_id, effect_variant); + return ESP_OK; } -void setup() -{ - esp_err_t err = ESP_OK; +void setup() { + esp_err_t err = ESP_OK; - /* Initialize driver */ - app_driver_handle_t light_handle = light_accessory_init(); - button_driver_init(); + /* Initialize driver */ + app_driver_handle_t light_handle = light_accessory_init(); + button_driver_init(); - /* Create a Matter node and add the mandatory Root Node device type on endpoint 0 */ - node::config_t node_config; + /* Create a Matter node and add the mandatory Root Node device type on endpoint 0 */ + node::config_t node_config; - // node handle can be used to add/modify other endpoints. - node_t *node = node::create(&node_config, app_attribute_update_cb, app_identification_cb); - if (node == nullptr) { - log_e("Failed to create Matter node"); - abort(); - } + // node handle can be used to add/modify other endpoints. + node_t *node = node::create(&node_config, app_attribute_update_cb, app_identification_cb); + if (node == nullptr) { + log_e("Failed to create Matter node"); + abort(); + } - extended_color_light::config_t light_config; - light_config.on_off.on_off = DEFAULT_POWER; - light_config.on_off.lighting.start_up_on_off = nullptr; - light_config.level_control.current_level = DEFAULT_BRIGHTNESS; - light_config.level_control.lighting.start_up_current_level = DEFAULT_BRIGHTNESS; - light_config.color_control.color_mode = (uint8_t)ColorControl::ColorMode::kColorTemperature; - light_config.color_control.enhanced_color_mode = (uint8_t)ColorControl::ColorMode::kColorTemperature; - light_config.color_control.color_temperature.startup_color_temperature_mireds = nullptr; - - // endpoint handles can be used to add/modify clusters. - endpoint_t *endpoint = extended_color_light::create(node, &light_config, ENDPOINT_FLAG_NONE, light_handle); - if (endpoint == nullptr) { - log_e("Failed to create extended color light endpoint"); - abort(); - } + extended_color_light::config_t light_config; + light_config.on_off.on_off = DEFAULT_POWER; + light_config.on_off.lighting.start_up_on_off = nullptr; + light_config.level_control.current_level = DEFAULT_BRIGHTNESS; + light_config.level_control.lighting.start_up_current_level = DEFAULT_BRIGHTNESS; + light_config.color_control.color_mode = (uint8_t)ColorControl::ColorMode::kColorTemperature; + light_config.color_control.enhanced_color_mode = (uint8_t)ColorControl::ColorMode::kColorTemperature; + light_config.color_control.color_temperature.startup_color_temperature_mireds = nullptr; + + // endpoint handles can be used to add/modify clusters. + endpoint_t *endpoint = extended_color_light::create(node, &light_config, ENDPOINT_FLAG_NONE, light_handle); + if (endpoint == nullptr) { + log_e("Failed to create extended color light endpoint"); + abort(); + } - light_endpoint_id = endpoint::get_id(endpoint); - log_i("Light created with endpoint_id %d", light_endpoint_id); + light_endpoint_id = endpoint::get_id(endpoint); + log_i("Light created with endpoint_id %d", light_endpoint_id); - /* Mark deferred persistence for some attributes that might be changed rapidly */ - cluster_t *level_control_cluster = cluster::get(endpoint, LevelControl::Id); - attribute_t *current_level_attribute = attribute::get(level_control_cluster, LevelControl::Attributes::CurrentLevel::Id); - attribute::set_deferred_persistence(current_level_attribute); + /* Mark deferred persistence for some attributes that might be changed rapidly */ + cluster_t *level_control_cluster = cluster::get(endpoint, LevelControl::Id); + attribute_t *current_level_attribute = attribute::get(level_control_cluster, LevelControl::Attributes::CurrentLevel::Id); + attribute::set_deferred_persistence(current_level_attribute); - cluster_t *color_control_cluster = cluster::get(endpoint, ColorControl::Id); - attribute_t *current_x_attribute = attribute::get(color_control_cluster, ColorControl::Attributes::CurrentX::Id); - attribute::set_deferred_persistence(current_x_attribute); - attribute_t *current_y_attribute = attribute::get(color_control_cluster, ColorControl::Attributes::CurrentY::Id); - attribute::set_deferred_persistence(current_y_attribute); - attribute_t *color_temp_attribute = attribute::get(color_control_cluster, ColorControl::Attributes::ColorTemperatureMireds::Id); - attribute::set_deferred_persistence(color_temp_attribute); + cluster_t *color_control_cluster = cluster::get(endpoint, ColorControl::Id); + attribute_t *current_x_attribute = attribute::get(color_control_cluster, ColorControl::Attributes::CurrentX::Id); + attribute::set_deferred_persistence(current_x_attribute); + attribute_t *current_y_attribute = attribute::get(color_control_cluster, ColorControl::Attributes::CurrentY::Id); // codespell:ignore + attribute::set_deferred_persistence(current_y_attribute); + attribute_t *color_temp_attribute = attribute::get(color_control_cluster, ColorControl::Attributes::ColorTemperatureMireds::Id); + attribute::set_deferred_persistence(color_temp_attribute); #if CHIP_DEVICE_CONFIG_ENABLE_THREAD - /* Set OpenThread platform config */ - esp_openthread_platform_config_t config = { - .radio_config = ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG(), - .host_config = ESP_OPENTHREAD_DEFAULT_HOST_CONFIG(), - .port_config = ESP_OPENTHREAD_DEFAULT_PORT_CONFIG(), - }; - set_openthread_platform_config(&config); + /* Set OpenThread platform config */ + esp_openthread_platform_config_t config = { + .radio_config = ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG(), + .host_config = ESP_OPENTHREAD_DEFAULT_HOST_CONFIG(), + .port_config = ESP_OPENTHREAD_DEFAULT_PORT_CONFIG(), + }; + set_openthread_platform_config(&config); #endif - /* Matter start */ - err = esp_matter::start(app_event_cb); - if (err != ESP_OK) { - log_e("Failed to start Matter, err:%d", err); - abort(); - } + /* Matter start */ + err = esp_matter::start(app_event_cb); + if (err != ESP_OK) { + log_e("Failed to start Matter, err:%d", err); + abort(); + } #if CONFIG_ENABLE_ENCRYPTED_OTA - err = esp_matter_ota_requestor_encrypted_init(s_decryption_key, s_decryption_key_len); - if (err != ESP_OK) { - log_e("Failed to initialized the encrypted OTA, err: %d", err); - abort(); - } -#endif // CONFIG_ENABLE_ENCRYPTED_OTA + err = esp_matter_ota_requestor_encrypted_init(s_decryption_key, s_decryption_key_len); + if (err != ESP_OK) { + log_e("Failed to initialized the encrypted OTA, err: %d", err); + abort(); + } +#endif // CONFIG_ENABLE_ENCRYPTED_OTA #if CONFIG_ENABLE_CHIP_SHELL - esp_matter::console::diagnostics_register_commands(); - esp_matter::console::wifi_register_commands(); + esp_matter::console::diagnostics_register_commands(); + esp_matter::console::wifi_register_commands(); #if CONFIG_OPENTHREAD_CLI - esp_matter::console::otcli_register_commands(); + esp_matter::console::otcli_register_commands(); #endif - esp_matter::console::init(); + esp_matter::console::init(); #endif } @@ -346,10 +309,10 @@ void loop() { static bool button_state = false; static bool started = false; - if(!isAccessoryCommissioned()) { + if (!isAccessoryCommissioned()) { log_w("Accessory not commissioned yet. Waiting for commissioning."); #ifdef RGB_BUILTIN - rgbLedWrite(RGB_BUILTIN, 48, 0, 20); // Purple indicates accessory not commissioned + rgbLedWrite(RGB_BUILTIN, 48, 0, 20); // Purple indicates accessory not commissioned #endif delay(5000); return; @@ -359,7 +322,7 @@ void loop() { if (!isWifiConnected()) { log_w("Wi-Fi not connected yet. Waiting for connection."); #ifdef RGB_BUILTIN - rgbLedWrite(RGB_BUILTIN, 48, 20, 0); // Orange indicates accessory not connected to Wi-Fi + rgbLedWrite(RGB_BUILTIN, 48, 20, 0); // Orange indicates accessory not connected to Wi-Fi #endif delay(5000); return; @@ -370,7 +333,7 @@ void loop() { if (!isThreadConnected()) { log_w("Thread not connected yet. Waiting for connection."); #ifdef RGB_BUILTIN - rgbLedWrite(RGB_BUILTIN, 0, 20, 48); // Blue indicates accessory not connected to Trhead + rgbLedWrite(RGB_BUILTIN, 0, 20, 48); // Blue indicates accessory not connected to Trhead #endif delay(5000); return; @@ -389,10 +352,10 @@ void loop() { // Check if the button is pressed and toggle the light right away if (digitalRead(button_gpio) == LOW && !button_state) { // deals with button debounce - button_time_stamp = millis(); // record the time while the button is pressed. - button_state = true; // pressed. + button_time_stamp = millis(); // record the time while the button is pressed. + button_state = true; // pressed. - // Toggle button is pressed - toggle the light + // Toggle button is pressed - toggle the light log_i("Toggle button pressed"); endpoint_t *endpoint = endpoint::get(node::get(), light_endpoint_id); @@ -408,14 +371,14 @@ void loop() { // Check if the button is released and handle the factory reset uint32_t time_diff = millis() - button_time_stamp; if (button_state && time_diff > 100 && digitalRead(button_gpio) == HIGH) { - button_state = false; // released. It can be pressed again after 100ms debounce. + button_state = false; // released. It can be pressed again after 100ms debounce. // Factory reset is triggered if the button is pressed for more than 10 seconds if (time_diff > 10000) { - log_i("Factory reset triggered. Light will retored to factory settings."); - esp_matter::factory_reset(); + log_i("Factory reset triggered. Light will restored to factory settings."); + esp_matter::factory_reset(); } } - delay(50); // WDT is happier with a delay + delay(50); // WDT is happier with a delay } diff --git a/examples/espidf-arduino-matter-light/platformio.ini b/examples/espidf-arduino-matter-light/platformio.ini index 2434a84f1..1a470a54c 100644 --- a/examples/espidf-arduino-matter-light/platformio.ini +++ b/examples/espidf-arduino-matter-light/platformio.ini @@ -17,10 +17,14 @@ platform = espressif32 framework = arduino, espidf board_build.partitions = partitions.csv monitor_speed = 115200 +build_unflags = + -std=c++17 + -std=gnu++2b +build_flags = + -std=gnu++2a - -[env:esp32s3] -board = esp32-s3-devkitc-1 +[env:esp32c6] +board = esp32-c6-devkitc-1 board_build.embed_txtfiles = managed_components/espressif__esp_insights/server_certs/https_server.crt managed_components/espressif__esp_rainmaker/server_certs/rmaker_mqtt_server.crt diff --git a/examples/espidf-arduino-matter-light/sdkconfig.defaults b/examples/espidf-arduino-matter-light/sdkconfig.defaults index 517a05a2e..7982e4178 100644 --- a/examples/espidf-arduino-matter-light/sdkconfig.defaults +++ b/examples/espidf-arduino-matter-light/sdkconfig.defaults @@ -1,3 +1,5 @@ +CONFIG_IDF_TARGET="esp32c6" + # Arduino Settings CONFIG_FREERTOS_HZ=1000 CONFIG_AUTOSTART_ARDUINO=y @@ -6,9 +8,17 @@ CONFIG_AUTOSTART_ARDUINO=y # Boot Messages - Log level CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y # Arduino Log Level -CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_VERBOSE=y +CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_INFO=y # IDF Log Level -CONFIG_LOG_DEFAULT_LEVEL_WARN=y +CONFIG_LOG_DEFAULT_LEVEL_ERROR=y + +# Default to 921600 baud when flashing and monitoring device +CONFIG_ESPTOOLPY_BAUD_921600B=y +CONFIG_ESPTOOLPY_BAUD=921600 +CONFIG_ESPTOOLPY_COMPRESSED=y +CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y +CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 +CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y #enable BT CONFIG_BT_ENABLED=y @@ -17,6 +27,11 @@ CONFIG_BT_NIMBLE_ENABLED=y #disable BT connection reattempt CONFIG_BT_NIMBLE_ENABLE_CONN_REATTEMPT=n +# NIMBLE +CONFIG_BT_NIMBLE_EXT_ADV=n +CONFIG_BT_NIMBLE_HCI_EVT_BUF_SIZE=70 +CONFIG_USE_BLE_ONLY_FOR_COMMISSIONING=y + #enable lwip ipv6 autoconfig CONFIG_LWIP_IPV6_AUTOCONFIG=y @@ -28,16 +43,17 @@ CONFIG_PARTITION_TABLE_OFFSET=0xC000 # Disable chip shell CONFIG_ENABLE_CHIP_SHELL=n +# Enable OTA Requester +CONFIG_ENABLE_OTA_REQUESTOR=n + #enable lwIP route hooks CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT=y CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y -# Button -CONFIG_BUTTON_PERIOD_TIME_MS=20 -CONFIG_BUTTON_LONG_PRESS_TIME_MS=5000 - # disable softap by default CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n +CONFIG_ENABLE_WIFI_STATION=y +CONFIG_ENABLE_WIFI_AP=n # Disable DS Peripheral CONFIG_ESP_SECURE_CERT_DS_PERIPHERAL=n @@ -52,15 +68,23 @@ CONFIG_MBEDTLS_HKDF_C=y # unique local addresses for fabrics(MAX_FABRIC), a link local address(1) CONFIG_LWIP_IPV6_NUM_ADDRESSES=6 +# libsodium +CONFIG_LIBSODIUM_USE_MBEDTLS_SHA=y + +# FreeRTOS should use legacy API +CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY=y + +# Use minimal mDNS +CONFIG_USE_MINIMAL_MDNS=y +CONFIG_ENABLE_EXTENDED_DISCOVERY=y -# ESP32-S3-DevKitC-1 Settings +# ESP32-C6-DevKit Settings # Buttons -CONFIG_BSP_BUTTONS_NUM=1 -CONFIG_BSP_BUTTON_1_TYPE_GPIO=y -CONFIG_BSP_BUTTON_1_GPIO=0 -CONFIG_BSP_BUTTON_1_LEVEL=0 +CONFIG_BUTTON_PIN=9 # LEDs -CONFIG_BSP_LEDS_NUM=1 -CONFIG_BSP_LED_TYPE_RGB=y -CONFIG_BSP_LED_RGB_GPIO=48 -CONFIG_BSP_LED_RGB_BACKEND_RMT=y \ No newline at end of file +CONFIG_WS2812_PIN=8 +# max GPIO +CONFIG_ENV_GPIO_RANGE_MIN=0 +CONFIG_ENV_GPIO_RANGE_MAX=30 +CONFIG_ENV_GPIO_IN_RANGE_MAX=30 +CONFIG_ENV_GPIO_OUT_RANGE_MAX=30 diff --git a/examples/espidf-arduino-matter-light/sdkconfig.defaults.c6_thread b/examples/espidf-arduino-matter-light/sdkconfig.defaults.c6_thread index 389c72c4b..502480f94 100644 --- a/examples/espidf-arduino-matter-light/sdkconfig.defaults.c6_thread +++ b/examples/espidf-arduino-matter-light/sdkconfig.defaults.c6_thread @@ -5,7 +5,7 @@ CONFIG_FREERTOS_HZ=1000 CONFIG_AUTOSTART_ARDUINO=y # Log Levels -# Boot Messages - Log level +# Boot Messages - Log level CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y # Arduino Log Level CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_INFO=y @@ -56,7 +56,7 @@ CONFIG_LWIP_MULTICAST_PING=y CONFIG_USE_MINIMAL_MDNS=n CONFIG_ENABLE_EXTENDED_DISCOVERY=y -# Enable OTA Requestor +# Enable OTA Requester CONFIG_ENABLE_OTA_REQUESTOR=n # Disable STA and AP for ESP32C6 @@ -77,4 +77,3 @@ CONFIG_MRP_MAX_RETRANS=3 # Enable HKDF in mbedtls CONFIG_MBEDTLS_HKDF_C=y - diff --git a/examples/espidf-arduino-matter-light/sdkconfig.defaults.esp32c3 b/examples/espidf-arduino-matter-light/sdkconfig.defaults.esp32c3 deleted file mode 100644 index f534f3b7d..000000000 --- a/examples/espidf-arduino-matter-light/sdkconfig.defaults.esp32c3 +++ /dev/null @@ -1,64 +0,0 @@ -CONFIG_IDF_TARGET="esp32c3" - -# Arduino Settings -CONFIG_FREERTOS_HZ=1000 -CONFIG_AUTOSTART_ARDUINO=y - -# Log Levels -# Boot Messages - Log level -CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y -# Arduino Log Level -CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_INFO=y -# IDF Log Level -CONFIG_LOG_DEFAULT_LEVEL_ERROR=y - -# Default to 921600 baud when flashing and monitoring device -CONFIG_ESPTOOLPY_BAUD_921600B=y -CONFIG_ESPTOOLPY_BAUD=921600 -CONFIG_ESPTOOLPY_COMPRESSED=y -CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y -CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 -CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y - -#enable BT -CONFIG_BT_ENABLED=y -CONFIG_BT_NIMBLE_ENABLED=y - -#disable BT connection reattempt -CONFIG_BT_NIMBLE_ENABLE_CONN_REATTEMPT=n - -#enable lwip ipv6 autoconfig -CONFIG_LWIP_IPV6_AUTOCONFIG=y - -# Use a custom partition table -CONFIG_PARTITION_TABLE_CUSTOM=y -CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" -CONFIG_PARTITION_TABLE_OFFSET=0xC000 - -# Disable chip shell -CONFIG_ENABLE_CHIP_SHELL=n - -# Enable OTA Requestor -CONFIG_ENABLE_OTA_REQUESTOR=n - -#enable lwIP route hooks -CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT=y -CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y - -# disable softap by default -CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n -CONFIG_ENABLE_WIFI_STATION=y -CONFIG_ENABLE_WIFI_AP=n - -# Disable DS Peripheral -CONFIG_ESP_SECURE_CERT_DS_PERIPHERAL=n - -# Use compact attribute storage mode -CONFIG_ESP_MATTER_NVS_USE_COMPACT_ATTR_STORAGE=y - -# Enable HKDF in mbedtls -CONFIG_MBEDTLS_HKDF_C=y - -# Increase LwIP IPv6 address number to 6 (MAX_FABRIC + 1) -# unique local addresses for fabrics(MAX_FABRIC), a link local address(1) -CONFIG_LWIP_IPV6_NUM_ADDRESSES=6 diff --git a/examples/espidf-arduino-matter-light/sdkconfig.defaults.esp32c6 b/examples/espidf-arduino-matter-light/sdkconfig.defaults.esp32c6 index 301ee1a4e..9fe589613 100644 --- a/examples/espidf-arduino-matter-light/sdkconfig.defaults.esp32c6 +++ b/examples/espidf-arduino-matter-light/sdkconfig.defaults.esp32c6 @@ -1,68 +1,5 @@ CONFIG_IDF_TARGET="esp32c6" -# Arduino Settings -CONFIG_FREERTOS_HZ=1000 -CONFIG_AUTOSTART_ARDUINO=y - -# Log Levels -# Boot Messages - Log level -CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y -# Arduino Log Level -CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_INFO=y -# IDF Log Level -CONFIG_LOG_DEFAULT_LEVEL_ERROR=y - -# Default to 921600 baud when flashing and monitoring device -CONFIG_ESPTOOLPY_BAUD_921600B=y -CONFIG_ESPTOOLPY_BAUD=921600 -CONFIG_ESPTOOLPY_COMPRESSED=y -CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y -CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 -CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y - -#enable BT -CONFIG_BT_ENABLED=y -CONFIG_BT_NIMBLE_ENABLED=y - -#disable BT connection reattempt -CONFIG_BT_NIMBLE_ENABLE_CONN_REATTEMPT=n - -#enable lwip ipv6 autoconfig -CONFIG_LWIP_IPV6_AUTOCONFIG=y - -# Use a custom partition table -CONFIG_PARTITION_TABLE_CUSTOM=y -CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" -CONFIG_PARTITION_TABLE_OFFSET=0xC000 - -# Disable chip shell -CONFIG_ENABLE_CHIP_SHELL=n - -# Enable OTA Requestor -CONFIG_ENABLE_OTA_REQUESTOR=n - -#enable lwIP route hooks -CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT=y -CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y - -# disable softap by default -CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n -CONFIG_ENABLE_WIFI_STATION=y -CONFIG_ENABLE_WIFI_AP=n - -# Disable DS Peripheral -CONFIG_ESP_SECURE_CERT_DS_PERIPHERAL=n - -# Use compact attribute storage mode -CONFIG_ESP_MATTER_NVS_USE_COMPACT_ATTR_STORAGE=y - -# Enable HKDF in mbedtls -CONFIG_MBEDTLS_HKDF_C=y - -# Increase LwIP IPv6 address number to 6 (MAX_FABRIC + 1) -# unique local addresses for fabrics(MAX_FABRIC), a link local address(1) -CONFIG_LWIP_IPV6_NUM_ADDRESSES=6 - # libsodium CONFIG_LIBSODIUM_USE_MBEDTLS_SHA=y diff --git a/examples/espidf-arduino-matter-light/sdkconfig.defaults.esp32s3 b/examples/espidf-arduino-matter-light/sdkconfig.defaults.esp32s3 deleted file mode 100644 index c7ecfa771..000000000 --- a/examples/espidf-arduino-matter-light/sdkconfig.defaults.esp32s3 +++ /dev/null @@ -1,64 +0,0 @@ -CONFIG_IDF_TARGET="esp32s3" - -# Arduino Settings -CONFIG_FREERTOS_HZ=1000 -CONFIG_AUTOSTART_ARDUINO=y - -# Log Levels -# Boot Messages - Log level -CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y -# Arduino Log Level -CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_INFO=y -# IDF Log Level -CONFIG_LOG_DEFAULT_LEVEL_ERROR=y - -# Default to 921600 baud when flashing and monitoring device -CONFIG_ESPTOOLPY_BAUD_921600B=y -CONFIG_ESPTOOLPY_BAUD=921600 -CONFIG_ESPTOOLPY_COMPRESSED=y -CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y -CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 -CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y - -#enable BT -CONFIG_BT_ENABLED=y -CONFIG_BT_NIMBLE_ENABLED=y - -#disable BT connection reattempt -CONFIG_BT_NIMBLE_ENABLE_CONN_REATTEMPT=n - -#enable lwip ipv6 autoconfig -CONFIG_LWIP_IPV6_AUTOCONFIG=y - -# Use a custom partition table -CONFIG_PARTITION_TABLE_CUSTOM=y -CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" -CONFIG_PARTITION_TABLE_OFFSET=0xC000 - -# Disable chip shell -CONFIG_ENABLE_CHIP_SHELL=n - -# Enable OTA Requestor -CONFIG_ENABLE_OTA_REQUESTOR=n - -#enable lwIP route hooks -CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT=y -CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y - -# disable softap by default -CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n -CONFIG_ENABLE_WIFI_STATION=y -CONFIG_ENABLE_WIFI_AP=n - -# Disable DS Peripheral -CONFIG_ESP_SECURE_CERT_DS_PERIPHERAL=n - -# Use compact attribute storage mode -CONFIG_ESP_MATTER_NVS_USE_COMPACT_ATTR_STORAGE=y - -# Enable HKDF in mbedtls -CONFIG_MBEDTLS_HKDF_C=y - -# Increase LwIP IPv6 address number to 6 (MAX_FABRIC + 1) -# unique local addresses for fabrics(MAX_FABRIC), a link local address(1) -CONFIG_LWIP_IPV6_NUM_ADDRESSES=6 From 2bdbd35be8ef2454770960d7728141e40bbbbdf5 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sat, 26 Apr 2025 13:32:44 +0200 Subject: [PATCH 41/60] Update README.md --- examples/espidf-arduino-matter-light/README.md | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/examples/espidf-arduino-matter-light/README.md b/examples/espidf-arduino-matter-light/README.md index 215d7a9a9..1bb4614c5 100644 --- a/examples/espidf-arduino-matter-light/README.md +++ b/examples/espidf-arduino-matter-light/README.md @@ -1,14 +1,12 @@ -| Supported Targets | ESP32-S3 | ESP32-C3 | ESP32-C6 | -| ----------------- | -------- | -------- | -------- | +| Supported Targets | ESP32-C3 | ESP32-C6 | +| ----------------- | -------- | -------- | # Managed Component Light -This example is configured by default to work with the ESP32-S3, which has the RGB LED GPIO set as pin 48 and the BOOT button on GPIO 0. +This example is configured by default to work with the ESP32-C6, which has the RGB LED GPIO set as pin 8 and the BOOT button on GPIO 9. -This example creates a Color Temperature Light device using the esp_matter component downloaded from the [Espressif Component Registry](https://components.espressif.com/) instead of an extra component locally, so the example can work without setting up the esp-matter environment. - -See the [docs](https://docs.espressif.com/projects/esp-matter/en/latest/esp32/developing.html) for more information about building and flashing the firmware. +This example creates a Color Temperature Light device using the esp_matter component automatically downloaded from the [Espressif Component Registry](https://components.espressif.com/). See the [docs](https://docs.espressif.com/projects/esp-matter/en/latest/esp32/developing.html) for more information about matter. The code is based on the Arduino API and uses Arduino as an IDF Component. @@ -27,8 +25,8 @@ There is no QR Code to be used when the Smartphone APP wants to add the Matter D Please enter the code manually: `34970112332` The devboard has a built-in LED that will be used as the Matter Light. -The default setting of the code uses pin 48 for the ESP32-S3. -Please change it in `main/matter_accessory_driver.h` or in the `sdkconfig.defaults.` file. +The default setting of the code uses pin 8 for the ESP32-C6 +Please change it in `main/matter_accessory_driver.h` or in the `sdkconfig.defaults` file. ## LED Status and Factory Mode @@ -53,9 +51,9 @@ Holding the BOOT button pressed for more than 10 seconds and then releasing it w ## Building the Application using WiFi and Matter -This example has been tested with Arduino Core 3.0.4. It should work with newer versions too. +This example has been tested with Arduino Core 3.2.0. It should work with newer versions too. -There is a configuration file for these SoC: esp32s3, esp32c3, esp32c6. +There is a configuration file for these SoC: esp32c3, esp32c6. Those are the tested devices that have a WS2812 RGB LED and can run BLE, WiFi and Matter. In case it is necessary to change the Button Pin or the REG LED Pin, please use the `menuconfig` and change the Menu Option `Light Matter Accessory` From f8ec6d4a160f05b85a525968aa5f10efe80445a8 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 28 Apr 2025 20:09:44 +0200 Subject: [PATCH 42/60] Add tl-install to install tools not in pio registry. Using for install of newer OpenOCD (#148) --- examples/arduino-blink/platformio.ini | 1 + platform.json | 36 ++++++++--- platform.py | 89 +++++++++++++++++++-------- 3 files changed, 94 insertions(+), 32 deletions(-) diff --git a/examples/arduino-blink/platformio.ini b/examples/arduino-blink/platformio.ini index e6c37cb53..ddec96cec 100644 --- a/examples/arduino-blink/platformio.ini +++ b/examples/arduino-blink/platformio.ini @@ -93,6 +93,7 @@ custom_component_remove = espressif/esp_hosted [env:esp32-c6-devkitc-1] platform = espressif32 framework = arduino +build_type = debug board = esp32-c6-devkitc-1 monitor_speed = 115200 custom_component_remove = espressif/esp_hosted diff --git a/platform.json b/platform.json index 89a2d2f93..0cb088fe0 100644 --- a/platform.json +++ b/platform.json @@ -6,13 +6,13 @@ "license": "Apache-2.0", "keywords": [ "dev-platform", - "Wi-Fi", + "WiFi", "Bluetooth", "Xtensa", "RISC-V" ], "engines": { - "platformio": ">=6.1.16" + "platformio": ">=6.1.18" }, "repository": { "type": "git", @@ -85,9 +85,16 @@ }, "tool-esptoolpy": { "type": "uploader", + "optional": false, "owner": "pioarduino", "version": "https://github.com/pioarduino/esptool/releases/download/v4.8.9/esptool.zip" }, + "tl-install": { + "type": "tool", + "optional": false, + "owner": "pioarduino", + "version": "https://github.com/pioarduino/esp_install/releases/download/v5.0.0/esp_install-v5.0.0.zip" + }, "tool-dfuutil-arduino": { "type": "uploader", "optional": true, @@ -97,11 +104,12 @@ "tool-openocd-esp32": { "type": "debugger", "optional": true, - "owner": "platformio", - "version": "~2.1100.0" + "owner": "pioarduino", + "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/openocd-v0.12.0-esp32-20250226.zip" }, "tool-mklittlefs": { "type": "uploader", + "optional": true, "owner": "tasmota", "version": "^3.2.0" }, @@ -118,34 +126,46 @@ "version": "~2.230.0" }, "tool-cppcheck": { + "type": "tool", "optional": true, "owner": "platformio", "version": "~1.21100" }, "tool-clangtidy": { + "type": "tool", "optional": true, "owner": "platformio", "version": "^1.190100.0" }, "tool-pvs-studio": { + "type": "tool", "optional": true, "owner": "platformio", "version": "^7.18.59866" }, "tool-cmake": { + "type": "tool", "optional": true, "owner": "platformio", "version": "~3.30.2" }, - "tool-esp-rom-elfs": { - "optional": true, - "owner": "platformio", - "version": "0.0.1+20241011" + "tool-esp-rom-elfs": { + "type": "tool", + "optional": true, + "owner": "platformio", + "version": "0.0.1+20241011" }, "tool-ninja": { + "type": "tool", "optional": true, "owner": "platformio", "version": "^1.7.0" + }, + "tool-scons": { + "type": "tool", + "optional": true, + "owner": "platformio", + "version": "~4.40801.0" } } } diff --git a/platform.py b/platform.py index d27a32b6e..8080001ac 100644 --- a/platform.py +++ b/platform.py @@ -13,22 +13,26 @@ # limitations under the License. import os -import urllib +import subprocess import sys -import json -import re -import requests +import shutil +from os.path import join from platformio.public import PlatformBase, to_unix_path +from platformio.proc import get_pythonexe_path +from platformio.project.config import ProjectConfig +from platformio.package.manager.tool import ToolPackageManager IS_WINDOWS = sys.platform.startswith("win") # Set Platformio env var to use windows_amd64 for all windows architectures # only windows_amd64 native espressif toolchains are available -# needs platformio core >= 6.1.16b2 or pioarduino core 6.1.16+test +# needs platformio/pioarduino core >= 6.1.17 if IS_WINDOWS: os.environ["PLATFORMIO_SYSTEM_TYPE"] = "windows_amd64" +python_exe = get_pythonexe_path() +pm = ToolPackageManager() class Espressif32Platform(PlatformBase): def configure_default_packages(self, variables, targets): @@ -38,11 +42,55 @@ def configure_default_packages(self, variables, targets): board_config = self.board_config(variables.get("board")) mcu = variables.get("board_build.mcu", board_config.get("build.mcu", "esp32")) board_sdkconfig = variables.get("board_espidf.custom_sdkconfig", board_config.get("espidf.custom_sdkconfig", "")) - core_variant_board = ''.join(variables.get("board_build.extra_flags", board_config.get("build.extra_flags", ""))) - core_variant_board = core_variant_board.replace("-D", " ") - core_variant_build = (''.join(variables.get("build_flags", []))).replace("-D", " ") frameworks = variables.get("pioframework", []) + def install_tool(TOOL): + self.packages[TOOL]["optional"] = False + TOOL_PATH = os.path.join(ProjectConfig.get_instance().get("platformio", "packages_dir"), TOOL) + TOOL_PACKAGE_PATH = os.path.join(TOOL_PATH, "package.json") + TOOLS_PATH_DEFAULT = os.path.join(os.path.expanduser("~"), ".platformio") + IDF_TOOLS = os.path.join(ProjectConfig.get_instance().get("platformio", "packages_dir"), "tl-install", "tools", "idf_tools.py") + TOOLS_JSON_PATH = os.path.join(TOOL_PATH, "tools.json") + TOOLS_PIO_PATH = os.path.join(TOOL_PATH, ".piopm") + IDF_TOOLS_CMD = ( + python_exe, + IDF_TOOLS, + "--quiet", + "--non-interactive", + "--tools-json", + TOOLS_JSON_PATH, + "install" + ) + + tl_flag = bool(os.path.exists(IDF_TOOLS)) + json_flag = bool(os.path.exists(TOOLS_JSON_PATH)) + pio_flag = bool(os.path.exists(TOOLS_PIO_PATH)) + if tl_flag and json_flag: + rc = subprocess.run(IDF_TOOLS_CMD).returncode + if rc != 0: + sys.stderr.write("Error: Couldn't execute 'idf_tools.py install'\n") + else: + tl_path = "file://" + join(TOOLS_PATH_DEFAULT, "tools", TOOL) + if not os.path.exists(join(TOOLS_PATH_DEFAULT, "tools", TOOL, "package.json")): + shutil.copyfile(TOOL_PACKAGE_PATH, join(TOOLS_PATH_DEFAULT, "tools", TOOL, "package.json")) + self.packages.pop(TOOL, None) + if os.path.exists(TOOL_PATH) and os.path.isdir(TOOL_PATH): + try: + shutil.rmtree(TOOL_PATH) + except Exception as e: + print(f"Error while removing the tool folder: {e}") + pm.install(tl_path) + # tool is already installed, just activate it + if tl_flag and pio_flag and not json_flag: + self.packages[TOOL]["version"] = TOOL_PATH + self.packages[TOOL]["optional"] = False + + return + + # Installer only needed for setup, deactivate when installed + if bool(os.path.exists(os.path.join(ProjectConfig.get_instance().get("platformio", "packages_dir"), "tl-install", "tools", "idf_tools.py"))): + self.packages["tl-install"]["optional"] = True + if "arduino" in frameworks: self.packages["framework-arduinoespressif32"]["optional"] = False self.packages["framework-arduinoespressif32-libs"]["optional"] = False @@ -73,8 +121,7 @@ def configure_default_packages(self, variables, targets): self.packages["tool-mkfatfs"]["optional"] = False else: self.packages["tool-mkspiffs"]["optional"] = False - if variables.get("upload_protocol"): - self.packages["tool-openocd-esp32"]["optional"] = False + if os.path.isdir("ulp"): self.packages["toolchain-esp32ulp"]["optional"] = False @@ -90,37 +137,31 @@ def configure_default_packages(self, variables, targets): else: del self.packages["tool-dfuutil-arduino"] - # Starting from v12, Espressif's toolchains are shipped without - # bundled GDB. Instead, it's distributed as separate packages for Xtensa - # and RISC-V targets. - for gdb_package in ("tool-xtensa-esp-elf-gdb", "tool-riscv32-esp-elf-gdb"): - self.packages[gdb_package]["optional"] = False - # if IS_WINDOWS: - # Note: On Windows GDB v12 is not able to - # launch a GDB server in pipe mode while v11 works fine - # self.packages[gdb_package]["version"] = "~11.2.0" + # install GDB and OpenOCD when debug mode or upload_protocol is set + if (variables.get("build_type") or "debug" in "".join(targets)) or variables.get("upload_protocol"): + for gdb_package in ("tool-xtensa-esp-elf-gdb", "tool-riscv32-esp-elf-gdb"): + self.packages[gdb_package]["optional"] = False + install_tool("tool-openocd-esp32") # Common packages for IDF and mixed Arduino+IDF projects if "espidf" in frameworks: self.packages["toolchain-esp32ulp"]["optional"] = False for p in self.packages: if p in ( - "tool-scons", "tool-cmake", "tool-ninja", + "tool-scons", "tool-esp-rom-elfs", ): self.packages[p]["optional"] = False - # elif p in ("tool-mconf", "tool-idf") and IS_WINDOWS: - # self.packages[p]["optional"] = False if mcu in ("esp32", "esp32s2", "esp32s3"): self.packages["toolchain-xtensa-esp-elf"]["optional"] = False else: self.packages.pop("toolchain-xtensa-esp-elf", None) - if mcu in ("esp32s2", "esp32s3", "esp32c2", "esp32c3", "esp32c6", "esp32h2", "esp32p4"): - if mcu in ("esp32c2", "esp32c3", "esp32c6", "esp32h2", "esp32p4"): + if mcu in ("esp32s2", "esp32s3", "esp32c2", "esp32c3", "esp32c5", "esp32c6", "esp32h2", "esp32p4"): + if mcu in ("esp32c2", "esp32c3", "esp32c5", "esp32c6", "esp32h2", "esp32p4"): self.packages.pop("toolchain-esp32ulp", None) # RISC-V based toolchain for ESP32C3, ESP32C6 ESP32S2, ESP32S3 ULP self.packages["toolchain-riscv32-esp"]["optional"] = False From 88a9675dcea394d04ae914a40b567663053862af Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 28 Apr 2025 20:41:26 +0200 Subject: [PATCH 43/60] Fix matter arduino as an component of IDF example (#150) *Co-authored-by: Sugar Glider --- examples/espidf-arduino-matter-light/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/espidf-arduino-matter-light/README.md b/examples/espidf-arduino-matter-light/README.md index 1bb4614c5..694ae2286 100644 --- a/examples/espidf-arduino-matter-light/README.md +++ b/examples/espidf-arduino-matter-light/README.md @@ -25,7 +25,7 @@ There is no QR Code to be used when the Smartphone APP wants to add the Matter D Please enter the code manually: `34970112332` The devboard has a built-in LED that will be used as the Matter Light. -The default setting of the code uses pin 8 for the ESP32-C6 +The default setting of the code uses pin 8 for the ESP32-C6, Please change it in `main/matter_accessory_driver.h` or in the `sdkconfig.defaults` file. ## LED Status and Factory Mode @@ -53,7 +53,7 @@ Holding the BOOT button pressed for more than 10 seconds and then releasing it w This example has been tested with Arduino Core 3.2.0. It should work with newer versions too. -There is a configuration file for these SoC: esp32c3, esp32c6. +There is a configuration file for these SoCs: esp32c3, esp32c6. Those are the tested devices that have a WS2812 RGB LED and can run BLE, WiFi and Matter. In case it is necessary to change the Button Pin or the REG LED Pin, please use the `menuconfig` and change the Menu Option `Light Matter Accessory` From 353222615607e4f6adef59146bae280953e4bf8c Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 28 Apr 2025 22:33:59 +0200 Subject: [PATCH 44/60] Update examples.yml --- .github/workflows/examples.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index c77c2082d..144526ae1 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -12,7 +12,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-24.04, windows-2022, macos-15] + os: [ubuntu-24.04, windows-latest, macos-15] example: - "examples/arduino-blink" - "examples/arduino-rmt-blink" @@ -22,7 +22,7 @@ jobs: - "examples/arduino-zigbee-switch" - "examples/tasmota" - "examples/espidf-arduino-h2zero-BLE_scan" - #- "examples/espidf-arduino-matter-light" + - "examples/espidf-arduino-matter-light" - "examples/arduino-matter-light" - "examples/espidf-arduino-blink" - "examples/espidf-arduino-littlefs" @@ -48,13 +48,14 @@ jobs: python-version: "3.13" - name: Install dependencies run: | - python -m pip install --upgrade pip pip install wheel pip install -U https://github.com/pioarduino/platformio-core/archive/refs/tags/v6.1.18.zip pio pkg install --global --platform file://. - name: git clone Tasmota and add to examples + if: "matrix.example == 'examples/tasmota'" run: | git clone -b development --depth 1 https://github.com/arendst/Tasmota.git examples/tasmota cp examples/tasmota_platformio_override.ini examples/tasmota/platformio_override.ini - name: Build examples + if: "matrix.example != 'examples/espidf-arduino-matter-light' || matrix.os != 'windows-latest'" run: pio run -d ${{ matrix.example }} From 3389fe54a6267e42e9fdc6ddb9e3089826526537 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 28 Apr 2025 22:35:06 +0200 Subject: [PATCH 45/60] Update CMakeLists.txt --- examples/espidf-arduino-matter-light/CMakeLists.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/espidf-arduino-matter-light/CMakeLists.txt b/examples/espidf-arduino-matter-light/CMakeLists.txt index 1430df8ff..70910dcdf 100644 --- a/examples/espidf-arduino-matter-light/CMakeLists.txt +++ b/examples/espidf-arduino-matter-light/CMakeLists.txt @@ -1,6 +1,6 @@ # The following lines of boilerplate have to be in your project's # CMakeLists in this exact order for cmake to work correctly -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.16.0) set(PROJECT_VER "1.0") set(PROJECT_VER_NUMBER 1) @@ -8,8 +8,7 @@ set(PROJECT_VER_NUMBER 1) # This should be done before using the IDF_TARGET variable. include($ENV{IDF_PATH}/tools/cmake/project.cmake) -idf_build_set_property(MINIMAL_BUILD ON) -project(arduino_managed_component_light) +project(espidf_arduino_matter_light) # WARNING: This is just an example for using key for decrypting the encrypted OTA image # Please do not use it as is. From c9629739919b42514e0a3192bd8a63e134b15f9d Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 28 Apr 2025 23:58:02 +0200 Subject: [PATCH 46/60] silence warning 'missing-field-initializers' in matter example --- examples/espidf-arduino-matter-light/platformio.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/espidf-arduino-matter-light/platformio.ini b/examples/espidf-arduino-matter-light/platformio.ini index 1a470a54c..8e63ecd1c 100644 --- a/examples/espidf-arduino-matter-light/platformio.ini +++ b/examples/espidf-arduino-matter-light/platformio.ini @@ -22,6 +22,8 @@ build_unflags = -std=gnu++2b build_flags = -std=gnu++2a + -Wno-missing-field-initializers + [env:esp32c6] board = esp32-c6-devkitc-1 From 3f2bba147bf631341876488527ada5d2acbfd256 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 30 Apr 2025 18:59:57 +0200 Subject: [PATCH 47/60] Refactor toolchain install --- platform.py | 81 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 33 deletions(-) diff --git a/platform.py b/platform.py index 8080001ac..96dcfe821 100644 --- a/platform.py +++ b/platform.py @@ -71,8 +71,10 @@ def install_tool(TOOL): sys.stderr.write("Error: Couldn't execute 'idf_tools.py install'\n") else: tl_path = "file://" + join(TOOLS_PATH_DEFAULT, "tools", TOOL) - if not os.path.exists(join(TOOLS_PATH_DEFAULT, "tools", TOOL, "package.json")): + try: shutil.copyfile(TOOL_PACKAGE_PATH, join(TOOLS_PATH_DEFAULT, "tools", TOOL, "package.json")) + except FileNotFoundError as e: + sys.stderr.write(f"Error copying tool package file: {e}\n") self.packages.pop(TOOL, None) if os.path.exists(TOOL_PATH) and os.path.isdir(TOOL_PATH): try: @@ -108,6 +110,51 @@ def install_tool(TOOL): if mcu == "esp32c2": self.packages["framework-arduino-c2-skeleton-lib"]["optional"] = False + mcu_toolchain_mapping = { + # Xtensa based and FSM toolchain + ("esp32", "esp32s2", "esp32s3"): { + "toolchains": ["toolchain-xtensa-esp-elf"], + "ulp_toolchain": ["toolchain-esp32ulp"] + (["toolchain-riscv32-esp"] if mcu != "esp32" else []), + "debug_tools": ["tool-xtensa-esp-elf-gdb"] + }, + # RISC-V based toolchain + ("esp32c2", "esp32c3", "esp32c5", "esp32c6", "esp32h2", "esp32p4"): { + "toolchains": ["toolchain-riscv32-esp"], + "ulp_toolchain": None, + "debug_tools": ["tool-riscv32-esp-elf-gdb"] + } + } + + # Iterate through MCU mappings + for supported_mcus, toolchain_data in mcu_toolchain_mapping.items(): + if mcu in supported_mcus: + # Set mandatory toolchains + for toolchain in toolchain_data["toolchains"]: + self.packages[toolchain]["optional"] = False + + # Set ULP toolchain if applicable + ulp_toolchain = toolchain_data.get("ulp_toolchain") + if ulp_toolchain and os.path.isdir("ulp"): + for toolchain in ulp_toolchain: + self.packages[toolchain]["optional"] = False + # Install debug tools if conditions match + if (variables.get("build_type") or "debug" in "".join(targets)) or variables.get("upload_protocol"): + for debug_tool in toolchain_data["debug_tools"]: + self.packages[debug_tool]["optional"] = False + install_tool("tool-openocd-esp32") + break # Exit loop once MCU is matched + + # Common packages for IDF and mixed Arduino+IDF projects + COMMON_IDF_PACKAGES = [ + "tool-cmake", + "tool-ninja", + "tool-scons", + "tool-esp-rom-elfs" + ] + if "espidf" in frameworks: + for package in COMMON_IDF_PACKAGES: + self.packages[package]["optional"] = False + # Enable check tools only when "check_tool" is active for p in self.packages: if p in ("tool-cppcheck", "tool-clangtidy", "tool-pvs-studio"): @@ -122,9 +169,6 @@ def install_tool(TOOL): else: self.packages["tool-mkspiffs"]["optional"] = False - if os.path.isdir("ulp"): - self.packages["toolchain-esp32ulp"]["optional"] = False - if "downloadfs" in targets: filesystem = variables.get("board_build.filesystem", "littlefs") if filesystem == "littlefs": @@ -137,35 +181,6 @@ def install_tool(TOOL): else: del self.packages["tool-dfuutil-arduino"] - # install GDB and OpenOCD when debug mode or upload_protocol is set - if (variables.get("build_type") or "debug" in "".join(targets)) or variables.get("upload_protocol"): - for gdb_package in ("tool-xtensa-esp-elf-gdb", "tool-riscv32-esp-elf-gdb"): - self.packages[gdb_package]["optional"] = False - install_tool("tool-openocd-esp32") - - # Common packages for IDF and mixed Arduino+IDF projects - if "espidf" in frameworks: - self.packages["toolchain-esp32ulp"]["optional"] = False - for p in self.packages: - if p in ( - "tool-cmake", - "tool-ninja", - "tool-scons", - "tool-esp-rom-elfs", - ): - self.packages[p]["optional"] = False - - if mcu in ("esp32", "esp32s2", "esp32s3"): - self.packages["toolchain-xtensa-esp-elf"]["optional"] = False - else: - self.packages.pop("toolchain-xtensa-esp-elf", None) - - if mcu in ("esp32s2", "esp32s3", "esp32c2", "esp32c3", "esp32c5", "esp32c6", "esp32h2", "esp32p4"): - if mcu in ("esp32c2", "esp32c3", "esp32c5", "esp32c6", "esp32h2", "esp32p4"): - self.packages.pop("toolchain-esp32ulp", None) - # RISC-V based toolchain for ESP32C3, ESP32C6 ESP32S2, ESP32S3 ULP - self.packages["toolchain-riscv32-esp"]["optional"] = False - return super().configure_default_packages(variables, targets) def get_boards(self, id_=None): From faee6ac85b20af1d09468ccd59c55ab65fb7eb4b Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 30 Apr 2025 19:56:47 +0200 Subject: [PATCH 48/60] New gdb v16.2 (#156) --- platform.json | 8 ++++---- platform.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/platform.json b/platform.json index 0cb088fe0..a5583fd77 100644 --- a/platform.json +++ b/platform.json @@ -74,14 +74,14 @@ "tool-xtensa-esp-elf-gdb": { "type": "debugger", "optional": true, - "owner": "platformio", - "version": "14.2.0+20240403" + "owner": "pioarduino", + "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/xtensa-esp-gdb-v16.2_20250324.zip" }, "tool-riscv32-esp-elf-gdb": { "type": "debugger", "optional": true, - "owner": "platformio", - "version": "14.2.0+20240403" + "owner": "pioarduino", + "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/riscv32-esp-gdb-v16.2_20250324.zip" }, "tool-esptoolpy": { "type": "uploader", diff --git a/platform.py b/platform.py index 96dcfe821..0b4a13b84 100644 --- a/platform.py +++ b/platform.py @@ -140,7 +140,7 @@ def install_tool(TOOL): # Install debug tools if conditions match if (variables.get("build_type") or "debug" in "".join(targets)) or variables.get("upload_protocol"): for debug_tool in toolchain_data["debug_tools"]: - self.packages[debug_tool]["optional"] = False + install_tool(debug_tool) install_tool("tool-openocd-esp32") break # Exit loop once MCU is matched From a3d12dd862d71d2f6ebb191b7818ad6305310d76 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 1 May 2025 11:11:20 +0200 Subject: [PATCH 49/60] use sdkconfig setting `MMU_PAGE_SIZE` --- builder/frameworks/espidf.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/builder/frameworks/espidf.py b/builder/frameworks/espidf.py index 42fd2ade3..c08456bc0 100644 --- a/builder/frameworks/espidf.py +++ b/builder/frameworks/espidf.py @@ -2068,6 +2068,15 @@ def _skip_prj_source_files(node): # For chips that support configurable MMU page size feature # If page size is configured to values other than the default "64KB" in menuconfig, mmu_page_size = "64KB" +if sdk_config.get("MMU_PAGE_SIZE_8KB", False): + mmu_page_size = "8KB" +elif sdk_config.get("MMU_PAGE_SIZE_16KB", False): + mmu_page_size = "16KB" +elif sdk_config.get("MMU_PAGE_SIZE_32KB", False): + mmu_page_size = "32KB" +else: + mmu_page_size = "64KB" + if sdk_config.get("SOC_MMU_PAGE_SIZE_CONFIGURABLE", False): if board_flash_size == "2MB": mmu_page_size = "32KB" From bb6350e89cfd5d8798aaeb907c040a87c8943b3d Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 1 May 2025 13:40:57 +0200 Subject: [PATCH 50/60] fix pvs studio install for windows --- platform.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform.json b/platform.json index a5583fd77..dce145d4f 100644 --- a/platform.json +++ b/platform.json @@ -141,7 +141,7 @@ "type": "tool", "optional": true, "owner": "platformio", - "version": "^7.18.59866" + "version": "^7.18.0" }, "tool-cmake": { "type": "tool", From 63072e0c147755bee1f3ebe55b178246dfea541e Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 1 May 2025 17:13:55 +0200 Subject: [PATCH 51/60] refactor check tools install --- platform.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/platform.py b/platform.py index 0b4a13b84..b5dac1b35 100644 --- a/platform.py +++ b/platform.py @@ -110,7 +110,7 @@ def install_tool(TOOL): if mcu == "esp32c2": self.packages["framework-arduino-c2-skeleton-lib"]["optional"] = False - mcu_toolchain_mapping = { + MCU_TOOLCHAIN_MAPPING = { # Xtensa based and FSM toolchain ("esp32", "esp32s2", "esp32s3"): { "toolchains": ["toolchain-xtensa-esp-elf"], @@ -124,9 +124,8 @@ def install_tool(TOOL): "debug_tools": ["tool-riscv32-esp-elf-gdb"] } } - # Iterate through MCU mappings - for supported_mcus, toolchain_data in mcu_toolchain_mapping.items(): + for supported_mcus, toolchain_data in MCU_TOOLCHAIN_MAPPING.items(): if mcu in supported_mcus: # Set mandatory toolchains for toolchain in toolchain_data["toolchains"]: @@ -155,10 +154,17 @@ def install_tool(TOOL): for package in COMMON_IDF_PACKAGES: self.packages[package]["optional"] = False - # Enable check tools only when "check_tool" is active - for p in self.packages: - if p in ("tool-cppcheck", "tool-clangtidy", "tool-pvs-studio"): - self.packages[p]["optional"] = False if str(variables.get("check_tool")).strip("['']") in p else True + CHECK_PACKAGES = [ + "tool-cppcheck", + "tool-clangtidy", + "tool-pvs-studio" + ] + # Install check tool listed in pio entry "check_tool" + if variables.get("check_tool") is not None: + for package in CHECK_PACKAGES: + for check_tool in variables.get("check_tool", ""): + if check_tool in package: + self.packages[package]["optional"] = False if "buildfs" in targets: filesystem = variables.get("board_build.filesystem", "littlefs") From 15cd60d3d901449d59ead9ee975d08a06e427200 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 1 May 2025 17:19:40 +0200 Subject: [PATCH 52/60] more examples to test check tools install --- examples/arduino-wifiscan/platformio.ini | 38 ++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/examples/arduino-wifiscan/platformio.ini b/examples/arduino-wifiscan/platformio.ini index 38cd6b894..8f3b3c6a9 100644 --- a/examples/arduino-wifiscan/platformio.ini +++ b/examples/arduino-wifiscan/platformio.ini @@ -12,3 +12,41 @@ platform = espressif32 framework = arduino board = esp-wrover-kit monitor_speed = 115200 + +[env:esp32-s2] +platform = espressif32 +framework = arduino +board = esp32-s2-saola-1 +upload_protocol = esp-prog +monitor_speed = 115200 + +[env:esp32-s3] +platform = espressif32 +framework = arduino +board = esp32-s3-devkitc-1 +upload_protocol = esp-builtin +monitor_speed = 115200 +check_tool = cppcheck + +[env:esp32-c2] +platform = espressif32 +framework = arduino +board = esp32-c2-devkitm-1 +upload_protocol = esp-prog +monitor_speed = 115200 +check_tool = clangtidy + +[env:esp32-c3] +platform = espressif32 +framework = arduino +board = esp32-c3-devkitm-1 +upload_protocol = esp-builtin +monitor_speed = 115200 +check_tool = pvs-studio + +[env:esp32-c6] +platform = espressif32 +framework = arduino +board = esp32-c6-devkitm-1 +upload_protocol = esp-builtin +monitor_speed = 115200 From 30dd6d81005d22fd72d9d1b143d24e63a18b6120 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 1 May 2025 17:45:52 +0200 Subject: [PATCH 53/60] Update platformio.ini --- examples/arduino-wifiscan/platformio.ini | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/examples/arduino-wifiscan/platformio.ini b/examples/arduino-wifiscan/platformio.ini index 8f3b3c6a9..ea44328ba 100644 --- a/examples/arduino-wifiscan/platformio.ini +++ b/examples/arduino-wifiscan/platformio.ini @@ -19,6 +19,7 @@ framework = arduino board = esp32-s2-saola-1 upload_protocol = esp-prog monitor_speed = 115200 +check_tool = clangtidy [env:esp32-s3] platform = espressif32 @@ -28,14 +29,6 @@ upload_protocol = esp-builtin monitor_speed = 115200 check_tool = cppcheck -[env:esp32-c2] -platform = espressif32 -framework = arduino -board = esp32-c2-devkitm-1 -upload_protocol = esp-prog -monitor_speed = 115200 -check_tool = clangtidy - [env:esp32-c3] platform = espressif32 framework = arduino From 60ef22a4f353d9e3dd97a1f40caeb1a0e2c20171 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 1 May 2025 18:21:07 +0200 Subject: [PATCH 54/60] Update c2 compile skeleton --- platform.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform.json b/platform.json index dce145d4f..6d2ed2f08 100644 --- a/platform.json +++ b/platform.json @@ -45,7 +45,7 @@ "type": "framework", "optional": true, "owner": "espressif", - "version": "https://github.com/pioarduino/platform-espressif32/releases/download/53.03.10-rc3/c2_arduino_compile_skeleton.zip" + "version": "https://github.com/pioarduino/platform-espressif32/releases/download/54.03.20/c2_arduino_compile_skeleton.zip" }, "framework-espidf": { "type": "framework", From d501a0a7a02e6ca6120117a00b689fa3f52cd045 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 1 May 2025 21:50:07 +0200 Subject: [PATCH 55/60] Update platformio.ini --- examples/arduino-wifiscan/platformio.ini | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/examples/arduino-wifiscan/platformio.ini b/examples/arduino-wifiscan/platformio.ini index ea44328ba..a80b5939a 100644 --- a/examples/arduino-wifiscan/platformio.ini +++ b/examples/arduino-wifiscan/platformio.ini @@ -29,6 +29,23 @@ upload_protocol = esp-builtin monitor_speed = 115200 check_tool = cppcheck +[env:esp32-c2] +platform = espressif32 +framework = arduino +board = esp32-c2-devkitm-1 +upload_protocol = esp-prog +monitor_speed = 115200 +check_tool = clangtidy +custom_component_remove = + espressif/esp-dsp + espressif/network_provisioning + espressif/esp-zboss-lib + espressif/esp-zigbee-lib + espressif/esp_rainmaker + espressif/esp-sr + espressif/esp-modbus + espressif/esp32-camera + [env:esp32-c3] platform = espressif32 framework = arduino From f4def7ffb924cd9657f8f32ee52902ad550f752e Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 2 May 2025 20:34:56 +0200 Subject: [PATCH 56/60] Remove all dependencies to Platformio registry (#160) --- platform.json | 56 +++++++++++++++++++++++++-------------------------- platform.py | 22 ++++++++++---------- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/platform.json b/platform.json index 6d2ed2f08..eca066cb9 100644 --- a/platform.json +++ b/platform.json @@ -56,20 +56,20 @@ "toolchain-xtensa-esp-elf": { "type": "toolchain", "optional": true, - "owner": "platformio", - "version": "14.2.0+20241119" + "owner": "pioarduino", + "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/xtensa-esp-elf-14.2.0_20241119.zip" }, "toolchain-riscv32-esp": { "type": "toolchain", "optional": true, - "owner": "platformio", - "version": "14.2.0+20241119" + "owner": "pioarduino", + "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/riscv32-esp-elf-14.2.0_20241119.zip" }, "toolchain-esp32ulp": { "type": "toolchain", "optional": true, - "owner": "platformio", - "version": "~1.23800.0" + "owner": "pioarduino", + "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/esp32ulp-elf-2.38_20240113.zip" }, "tool-xtensa-esp-elf-gdb": { "type": "debugger", @@ -98,8 +98,8 @@ "tool-dfuutil-arduino": { "type": "uploader", "optional": true, - "owner": "platformio", - "version": "~1.11.0" + "owner": "pioarduino", + "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/dfuutil-arduino-v1.11.0.zip" }, "tool-openocd-esp32": { "type": "debugger", @@ -110,62 +110,62 @@ "tool-mklittlefs": { "type": "uploader", "optional": true, - "owner": "tasmota", - "version": "^3.2.0" + "owner": "pioarduino", + "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/mklittlefs-3.2.0.zip" }, "tool-mkfatfs": { "type": "uploader", "optional": true, - "owner": "platformio", - "version": "~2.0.0" + "owner": "pioarduino", + "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/mkfatfs-v2.0.1.zip" }, "tool-mkspiffs": { "type": "uploader", "optional": true, - "owner": "platformio", - "version": "~2.230.0" + "owner": "pioarduino", + "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/mkspiffs-v2.230.0.zip" }, "tool-cppcheck": { "type": "tool", "optional": true, - "owner": "platformio", - "version": "~1.21100" + "owner": "pioarduino", + "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/cppcheck-v2.11.0-230717.zip" }, "tool-clangtidy": { "type": "tool", "optional": true, - "owner": "platformio", - "version": "^1.190100.0" + "owner": "pioarduino", + "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/clangtidy-v18.1.1.zip" }, "tool-pvs-studio": { "type": "tool", "optional": true, - "owner": "platformio", - "version": "^7.18.0" + "owner": "pioarduino", + "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/pvs-studio-v7.18.zip" }, "tool-cmake": { "type": "tool", "optional": true, - "owner": "platformio", - "version": "~3.30.2" + "owner": "pioarduino", + "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/cmake-3.30.2.zip" }, "tool-esp-rom-elfs": { "type": "tool", "optional": true, - "owner": "platformio", - "version": "0.0.1+20241011" + "owner": "pioarduino", + "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/esp-rom-elfs-20241011.zip" }, "tool-ninja": { "type": "tool", "optional": true, - "owner": "platformio", - "version": "^1.7.0" + "owner": "pioarduino", + "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/ninja-1.10.2.zip" }, "tool-scons": { "type": "tool", "optional": true, - "owner": "platformio", - "version": "~4.40801.0" + "owner": "pioarduino", + "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/scons-4.8.1.zip" } } } diff --git a/platform.py b/platform.py index b5dac1b35..ad350317f 100644 --- a/platform.py +++ b/platform.py @@ -129,13 +129,13 @@ def install_tool(TOOL): if mcu in supported_mcus: # Set mandatory toolchains for toolchain in toolchain_data["toolchains"]: - self.packages[toolchain]["optional"] = False + install_tool(toolchain) # Set ULP toolchain if applicable ulp_toolchain = toolchain_data.get("ulp_toolchain") if ulp_toolchain and os.path.isdir("ulp"): for toolchain in ulp_toolchain: - self.packages[toolchain]["optional"] = False + install_tool(toolchain) # Install debug tools if conditions match if (variables.get("build_type") or "debug" in "".join(targets)) or variables.get("upload_protocol"): for debug_tool in toolchain_data["debug_tools"]: @@ -152,7 +152,7 @@ def install_tool(TOOL): ] if "espidf" in frameworks: for package in COMMON_IDF_PACKAGES: - self.packages[package]["optional"] = False + install_tool(package) CHECK_PACKAGES = [ "tool-cppcheck", @@ -164,28 +164,28 @@ def install_tool(TOOL): for package in CHECK_PACKAGES: for check_tool in variables.get("check_tool", ""): if check_tool in package: - self.packages[package]["optional"] = False + install_tool(package) if "buildfs" in targets: filesystem = variables.get("board_build.filesystem", "littlefs") if filesystem == "littlefs": - self.packages["tool-mklittlefs"]["optional"] = False + install_tool("tool-mklittlefs") elif filesystem == "fatfs": - self.packages["tool-mkfatfs"]["optional"] = False + install_tool("tool-mkfatfs") else: - self.packages["tool-mkspiffs"]["optional"] = False + install_tool("tool-mkspiffs") if "downloadfs" in targets: filesystem = variables.get("board_build.filesystem", "littlefs") if filesystem == "littlefs": # Use Tasmota mklittlefs v4.0.0 to unpack, older version is incompatible - self.packages["tool-mklittlefs"]["version"] = "~4.0.0" + self.packages["tool-mklittlefs"]["version"] = "https://github.com/pioarduino/registry/releases/download/0.0.1/mklittlefs-4.0.0.zip" + self.packages["tool-mklittlefs"]["optional"] = False + install_tool("tool-mklittlefs") # Currently only Arduino Nano ESP32 uses the dfuutil tool as uploader if variables.get("board") == "arduino_nano_esp32": - self.packages["tool-dfuutil-arduino"]["optional"] = False - else: - del self.packages["tool-dfuutil-arduino"] + install_tool("tool-dfuutil-arduino") return super().configure_default_packages(variables, targets) From 7a3301452df93c8887320539d1299fce56dd78a2 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 4 May 2025 18:17:49 +0200 Subject: [PATCH 57/60] check for requirements match of already installed tools (#165) --- platform.json | 32 +++++++++++++++++++++---- platform.py | 66 ++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 85 insertions(+), 13 deletions(-) diff --git a/platform.json b/platform.json index eca066cb9..7e47654a7 100644 --- a/platform.json +++ b/platform.json @@ -57,30 +57,35 @@ "type": "toolchain", "optional": true, "owner": "pioarduino", + "package-version": "14.2.0+20241119", "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/xtensa-esp-elf-14.2.0_20241119.zip" }, "toolchain-riscv32-esp": { "type": "toolchain", "optional": true, "owner": "pioarduino", + "package-version": "14.2.0+20241119", "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/riscv32-esp-elf-14.2.0_20241119.zip" }, "toolchain-esp32ulp": { "type": "toolchain", "optional": true, "owner": "pioarduino", + "package-version": "2.38.0+20240113", "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/esp32ulp-elf-2.38_20240113.zip" }, - "tool-xtensa-esp-elf-gdb": { + "tool-xtensa-esp-elf-gdb": { "type": "debugger", "optional": true, "owner": "pioarduino", + "package-version": "16.2.0+20250324", "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/xtensa-esp-gdb-v16.2_20250324.zip" }, "tool-riscv32-esp-elf-gdb": { "type": "debugger", "optional": true, "owner": "pioarduino", + "package-version": "16.2.0+20250324", "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/riscv32-esp-gdb-v16.2_20250324.zip" }, "tool-esptoolpy": { @@ -99,72 +104,91 @@ "type": "uploader", "optional": true, "owner": "pioarduino", + "package-version": "1.11.0", "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/dfuutil-arduino-v1.11.0.zip" }, "tool-openocd-esp32": { "type": "debugger", "optional": true, "owner": "pioarduino", + "package-version": "2.1200.20250226", "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/openocd-v0.12.0-esp32-20250226.zip" }, "tool-mklittlefs": { "type": "uploader", "optional": true, "owner": "pioarduino", + "package-version": "3.2.0", "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/mklittlefs-3.2.0.zip" }, - "tool-mkfatfs": { + "tool-mklittlefs-4.0.0": { "type": "uploader", "optional": true, "owner": "pioarduino", - "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/mkfatfs-v2.0.1.zip" + "package-version": "4.0.0", + "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/mklittlefs-4.0.0.zip" }, "tool-mkspiffs": { "type": "uploader", "optional": true, "owner": "pioarduino", + "package-version": "2.230.0", "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/mkspiffs-v2.230.0.zip" + }, + "tool-mkfatfs": { + "type": "uploader", + "optional": true, + "owner": "pioarduino", + "package-version": "2.0.1", + "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/mkfatfs-v2.0.1.zip" }, "tool-cppcheck": { "type": "tool", "optional": true, "owner": "pioarduino", + "package-version": "2.11.0+230717", "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/cppcheck-v2.11.0-230717.zip" }, "tool-clangtidy": { "type": "tool", "optional": true, "owner": "pioarduino", + "package-version": "18.1.1", "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/clangtidy-v18.1.1.zip" }, "tool-pvs-studio": { "type": "tool", "optional": true, "owner": "pioarduino", - "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/pvs-studio-v7.18.zip" + "package-version": "7.36.91321", + "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/pvs-studio-v7.36.91321.zip" }, "tool-cmake": { "type": "tool", "optional": true, "owner": "pioarduino", + "package-version": "3.30.2", "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/cmake-3.30.2.zip" }, "tool-esp-rom-elfs": { "type": "tool", "optional": true, "owner": "pioarduino", + "package-version": "2024.10.11", "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/esp-rom-elfs-20241011.zip" }, "tool-ninja": { "type": "tool", "optional": true, "owner": "pioarduino", + "package-version": "1.10.2", "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/ninja-1.10.2.zip" }, "tool-scons": { "type": "tool", "optional": true, "owner": "pioarduino", + "package-version": "4.40801.0", "version": "https://github.com/pioarduino/registry/releases/download/0.0.1/scons-4.8.1.zip" } } diff --git a/platform.py b/platform.py index ad350317f..3d089dde8 100644 --- a/platform.py +++ b/platform.py @@ -13,6 +13,8 @@ # limitations under the License. import os +import requests +import json import subprocess import sys import shutil @@ -44,7 +46,7 @@ def configure_default_packages(self, variables, targets): board_sdkconfig = variables.get("board_espidf.custom_sdkconfig", board_config.get("espidf.custom_sdkconfig", "")) frameworks = variables.get("pioframework", []) - def install_tool(TOOL): + def install_tool(TOOL, retry_count=0): self.packages[TOOL]["optional"] = False TOOL_PATH = os.path.join(ProjectConfig.get_instance().get("platformio", "packages_dir"), TOOL) TOOL_PACKAGE_PATH = os.path.join(TOOL_PATH, "package.json") @@ -80,13 +82,37 @@ def install_tool(TOOL): try: shutil.rmtree(TOOL_PATH) except Exception as e: - print(f"Error while removing the tool folder: {e}") + print(f"Error while removing the tool folder: {e}") pm.install(tl_path) # tool is already installed, just activate it if tl_flag and pio_flag and not json_flag: - self.packages[TOOL]["version"] = TOOL_PATH - self.packages[TOOL]["optional"] = False - + with open(TOOL_PACKAGE_PATH, "r") as file: + package_data = json.load(file) + # check installed tool version against listed in platforms.json + if "package-version" in self.packages[TOOL] \ + and "version" in package_data \ + and self.packages[TOOL]["package-version"] == package_data["version"]: + self.packages[TOOL]["version"] = TOOL_PATH + self.packages[TOOL]["optional"] = False + elif "package-version" not in self.packages[TOOL]: + # No version check needed, just use the installed tool + self.packages[TOOL]["version"] = TOOL_PATH + self.packages[TOOL]["optional"] = False + elif "version" not in package_data: + print(f"Warning: Cannot determine installed version for {TOOL}. Reinstalling...") + else: # Installed version does not match required version, deinstall existing and install needed + self.packages.pop(TOOL, None) + if os.path.exists(TOOL_PATH) and os.path.isdir(TOOL_PATH): + try: + shutil.rmtree(TOOL_PATH) + except Exception as e: + print(f"Error while removing the tool folder: {e}") + if retry_count >= 3: # Limit to 3 retries + print(f"Failed to install {TOOL} after multiple attempts. Please check your network connection and try again manually.") + return + print(f"Wrong version for {TOOL}. Installing needed version...") + install_tool(TOOL, retry_count + 1) + return # Installer only needed for setup, deactivate when installed @@ -130,7 +156,6 @@ def install_tool(TOOL): # Set mandatory toolchains for toolchain in toolchain_data["toolchains"]: install_tool(toolchain) - # Set ULP toolchain if applicable ulp_toolchain = toolchain_data.get("ulp_toolchain") if ulp_toolchain and os.path.isdir("ulp"): @@ -169,6 +194,13 @@ def install_tool(TOOL): if "buildfs" in targets: filesystem = variables.get("board_build.filesystem", "littlefs") if filesystem == "littlefs": + # ensure use of mklittlefs 3.2.0 + piopm_path = os.path.join(ProjectConfig.get_instance().get("platformio", "packages_dir"), "tool-mklittlefs", ".piopm") + if os.path.exists(piopm_path): + with open(piopm_path, "r") as file: + package_data = json.load(file) + if package_data['version'] == "4.0.0": + os.remove(piopm_path) install_tool("tool-mklittlefs") elif filesystem == "fatfs": install_tool("tool-mkfatfs") @@ -179,9 +211,25 @@ def install_tool(TOOL): filesystem = variables.get("board_build.filesystem", "littlefs") if filesystem == "littlefs": # Use Tasmota mklittlefs v4.0.0 to unpack, older version is incompatible - self.packages["tool-mklittlefs"]["version"] = "https://github.com/pioarduino/registry/releases/download/0.0.1/mklittlefs-4.0.0.zip" - self.packages["tool-mklittlefs"]["optional"] = False - install_tool("tool-mklittlefs") + # make sure mklittlefs 3.2.0 is installed + mklittlefs_dir = os.path.join(ProjectConfig.get_instance().get("platformio", "packages_dir"), "tool-mklittlefs") + if not os.path.exists(mklittlefs_dir): + install_tool("tool-mklittlefs") + if os.path.exists(os.path.join(mklittlefs_dir, "tools.json")): + install_tool("tool-mklittlefs") + mklittlefs400_dir = os.path.join(ProjectConfig.get_instance().get("platformio", "packages_dir"), "tool-mklittlefs-4.0.0") + if not os.path.exists(mklittlefs400_dir): + # install mklittlefs 4.0.0 + install_tool("tool-mklittlefs-4.0.0") + if os.path.exists(os.path.join(mklittlefs400_dir, "tools.json")): + install_tool("tool-mklittlefs-4.0.0") + # use mklittlefs 4.0.0 instead of 3.2.0 by copying over + if os.path.exists(mklittlefs400_dir): + shutil.copyfile( + os.path.join(mklittlefs_dir, "package.json"), + os.path.join(mklittlefs400_dir, "package.json"), + ) + shutil.copytree(mklittlefs400_dir, mklittlefs_dir, dirs_exist_ok=True) # Currently only Arduino Nano ESP32 uses the dfuutil tool as uploader if variables.get("board") == "arduino_nano_esp32": From 829c345bc2099d4e310a615ecaefa61d5146a5d0 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 4 May 2025 21:19:54 +0200 Subject: [PATCH 58/60] fix crash when reinstalling --- platform.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/platform.py b/platform.py index 3d089dde8..eb33bf8ca 100644 --- a/platform.py +++ b/platform.py @@ -77,7 +77,6 @@ def install_tool(TOOL, retry_count=0): shutil.copyfile(TOOL_PACKAGE_PATH, join(TOOLS_PATH_DEFAULT, "tools", TOOL, "package.json")) except FileNotFoundError as e: sys.stderr.write(f"Error copying tool package file: {e}\n") - self.packages.pop(TOOL, None) if os.path.exists(TOOL_PATH) and os.path.isdir(TOOL_PATH): try: shutil.rmtree(TOOL_PATH) @@ -101,7 +100,6 @@ def install_tool(TOOL, retry_count=0): elif "version" not in package_data: print(f"Warning: Cannot determine installed version for {TOOL}. Reinstalling...") else: # Installed version does not match required version, deinstall existing and install needed - self.packages.pop(TOOL, None) if os.path.exists(TOOL_PATH) and os.path.isdir(TOOL_PATH): try: shutil.rmtree(TOOL_PATH) From 2c337e492dda04bd8dce527e8ff590823649d6fd Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 5 May 2025 14:06:23 +0200 Subject: [PATCH 59/60] fix uploadfs --- platform.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/platform.py b/platform.py index eb33bf8ca..e7a4a0928 100644 --- a/platform.py +++ b/platform.py @@ -189,7 +189,7 @@ def install_tool(TOOL, retry_count=0): if check_tool in package: install_tool(package) - if "buildfs" in targets: + if "buildfs" or "uploadfs" in targets: filesystem = variables.get("board_build.filesystem", "littlefs") if filesystem == "littlefs": # ensure use of mklittlefs 3.2.0 @@ -197,7 +197,7 @@ def install_tool(TOOL, retry_count=0): if os.path.exists(piopm_path): with open(piopm_path, "r") as file: package_data = json.load(file) - if package_data['version'] == "4.0.0": + if package_data['version'] != "3.2.0": os.remove(piopm_path) install_tool("tool-mklittlefs") elif filesystem == "fatfs": @@ -228,10 +228,15 @@ def install_tool(TOOL, retry_count=0): os.path.join(mklittlefs400_dir, "package.json"), ) shutil.copytree(mklittlefs400_dir, mklittlefs_dir, dirs_exist_ok=True) + del self.packages["tool-mkfatfs"] + elif filesystem == "fatfs": + install_tool("tool-mkfatfs") # Currently only Arduino Nano ESP32 uses the dfuutil tool as uploader if variables.get("board") == "arduino_nano_esp32": install_tool("tool-dfuutil-arduino") + else: + del self.packages["tool-dfuutil-arduino"] return super().configure_default_packages(variables, targets) From 5ce80da3f83b7252cf63b69823bb02923d2257d2 Mon Sep 17 00:00:00 2001 From: Jason2866 Date: Thu, 8 May 2025 14:54:54 +0200 Subject: [PATCH 60/60] change NimBLE example --- .github/workflows/examples.yml | 4 +- examples/arduino-NimBLE-ext_client/README.md | 5 + .../include/README | 0 .../lib/README | 0 .../arduino-NimBLE-ext_client/platformio.ini | 53 +++++++ .../src/NimBLE_extended_client.ino | 150 ++++++++++++++++++ .../espidf-arduino-h2zero-BLE_scan/.gitignore | 2 - .../CMakeLists.txt | 4 - .../espidf-arduino-h2zero-BLE_scan/README.md | 7 - .../platformio.ini | 27 ---- .../sdkconfig.defaults | 34 ---- .../src/CMakeLists.txt | 6 - .../src/idf_component.yml | 41 ----- .../src/main.cpp | 54 ------- 14 files changed, 210 insertions(+), 177 deletions(-) create mode 100644 examples/arduino-NimBLE-ext_client/README.md rename examples/{espidf-arduino-h2zero-BLE_scan => arduino-NimBLE-ext_client}/include/README (100%) rename examples/{espidf-arduino-h2zero-BLE_scan => arduino-NimBLE-ext_client}/lib/README (100%) create mode 100644 examples/arduino-NimBLE-ext_client/platformio.ini create mode 100644 examples/arduino-NimBLE-ext_client/src/NimBLE_extended_client.ino delete mode 100644 examples/espidf-arduino-h2zero-BLE_scan/.gitignore delete mode 100644 examples/espidf-arduino-h2zero-BLE_scan/CMakeLists.txt delete mode 100644 examples/espidf-arduino-h2zero-BLE_scan/README.md delete mode 100644 examples/espidf-arduino-h2zero-BLE_scan/platformio.ini delete mode 100644 examples/espidf-arduino-h2zero-BLE_scan/sdkconfig.defaults delete mode 100644 examples/espidf-arduino-h2zero-BLE_scan/src/CMakeLists.txt delete mode 100644 examples/espidf-arduino-h2zero-BLE_scan/src/idf_component.yml delete mode 100644 examples/espidf-arduino-h2zero-BLE_scan/src/main.cpp diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 144526ae1..f244ae3ac 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -20,10 +20,10 @@ jobs: - "examples/arduino-wifiscan" - "examples/arduino-zigbee-light" - "examples/arduino-zigbee-switch" + - "examples/arduino-NimBLE-ext_client" + - "examples/arduino-matter-light" - "examples/tasmota" - - "examples/espidf-arduino-h2zero-BLE_scan" - "examples/espidf-arduino-matter-light" - - "examples/arduino-matter-light" - "examples/espidf-arduino-blink" - "examples/espidf-arduino-littlefs" - "examples/espidf-blink" diff --git a/examples/arduino-NimBLE-ext_client/README.md b/examples/arduino-NimBLE-ext_client/README.md new file mode 100644 index 000000000..be15da92d --- /dev/null +++ b/examples/arduino-NimBLE-ext_client/README.md @@ -0,0 +1,5 @@ +# NimBLE_extended_client example using h2zero Arduino NimBLE stack + +BLE 5 client example, using the great [h2zero NimBLE](https://github.com/h2zero/NimBLE-Arduino) implementation. + +Thx @h2zero for the great BLE library. diff --git a/examples/espidf-arduino-h2zero-BLE_scan/include/README b/examples/arduino-NimBLE-ext_client/include/README similarity index 100% rename from examples/espidf-arduino-h2zero-BLE_scan/include/README rename to examples/arduino-NimBLE-ext_client/include/README diff --git a/examples/espidf-arduino-h2zero-BLE_scan/lib/README b/examples/arduino-NimBLE-ext_client/lib/README similarity index 100% rename from examples/espidf-arduino-h2zero-BLE_scan/lib/README rename to examples/arduino-NimBLE-ext_client/lib/README diff --git a/examples/arduino-NimBLE-ext_client/platformio.ini b/examples/arduino-NimBLE-ext_client/platformio.ini new file mode 100644 index 000000000..0991425fe --- /dev/null +++ b/examples/arduino-NimBLE-ext_client/platformio.ini @@ -0,0 +1,53 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env] +platform = espressif32 +framework = arduino +monitor_speed = 115200 +build_flags = + '-DCONFIG_BT_NIMBLE_EXT_ADV=1' +lib_deps = + https://github.com/h2zero/NimBLE-Arduino +lib_ignore = + BLE + BluetoothSerial + SimpleBLE + WiFiProv +custom_component_remove = + espressif/esp_hosted + espressif/esp_wifi_remote + espressif/esp-dsp + espressif/network_provisioning + espressif/esp_rainmaker + espressif/rmaker_common + espressif/esp_insights + espressif/esp_diag_data_store + espressif/esp_diagnostics + espressif/libsodium + espressif/esp-modbus + espressif/esp-cbor + espressif/esp-sr + espressif/esp32-camera + +[env:esp32s3] +board = esp32-s3-devkitc-1 + +[env:esp32c2] +board = esp32-c2-devkitm-1 + +[env:esp32c3] +board = esp32-c3-devkitm-1 + +[env:esp32c6] +board = esp32-c6-devkitm-1 + +[env:esp32h2] +board = esp32-h2-devkitm-1 diff --git a/examples/arduino-NimBLE-ext_client/src/NimBLE_extended_client.ino b/examples/arduino-NimBLE-ext_client/src/NimBLE_extended_client.ino new file mode 100644 index 000000000..5062d4039 --- /dev/null +++ b/examples/arduino-NimBLE-ext_client/src/NimBLE_extended_client.ino @@ -0,0 +1,150 @@ + +/** NimBLE Extended Client Demo: + * + * Demonstrates the Bluetooth 5.x client capabilities. + * + * Created: on April 2 2022 + * Author: H2zero + * + */ + +#include +#include +#if !CONFIG_BT_NIMBLE_EXT_ADV +# error Must enable extended advertising, see nimconfig.h file. +#endif + +#define SERVICE_UUID "ABCD" +#define CHARACTERISTIC_UUID "1234" + +static const NimBLEAdvertisedDevice* advDevice; +static bool doConnect = false; +static uint32_t scanTime = 10 * 1000; // In milliseconds, 0 = scan forever + +/** Define the PHY's to use when connecting to peer devices, can be 1, 2, or all 3 (default).*/ +static uint8_t connectPhys = BLE_GAP_LE_PHY_CODED_MASK | BLE_GAP_LE_PHY_1M_MASK /*| BLE_GAP_LE_PHY_2M_MASK */; + +/** Define a class to handle the callbacks for client connection events */ +class ClientCallbacks : public NimBLEClientCallbacks { + void onConnect(NimBLEClient* pClient) override { Serial.printf("Connected\n"); }; + + void onDisconnect(NimBLEClient* pClient, int reason) override { + Serial.printf("%s Disconnected, reason = %d - Starting scan\n", pClient->getPeerAddress().toString().c_str(), reason); + NimBLEDevice::getScan()->start(scanTime); + } +} clientCallbacks; + +/** Define a class to handle the callbacks when advertisements are received */ +class scanCallbacks : public NimBLEScanCallbacks { + void onResult(const NimBLEAdvertisedDevice* advertisedDevice) override { + Serial.printf("Advertised Device found: %s\n", advertisedDevice->toString().c_str()); + if (advertisedDevice->isAdvertisingService(NimBLEUUID("ABCD"))) { + Serial.printf("Found Our Service\n"); + doConnect = true; + /** Save the device reference in a global for the client to use*/ + advDevice = advertisedDevice; + /** stop scan before connecting */ + NimBLEDevice::getScan()->stop(); + } + } + + /** Callback to process the results of the completed scan or restart it */ + void onScanEnd(const NimBLEScanResults& results, int rc) override { Serial.printf("Scan Ended\n"); } +} scanCallbacks; + +/** Handles the provisioning of clients and connects / interfaces with the server */ +bool connectToServer() { + NimBLEClient* pClient = nullptr; + + pClient = NimBLEDevice::createClient(); + pClient->setClientCallbacks(&clientCallbacks, false); + + /** + * Set the PHY's to use for this connection. This is a bitmask that represents the PHY's: + * * 0x01 BLE_GAP_LE_PHY_1M_MASK + * * 0x02 BLE_GAP_LE_PHY_2M_MASK + * * 0x04 BLE_GAP_LE_PHY_CODED_MASK + * Combine these with OR ("|"), eg BLE_GAP_LE_PHY_1M_MASK | BLE_GAP_LE_PHY_2M_MASK | BLE_GAP_LE_PHY_CODED_MASK; + */ + pClient->setConnectPhy(connectPhys); + + /** Set how long we are willing to wait for the connection to complete (milliseconds), default is 30000. */ + pClient->setConnectTimeout(10 * 1000); + + if (!pClient->connect(advDevice)) { + /** Created a client but failed to connect, don't need to keep it as it has no data */ + NimBLEDevice::deleteClient(pClient); + Serial.printf("Failed to connect, deleted client\n"); + return false; + } + + Serial.printf("Connected to: %s RSSI: %d\n", pClient->getPeerAddress().toString().c_str(), pClient->getRssi()); + + /** Now we can read/write/subscribe the characteristics of the services we are interested in */ + NimBLERemoteService* pSvc = nullptr; + NimBLERemoteCharacteristic* pChr = nullptr; + + pSvc = pClient->getService(SERVICE_UUID); + if (pSvc) { + pChr = pSvc->getCharacteristic(CHARACTERISTIC_UUID); + if (pChr) { + if (pChr->canRead()) { + std::string value = pChr->readValue(); + Serial.printf("Characteristic value: %s\n", value.c_str()); + } + } + + } else { + Serial.printf("ABCD service not found.\n"); + } + + NimBLEDevice::deleteClient(pClient); + Serial.printf("Done with this device!\n"); + return true; +} + +void setup() { + Serial.begin(115200); + Serial.printf("Starting NimBLE Client\n"); + + /** Initialize NimBLE and set the device name */ + NimBLEDevice::init("NimBLE Extended Client"); + + /** Create aNimBLE Scan instance and set the callbacks for scan events */ + NimBLEScan* pScan = NimBLEDevice::getScan(); + pScan->setScanCallbacks(&scanCallbacks); + + /** Set scan interval (how often) and window (how long) in milliseconds */ + pScan->setInterval(97); + pScan->setWindow(67); + + /** + * Active scan will gather scan response data from advertisers + * but will use more energy from both devices + */ + pScan->setActiveScan(true); + + /** + * Start scanning for advertisers for the scan time specified (in milliseconds) 0 = forever + * Optional callback for when scanning stops. + */ + pScan->start(scanTime); + + Serial.printf("Scanning for peripherals\n"); +} + +void loop() { + /** Loop here until we find a device we want to connect to */ + if (doConnect) { + if (connectToServer()) { + Serial.printf("Success!, scanning for more!\n"); + } else { + Serial.printf("Failed to connect, starting scan\n"); + } + + doConnect = false; + NimBLEDevice::getScan()->start(scanTime); + } + + delay(10); +} diff --git a/examples/espidf-arduino-h2zero-BLE_scan/.gitignore b/examples/espidf-arduino-h2zero-BLE_scan/.gitignore deleted file mode 100644 index b9f3806a2..000000000 --- a/examples/espidf-arduino-h2zero-BLE_scan/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.pio -.vscode diff --git a/examples/espidf-arduino-h2zero-BLE_scan/CMakeLists.txt b/examples/espidf-arduino-h2zero-BLE_scan/CMakeLists.txt deleted file mode 100644 index b6275f681..000000000 --- a/examples/espidf-arduino-h2zero-BLE_scan/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 3.16.0) -include($ENV{IDF_PATH}/tools/cmake/project.cmake) -add_compile_definitions(ARDUINO_ARCH_ESP32=1) -project(Arduino_IDF_BLE_scan) diff --git a/examples/espidf-arduino-h2zero-BLE_scan/README.md b/examples/espidf-arduino-h2zero-BLE_scan/README.md deleted file mode 100644 index 5601e540c..000000000 --- a/examples/espidf-arduino-h2zero-BLE_scan/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Arduino_IDF_BLE_scan example using 3rd party NimBLE stack - -BLE scan example, using the great h2zero NimBLE implementation. The needed NimBLE lib is loaded via the IDF component manager -> `idf_component.yml`. -Mandantory not to forget to switch Arduino included BLE libs. -Done in `sdkconfig.defaults` - -Thx @h2zero for the great BLE library. diff --git a/examples/espidf-arduino-h2zero-BLE_scan/platformio.ini b/examples/espidf-arduino-h2zero-BLE_scan/platformio.ini deleted file mode 100644 index 7b9a51745..000000000 --- a/examples/espidf-arduino-h2zero-BLE_scan/platformio.ini +++ /dev/null @@ -1,27 +0,0 @@ -; PlatformIO Project Configuration File -; -; Build options: build flags, source filter -; Upload options: custom upload port, speed and extra flags -; Library options: dependencies, extra library storages -; Advanced options: extra scripting -; -; Please visit documentation for the other options and examples -; https://docs.platformio.org/page/projectconf.html - -[env] -platform = espressif32 -framework = arduino, espidf -monitor_speed = 115200 -board_build.embed_txtfiles = - managed_components/espressif__esp_insights/server_certs/https_server.crt - managed_components/espressif__esp_rainmaker/server_certs/rmaker_mqtt_server.crt - managed_components/espressif__esp_rainmaker/server_certs/rmaker_claim_service_server.crt - managed_components/espressif__esp_rainmaker/server_certs/rmaker_ota_server.crt -lib_ignore = - BLE - BluetoothSerial - SimpleBLE - WiFiProv - -[env:esp32] -board = esp32dev diff --git a/examples/espidf-arduino-h2zero-BLE_scan/sdkconfig.defaults b/examples/espidf-arduino-h2zero-BLE_scan/sdkconfig.defaults deleted file mode 100644 index 267ca7f35..000000000 --- a/examples/espidf-arduino-h2zero-BLE_scan/sdkconfig.defaults +++ /dev/null @@ -1,34 +0,0 @@ -# CONFIG_AUTOSTART_ARDUINO is not set -# CONFIG_WS2812_LED_ENABLE is not set -CONFIG_FREERTOS_HZ=1000 -CONFIG_MBEDTLS_PSK_MODES=y -CONFIG_MBEDTLS_KEY_EXCHANGE_PSK=y -CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y -CONFIG_COMPILER_OPTIMIZATION_SIZE=y -CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y -CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE=y - -# Override some defaults so BT stack is enabled -# in this example -# -# BT config -# -CONFIG_BT_ENABLED=y -CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y -CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=n -CONFIG_BTDM_CTRL_MODE_BTDM=n -CONFIG_BT_BLUEDROID_ENABLED=n -CONFIG_BT_NIMBLE_ENABLED=y - -# -# Arduino Configuration -# -# -# Disable all Arduino included BLE libraries -# -CONFIG_ARDUINO_SELECTIVE_COMPILATION=y -# CONFIG_ARDUINO_SELECTIVE_WiFiProv is not set -# CONFIG_ARDUINO_SELECTIVE_BLE is not set -# CONFIG_ARDUINO_SELECTIVE_BluetoothSerial is not set -# CONFIG_ARDUINO_SELECTIVE_SimpleBLE is not set -# end of Arduino Configuration \ No newline at end of file diff --git a/examples/espidf-arduino-h2zero-BLE_scan/src/CMakeLists.txt b/examples/espidf-arduino-h2zero-BLE_scan/src/CMakeLists.txt deleted file mode 100644 index 483bc0cfc..000000000 --- a/examples/espidf-arduino-h2zero-BLE_scan/src/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -# This file was automatically generated for projects -# without default 'CMakeLists.txt' file. - -FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/src/*.*) - -idf_component_register(SRCS ${app_sources}) diff --git a/examples/espidf-arduino-h2zero-BLE_scan/src/idf_component.yml b/examples/espidf-arduino-h2zero-BLE_scan/src/idf_component.yml deleted file mode 100644 index 0d925b9bd..000000000 --- a/examples/espidf-arduino-h2zero-BLE_scan/src/idf_component.yml +++ /dev/null @@ -1,41 +0,0 @@ -dependencies: - # Required IDF version - idf: ">=4.4" - - esp-nimble-cpp: - git: https://github.com/h2zero/esp-nimble-cpp.git - version: 877a29a8b1d0022c5e8f67ba8b879316e67b6c3d - - - # # Defining a dependency from the registry: - # # https://components.espressif.com/component/example/cmp - # example/cmp: "^3.3.3" # Automatically update minor releases - # - # # Other ways to define dependencies - # - # # For components maintained by Espressif only name can be used. - # # Same as `espressif/cmp` - # component: "~1.0.0" # Automatically update bugfix releases - # - # # Or in a longer form with extra parameters - # component2: - # version: ">=2.0.0" - # - # # For transient dependencies `public` flag can be set. - # # `public` flag doesn't have an effect for the `main` component. - # # All dependencies of `main` are public by default. - # public: true - # - # # For components hosted on non-default registry: - # service_url: "https://componentregistry.company.com" - # - # # For components in git repository: - # test_component: - # path: test_component - # git: ssh://git@gitlab.com/user/components.git - # - # # For test projects during component development - # # components can be used from a local directory - # # with relative or absolute path - # some_local_component: - # path: ../../projects/component diff --git a/examples/espidf-arduino-h2zero-BLE_scan/src/main.cpp b/examples/espidf-arduino-h2zero-BLE_scan/src/main.cpp deleted file mode 100644 index 04b6e5f0d..000000000 --- a/examples/espidf-arduino-h2zero-BLE_scan/src/main.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleScan.cpp - Ported to Arduino ESP32 by Evandro Copercini - Refactored back to IDF by H2zero -*/ - -/** NimBLE differences highlighted in comment blocks **/ - -/*******original******** -#include -#include -#include -#include -***********************/ - -#include - -#include - -extern "C"{void app_main(void);} - -int scanTime = 5 * 1000; // In milliseconds, 0 = scan forever -BLEScan* pBLEScan; - -class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks { - void onResult(BLEAdvertisedDevice* advertisedDevice) { - printf("Advertised Device: %s \n", advertisedDevice->toString().c_str()); - } -}; - -void scanTask (void * parameter){ - for(;;) { - // put your main code here, to run repeatedly: - BLEScanResults foundDevices = pBLEScan->getResults(scanTime, false); - printf("Devices found: %d\n", foundDevices.getCount()); - printf("Scan done!\n"); - pBLEScan->clearResults(); // delete results fromBLEScan buffer to release memory - vTaskDelay(2000/portTICK_PERIOD_MS); // Delay a second between loops. - } - - vTaskDelete(NULL); -} - -void app_main(void) { - printf("Scanning...\n"); - - BLEDevice::init(""); - pBLEScan = BLEDevice::getScan(); //create new scan - pBLEScan->setScanCallbacks(new MyAdvertisedDeviceCallbacks()); - pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster - pBLEScan->setInterval(100); - pBLEScan->setWindow(99); // less or equal setInterval value - xTaskCreate(scanTask, "scanTask", 5000, NULL, 1, NULL); -}