Arduino 3.1.x based on IDF 5.3.x (#74)
* IDF 5.3 support * IDF 5.3 * IDF 5.3 toolchains remove dynamic toolchains support, currently only older incompatible are possible to fetch. * Fix owner of * ULP compability for IDF 5.3 * remove debug print * Fix bootloader offset code retrieve * Update esp32-c6-devkitc-1.json * use espressif Arduino branch `release/v3.1.x` * Update README.md * Update README.md * Fix compile issue with managed components * use latest Arduino 3.1.0 libs * fetch Arduino libs dl URL from manifest json * fetch Arduino libs dl URL from manifest json * Update README.md * Fix IDF 5.3 ULP compile * Use espressif Arduino branch release/v3.1.x * Update platform.py * better handling of complex Macros from cmake model * IDF 5.3.1 release * fix handling of cc fragments * unchanged IDF 5.3.1 * ULP has now a cmake build script * add arduino/idf examples * fix used platform * prepare LP ULP support * enable bootloader components build * ULP LP support * add missing P4 * add P4 * change some if checks * Update README.md * remove wrong left over code * add ULP LP example / update Matter example * fix path * add zigbee examples * disable zigbee examples needs merge of the open zigbee Arduino PR * esptool.py v4.8.0 * add cmake_utilities for C2 * add auto select "espidf" when pio var "custom_sdkconfig" is set * IDF v5.3.1.240924 * Update main.py * matter example currently broken * Update platformio.ini * Update platformio.ini * Update platformio.ini * Update platformio.ini * Update examples.yml * IDF v5.3.1.241016 * Update Zigbee_On_Off_Light.ino * Update Zigbee_On_Off_Switch.ino * Update examples.yml * Update platformio.ini * Update platformio.ini * Update examples.yml * esptool.py v4.8.1.1 s2 s3 usb jtag reset fix * Update platform.py * Update gdb 14.2.0+20240403 * fix owner for gdb * Update IDF v5.3.1.241024 * Update adafruit_matrixportal_esp32s3.json * Use compatible h2zero NimBLE git commit * Update Zigbee_On_Off_Light.ino * Update Zigbee_On_Off_Switch.ino * fix custom partiton table offset calculation * Update README.md * Create esp32-p4.json * add P4 to blink example * Update Zigbee_On_Off_Switch.ino * Update Zigbee_On_Off_Light.ino * Update sdkconfig.defaults * add P4 to LP example * Create esp32-p4-evboard.json * IDF 5.3.2 release * prep for "pioarduino-build.py" script * add missing import os * fix not defined var * Update Zigbee_On_Off_Switch.ino * esptool.py v4.8.5 * Update Zigbee_On_Off_Light.ino * add Hybrid Compile (#73) * Update README.md * set Arduino compile option `UPDATE_NOCRYPT` in example Tasmota * Update C2 Hybrid compile skeleton * Update IDF v5.3.2.241210 * Revert to IDF 5.3.2 * Update pioarduino IDF 5.2 * Update release_zips.yml
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"build": {
|
||||
"arduino":{
|
||||
"ldscript": "esp32s3_out.ld",
|
||||
"partitions": "partitions-8MB-tinyuf2.csv"
|
||||
"partitions": "tinyuf2-partitions-8MB.csv",
|
||||
"memory_type": "qio_qspi"
|
||||
},
|
||||
"core": "esp32",
|
||||
"extra_flags": [
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"build": {
|
||||
"core": "esp32",
|
||||
"extra_flags": [
|
||||
"-DBOARD_HAS_PSRAM"
|
||||
],
|
||||
"f_cpu": "360000000L",
|
||||
"f_flash": "80000000L",
|
||||
"flash_mode": "qio",
|
||||
"mcu": "esp32p4",
|
||||
"variant": "esp32p4"
|
||||
},
|
||||
"arduino": {
|
||||
"partitions": "default_16MB.csv"
|
||||
},
|
||||
"connectivity": [
|
||||
"bluetooth",
|
||||
"openthread"
|
||||
],
|
||||
"debug": {
|
||||
"openocd_target": "esp32p4.cfg"
|
||||
},
|
||||
"frameworks": [
|
||||
"arduino",
|
||||
"espidf"
|
||||
],
|
||||
"name": "Espressif ESP32-P4 Function EV Board",
|
||||
"upload": {
|
||||
"flash_size": "16MB",
|
||||
"maximum_ram_size": 512000,
|
||||
"maximum_size": 16777216,
|
||||
"require_upload_port": true,
|
||||
"speed": 1500000
|
||||
},
|
||||
"url": "https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32p4/esp32-p4-function-ev-board/index.html",
|
||||
"vendor": "Espressif"
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"build": {
|
||||
"core": "esp32",
|
||||
"extra_flags": [
|
||||
"-DBOARD_HAS_PSRAM"
|
||||
],
|
||||
"f_cpu": "360000000L",
|
||||
"f_flash": "80000000L",
|
||||
"flash_mode": "qio",
|
||||
"mcu": "esp32p4",
|
||||
"variant": "esp32p4"
|
||||
},
|
||||
"connectivity": [
|
||||
"bluetooth",
|
||||
"openthread"
|
||||
],
|
||||
"debug": {
|
||||
"openocd_target": "esp32p4.cfg"
|
||||
},
|
||||
"frameworks": [
|
||||
"arduino",
|
||||
"espidf"
|
||||
],
|
||||
"name": "Espressif ESP32-P4 generic",
|
||||
"upload": {
|
||||
"flash_size": "4MB",
|
||||
"maximum_ram_size": 327680,
|
||||
"maximum_size": 4194304,
|
||||
"require_upload_port": true,
|
||||
"speed": 460800
|
||||
},
|
||||
"url": "https://docs.espressif.com",
|
||||
"vendor": "Espressif"
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
"build": {
|
||||
"core": "esp32",
|
||||
"extra_flags": "-DARDUINO_ESP32_DEV -DARDUINO_USB_CDC_ON_BOOT=0 -DCORE32SOLO1",
|
||||
"f_cpu": "80000000L",
|
||||
"f_cpu": "160000000L",
|
||||
"f_flash": "40000000L",
|
||||
"flash_mode": "dio",
|
||||
"mcu": "esp32",
|
||||
@@ -29,6 +29,11 @@
|
||||
"require_upload_port": true,
|
||||
"speed": 460800
|
||||
},
|
||||
"espidf": {
|
||||
"custom_sdkconfig": [
|
||||
"CONFIG_FREERTOS_UNICORE=y"
|
||||
]
|
||||
},
|
||||
"url": "https://en.wikipedia.org/wiki/ESP32",
|
||||
"vendor": "Espressif"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"build": {
|
||||
"arduino": {
|
||||
"memory_type": "qio_opi",
|
||||
"partitions": "default_16MB.csv"
|
||||
},
|
||||
"core": "esp32",
|
||||
"f_cpu": "240000000L",
|
||||
"f_flash": "80000000L",
|
||||
"f_boot": "120000000L",
|
||||
"boot": "qio",
|
||||
"flash_mode": "qio",
|
||||
"extra_flags": [
|
||||
"-DBOARD_HAS_PSRAM",
|
||||
"-DARDUINO_USB_MODE=1",
|
||||
"-DARDUINO_USB_CDC_ON_BOOT=1",
|
||||
"-DARDUINO_RUNNING_CORE=1",
|
||||
"-DARDUINO_EVENT_RUNNING_CORE=1"
|
||||
],
|
||||
"hwids": [
|
||||
[
|
||||
"0x303A",
|
||||
"0x1001"
|
||||
]
|
||||
],
|
||||
"mcu": "esp32s3",
|
||||
"variant": "esp32s3"
|
||||
},
|
||||
"connectivity": [
|
||||
"bluetooth",
|
||||
"wifi"
|
||||
],
|
||||
"debug": {
|
||||
"openocd_target": "esp32s3.cfg"
|
||||
},
|
||||
"frameworks": [
|
||||
"arduino",
|
||||
"espidf"
|
||||
],
|
||||
"name": "ESP32-S3 16MB QIO, 8MB OPI PSRAM",
|
||||
"upload": {
|
||||
"flash_size": "16MB",
|
||||
"maximum_ram_size": 327680,
|
||||
"maximum_size": 16777216,
|
||||
"require_upload_port": true,
|
||||
"speed": 460800
|
||||
},
|
||||
"url": "https://www.espressif.com/sites/default/files/documentation/esp32-s3-wroom-1_wroom-1u_datasheet_en.pdf",
|
||||
"vendor": "espressif"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
idf_component_register(SRCS "sketch.cpp" "arduino-lib-builder-gcc.c" "arduino-lib-builder-cpp.cpp" "arduino-lib-builder-as.S" INCLUDE_DIRS ".")
|
||||
@@ -0,0 +1,12 @@
|
||||
dependencies:
|
||||
# Required IDF version
|
||||
idf: ">=5.1"
|
||||
espressif/cmake_utilities:
|
||||
version: "0.*"
|
||||
espressif/fb_gfx:
|
||||
version: "master"
|
||||
path: components/fb_gfx
|
||||
git: https://github.com/espressif/esp32-arduino-lib-builder.git
|
||||
require: public
|
||||
rules:
|
||||
- if: "target in [esp32, esp32s2, esp32s3, esp32p4]"
|
||||
@@ -0,0 +1,10 @@
|
||||
#include "Arduino.h"
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.println("Hello World!");
|
||||
delay(1000);
|
||||
}
|
||||
@@ -110,14 +110,14 @@ env.Append(
|
||||
" ".join(
|
||||
[
|
||||
"riscv32-esp-elf-objcopy"
|
||||
if mcu in ("esp32c2","esp32c3","esp32c6","esp32h2")
|
||||
if mcu in ("esp32c2","esp32c3","esp32c6","esp32h2","esp32p4")
|
||||
else "xtensa-%s-elf-objcopy" % mcu,
|
||||
"--input-target",
|
||||
"binary",
|
||||
"--output-target",
|
||||
"elf32-littleriscv" if mcu in ("esp32c2","esp32c3","esp32c6","esp32h2") else "elf32-xtensa-le",
|
||||
"elf32-littleriscv" if mcu in ("esp32c2","esp32c3","esp32c6","esp32h2","esp32p4") else "elf32-xtensa-le",
|
||||
"--binary-architecture",
|
||||
"riscv" if mcu in ("esp32c2","esp32c3","esp32c6","esp32h2") else "xtensa",
|
||||
"riscv" if mcu in ("esp32c2","esp32c3","esp32c6","esp32h2","esp32p4") else "xtensa",
|
||||
"--rename-section",
|
||||
".data=.rodata.embedded",
|
||||
"$SOURCE",
|
||||
|
||||
+11
-8
@@ -131,7 +131,7 @@ def _parse_partitions(env):
|
||||
|
||||
result = []
|
||||
next_offset = 0
|
||||
bound = int(board.get("upload.offset_address", "0x10000"), 16) # default 0x10000
|
||||
app_offset = int(board.get("upload.offset_address", "0x10000"), 16) # default 0x10000
|
||||
with open(partitions_csv) as fp:
|
||||
for line in fp.readlines():
|
||||
line = line.strip()
|
||||
@@ -140,23 +140,25 @@ def _parse_partitions(env):
|
||||
tokens = [t.strip() for t in line.split(",")]
|
||||
if len(tokens) < 5:
|
||||
continue
|
||||
bound = 0x10000 if tokens[1] in ("0", "app") else 4
|
||||
calculated_offset = (next_offset + bound - 1) & ~(bound - 1)
|
||||
partition = {
|
||||
"name": tokens[0],
|
||||
"type": tokens[1],
|
||||
"subtype": tokens[2],
|
||||
"offset": tokens[3] or next_offset,
|
||||
"offset": tokens[3] or calculated_offset,
|
||||
"size": tokens[4],
|
||||
"flags": tokens[5] if len(tokens) > 5 else None
|
||||
}
|
||||
result.append(partition)
|
||||
next_offset = _parse_size(partition["offset"])
|
||||
if (partition["subtype"] == "ota_0"):
|
||||
bound = next_offset
|
||||
next_offset = (next_offset + bound - 1) & ~(bound - 1)
|
||||
app_offset = next_offset
|
||||
next_offset = next_offset + _parse_size(partition["size"])
|
||||
# Configure application partition offset
|
||||
env.Replace(ESP32_APP_OFFSET=str(hex(bound)))
|
||||
env.Replace(ESP32_APP_OFFSET=str(hex(app_offset)))
|
||||
# Propagate application offset to debug configurations
|
||||
env["INTEGRATION_EXTRA_DATA"].update({"application_offset": str(hex(bound))})
|
||||
env["INTEGRATION_EXTRA_DATA"].update({"application_offset": str(hex(app_offset))})
|
||||
return result
|
||||
|
||||
|
||||
@@ -232,7 +234,7 @@ board = env.BoardConfig()
|
||||
mcu = board.get("build.mcu", "esp32")
|
||||
toolchain_arch = "xtensa-%s" % mcu
|
||||
filesystem = board.get("build.filesystem", "spiffs")
|
||||
if mcu in ("esp32c2", "esp32c3", "esp32c6", "esp32h2"):
|
||||
if mcu in ("esp32c2", "esp32c3", "esp32c6", "esp32h2", "esp32p4"):
|
||||
toolchain_arch = "riscv32-esp"
|
||||
|
||||
if "INTEGRATION_EXTRA_DATA" not in env:
|
||||
@@ -253,7 +255,7 @@ env.Replace(
|
||||
GDB=join(
|
||||
platform.get_package_dir(
|
||||
"tool-riscv32-esp-elf-gdb"
|
||||
if mcu in ("esp32c2", "esp32c3", "esp32c6")
|
||||
if mcu in ("esp32c2", "esp32c3", "esp32c6", "esp32h2", "esp32p4")
|
||||
else "tool-xtensa-esp-elf-gdb"
|
||||
)
|
||||
or "",
|
||||
@@ -298,6 +300,7 @@ env.Replace(
|
||||
),
|
||||
|
||||
ESP32_APP_OFFSET=env.get("INTEGRATION_EXTRA_DATA").get("application_offset"),
|
||||
ARDUINO_LIB_COMPILE_FLAG="Inactive",
|
||||
|
||||
PROGSUFFIX=".elf"
|
||||
)
|
||||
|
||||
@@ -7,22 +7,104 @@
|
||||
; Please visit documentation for the other options and examples
|
||||
; http://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[env:esp-wrover-kit]
|
||||
[env:esp32solo1]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
board = esp-wrover-kit
|
||||
board = esp32-solo1
|
||||
build_flags = -DLED_BUILTIN=2
|
||||
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:esp32-c2-devkitm-1]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
board = esp32-c2-devkitm-1
|
||||
monitor_speed = 115200
|
||||
build_flags =
|
||||
-DLED_BUILTIN=2
|
||||
custom_sdkconfig = 'CONFIG_IDF_TARGET="esp32c2"'
|
||||
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
|
||||
framework = arduino
|
||||
board = esp32s3_120_16_8-qio_opi
|
||||
custom_sdkconfig = CONFIG_SPIRAM_MODE_OCT=y
|
||||
CONFIG_SPIRAM_SPEED_120M=y
|
||||
CONFIG_LCD_RGB_ISR_IRAM_SAFE=y
|
||||
CONFIG_GDMA_CTRL_FUNC_IN_IRAM=y
|
||||
CONFIG_I2S_ISR_IRAM_SAFE=y
|
||||
CONFIG_GDMA_ISR_IRAM_SAFE=y
|
||||
CONFIG_SPIRAM_XIP_FROM_PSRAM=y
|
||||
CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y
|
||||
CONFIG_SPIRAM_RODATA=y
|
||||
CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y
|
||||
CONFIG_ESP32S3_DATA_CACHE_64KB=y
|
||||
CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y
|
||||
custom_component_remove = espressif/esp_hosted
|
||||
espressif/esp_wifi_remote
|
||||
espressif/qrcode
|
||||
espressif/esp_insights
|
||||
espressif/esp_diag_data_store
|
||||
espressif/esp_diagnostics
|
||||
espressif/esp_rainmaker
|
||||
espressif/rmaker_common
|
||||
custom_component_add = lvgl/lvgl @ ^9.2.2
|
||||
|
||||
[env:esp32-c6-devkitc-1]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
board = esp32-c6-devkitc-1
|
||||
monitor_speed = 115200
|
||||
custom_component_remove = espressif/esp_hosted
|
||||
espressif/esp_wifi_remote
|
||||
espressif/mdns
|
||||
espressif/esp-dsp
|
||||
espressif/esp_modem
|
||||
espressif/esp32-camera
|
||||
|
||||
[env:esp32-h2-devkitm-1]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
board = esp32-h2-devkitm-1
|
||||
monitor_speed = 115200
|
||||
custom_component_remove = espressif/esp_hosted
|
||||
espressif/esp_wifi_remote
|
||||
espressif/mdns
|
||||
espressif/esp-dsp
|
||||
espressif/esp_modem
|
||||
espressif/esp32-camera
|
||||
|
||||
[env:esp32-p4]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
board = esp32-p4
|
||||
build_flags = -DLED_BUILTIN=2
|
||||
monitor_speed = 115200
|
||||
custom_component_remove = espressif/esp_hosted
|
||||
espressif/esp_wifi_remote
|
||||
espressif/mdns
|
||||
espressif/esp-dsp
|
||||
espressif/esp_modem
|
||||
espressif/esp32-camera
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(lp_core_pulse_counter)
|
||||
@@ -0,0 +1,51 @@
|
||||
| Supported Targets | ESP32-C6 |
|
||||
| ----------------- | -------- |
|
||||
|
||||
This example demonstrates how to program the ULP Core coprocessor to count pulses on an IO while the main CPUs are either running some other code or are in deep sleep. See the README.md file in the upper level 'examples' directory for more information about examples.
|
||||
|
||||
At runtime, the main code running on the ESP (found in lp_core_pulse_counter_example_main.c) loads ULP program into the `RTC_SLOW_MEM` memory region using `ulp_lp_core_load_binary` function. Main code configures the ULP program by setting up values of some variables and then starts it using `ulp_lp_core_run`. Once the ULP program is started, it monitors the IO pin for pulses.
|
||||
|
||||
When the ULP program finds an edge in the input signal, it performs debouncing and increments the variable maintaining the total edge count. Once the edge count reaches certain value, ULP triggers wake up from deep sleep. Note that the ULP program keeps running and monitoring the input signal even when the SoC is woken up.
|
||||
|
||||
### Hardware Required
|
||||
|
||||
To run this example, you should have a development board based on any of the chips listed in the supported targets table at the top and a host machine with a serial input connection.
|
||||
|
||||
#### Pin Assignment:
|
||||
|
||||
**Note:** The following pin assignments are used by default.
|
||||
|
||||
|
||||
| | Uart Tx | Pulse Count Input |
|
||||
| ----------------------- | ------- | ----------------- |
|
||||
| ESP32-C6 | GPIO5 | GPIO6 |
|
||||
| Host machine | Rx | N/A |
|
||||
|
||||
|
||||
## Example Output
|
||||
|
||||
The log output from the serial monitor connected to the main core should indicate that the LP core and the LP UART peripheral have been successfully initialized. The main CPU would then enter deep sleep mode.
|
||||
|
||||
```bash
|
||||
Using pin 6 as pulse counter input
|
||||
ULP will wake up processor after every 10 pulses
|
||||
Not a ULP wakeup, initializing it!
|
||||
Entering in deep sleep
|
||||
...
|
||||
rst:0x5 (SLEEP_WAKEUP),boot:0xc (SPI_FAST_FLASH_BOOT)
|
||||
...
|
||||
ULP woke up the main CPU!
|
||||
Pulse count: 11
|
||||
Entering in deep sleep
|
||||
```
|
||||
|
||||
The log output from the serial monitor connected to the LP core should display output as below -
|
||||
|
||||
```bash
|
||||
LP Core pulse counter started
|
||||
Pulse count: 10, wake-up main CPU
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
(For any technical queries, please open an [issue](https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you as soon as possible.)
|
||||
@@ -0,0 +1,18 @@
|
||||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter, extra scripting
|
||||
; Upload options: custom port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; http://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[env:esp32-c6]
|
||||
platform = espressif32
|
||||
framework = espidf
|
||||
board = esp32-c6-devkitc-1
|
||||
|
||||
[env:esp32-p4]
|
||||
platform = espressif32
|
||||
framework = espidf
|
||||
board = esp32-p4
|
||||
@@ -0,0 +1,30 @@
|
||||
# SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
import logging
|
||||
|
||||
import pytest
|
||||
from pytest_embedded import Dut
|
||||
|
||||
|
||||
@pytest.mark.esp32c6
|
||||
@pytest.mark.esp32p4
|
||||
@pytest.mark.generic
|
||||
def test_lp_core_pcnt(dut: Dut) -> None:
|
||||
|
||||
res = dut.expect(r'ULP will wake up processor after every (\d+) pulses')
|
||||
wakeup_limit = res.group(1).decode('utf-8')
|
||||
assert (int(wakeup_limit) > 0)
|
||||
logging.info(f'Wake-up limit: {wakeup_limit} pulses')
|
||||
|
||||
dut.expect_exact('Not a ULP wakeup, initializing it!')
|
||||
dut.expect_exact('Entering in deep sleep')
|
||||
|
||||
dut.expect_exact('ULP woke up the main CPU!')
|
||||
|
||||
res = dut.expect(r'Pulse count: (\d+)')
|
||||
pulse_count = res.group(1).decode('utf-8')
|
||||
logging.info(f'Pulse count: {pulse_count}')
|
||||
|
||||
# Check that pulse count is correct, we could have gotten pulses between triggering
|
||||
# the wakeup signal and printing the count, but it should at be equal to or greater
|
||||
assert (int(pulse_count) >= int(wakeup_limit))
|
||||
@@ -0,0 +1,11 @@
|
||||
#
|
||||
# Ultra Low Power (ULP) Co-processor
|
||||
#
|
||||
CONFIG_ULP_COPROC_ENABLED=y
|
||||
CONFIG_ULP_COPROC_TYPE_LP_CORE=y
|
||||
CONFIG_ULP_COPROC_RESERVE_MEM=8128
|
||||
# Set log level to Warning to produce clean output
|
||||
CONFIG_BOOTLOADER_LOG_LEVEL_WARN=y
|
||||
CONFIG_BOOTLOADER_LOG_LEVEL=2
|
||||
CONFIG_LOG_DEFAULT_LEVEL_WARN=y
|
||||
CONFIG_LOG_DEFAULT_LEVEL=2
|
||||
@@ -0,0 +1,23 @@
|
||||
idf_component_register(SRCS "lp_core_pulse_counter_example_main.c"
|
||||
INCLUDE_DIRS ".")
|
||||
|
||||
#
|
||||
# ULP support additions to component CMakeLists.txt.
|
||||
#
|
||||
# 1. The ULP app name must be unique (if multiple components use ULP).
|
||||
set(ulp_app_name ulp_main)
|
||||
#
|
||||
# 2. Specify all C and Assembly source files.
|
||||
# Files should be placed into a separate directory (in this case, ulp/),
|
||||
# which should not be added to COMPONENT_SRCS.
|
||||
set(ulp_sources "../ulp/main.c")
|
||||
|
||||
#
|
||||
# 3. List all the component source files which include automatically
|
||||
# generated ULP export file, ${ulp_app_name}.h:
|
||||
set(ulp_exp_dep_srcs "lp_core_pulse_counter_example_main.c")
|
||||
|
||||
#
|
||||
# 4. Call function to build ULP binary and embed in project using the argument
|
||||
# values above.
|
||||
ulp_embed_binary(${ulp_app_name} "${ulp_sources}" "${ulp_exp_dep_srcs}")
|
||||
@@ -0,0 +1,20 @@
|
||||
menu "Example Configuration"
|
||||
config EXAMPLE_PULSE_COUNT_PIN
|
||||
int "Input pin for the pulse counter"
|
||||
default 6
|
||||
help
|
||||
GPIO pin used as the input for the pulse counter
|
||||
|
||||
config EXAMPLE_PULSE_COUNT_WAKEUP_LIMIT
|
||||
int "Wake-up pulse count limit"
|
||||
default 10
|
||||
help
|
||||
Number of pulses counted after which the ULP will wake up the main CPU
|
||||
|
||||
config EXAMPLE_PULSE_COUNT_SIMULATE
|
||||
bool "Simulate pulses on input pin"
|
||||
default n
|
||||
help
|
||||
The ULP will periodically toggle the input pin to simulate pulses
|
||||
|
||||
endmenu
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
/* LP core gpio example
|
||||
|
||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
|
||||
Unless required by applicable law or agreed to in writing, this
|
||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
#include "esp_sleep.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/rtc_io.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "ulp_lp_core.h"
|
||||
#include "ulp_main.h"
|
||||
#include "lp_core_uart.h"
|
||||
|
||||
extern const uint8_t ulp_main_bin_start[] asm("_binary_ulp_main_bin_start");
|
||||
extern const uint8_t ulp_main_bin_end[] asm("_binary_ulp_main_bin_end");
|
||||
|
||||
|
||||
static void init_ulp_program(void);
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
/* If user is using USB-serial-jtag then idf monitor needs some time to
|
||||
* re-connect to the USB port. We wait 1 sec here to allow for it to make the reconnection
|
||||
* before we print anything. Otherwise the chip will go back to sleep again before the user
|
||||
* has time to monitor any output.
|
||||
*/
|
||||
vTaskDelay(pdMS_TO_TICKS(1000));
|
||||
|
||||
/* Initialize selected GPIO as RTC IO, enable input/output, disable pullup and pulldown */
|
||||
printf("Using pin %d as pulse counter input\n", CONFIG_EXAMPLE_PULSE_COUNT_PIN);
|
||||
rtc_gpio_init(CONFIG_EXAMPLE_PULSE_COUNT_PIN);
|
||||
rtc_gpio_set_direction(CONFIG_EXAMPLE_PULSE_COUNT_PIN, RTC_GPIO_MODE_INPUT_OUTPUT);
|
||||
rtc_gpio_pulldown_dis(CONFIG_EXAMPLE_PULSE_COUNT_PIN);
|
||||
rtc_gpio_pullup_dis(CONFIG_EXAMPLE_PULSE_COUNT_PIN);
|
||||
|
||||
printf("ULP will wake up processor after every %d pulses\n", CONFIG_EXAMPLE_PULSE_COUNT_WAKEUP_LIMIT);
|
||||
|
||||
esp_sleep_wakeup_cause_t cause = esp_sleep_get_wakeup_cause();
|
||||
/* not a wakeup from ULP, load the firmware */
|
||||
if (cause != ESP_SLEEP_WAKEUP_ULP) {
|
||||
printf("Not a ULP wakeup, initializing it! \n");
|
||||
init_ulp_program();
|
||||
} else {
|
||||
printf("ULP woke up the main CPU!\n");
|
||||
printf("Pulse count: %"PRIu32"\n", ulp_pulse_count);
|
||||
}
|
||||
|
||||
/* Go back to sleep, only the ULP will run */
|
||||
printf("Entering in deep sleep\n\n");
|
||||
|
||||
/* Small delay to ensure the messages are printed */
|
||||
ESP_ERROR_CHECK( esp_sleep_enable_ulp_wakeup());
|
||||
|
||||
esp_deep_sleep_start();
|
||||
}
|
||||
|
||||
static void init_ulp_program(void)
|
||||
{
|
||||
lp_core_uart_cfg_t uart_cfg = LP_CORE_UART_DEFAULT_CONFIG();
|
||||
|
||||
ESP_ERROR_CHECK(lp_core_uart_init(&uart_cfg));
|
||||
|
||||
esp_err_t err = ulp_lp_core_load_binary(ulp_main_bin_start, (ulp_main_bin_end - ulp_main_bin_start));
|
||||
ESP_ERROR_CHECK(err);
|
||||
|
||||
/* Start the program */
|
||||
ulp_lp_core_cfg_t cfg = {
|
||||
.wakeup_source = ULP_LP_CORE_WAKEUP_SOURCE_HP_CPU,
|
||||
};
|
||||
|
||||
err = ulp_lp_core_run(&cfg);
|
||||
ESP_ERROR_CHECK(err);
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "sdkconfig.h"
|
||||
#include "ulp_lp_core.h"
|
||||
#include "ulp_lp_core_utils.h"
|
||||
#include "ulp_lp_core_gpio.h"
|
||||
#include "ulp_lp_core_interrupts.h"
|
||||
#include "ulp_lp_core_print.h"
|
||||
#include "riscv/csr.h"
|
||||
|
||||
#define DEBOUNCE_INTERVAL_CYCLES 10 // 10 cycles is about 0.625 us at 16 MHz
|
||||
|
||||
#define SIMULATED_PULSE_FREQUENCY_HZ 2
|
||||
#define SIMULATED_PULSE_DELAY_US (1000000 / SIMULATED_PULSE_FREQUENCY_HZ) / 2
|
||||
|
||||
uint32_t pulse_count;
|
||||
static uint32_t last_trigger_time_cycles;
|
||||
|
||||
void LP_CORE_ISR_ATTR ulp_lp_core_lp_io_intr_handler(void)
|
||||
{
|
||||
ulp_lp_core_gpio_clear_intr_status();
|
||||
uint32_t trigger_time_cycles = RV_READ_CSR(mcycle);
|
||||
/* Do some simple debouncing, do not count spurious pulses */
|
||||
if (trigger_time_cycles - last_trigger_time_cycles > DEBOUNCE_INTERVAL_CYCLES) {
|
||||
pulse_count++;
|
||||
last_trigger_time_cycles = trigger_time_cycles;
|
||||
}
|
||||
|
||||
if (pulse_count % CONFIG_EXAMPLE_PULSE_COUNT_WAKEUP_LIMIT == 0) {
|
||||
lp_core_printf("Pulse count: %d, wake-up main CPU\n", pulse_count);
|
||||
ulp_lp_core_wakeup_main_processor();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
lp_core_printf("LP Core pulse counter started\n");
|
||||
ulp_lp_core_intr_enable();
|
||||
ulp_lp_core_gpio_intr_enable(CONFIG_EXAMPLE_PULSE_COUNT_PIN, LP_IO_INTR_POSEDGE);
|
||||
|
||||
while(1) {
|
||||
|
||||
#if CONFIG_EXAMPLE_PULSE_COUNT_SIMULATE
|
||||
/* No external device connected to generate pulses, we simulate them ourselves instead */
|
||||
ulp_lp_core_delay_us(SIMULATED_PULSE_DELAY_US);
|
||||
ulp_lp_core_gpio_set_level(CONFIG_EXAMPLE_PULSE_COUNT_PIN, 1);
|
||||
ulp_lp_core_delay_us(SIMULATED_PULSE_DELAY_US);
|
||||
ulp_lp_core_gpio_set_level(CONFIG_EXAMPLE_PULSE_COUNT_PIN, 0);
|
||||
#else
|
||||
/* Put CPU into a wait state to reduce power consumption while waiting for pulses */
|
||||
ulp_lp_core_wait_for_intr();
|
||||
#endif //CONFIG_EXAMPLE_PULSE_COUNT_SIMULATE
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
[platformio]
|
||||
default_envs = tasmota32-hybrid
|
||||
|
||||
[env:tasmota32_base]
|
||||
platform = file://.
|
||||
|
||||
[env:tasmota32-hybrid]
|
||||
extends = env:tasmota32_base
|
||||
board = esp32
|
||||
build_flags = ${env:tasmota32_base.build_flags}
|
||||
-DHTTPCLIENT_NOSECURE
|
||||
-DUPDATE_NOCRYPT
|
||||
lib_ignore = ${env:tasmota32_base.lib_ignore}
|
||||
Micro-RTSP
|
||||
epdiy
|
||||
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'
|
||||
'# 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
|
||||
espressif/esp-dsp
|
||||
espressif/network_provisioning
|
||||
espressif/esp-zboss-lib
|
||||
espressif/esp-zigbee-lib
|
||||
espressif/esp_rainmaker
|
||||
espressif/rmaker_common
|
||||
espressif/esp_insights
|
||||
espressif/esp_diag_data_store
|
||||
espressif/esp_diagnostics
|
||||
espressif/cbor
|
||||
espressif/qrcode
|
||||
espressif/esp-sr
|
||||
espressif/libsodium
|
||||
espressif/esp-modbus
|
||||
chmorgan/esp-libhelix-mp3
|
||||
espressif/esp32-camera
|
||||
Reference in New Issue
Block a user