Compare commits

..

18 Commits

Author SHA1 Message Date
Jonathan Swoboda 019984dba1 Merge branch 'dev' into jesserockz-2026-375 2026-06-30 07:53:04 -04:00
Jesse Hills 67489f6196 [rp2] Address esphbot review suggestions
* Ethernet: rename ``RP2040_ETHERNET_TYPES`` → ``RP2_ETHERNET_TYPES``
  and ``_RP2040_SPI_LIBRARIES`` → ``_RP2_SPI_LIBRARIES``; update the
  user-facing validation error from "supported on RP2040" to
  "supported on the RP2 platform" so RP2350 (Pico 2) users picking an
  unsupported PHY don't get a misleading message under the family-level
  gate.

* CORE.is_rp2040 now logs a one-shot deprecation warning on first
  access (deduped via CORE.data) to match the parallel
  ``cv.only_on_rp2040`` shim. Same removal target (2027.7.0).
2026-06-30 10:34:27 +12:00
Jesse Hills 71f4e36c66 [scripts] Export deprecated component aliases to the schema dump
``build_language_schema.py`` walked ``esphome/components/`` directly,
so canonical-only directories left their deprecated aliases invisible
to the editor / dashboard autocomplete. Configs migrated only at
runtime via the ``_resolve_component_aliases`` pre-pass would still
light up as unknown top-level keys.

After building the per-component bundles, mirror each canonical
entry under every alias declared via ``ALIASES = [...]``, tagging
the duplicate with ``alias_of`` (canonical name) and
``removal_version`` (when ``ALIAS_REMOVAL_VERSION`` is set). Schema
consumers can render a deprecation hint and point users at the
canonical key without losing autocomplete on legacy configs.
2026-06-30 09:33:12 +12:00
Jesse Hills d30a509173 Merge remote-tracking branch 'origin/dev' into jesserockz-2026-375
# Conflicts:
#	esphome/components/mdns/mdns_component.cpp
#	esphome/components/rp2/gpio.h
2026-06-30 09:21:35 +12:00
Jesse Hills cd06525700 Merge remote-tracking branch 'origin/dev' into jesserockz-2026-375
# Conflicts:
#	tests/unit_tests/test_config_validation.py
2026-06-25 22:40:11 +12:00
Jesse Hills 77cad4b351 Merge remote-tracking branch 'origin/dev' into jesserockz-2026-375 2026-06-25 22:34:50 +12:00
Jesse Hills 94d4e22f99 [wizard] Replace boards_list elif chain with dict lookup
The trailing ``elif platform == "RP2":`` arm of the elif chain left its
False branch structurally unreachable — every other validated platform
matched an earlier elif, so the only fall-through went to the defensive
``else: raise NotImplementedError``. Codecov flagged the partial branch
on the patched line.

Replace the chain with a platform → (example board, boards module) dict
lookup. Removes the unreachable branch, halves the line count, and
keeps the same example-board prompts and behavior. KeyError surfaces
the same way as the prior NotImplementedError for an unsupported
platform.
2026-06-25 17:20:22 +12:00
Jesse Hills f21258f6cf Merge branch 'dev' into jesserockz-2026-375 2026-06-25 16:08:54 +12:00
Jesse Hills 1832d023d7 [tests] Cover the libretiny branch of the interactive wizard
The interactive wizard's platform / board-link / boards-list elif chain
includes an ``elif platform == "RP2":`` arm that ``test_wizard_accepts_rpipico_board``
exercises on the True side. Without an interactive wizard test that
reaches those elifs with a non-RP2 platform, the False side stayed
uncovered and codecov flagged the line as a partial branch.

Add ``test_wizard_accepts_default_answers_bk72xx`` — same fixture shape
as the existing ESP32 / ESP8266 variants — so the BK72XX path
falls through the RP2 elifs and pins both branches.
2026-06-25 14:18:52 +12:00
Jesse Hills 120a38a2d0 Merge remote-tracking branch 'origin/dev' into jesserockz-2026-375 2026-06-24 08:53:42 +12:00
Jesse Hills 7c4ff3abdc [tests] Cover rp2 helpers, deprecation shims, and SplitDefault/require_framework_version variants
Brings new code introduced by this PR up to 100% patch coverage:

* ``CORE.is_rp2`` and the deprecated ``CORE.is_rp2040`` alias property
  (test_core.py).
* ``cv.only_on_rp2`` family gate and the ``cv.only_on_rp2040``
  deprecation shim (warning emission, one-shot dedupe via CORE.data,
  delegation to ``only_on_rp2`` on non-rp2 platforms).
* ``SplitDefault`` rp2 variant key resolution
  (``rp2_2040_arduino`` / ``rp2_2040`` / fallback to base framework).
* ``require_framework_version`` variant-specific keys for both ESP32
  (``esp32_c3_arduino``) and RP2 (``rp2_2040_arduino``).
* The ``upload_using_platformio`` signed-bin-already-exists branch and
  the ``port is None`` flag path (test_main.py).
2026-06-24 07:11:57 +12:00
Jesse Hills 219cb74bff [tests] Tighten ALIASES framework tests
``test_read_aliases_handles_syntax_error`` was a silent no-op:
``_read_aliases`` returns early when the source doesn't contain the
substring ``ALIASES``, so the broken stub (``def broken( :``) never
reached the parser and the syntax-error branch wasn't exercised. Include
``ALIASES`` in the broken source so the test actually fails on parse.

``test_build_alias_map_handles_missing_dir`` used a hard-coded absolute
path (``/nonexistent-components-dir-for-test``) that a developer machine
or CI image could plausibly create. Use ``tmp_path / "does-not-exist"``
so the missing-dir condition is guaranteed.

Addresses Copilot review comments 3456448661 and 3456448675.
2026-06-24 07:11:36 +12:00
Jesse Hills cd363f4a8b [wizard] Emit canonical rp2: key for new configs
The wizard generated ``rp2040:`` blocks for new configs, which immediately
landed on the deprecated alias path and emitted a deprecation warning the
first time the user ran ``esphome config``. Rename the wizard's RP2 paths
to the canonical platform key so new configs are written with ``rp2:``
from the start. The internal ``platform`` label and the ``HARDWARE_BASE_CONFIGS``
key flip from ``RP2040`` to ``RP2``; the interactive prompt now offers
``RP2`` in the platform list.

Adds ``test_wizard_write_defaults_platform_from_board_rp2`` to lock in the
``rp2:`` emission and guard against regressing to ``rp2040:``.
2026-06-24 07:11:17 +12:00
Jesse Hills e35c2ef66e [rp2] Preserve RP2040_BOARD_PINS / RP2040_BASE_PINS aliases for external imports
The ``_AliasFinder`` routes legacy ``from esphome.components.rp2040 import
boards`` to the canonical rp2 module, but external custom components and
tooling (device-builder among them) also reach for the legacy symbol
names ``RP2040_BOARD_PINS`` / ``RP2040_BASE_PINS``. Expose them as
deprecation-documented aliases of ``RP2_BOARD_PINS`` / ``RP2_BASE_PINS``
so downstream board-pin lookups keep working. Scheduled for removal in
2027.7.0.
2026-06-24 07:10:52 +12:00
Jesse Hills fb8c4b23c9 Update codeowners 2026-06-23 16:22:27 +12:00
Jesse Hills e24cd8d2f8 [ci] Add RP2350_ARD to memory-impact platform preference
Renamed test fixtures hint RP2350_ARD via _detect_platform_hint_from_filename,
but the platform wasn't in MEMORY_IMPACT_PLATFORM_PREFERENCE, so
_select_platform_by_count crashed with ValueError when computing the
preference index. List it just after the RP2040 entry.
2026-06-23 16:14:16 +12:00
Jesse Hills 9ad45c84bf [rp2] Push alias removal target out to 2027.7.0
One-year deprecation window from the 2026.7.0 introduction.
2026-06-23 16:12:31 +12:00
Jesse Hills 84cc834344 [rp2] Rename rp2040 platform to rp2
The Raspberry Pi RP-series platform is no longer RP2040-only — RP2350
variants share the same arduino-pico toolchain. Rename the canonical
component to ``rp2`` (matching the BK72XX / RTL87XX family-naming
pattern) and route legacy ``rp2040:`` configs and Python imports
through the new ``ALIASES`` framework. ``Platform.RP2`` and
``PlatformFramework.RP2_ARDUINO`` are the canonical values; the
``RP2040`` spellings remain as deprecated aliases.

Scheduled removal of the ``rp2040`` aliases: 2027.6.0.
2026-06-23 13:27:27 +12:00
158 changed files with 1303 additions and 1093 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
ARG BUILD_BASE_VERSION=2026.06.1
ARG BUILD_BASE_VERSION=2025.04.0
FROM ghcr.io/esphome/docker-base:debian-${BUILD_BASE_VERSION} AS base
+2 -5
View File
@@ -15,6 +15,7 @@
// uncomment and edit the path in order to pass through local USB serial to the container
// , "--device=/dev/ttyACM0"
],
"appPort": 6052,
// if you are using avahi in the host device, uncomment these to allow the
// devcontainer to find devices via mdns
//"mounts": [
@@ -40,11 +41,7 @@
],
"settings": {
"python.languageServer": "Pylance",
// Use the container's pre-provisioned venv (built by the Dockerfile, outside the
// bind-mounted workspace) rather than a ./venv that may leak in from the host and
// mismatch the container's Python. See .devcontainer/Dockerfile (esphome-venv).
"python.defaultInterpreterPath": "/home/esphome/.local/esphome-venv/bin/python",
"python.terminal.activateEnvironment": true,
"python.pythonPath": "/usr/bin/python3",
"pylint.args": [
"--rcfile=${workspaceFolder}/pyproject.toml"
],
+1 -1
View File
@@ -112,7 +112,7 @@ jobs:
script/build_codeowners.py --check
script/build_language_schema.py --check
script/generate-esp32-boards.py --check
script/generate-rp2040-boards.py --check
script/generate-rp2-boards.py --check
script/ci_check_duplicate_test_ids.py
import-time:
+1 -1
View File
@@ -425,7 +425,7 @@ esphome/components/rf_bridge/* @jesserockz
esphome/components/rgbct/* @jesserockz
esphome/components/ring_buffer/* @kahrendt
esphome/components/router/speaker/* @kahrendt
esphome/components/rp2040/* @jesserockz
esphome/components/rp2/* @jesserockz
esphome/components/rp2040_ble/* @bdraco
esphome/components/rp2040_pio_led_strip/* @Papa-DMan
esphome/components/rp2040_pwm/* @jesserockz
+5 -5
View File
@@ -354,7 +354,7 @@ def choose_upload_log_host(
bootsel_permission_error = False
if (
purpose == Purpose.UPLOADING
and CORE.is_rp2040
and CORE.is_rp2
and (picotool := _find_picotool()) is not None
):
bootsel = detect_rp2040_bootsel(picotool)
@@ -401,7 +401,7 @@ def choose_upload_log_host(
# Show helpful BOOTSEL instructions for RP2040 when no BOOTSEL device is found
if (
purpose == Purpose.UPLOADING
and CORE.is_rp2040
and CORE.is_rp2
and not any(get_port_type(opt[1]) == PortType.BOOTSEL for opt in options)
):
if bootsel_permission_error:
@@ -979,7 +979,7 @@ def upload_using_platformio(config: ConfigType, port: str) -> int:
# RP2040 platform-raspberrypi build recipe expects firmware.bin.signed for
# the upload target, but 'nobuild' skips the build phase that creates it.
# Create it here so the upload doesn't fail.
if CORE.is_rp2040:
if CORE.is_rp2:
idedata = toolchain.get_idedata(config)
build_dir = Path(idedata.firmware_elf_path).parent
firmware_bin = build_dir / "firmware.bin"
@@ -1167,7 +1167,7 @@ def upload_program(
if CORE.is_esp32 or CORE.is_esp8266:
file = getattr(args, "file", None)
exit_code = upload_using_esptool(config, host, file, args.upload_speed)
elif CORE.is_rp2040 or CORE.is_libretiny:
elif CORE.is_rp2 or CORE.is_libretiny:
exit_code = upload_using_platformio(config, host)
# else: Unknown target platform, exit_code remains 1
@@ -1641,7 +1641,7 @@ def command_run(args: ArgsProtocol, config: ConfigType) -> int | None:
# After BOOTSEL upload, wait for a new serial port to appear
# so it shows up in the log chooser
if successful_device is None and CORE.is_rp2040:
if successful_device is None and CORE.is_rp2:
_wait_for_serial_port(known_ports=pre_upload_ports)
# If exactly one new serial port appeared, use it directly
serial_ports = get_serial_ports()
+6
View File
@@ -0,0 +1,6 @@
# Importing `esphome.loader` here installs the component-alias
# ``sys.meta_path`` finder before any submodule lookup runs. Without this,
# `from esphome.components import <legacy_alias>` from a fresh interpreter
# can race the finder install and raise ImportError, since the legacy
# alias dir no longer exists on disk.
from esphome import loader as _loader # noqa: F401
+4 -4
View File
@@ -227,12 +227,12 @@ ESP32_VARIANT_ADC2_PIN_TO_CHANNEL = {
def validate_adc_pin(value):
if str(value).upper() == "VCC":
if CORE.is_rp2040:
if CORE.is_rp2:
return pins.internal_gpio_input_pin_schema(29)
return cv.only_on([PLATFORM_ESP8266])("VCC")
if str(value).upper() == "TEMPERATURE":
return cv.only_on_rp2040("TEMPERATURE")
return cv.only_on_rp2("TEMPERATURE")
if CORE.is_esp32:
conf = pins.internal_gpio_input_pin_schema(value)
@@ -261,11 +261,11 @@ def validate_adc_pin(value):
raise cv.Invalid("ESP8266: Only pin A0 (GPIO17) supports ADC")
return conf
if CORE.is_rp2040:
if CORE.is_rp2:
conf = pins.internal_gpio_input_pin_schema(value)
number = conf[CONF_NUMBER]
if number not in (26, 27, 28, 29):
raise cv.Invalid("RP2040: Only pins 26, 27, 28 and 29 support ADC")
raise cv.Invalid("RP2: Only pins 26, 27, 28 and 29 support ADC")
return conf
if CORE.is_libretiny:
+4 -4
View File
@@ -123,9 +123,9 @@ class ADCSensor final : public sensor::Sensor, public PollingComponent, public v
void set_autorange(bool autorange) { this->autorange_ = autorange; }
#endif // USE_ESP32
#ifdef USE_RP2040
#ifdef USE_RP2
void set_is_temperature() { this->is_temperature_ = true; }
#endif // USE_RP2040
#endif // USE_RP2
protected:
uint8_t sample_count_{1};
@@ -152,9 +152,9 @@ class ADCSensor final : public sensor::Sensor, public PollingComponent, public v
static adc_oneshot_unit_handle_t shared_adc_handles[2];
#endif // USE_ESP32
#ifdef USE_RP2040
#ifdef USE_RP2
bool is_temperature_{false};
#endif // USE_RP2040
#endif // USE_RP2
#ifdef USE_ZEPHYR
const struct adc_dt_spec *channel_ = nullptr;
@@ -1,4 +1,4 @@
#ifdef USE_RP2040
#ifdef USE_RP2
#include "adc_sensor.h"
#include "esphome/core/log.h"
@@ -17,7 +17,7 @@
namespace esphome::adc {
static const char *const TAG = "adc.rp2040";
static const char *const TAG = "adc.rp2";
void ADCSensor::setup() {
static bool initialized = false;
@@ -102,4 +102,4 @@ float ADCSensor::sample() {
} // namespace esphome::adc
#endif // USE_RP2040
#endif // USE_RP2
+1 -1
View File
@@ -201,7 +201,7 @@ FILTER_SOURCE_FILES = filter_source_files_from_platform(
PlatformFramework.ESP32_IDF,
},
"adc_sensor_esp8266.cpp": {PlatformFramework.ESP8266_ARDUINO},
"adc_sensor_rp2040.cpp": {PlatformFramework.RP2040_ARDUINO},
"adc_sensor_rp2.cpp": {PlatformFramework.RP2_ARDUINO},
"adc_sensor_libretiny.cpp": {
PlatformFramework.BK72XX_ARDUINO,
PlatformFramework.RTL87XX_ARDUINO,
+3 -3
View File
@@ -300,7 +300,7 @@ CONFIG_SCHEMA = cv.All(
CONF_LISTEN_BACKLOG,
esp8266=1, # Limited RAM (~40KB free), LWIP raw sockets
esp32=4, # More RAM (520KB), BSD sockets
rp2040=1, # Limited RAM (264KB), LWIP raw sockets like ESP8266
rp2=1, # Limited RAM (264KB), LWIP raw sockets like ESP8266
bk72xx=4, # Moderate RAM, BSD-style sockets
rtl87xx=4, # Moderate RAM, BSD-style sockets
host=4, # Abundant resources
@@ -311,7 +311,7 @@ CONFIG_SCHEMA = cv.All(
CONF_MAX_CONNECTIONS,
esp8266=4, # ~40KB free RAM, each connection uses ~500-1000 bytes
esp32=5, # 520KB RAM available
rp2040=4, # 264KB RAM but LWIP constraints
rp2=4, # 264KB RAM but LWIP constraints
bk72xx=5, # Moderate RAM
rtl87xx=5, # Moderate RAM
host=8, # Abundant resources
@@ -326,7 +326,7 @@ CONFIG_SCHEMA = cv.All(
CONF_MAX_SEND_QUEUE,
esp8266=4, # Limited RAM, need to fail fast
esp32=8, # More RAM, can buffer more
rp2040=8, # Moderate RAM
rp2=8, # Moderate RAM
bk72xx=8, # Moderate RAM
nrf52=8, # Moderate RAM
rtl87xx=8, # Moderate RAM
+1 -1
View File
@@ -1759,7 +1759,7 @@ bool APIConnection::send_device_info_response_() {
// Manufacturer string - define once, handle ESP8266 PROGMEM separately
#if defined(USE_ESP8266) || defined(USE_ESP32)
#define ESPHOME_MANUFACTURER "Espressif"
#elif defined(USE_RP2040)
#elif defined(USE_RP2)
#define ESPHOME_MANUFACTURER "Raspberry Pi"
#elif defined(USE_BK72XX)
#define ESPHOME_MANUFACTURER "Beken"
+4 -4
View File
@@ -18,8 +18,8 @@
#ifdef USE_ESP32_CRASH_HANDLER
#include "esphome/components/esp32/crash_handler.h"
#endif
#ifdef USE_RP2040_CRASH_HANDLER
#include "esphome/components/rp2040/crash_handler.h"
#ifdef USE_RP2_CRASH_HANDLER
#include "esphome/components/rp2/crash_handler.h"
#endif
#ifdef USE_ESP8266_CRASH_HANDLER
#include "esphome/components/esp8266/crash_handler.h"
@@ -279,8 +279,8 @@ class APIConnection final : public APIServerConnectionBase {
esp32::crash_handler_log();
esp32::crash_handler_clear();
#endif
#ifdef USE_RP2040_CRASH_HANDLER
rp2040::crash_handler_log();
#ifdef USE_RP2_CRASH_HANDLER
rp2::crash_handler_log();
#endif
#ifdef USE_ESP8266_CRASH_HANDLER
esp8266::crash_handler_log();
+3 -3
View File
@@ -13,7 +13,7 @@ def AUTO_LOAD() -> list[str]:
if (
not CORE.is_esp32
and not CORE.is_esp8266
and not CORE.is_rp2040
and not CORE.is_rp2
and not CORE.is_libretiny
):
return ["socket"]
@@ -37,7 +37,7 @@ async def to_code(config):
elif CORE.is_esp8266:
# https://github.com/ESP32Async/ESPAsyncTCP
cg.add_library("ESP32Async/ESPAsyncTCP", "2.0.0")
elif CORE.is_rp2040:
elif CORE.is_rp2:
# https://github.com/ayushsharma82/RPAsyncTCP
# RPAsyncTCP is a drop-in replacement for AsyncTCP_RP2040W with better
# ESPAsyncWebServer compatibility
@@ -47,6 +47,6 @@ async def to_code(config):
def FILTER_SOURCE_FILES() -> list[str]:
# Exclude socket implementation for platforms that use AsyncTCP libraries
if CORE.is_esp32 or CORE.is_esp8266 or CORE.is_rp2040 or CORE.is_libretiny:
if CORE.is_esp32 or CORE.is_esp8266 or CORE.is_rp2 or CORE.is_libretiny:
return ["async_tcp_socket.cpp"]
return []
+1 -1
View File
@@ -7,7 +7,7 @@
#elif defined(USE_ESP8266)
// Use ESPAsyncTCP library for ESP8266 (always Arduino)
#include <ESPAsyncTCP.h>
#elif defined(USE_RP2040)
#elif defined(USE_RP2)
// Use RPAsyncTCP library for RP2040
#include <RPAsyncTCP.h>
#else
@@ -1,6 +1,6 @@
#include "async_tcp_socket.h"
#if !defined(USE_ESP32) && !defined(USE_ESP8266) && !defined(USE_RP2040) && !defined(USE_LIBRETINY) && \
#if !defined(USE_ESP32) && !defined(USE_ESP8266) && !defined(USE_RP2) && !defined(USE_LIBRETINY) && \
(defined(USE_SOCKET_IMPL_LWIP_SOCKETS) || defined(USE_SOCKET_IMPL_BSD_SOCKETS))
#include "esphome/components/network/util.h"
@@ -2,7 +2,7 @@
#include "esphome/core/defines.h"
#if !defined(USE_ESP32) && !defined(USE_ESP8266) && !defined(USE_RP2040) && !defined(USE_LIBRETINY) && \
#if !defined(USE_ESP32) && !defined(USE_ESP8266) && !defined(USE_RP2) && !defined(USE_LIBRETINY) && \
(defined(USE_SOCKET_IMPL_LWIP_SOCKETS) || defined(USE_SOCKET_IMPL_BSD_SOCKETS))
#include "esphome/components/socket/socket.h"
@@ -13,7 +13,7 @@ from esphome.const import (
PLATFORM_ESP32,
PLATFORM_ESP8266,
PLATFORM_LN882X,
PLATFORM_RP2040,
PLATFORM_RP2,
PLATFORM_RTL87XX,
PlatformFramework,
)
@@ -54,7 +54,7 @@ CONFIG_SCHEMA = cv.All(
PLATFORM_ESP8266,
PLATFORM_BK72XX,
PLATFORM_LN882X,
PLATFORM_RP2040,
PLATFORM_RP2,
PLATFORM_RTL87XX,
]
),
@@ -105,7 +105,7 @@ async def to_code(config):
if config[CONF_COMPRESSION] == "gzip":
cg.add_define("USE_CAPTIVE_PORTAL_GZIP")
if CORE.using_arduino and (CORE.is_esp8266 or CORE.is_libretiny or CORE.is_rp2040):
if CORE.using_arduino and (CORE.is_esp8266 or CORE.is_libretiny or CORE.is_rp2):
cg.add_library("DNSServer", None)
+1 -1
View File
@@ -70,7 +70,7 @@ FILTER_SOURCE_FILES = filter_source_files_from_platform(
},
"debug_esp8266.cpp": {PlatformFramework.ESP8266_ARDUINO},
"debug_host.cpp": {PlatformFramework.HOST_NATIVE},
"debug_rp2040.cpp": {PlatformFramework.RP2040_ARDUINO},
"debug_rp2.cpp": {PlatformFramework.RP2_ARDUINO},
"debug_libretiny.cpp": {
PlatformFramework.BK72XX_ARDUINO,
PlatformFramework.RTL87XX_ARDUINO,
@@ -1,5 +1,5 @@
#include "debug_component.h"
#ifdef USE_RP2040
#ifdef USE_RP2
#include "esphome/core/defines.h"
#include "esphome/core/log.h"
#include <Arduino.h>
@@ -9,8 +9,8 @@
#else
#include <hardware/structs/vreg_and_chip_reset.h>
#endif
#ifdef USE_RP2040_CRASH_HANDLER
#include "esphome/components/rp2040/crash_handler.h"
#ifdef USE_RP2_CRASH_HANDLER
#include "esphome/components/rp2/crash_handler.h"
#endif
namespace esphome::debug {
@@ -41,8 +41,8 @@ const char *DebugComponent::get_reset_reason_(std::span<char, RESET_REASON_BUFFE
if (watchdog_caused_reboot()) {
bool handled = false;
#ifdef USE_RP2040_CRASH_HANDLER
if (rp2040::crash_handler_has_data()) {
#ifdef USE_RP2_CRASH_HANDLER
if (rp2::crash_handler_has_data()) {
pos = buf_append_str(buf, size, pos, "Crash (HardFault)|");
handled = true;
}
+1 -1
View File
@@ -12,7 +12,7 @@ namespace esphome {
uint32_t random_uint32() { return os_random(); }
bool random_bytes(uint8_t *data, size_t len) { return os_get_random(data, len) == 0; }
// ESP8266 Mutex is defined inline as a no-op in helpers.h when USE_ESP8266 (or USE_RP2040) is set,
// ESP8266 Mutex is defined inline as a no-op in helpers.h when USE_ESP8266 (or USE_RP2) is set,
// independent of the ESPHOME_THREAD_SINGLE thread model define.
IRAM_ATTR InterruptLock::InterruptLock() { state_ = xt_rsil(15); }
+1 -1
View File
@@ -126,7 +126,7 @@ CONFIG_SCHEMA = cv.All(
CONF_PORT,
esp8266=8266,
esp32=3232,
rp2040=2040,
rp2=2040,
bk72xx=8892,
ln882x=8820,
rtl87xx=8892,
@@ -8,7 +8,7 @@
#include "esphome/components/ota/ota_backend.h"
#include "esphome/components/ota/ota_backend_esp8266.h"
#include "esphome/components/ota/ota_backend_arduino_libretiny.h"
#include "esphome/components/ota/ota_backend_arduino_rp2040.h"
#include "esphome/components/ota/ota_backend_arduino_rp2.h"
#include "esphome/components/ota/ota_backend_esp_idf.h"
#include "esphome/core/application.h"
#include "esphome/core/hal.h"
+15 -13
View File
@@ -179,9 +179,11 @@ _ALWAYS_EXTERNAL_IDF_COMPONENTS = {"LAN8670", "ENC28J60"}
# ESP32-only SPI ethernet types (W5100 is RP2040-only, no ESP-IDF driver)
SPI_ETHERNET_TYPES = {"W5500", "DM9051", "ENC28J60"}
# RP2040-supported ethernet types (SPI and PIO QSPI)
RP2040_ETHERNET_TYPES = {"W5100", "W5500", "W6100", "W6300", "ENC28J60"}
_RP2040_SPI_LIBRARIES = {
# RP2-supported ethernet types (SPI and PIO QSPI). Applies to the whole
# RP2 family (RP2040 and RP2350); the chip-specific W5100 caveat in the
# comment above is about ESP-IDF driver coverage, not the RP2 platform.
RP2_ETHERNET_TYPES = {"W5100", "W5500", "W6100", "W6300", "ENC28J60"}
_RP2_SPI_LIBRARIES = {
"W5100": "lwIP_w5100",
"W5500": "lwIP_w5500",
"ENC28J60": "lwIP_enc28j60",
@@ -361,10 +363,10 @@ def _validate(config):
f"{config[CONF_TYPE]} PHY requires RMII interface and is only supported "
f"on ESP32 classic and ESP32-P4, not {variant}"
)
elif CORE.is_rp2040 and config[CONF_TYPE] not in RP2040_ETHERNET_TYPES:
elif CORE.is_rp2 and config[CONF_TYPE] not in RP2_ETHERNET_TYPES:
raise cv.Invalid(
f"Only {', '.join(sorted(RP2040_ETHERNET_TYPES))} are supported on RP2040, "
f"not {config[CONF_TYPE]}"
f"Only {', '.join(sorted(RP2_ETHERNET_TYPES))} are supported on the RP2 "
f"platform, not {config[CONF_TYPE]}"
)
return config
@@ -459,7 +461,7 @@ SPI_SCHEMA = cv.All(
}
),
),
cv.only_on([Platform.ESP32, Platform.RP2040]),
cv.only_on([Platform.ESP32, Platform.RP2]),
_validate_spi_interface,
)
@@ -473,13 +475,13 @@ CONFIG_SCHEMA = cv.All(
"JL1101": RMII_SCHEMA,
"KSZ8081": RMII_SCHEMA,
"KSZ8081RNA": RMII_SCHEMA,
"W5100": cv.All(SPI_SCHEMA, cv.only_on([Platform.RP2040])),
"W5100": cv.All(SPI_SCHEMA, cv.only_on([Platform.RP2])),
"W5500": SPI_SCHEMA,
"OPENETH": cv.All(BASE_SCHEMA, cv.only_on([Platform.ESP32])),
"DM9051": SPI_SCHEMA,
"ENC28J60": SPI_SCHEMA,
"W6100": cv.All(SPI_SCHEMA, cv.only_on([Platform.RP2040])),
"W6300": cv.All(SPI_SCHEMA, cv.only_on([Platform.RP2040])),
"W6100": cv.All(SPI_SCHEMA, cv.only_on([Platform.RP2])),
"W6300": cv.All(SPI_SCHEMA, cv.only_on([Platform.RP2])),
"LAN8670": RMII_SCHEMA,
"GENERIC": GENERIC_SCHEMA,
"YT8531": GENERIC_SCHEMA,
@@ -537,7 +539,7 @@ async def to_code(config):
if CORE.is_esp32:
await _to_code_esp32(var, config)
elif CORE.is_rp2040:
elif CORE.is_rp2:
await _to_code_rp2040(var, config)
cg.add(var.set_type(ETHERNET_TYPES[config[CONF_TYPE]]))
@@ -670,7 +672,7 @@ async def _to_code_rp2040(var: cg.Pvariable, config: ConfigType) -> None:
cg.add(var.set_reset_pin(config[CONF_RESET_PIN]))
cg.add_define("USE_ETHERNET_SPI")
cg.add_library(_RP2040_SPI_LIBRARIES[config[CONF_TYPE]], None)
cg.add_library(_RP2_SPI_LIBRARIES[config[CONF_TYPE]], None)
def _final_validate_rmii_pins(config: ConfigType) -> None:
@@ -752,7 +754,7 @@ _platform_filter = filter_source_files_from_platform(
PlatformFramework.ESP32_IDF,
PlatformFramework.ESP32_ARDUINO,
},
"ethernet_component_rp2040.cpp": {PlatformFramework.RP2040_ARDUINO},
"ethernet_component_rp2.cpp": {PlatformFramework.RP2_ARDUINO},
"esp_eth_phy_jl1101.c": {
PlatformFramework.ESP32_IDF,
PlatformFramework.ESP32_ARDUINO,
@@ -25,7 +25,7 @@ extern "C" eth_esp32_emac_config_t eth_esp32_emac_default_config(void);
#endif
#endif // USE_ESP32
#ifdef USE_RP2040
#ifdef USE_RP2
#if defined(USE_ETHERNET_W5500)
#include <W5500lwIP.h>
#elif defined(USE_ETHERNET_W5100)
@@ -182,14 +182,14 @@ class EthernetComponent final : public Component {
#endif // USE_ETHERNET_SPI
#endif // USE_ESP32
#ifdef USE_RP2040
#ifdef USE_RP2
void set_clk_pin(uint8_t clk_pin);
void set_miso_pin(uint8_t miso_pin);
void set_mosi_pin(uint8_t mosi_pin);
void set_cs_pin(uint8_t cs_pin);
void set_interrupt_pin(int8_t interrupt_pin);
void set_reset_pin(int8_t reset_pin);
#endif // USE_RP2040
#endif // USE_RP2
#ifdef USE_ETHERNET_IP_STATE_LISTENERS
void add_ip_state_listener(EthernetIPStateListener *listener) { this->ip_state_listeners_.push_back(listener); }
@@ -272,7 +272,7 @@ class EthernetComponent final : public Component {
esp_eth_phy_t *phy_{nullptr};
#endif // USE_ESP32
#ifdef USE_RP2040
#ifdef USE_RP2
static constexpr uint32_t LINK_CHECK_INTERVAL = 500; // ms between link/IP polls
#if defined(USE_ETHERNET_W5100)
static constexpr uint32_t RESET_DELAY_MS = 150; // W5100S PLL lock time
@@ -301,7 +301,7 @@ class EthernetComponent final : public Component {
uint8_t cs_pin_;
int8_t interrupt_pin_{-1};
int8_t reset_pin_{-1};
#endif // USE_RP2040
#endif // USE_RP2
// Common members
#ifdef USE_ETHERNET_MANUAL_IP
@@ -1,12 +1,12 @@
#include "ethernet_component.h"
#if defined(USE_ETHERNET) && defined(USE_RP2040)
#if defined(USE_ETHERNET) && defined(USE_RP2)
#include "esphome/core/application.h"
#include "esphome/core/helpers.h"
#include "esphome/core/log.h"
#include "esphome/components/rp2040/gpio.h"
#include "esphome/components/rp2/gpio.h"
#include <SPI.h>
#include <lwip/dns.h>
@@ -29,7 +29,7 @@ void EthernetComponent::setup() {
// Toggle reset pin if configured
if (this->reset_pin_ >= 0) {
rp2040::RP2040GPIOPin reset_pin;
rp2::RP2GPIOPin reset_pin;
reset_pin.set_pin(this->reset_pin_);
reset_pin.set_flags(gpio::FLAG_OUTPUT);
reset_pin.setup();
@@ -380,4 +380,4 @@ void EthernetComponent::disable() {
} // namespace esphome::ethernet
#endif // USE_ETHERNET && USE_RP2040
#endif // USE_ETHERNET && USE_RP2
@@ -7,7 +7,7 @@
#include <cinttypes>
#if !defined(USE_RP2040) && !defined(USE_HOST)
#if !defined(USE_RP2) && !defined(USE_HOST)
namespace esphome::factory_reset {
@@ -73,4 +73,4 @@ void FactoryResetComponent::setup() {
} // namespace esphome::factory_reset
#endif // !defined(USE_RP2040) && !defined(USE_HOST)
#endif // !defined(USE_RP2) && !defined(USE_HOST)
@@ -3,7 +3,7 @@
#include "esphome/core/component.h"
#include "esphome/core/automation.h"
#include "esphome/core/preferences.h"
#if !defined(USE_RP2040) && !defined(USE_HOST)
#if !defined(USE_RP2) && !defined(USE_HOST)
#ifdef USE_ESP32
#include <esp_system.h>
@@ -32,4 +32,4 @@ class FactoryResetComponent final : public Component {
} // namespace esphome::factory_reset
#endif // !defined(USE_RP2040) && !defined(USE_HOST)
#endif // !defined(USE_RP2) && !defined(USE_HOST)
@@ -48,7 +48,7 @@ CONFIG_SCHEMA = (
host=True,
ln882x=False,
nrf52=False,
rp2040=True,
rp2=True,
rtl87xx=False,
): cv.boolean,
cv.Optional(CONF_INTERRUPT_TYPE, default="ANY"): cv.enum(
@@ -1,6 +1,6 @@
#include <cstring>
#include "hmac_sha256.h"
#if defined(USE_ESP32) || defined(USE_ESP8266) || defined(USE_RP2040) || defined(USE_LIBRETINY) || defined(USE_HOST)
#if defined(USE_ESP32) || defined(USE_ESP8266) || defined(USE_RP2) || defined(USE_LIBRETINY) || defined(USE_HOST)
#include "esphome/core/helpers.h"
namespace esphome::hmac_sha256 {
+1 -1
View File
@@ -1,7 +1,7 @@
#pragma once
#include "esphome/core/defines.h"
#if defined(USE_ESP32) || defined(USE_ESP8266) || defined(USE_RP2040) || defined(USE_LIBRETINY) || defined(USE_HOST)
#if defined(USE_ESP32) || defined(USE_ESP8266) || defined(USE_RP2) || defined(USE_LIBRETINY) || defined(USE_HOST)
#include <string>
+6 -6
View File
@@ -73,7 +73,7 @@ def validate_url(value):
def validate_ssl_verification(config):
error_message = ""
if CORE.is_rp2040 and config[CONF_VERIFY_SSL]:
if CORE.is_rp2 and config[CONF_VERIFY_SSL]:
error_message = "ESPHome does not support certificate verification on RP2040"
if (
@@ -96,7 +96,7 @@ def _declare_request_class(value):
return cv.declare_id(HttpRequestHost)(value)
if CORE.is_esp32:
return cv.declare_id(HttpRequestIDF)(value)
if CORE.is_esp8266 or CORE.is_rp2040:
if CORE.is_esp8266 or CORE.is_rp2:
return cv.declare_id(HttpRequestArduino)(value)
return NotImplementedError
@@ -118,7 +118,7 @@ CONFIG_SCHEMA = cv.All(
),
cv.Optional(CONF_VERIFY_SSL, default=True): cv.boolean,
cv.Optional(CONF_WATCHDOG_TIMEOUT): cv.All(
cv.Any(cv.only_on_esp32, cv.only_on_rp2040),
cv.Any(cv.only_on_esp32, cv.only_on_rp2),
cv.positive_not_null_time_period,
cv.positive_time_period_milliseconds,
),
@@ -144,7 +144,7 @@ CONFIG_SCHEMA = cv.All(
esp8266_arduino=cv.Version(2, 5, 1),
esp32_arduino=cv.Version(0, 0, 0),
esp_idf=cv.Version(0, 0, 0),
rp2040_arduino=cv.Version(0, 0, 0),
rp2_arduino=cv.Version(0, 0, 0),
host=cv.Version(0, 0, 0),
),
validate_ssl_verification,
@@ -204,7 +204,7 @@ async def to_code(config):
)
if CORE.is_esp8266:
cg.add_library("ESP8266HTTPClient", None)
if CORE.is_rp2040 and CORE.using_arduino:
if CORE.is_rp2 and CORE.using_arduino:
cg.add_library("HTTPClient", None)
if CORE.is_host:
if IS_MACOS:
@@ -368,7 +368,7 @@ FILTER_SOURCE_FILES = filter_source_files_from_platform(
"http_request_host.cpp": {PlatformFramework.HOST_NATIVE},
"http_request_arduino.cpp": {
PlatformFramework.ESP8266_ARDUINO,
PlatformFramework.RP2040_ARDUINO,
PlatformFramework.RP2_ARDUINO,
PlatformFramework.BK72XX_ARDUINO,
PlatformFramework.RTL87XX_ARDUINO,
PlatformFramework.LN882X_ARDUINO,
@@ -72,7 +72,7 @@ std::shared_ptr<HttpContainer> HttpRequestArduino::perform(const std::string &ur
bool status = container->client_.begin(*stream_ptr, url.c_str());
#elif defined(USE_RP2040)
#elif defined(USE_RP2)
if (secure) {
container->client_.setInsecure();
}
@@ -4,7 +4,7 @@
#if defined(USE_ARDUINO) && !defined(USE_ESP32)
#if defined(USE_RP2040)
#if defined(USE_RP2)
#include <HTTPClient.h>
#include <WiFiClient.h>
#endif
@@ -36,7 +36,7 @@ CONFIG_SCHEMA = cv.All(
esp8266_arduino=cv.Version(2, 5, 1),
esp32_arduino=cv.Version(0, 0, 0),
esp_idf=cv.Version(0, 0, 0),
rp2040_arduino=cv.Version(0, 0, 0),
rp2_arduino=cv.Version(0, 0, 0),
),
)
+8 -8
View File
@@ -49,7 +49,7 @@ from esphome.const import (
PLATFORM_ESP8266,
PLATFORM_HOST,
PLATFORM_NRF52,
PLATFORM_RP2040,
PLATFORM_RP2,
PlatformFramework,
)
from esphome.core import CORE, CoroPriority, coroutine_with_priority
@@ -130,7 +130,7 @@ def validate_config(config):
return cv.require_framework_version(
esp_idf=cv.Version(5, 4, 2), esp32_arduino=cv.Version(3, 2, 1)
)(config)
if CORE.is_rp2040:
if CORE.is_rp2:
sda_controller = _rp2040_i2c_controller(config[CONF_SDA])
scl_controller = _rp2040_i2c_controller(config[CONF_SCL])
if sda_controller != scl_controller:
@@ -171,7 +171,7 @@ CONFIG_SCHEMA = cv.All(
CONF_SDA,
esp32="SDA",
esp8266="SDA",
rp2040="SDA",
rp2="SDA",
nrf52="SDA",
): pins.internal_gpio_pin_number,
cv.SplitDefault(CONF_SDA_PULLUP_ENABLED, esp32=True): cv.All(
@@ -181,7 +181,7 @@ CONFIG_SCHEMA = cv.All(
CONF_SCL,
esp32="SCL",
esp8266="SCL",
rp2040="SCL",
rp2="SCL",
nrf52="SCL",
): pins.internal_gpio_pin_number,
cv.SplitDefault(CONF_SCL_PULLUP_ENABLED, esp32=True): cv.All(
@@ -191,7 +191,7 @@ CONFIG_SCHEMA = cv.All(
CONF_FREQUENCY,
esp32="50kHz",
esp8266="50kHz",
rp2040="50kHz",
rp2="50kHz",
nrf52="100kHz",
host="50kHz",
): cv.All(
@@ -219,7 +219,7 @@ CONFIG_SCHEMA = cv.All(
[
PLATFORM_ESP32,
PLATFORM_ESP8266,
PLATFORM_RP2040,
PLATFORM_RP2,
PLATFORM_NRF52,
PLATFORM_HOST,
]
@@ -233,7 +233,7 @@ def _final_validate(config):
full_config = fv.full_config.get()[CONF_I2C]
if CORE.using_zephyr and len(full_config) > 1:
raise cv.Invalid("Second i2c is not implemented on Zephyr yet")
if CORE.is_rp2040:
if CORE.is_rp2:
if len(full_config) > 2:
raise cv.Invalid(
"The maximum number of I2C interfaces for RP2040/RP2350 is 2"
@@ -443,7 +443,7 @@ FILTER_SOURCE_FILES = filter_source_files_from_platform(
{
"i2c_bus_arduino.cpp": {
PlatformFramework.ESP8266_ARDUINO,
PlatformFramework.RP2040_ARDUINO,
PlatformFramework.RP2_ARDUINO,
PlatformFramework.BK72XX_ARDUINO,
PlatformFramework.RTL87XX_ARDUINO,
PlatformFramework.LN882X_ARDUINO,
+4 -4
View File
@@ -19,7 +19,7 @@ void ArduinoI2CBus::setup() {
#if defined(USE_ESP8266)
wire_ = new TwoWire(); // NOLINT(cppcoreguidelines-owning-memory)
#elif defined(USE_RP2040)
#elif defined(USE_RP2)
// Select Wire instance based on pin assignment, not definition order.
// I2C controller = (gpio / 2) % 2: even pairs (0-1,4-5,...) → I2C0, odd pairs (2-3,6-7,...) → I2C1
// RP2040 datasheet Table 2 (section 1.4.3): https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf
@@ -41,7 +41,7 @@ void ArduinoI2CBus::setup() {
}
void ArduinoI2CBus::set_pins_and_clock_() {
#ifdef USE_RP2040
#ifdef USE_RP2
wire_->setSDA(this->sda_pin_);
wire_->setSCL(this->scl_pin_);
wire_->begin();
@@ -52,7 +52,7 @@ void ArduinoI2CBus::set_pins_and_clock_() {
#if defined(USE_ESP8266)
// https://github.com/esp8266/Arduino/blob/master/libraries/Wire/Wire.h
wire_->setClockStretchLimit(timeout_); // unit: us
#elif defined(USE_RP2040)
#elif defined(USE_RP2)
// https://github.com/earlephilhower/ArduinoCore-API/blob/e37df85425e0ac020bfad226d927f9b00d2e0fb7/api/Stream.h
wire_->setTimeout(timeout_ / 1000); // unit: ms
#endif
@@ -70,7 +70,7 @@ void ArduinoI2CBus::dump_config() {
if (timeout_ > 0) {
#if defined(USE_ESP8266)
ESP_LOGCONFIG(TAG, " Timeout: %u us", this->timeout_);
#elif defined(USE_RP2040)
#elif defined(USE_RP2)
ESP_LOGCONFIG(TAG, " Timeout: %u ms", this->timeout_ / 1000);
#endif
}
@@ -1,4 +1,4 @@
#ifdef USE_RP2040
#ifdef USE_RP2
#include "esphome/core/log.h"
#include "internal_temperature.h"
@@ -7,7 +7,7 @@
namespace esphome::internal_temperature {
static const char *const TAG = "internal_temperature.rp2040";
static const char *const TAG = "internal_temperature.rp2";
void InternalTemperatureSensor::update() {
float temperature = NAN;
@@ -28,4 +28,4 @@ void InternalTemperatureSensor::update() {
} // namespace esphome::internal_temperature
#endif // USE_RP2040
#endif // USE_RP2
@@ -10,7 +10,7 @@ from esphome.const import (
PLATFORM_ESP32,
PLATFORM_LN882X,
PLATFORM_NRF52,
PLATFORM_RP2040,
PLATFORM_RP2,
STATE_CLASS_MEASUREMENT,
UNIT_CELSIUS,
PlatformFramework,
@@ -34,7 +34,7 @@ CONFIG_SCHEMA = cv.All(
cv.only_on(
[
PLATFORM_ESP32,
PLATFORM_RP2040,
PLATFORM_RP2,
PLATFORM_BK72XX,
PLATFORM_NRF52,
PLATFORM_LN882X,
@@ -58,7 +58,7 @@ FILTER_SOURCE_FILES = filter_source_files_from_platform(
PlatformFramework.ESP32_ARDUINO,
PlatformFramework.ESP32_IDF,
},
"internal_temperature_rp2040.cpp": {PlatformFramework.RP2040_ARDUINO},
"internal_temperature_rp2.cpp": {PlatformFramework.RP2_ARDUINO},
"internal_temperature_bk72xx.cpp": {
PlatformFramework.BK72XX_ARDUINO,
},
+7 -11
View File
@@ -54,7 +54,7 @@ from esphome.const import (
PLATFORM_ESP8266,
PLATFORM_LN882X,
PLATFORM_NRF52,
PLATFORM_RP2040,
PLATFORM_RP2,
PLATFORM_RTL87XX,
PlatformFramework,
)
@@ -154,7 +154,7 @@ HARDWARE_UART_TO_SERIAL = {
UART2: cg.global_ns.Serial2,
DEFAULT: cg.global_ns.Serial,
},
PLATFORM_RP2040: {
PLATFORM_RP2: {
UART0: cg.global_ns.Serial1,
UART1: cg.global_ns.Serial2,
USB_CDC: cg.global_ns.Serial,
@@ -171,7 +171,7 @@ def uart_selection(value):
return cv.one_of(*UART_SELECTION_ESP32[variant], upper=True)(value)
if CORE.is_esp8266:
return cv.one_of(*UART_SELECTION_ESP8266, upper=True)(value)
if CORE.is_rp2040:
if CORE.is_rp2:
return cv.one_of(*UART_SELECTION_RP2040, upper=True)(value)
if CORE.is_libretiny:
family = get_libretiny_family()
@@ -282,7 +282,7 @@ CONFIG_SCHEMA = cv.All(
esp32_s2=USB_CDC,
esp32_s3=USB_SERIAL_JTAG,
esp32_s31=USB_SERIAL_JTAG,
rp2040=USB_CDC,
rp2=USB_CDC,
bk72xx=DEFAULT,
ln882x=DEFAULT,
rtl87xx=DEFAULT,
@@ -292,7 +292,7 @@ CONFIG_SCHEMA = cv.All(
[
PLATFORM_ESP8266,
PLATFORM_ESP32,
PLATFORM_RP2040,
PLATFORM_RP2,
PLATFORM_BK72XX,
PLATFORM_LN882X,
PLATFORM_RTL87XX,
@@ -417,11 +417,7 @@ async def _late_logger_init(config: ConfigType) -> None:
cg.add_define("USE_ESP8266_LOGGER_SERIAL1")
enable_serial1()
if (
(CORE.is_esp8266 or CORE.is_rp2040)
and has_serial_logging
and is_at_least_verbose
):
if (CORE.is_esp8266 or CORE.is_rp2) and has_serial_logging and is_at_least_verbose:
debug_serial_port = HARDWARE_UART_TO_SERIAL[CORE.target_platform][
config.get(CONF_HARDWARE_UART)
]
@@ -605,7 +601,7 @@ FILTER_SOURCE_FILES = filter_source_files_from_platform(
},
"logger_esp8266.cpp": {PlatformFramework.ESP8266_ARDUINO},
"logger_host.cpp": {PlatformFramework.HOST_NATIVE},
"logger_rp2040.cpp": {PlatformFramework.RP2040_ARDUINO},
"logger_rp2.cpp": {PlatformFramework.RP2_ARDUINO},
"logger_libretiny.cpp": {
PlatformFramework.BK72XX_ARDUINO,
PlatformFramework.RTL87XX_ARDUINO,
+1 -1
View File
@@ -206,7 +206,7 @@ void Logger::set_baud_rate(uint32_t baud_rate) { this->baud_rate_ = baud_rate; }
void Logger::set_log_level(const char *tag, uint8_t log_level) { this->log_levels_[tag] = log_level; }
#endif
#if defined(USE_ESP32) || defined(USE_ESP8266) || defined(USE_RP2040) || defined(USE_LIBRETINY) || defined(USE_ZEPHYR)
#if defined(USE_ESP32) || defined(USE_ESP8266) || defined(USE_RP2) || defined(USE_LIBRETINY) || defined(USE_ZEPHYR)
UARTSelection Logger::get_uart() const { return this->uart_; }
#endif
+8 -8
View File
@@ -23,10 +23,10 @@
#if defined(USE_ESP8266)
#include <HardwareSerial.h>
#endif // USE_ESP8266
#ifdef USE_RP2040
#ifdef USE_RP2
#include <HardwareSerial.h>
#include <SerialUSB.h>
#endif // USE_RP2040
#endif // USE_RP2
#endif // USE_ARDUINO
#ifdef USE_ESP32
@@ -96,7 +96,7 @@ struct CStrCompare {
// macOS allows up to 64 bytes, Linux up to 16
static constexpr size_t THREAD_NAME_BUF_SIZE = 64;
#if defined(USE_ESP32) || defined(USE_ESP8266) || defined(USE_RP2040) || defined(USE_LIBRETINY) || defined(USE_ZEPHYR)
#if defined(USE_ESP32) || defined(USE_ESP8266) || defined(USE_RP2) || defined(USE_LIBRETINY) || defined(USE_ZEPHYR)
/** Enum for logging UART selection
*
* Advanced configuration (pin selection, etc) is not supported.
@@ -122,7 +122,7 @@ enum UARTSelection : uint8_t {
UART_SELECTION_UART0_SWAP,
#endif // USE_ESP8266
};
#endif // USE_ESP32 || USE_ESP8266 || USE_RP2040 || USE_LIBRETINY || USE_ZEPHYR
#endif // USE_ESP32 || USE_ESP8266 || USE_RP2 || USE_LIBRETINY || USE_ZEPHYR
/**
* @brief Logger component for all ESPHome logging.
@@ -160,7 +160,7 @@ class Logger final : public Component {
#ifdef USE_HOST
void create_pthread_key() { pthread_key_create(&log_recursion_key_, nullptr); }
#endif
#if defined(USE_ESP32) || defined(USE_ESP8266) || defined(USE_RP2040) || defined(USE_LIBRETINY) || defined(USE_ZEPHYR)
#if defined(USE_ESP32) || defined(USE_ESP8266) || defined(USE_RP2) || defined(USE_LIBRETINY) || defined(USE_ZEPHYR)
void set_uart_selection(UARTSelection uart_selection) { uart_ = uart_selection; }
/// Get the UART used by the logger.
UARTSelection get_uart() const;
@@ -351,7 +351,7 @@ class Logger final : public Component {
#endif
// Group smaller types together at the end
uint8_t current_level_{ESPHOME_LOG_LEVEL_VERY_VERBOSE};
#if defined(USE_ESP32) || defined(USE_ESP8266) || defined(USE_RP2040) || defined(USE_ZEPHYR)
#if defined(USE_ESP32) || defined(USE_ESP8266) || defined(USE_RP2) || defined(USE_ZEPHYR)
UARTSelection uart_{UART_SELECTION_UART0};
#endif
#ifdef USE_LIBRETINY
@@ -505,8 +505,8 @@ class LoggerMessageTrigger final : public Trigger<uint8_t, const char *, const c
#include "logger_esp32.h"
#elif defined(USE_ESP8266)
#include "logger_esp8266.h"
#elif defined(USE_RP2040)
#include "logger_rp2040.h"
#elif defined(USE_RP2)
#include "logger_rp2.h"
#elif defined(USE_LIBRETINY)
#include "logger_libretiny.h"
#endif
@@ -1,8 +1,8 @@
#ifdef USE_RP2040
#ifdef USE_RP2
#include "logger.h"
#include "esphome/core/defines.h"
#ifdef USE_RP2040_CRASH_HANDLER
#include "esphome/components/rp2040/crash_handler.h"
#ifdef USE_RP2_CRASH_HANDLER
#include "esphome/components/rp2/crash_handler.h"
#endif
#include "esphome/core/log.h"
@@ -29,8 +29,8 @@ void Logger::pre_setup() {
}
global_logger = this;
ESP_LOGI(TAG, "Log initialized");
#ifdef USE_RP2040_CRASH_HANDLER
rp2040::crash_handler_log();
#ifdef USE_RP2_CRASH_HANDLER
rp2::crash_handler_log();
#endif
}
@@ -50,4 +50,4 @@ const LogString *Logger::get_uart_selection_() {
}
} // namespace esphome::logger
#endif // USE_RP2040
#endif // USE_RP2
@@ -1,6 +1,6 @@
#pragma once
#ifdef USE_RP2040
#ifdef USE_RP2
#include "esphome/core/helpers.h"
namespace esphome::logger {
+1 -1
View File
@@ -929,7 +929,7 @@ void lv_mem_init() {}
void lv_mem_deinit() {}
#if defined(USE_HOST) || defined(USE_RP2040) || defined(USE_ESP8266)
#if defined(USE_HOST) || defined(USE_RP2) || defined(USE_ESP8266)
void *lv_malloc_core(size_t size) {
auto *ptr = malloc(size); // NOLINT
if (ptr == nullptr) {
+4 -4
View File
@@ -5,7 +5,7 @@
namespace esphome::md5 {
#if defined(USE_ARDUINO) && !defined(USE_RP2040) && !defined(USE_ESP32)
#if defined(USE_ARDUINO) && !defined(USE_RP2) && !defined(USE_ESP32)
void MD5Digest::init() {
memset(this->digest_, 0, 16);
MD5Init(&this->ctx_);
@@ -14,7 +14,7 @@ void MD5Digest::init() {
void MD5Digest::add(const uint8_t *data, size_t len) { MD5Update(&this->ctx_, data, len); }
void MD5Digest::calculate() { MD5Final(this->digest_, &this->ctx_); }
#endif // USE_ARDUINO && !USE_RP2040
#endif // USE_ARDUINO && !USE_RP2
#ifdef USE_ESP32
void MD5Digest::init() {
@@ -27,7 +27,7 @@ void MD5Digest::add(const uint8_t *data, size_t len) { esp_rom_md5_update(&this-
void MD5Digest::calculate() { esp_rom_md5_final(this->digest_, &this->ctx_); }
#endif // USE_ESP32
#ifdef USE_RP2040
#ifdef USE_RP2
void MD5Digest::init() {
memset(this->digest_, 0, 16);
br_md5_init(&this->ctx_);
@@ -36,7 +36,7 @@ void MD5Digest::init() {
void MD5Digest::add(const uint8_t *data, size_t len) { br_md5_update(&this->ctx_, data, len); }
void MD5Digest::calculate() { br_md5_out(&this->ctx_, this->digest_); }
#endif // USE_RP2040
#endif // USE_RP2
#ifdef USE_HOST
MD5Digest::~MD5Digest() {
+1 -1
View File
@@ -19,7 +19,7 @@
#define MD5_CTX_TYPE md5_context_t
#endif
#ifdef USE_RP2040
#ifdef USE_RP2
#include <MD5Builder.h>
#define MD5_CTX_TYPE br_md5_context
#endif
+6 -6
View File
@@ -70,11 +70,11 @@ def _require_network_interface(config: ConfigType) -> ConfigType:
window. Reject at config time rather than silently producing a component
that never initializes.
"""
if config.get(CONF_DISABLED) or not (CORE.is_esp8266 or CORE.is_rp2040):
if config.get(CONF_DISABLED) or not (CORE.is_esp8266 or CORE.is_rp2):
return config
full_config = fv.full_config.get()
has_wifi = "wifi" in full_config
has_ethernet = CORE.is_rp2040 and "ethernet" in full_config
has_ethernet = CORE.is_rp2 and "ethernet" in full_config
if not (has_wifi or has_ethernet):
options = "'wifi'" if CORE.is_esp8266 else "'wifi' or 'ethernet'"
raise cv.Invalid(
@@ -192,18 +192,18 @@ async def to_code(config):
if CORE.using_arduino:
if CORE.is_esp8266:
cg.add_library("ESP8266mDNS", None)
elif CORE.is_rp2040:
elif CORE.is_rp2:
cg.add_library("LEAmDNS", None)
# Subscribe to the network IP state listener(s) so MDNS.update() is only
# scheduled during the probe+announce phase. Same on_ip_state() override
# serves both WiFi and Ethernet (signatures match).
if CORE.is_esp8266 or CORE.is_rp2040:
if CORE.is_esp8266 or CORE.is_rp2:
if "wifi" in CORE.config:
from esphome.components import wifi
wifi.request_wifi_ip_state_listener()
if CORE.is_rp2040 and "ethernet" in CORE.config:
if CORE.is_rp2 and "ethernet" in CORE.config:
from esphome.components import ethernet
ethernet.request_ethernet_ip_state_listener()
@@ -274,7 +274,7 @@ FILTER_SOURCE_FILES = filter_source_files_from_platform(
},
"mdns_esp8266.cpp": {PlatformFramework.ESP8266_ARDUINO},
"mdns_host.cpp": {PlatformFramework.HOST_NATIVE},
"mdns_rp2040.cpp": {PlatformFramework.RP2040_ARDUINO},
"mdns_rp2.cpp": {PlatformFramework.RP2_ARDUINO},
"mdns_libretiny.cpp": {
PlatformFramework.BK72XX_ARDUINO,
PlatformFramework.RTL87XX_ARDUINO,
+4 -4
View File
@@ -100,7 +100,7 @@ void MDNSComponent::compile_records_(StaticVector<MDNSService, MDNS_SERVICE_COUN
if (!friendly_name_empty) {
txt_count++; // friendly_name
}
#if defined(USE_ESP8266) || defined(USE_ESP32) || defined(USE_RP2040) || defined(USE_LIBRETINY) || defined(USE_NRF52)
#if defined(USE_ESP8266) || defined(USE_ESP32) || defined(USE_RP2) || defined(USE_LIBRETINY) || defined(USE_NRF52)
txt_count++; // platform
#endif
#if defined(USE_WIFI) || defined(USE_ETHERNET) || defined(USE_OPENTHREAD)
@@ -136,9 +136,9 @@ void MDNSComponent::compile_records_(StaticVector<MDNSService, MDNS_SERVICE_COUN
#elif defined(USE_ESP32)
MDNS_STATIC_CONST_CHAR(PLATFORM_ESP32, "ESP32");
txt_records.push_back({MDNS_STR(TXT_PLATFORM), MDNS_STR(PLATFORM_ESP32)});
#elif defined(USE_RP2040)
MDNS_STATIC_CONST_CHAR(PLATFORM_RP2040, "RP2040");
txt_records.push_back({MDNS_STR(TXT_PLATFORM), MDNS_STR(PLATFORM_RP2040)});
#elif defined(USE_RP2)
MDNS_STATIC_CONST_CHAR(PLATFORM_RP2, "RP2");
txt_records.push_back({MDNS_STR(TXT_PLATFORM), MDNS_STR(PLATFORM_RP2)});
#elif defined(USE_LIBRETINY)
txt_records.push_back({MDNS_STR(TXT_PLATFORM), MDNS_STR(lt_cpu_get_model_name())});
#elif defined(USE_NRF52)
+2 -2
View File
@@ -7,7 +7,7 @@
#include "esphome/core/helpers.h"
// On ESP8266 and RP2040 the scheduler-backed MDNS.update() polling window is armed by
// IP state listener events on whichever network interface is configured.
#if (defined(USE_ESP8266) || defined(USE_RP2040)) && \
#if (defined(USE_ESP8266) || defined(USE_RP2)) && \
((defined(USE_WIFI) && defined(USE_WIFI_IP_STATE_LISTENERS)) || \
(defined(USE_ETHERNET) && defined(USE_ETHERNET_IP_STATE_LISTENERS)))
#include "esphome/components/network/ip_address.h"
@@ -145,7 +145,7 @@ class MDNSComponent final : public Component
#ifdef USE_MDNS_STORE_SERVICES
StaticVector<MDNSService, MDNS_SERVICE_COUNT> services_{};
#endif
#if defined(USE_RP2040) && defined(USE_MDNS_EVENT_DRIVEN_POLLING)
#if defined(USE_RP2) && defined(USE_MDNS_EVENT_DRIVEN_POLLING)
// RP2040 defers MDNS.begin() until the first IP-up event; this tracks that.
bool initialized_{false};
#endif
@@ -1,5 +1,5 @@
#include "esphome/core/defines.h"
#if defined(USE_RP2040) && defined(USE_MDNS)
#if defined(USE_RP2) && defined(USE_MDNS)
#include "esphome/components/network/ip_address.h"
#include "esphome/components/network/util.h"
@@ -17,7 +17,7 @@
namespace esphome::mdns {
static void register_rp2040(MDNSComponent *, StaticVector<MDNSService, MDNS_SERVICE_COUNT> &services) {
static void register_rp2(MDNSComponent *, StaticVector<MDNSService, MDNS_SERVICE_COUNT> &services) {
MDNS.begin(App.get_name().c_str());
for (const auto &service : services) {
@@ -82,7 +82,7 @@ void MDNSComponent::on_ip_state(const network::IPAddresses &ips, const network::
return;
}
if (!this->initialized_) {
this->setup_buffers_and_register_(register_rp2040);
this->setup_buffers_and_register_(register_rp2);
this->initialized_ = true;
} else {
MDNS.notifyAPChange();
+1 -10
View File
@@ -57,7 +57,6 @@ from esphome.const import (
PLATFORM_BK72XX,
PLATFORM_ESP32,
PLATFORM_ESP8266,
PLATFORM_LN882X,
PLATFORM_RTL87XX,
PlatformFramework,
)
@@ -319,15 +318,7 @@ CONFIG_SCHEMA = cv.All(
}
),
validate_config,
cv.only_on(
[
PLATFORM_BK72XX,
PLATFORM_ESP32,
PLATFORM_ESP8266,
PLATFORM_LN882X,
PLATFORM_RTL87XX,
]
),
cv.only_on([PLATFORM_ESP32, PLATFORM_ESP8266, PLATFORM_BK72XX, PLATFORM_RTL87XX]),
_consume_mqtt_sockets,
)
+1 -1
View File
@@ -319,7 +319,7 @@ bool MQTTComponent::send_discovery_() {
device_info[MQTT_DEVICE_MODEL] = ESPHOME_BOARD;
#if defined(USE_ESP8266) || defined(USE_ESP32)
device_info[MQTT_DEVICE_MANUFACTURER] = "Espressif";
#elif defined(USE_RP2040)
#elif defined(USE_RP2)
device_info[MQTT_DEVICE_MANUFACTURER] = "Raspberry Pi";
#elif defined(USE_BK72XX)
device_info[MQTT_DEVICE_MANUFACTURER] = "Beken";
+3 -3
View File
@@ -124,7 +124,7 @@ CONFIG_SCHEMA = cv.Schema(
esp32=False,
esp8266=False,
host=False,
rp2040=False,
rp2=False,
nrf52=True,
): cv.All(
cv.boolean,
@@ -135,7 +135,7 @@ CONFIG_SCHEMA = cv.Schema(
esp32_arduino=cv.Version(0, 0, 0),
esp8266_arduino=cv.Version(0, 0, 0),
host=cv.Version(0, 0, 0),
rp2040_arduino=cv.Version(0, 0, 0),
rp2_arduino=cv.Version(0, 0, 0),
nrf52_zephyr=cv.Version(0, 0, 0),
),
cv.boolean_false,
@@ -263,7 +263,7 @@ async def to_code(config):
cg.add_build_flag("-DCONFIG_IPV6")
if CORE.is_esp8266:
cg.add_build_flag("-DPIO_FRAMEWORK_ARDUINO_LWIP2_IPV6_LOW_MEMORY")
if CORE.is_rp2040:
if CORE.is_rp2:
cg.add_build_flag("-DPIO_FRAMEWORK_ARDUINO_ENABLE_IPV6")
# Pvariable creation lives in a separate coroutine at NETWORK_SERVICES so it
# emits after wifi/ethernet at COMMUNICATION. This keeps compile-time config
+1 -1
View File
@@ -19,7 +19,7 @@ FILTER_SOURCE_FILES = filter_source_files_from_platform(
},
"nextion_upload_arduino.cpp": {
PlatformFramework.ESP8266_ARDUINO,
PlatformFramework.RP2040_ARDUINO,
PlatformFramework.RP2_ARDUINO,
PlatformFramework.BK72XX_ARDUINO,
PlatformFramework.RTL87XX_ARDUINO,
PlatformFramework.LN882X_ARDUINO,
+1 -1
View File
@@ -61,7 +61,7 @@ CONFIG_SCHEMA = cv.Schema(
# esp8266_arduino=cv.Version(2, 7, 0),
esp32_arduino=cv.Version(0, 0, 0),
esp_idf=cv.Version(4, 0, 0),
rp2040_arduino=cv.Version(0, 0, 0),
rp2_arduino=cv.Version(0, 0, 0),
host=cv.Version(0, 0, 0),
),
runtime_image.validate_runtime_image_settings,
+2 -2
View File
@@ -99,7 +99,7 @@ async def to_code(config):
cg.add_define("USE_OTA")
CORE.add_job(final_step)
if CORE.is_rp2040 and CORE.using_arduino:
if CORE.is_rp2 and CORE.using_arduino:
cg.add_library("Updater", None)
@@ -158,7 +158,7 @@ FILTER_SOURCE_FILES = filter_source_files_from_platform(
PlatformFramework.ESP32_IDF,
},
"ota_backend_esp8266.cpp": {PlatformFramework.ESP8266_ARDUINO},
"ota_backend_arduino_rp2040.cpp": {PlatformFramework.RP2040_ARDUINO},
"ota_backend_arduino_rp2.cpp": {PlatformFramework.RP2_ARDUINO},
"ota_backend_arduino_libretiny.cpp": {
PlatformFramework.BK72XX_ARDUINO,
PlatformFramework.RTL87XX_ARDUINO,
@@ -1,9 +1,9 @@
#ifdef USE_ARDUINO
#ifdef USE_RP2040
#include "ota_backend_arduino_rp2040.h"
#ifdef USE_RP2
#include "ota_backend_arduino_rp2.h"
#include "ota_backend.h"
#include "esphome/components/rp2040/preferences.h"
#include "esphome/components/rp2/preferences.h"
#include "esphome/core/defines.h"
#include "esphome/core/log.h"
@@ -11,11 +11,11 @@
namespace esphome::ota {
static const char *const TAG = "ota.arduino_rp2040";
static const char *const TAG = "ota.arduino_rp2";
std::unique_ptr<ArduinoRP2040OTABackend> make_ota_backend() { return make_unique<ArduinoRP2040OTABackend>(); }
std::unique_ptr<ArduinoRP2OTABackend> make_ota_backend() { return make_unique<ArduinoRP2OTABackend>(); }
OTAResponseTypes ArduinoRP2040OTABackend::begin(size_t image_size, OTAType ota_type) {
OTAResponseTypes ArduinoRP2OTABackend::begin(size_t image_size, OTAType ota_type) {
if (ota_type != OTA_TYPE_UPDATE_APP) {
return OTA_RESPONSE_ERROR_UNSUPPORTED_OTA_TYPE;
}
@@ -23,7 +23,7 @@ OTAResponseTypes ArduinoRP2040OTABackend::begin(size_t image_size, OTAType ota_t
// web_server is not supported for RP2040, so this is not an issue.
bool ret = Update.begin(image_size, U_FLASH);
if (ret) {
rp2040::preferences_prevent_write(true);
rp2::preferences_prevent_write(true);
return OTA_RESPONSE_OK;
}
@@ -42,12 +42,12 @@ OTAResponseTypes ArduinoRP2040OTABackend::begin(size_t image_size, OTAType ota_t
return OTA_RESPONSE_ERROR_UNKNOWN;
}
void ArduinoRP2040OTABackend::set_update_md5(const char *md5) {
void ArduinoRP2OTABackend::set_update_md5(const char *md5) {
Update.setMD5(md5);
this->md5_set_ = true;
}
OTAResponseTypes ArduinoRP2040OTABackend::write(uint8_t *data, size_t len) {
OTAResponseTypes ArduinoRP2OTABackend::write(uint8_t *data, size_t len) {
size_t written = Update.write(data, len);
if (written == len) {
return OTA_RESPONSE_OK;
@@ -59,7 +59,7 @@ OTAResponseTypes ArduinoRP2040OTABackend::write(uint8_t *data, size_t len) {
return OTA_RESPONSE_ERROR_WRITING_FLASH;
}
OTAResponseTypes ArduinoRP2040OTABackend::end() {
OTAResponseTypes ArduinoRP2OTABackend::end() {
// Use strict validation (false) when MD5 is set, lenient validation (true) when no MD5
// This matches the behavior of the old web_server OTA implementation
if (Update.end(!this->md5_set_)) {
@@ -72,11 +72,11 @@ OTAResponseTypes ArduinoRP2040OTABackend::end() {
return OTA_RESPONSE_ERROR_UPDATE_END;
}
void ArduinoRP2040OTABackend::abort() {
void ArduinoRP2OTABackend::abort() {
Update.end();
rp2040::preferences_prevent_write(false);
rp2::preferences_prevent_write(false);
}
} // namespace esphome::ota
#endif // USE_RP2040
#endif // USE_RP2
#endif // USE_ARDUINO
@@ -1,6 +1,6 @@
#pragma once
#ifdef USE_ARDUINO
#ifdef USE_RP2040
#ifdef USE_RP2
#include "ota_backend.h"
#include "esphome/core/defines.h"
@@ -8,7 +8,7 @@
namespace esphome::ota {
class ArduinoRP2040OTABackend final {
class ArduinoRP2OTABackend final {
public:
OTAResponseTypes begin(size_t image_size, OTAType ota_type = OTA_TYPE_UPDATE_APP);
void set_update_md5(const char *md5);
@@ -21,8 +21,8 @@ class ArduinoRP2040OTABackend final {
bool md5_set_{false};
};
std::unique_ptr<ArduinoRP2040OTABackend> make_ota_backend();
std::unique_ptr<ArduinoRP2OTABackend> make_ota_backend();
} // namespace esphome::ota
#endif // USE_RP2040
#endif // USE_RP2
#endif // USE_ARDUINO
+2 -2
View File
@@ -8,8 +8,8 @@
#include "ota_backend_esp8266.h"
#elif defined(USE_ESP32)
#include "ota_backend_esp_idf.h"
#elif defined(USE_RP2040)
#include "ota_backend_arduino_rp2040.h"
#elif defined(USE_RP2)
#include "ota_backend_arduino_rp2.h"
#elif defined(USE_LIBRETINY)
#include "ota_backend_arduino_libretiny.h"
#elif defined(USE_HOST)
@@ -118,7 +118,7 @@ CONFIG_SCHEMA = remote_base.validate_triggers(
bk72xx="1000b",
ln882x="1000b",
rtl87xx="1000b",
rp2040="1000b",
rp2="1000b",
): cv.validate_bytes,
cv.Optional(CONF_FILTER, default="50us"): cv.All(
cv.positive_time_period_microseconds,
@@ -248,7 +248,7 @@ FILTER_SOURCE_FILES = filter_source_files_from_platform(
PlatformFramework.BK72XX_ARDUINO,
PlatformFramework.RTL87XX_ARDUINO,
PlatformFramework.LN882X_ARDUINO,
PlatformFramework.RP2040_ARDUINO,
PlatformFramework.RP2_ARDUINO,
},
}
)
@@ -3,7 +3,7 @@
#include "esphome/core/helpers.h"
#include "esphome/core/log.h"
#if defined(USE_LIBRETINY) || defined(USE_ESP8266) || defined(USE_RP2040) || (defined(USE_ESP32) && !SOC_RMT_SUPPORTED)
#if defined(USE_LIBRETINY) || defined(USE_ESP8266) || defined(USE_RP2) || (defined(USE_ESP32) && !SOC_RMT_SUPPORTED)
namespace esphome::remote_receiver {
@@ -14,7 +14,7 @@
namespace esphome::remote_receiver {
#if defined(USE_ESP8266) || defined(USE_LIBRETINY) || defined(USE_RP2040) || (defined(USE_ESP32) && !SOC_RMT_SUPPORTED)
#if defined(USE_ESP8266) || defined(USE_LIBRETINY) || defined(USE_RP2) || (defined(USE_ESP32) && !SOC_RMT_SUPPORTED)
struct RemoteReceiverComponentStore {
static void gpio_intr(RemoteReceiverComponentStore *arg);
@@ -93,11 +93,11 @@ class RemoteReceiverComponent final : public remote_base::RemoteReceiverBase,
std::string error_string_;
#endif
#if defined(USE_ESP8266) || defined(USE_LIBRETINY) || defined(USE_RP2040) || defined(USE_ESP32)
#if defined(USE_ESP8266) || defined(USE_LIBRETINY) || defined(USE_RP2) || defined(USE_ESP32)
RemoteReceiverComponentStore store_;
#endif
#if defined(USE_ESP8266) || defined(USE_LIBRETINY) || defined(USE_RP2040) || (defined(USE_ESP32) && !SOC_RMT_SUPPORTED)
#if defined(USE_ESP8266) || defined(USE_LIBRETINY) || defined(USE_RP2) || (defined(USE_ESP32) && !SOC_RMT_SUPPORTED)
HighFrequencyLoopRequester high_freq_;
#endif
@@ -185,7 +185,7 @@ FILTER_SOURCE_FILES = filter_source_files_from_platform(
PlatformFramework.BK72XX_ARDUINO,
PlatformFramework.RTL87XX_ARDUINO,
PlatformFramework.LN882X_ARDUINO,
PlatformFramework.RP2040_ARDUINO,
PlatformFramework.RP2_ARDUINO,
},
}
)
@@ -2,7 +2,7 @@
#include "esphome/core/log.h"
#include "esphome/core/application.h"
#if defined(USE_LIBRETINY) || defined(USE_ESP8266) || defined(USE_RP2040) || (defined(USE_ESP32) && !SOC_RMT_SUPPORTED)
#if defined(USE_LIBRETINY) || defined(USE_ESP8266) || defined(USE_RP2) || (defined(USE_ESP32) && !SOC_RMT_SUPPORTED)
namespace esphome::remote_transmitter {
@@ -64,7 +64,7 @@ class RemoteTransmitterComponent final : public remote_base::RemoteTransmitterBa
protected:
void send_internal(uint32_t send_times, uint32_t send_wait) override;
#if defined(USE_ESP8266) || defined(USE_LIBRETINY) || defined(USE_RP2040) || (defined(USE_ESP32) && !SOC_RMT_SUPPORTED)
#if defined(USE_ESP8266) || defined(USE_LIBRETINY) || defined(USE_RP2) || (defined(USE_ESP32) && !SOC_RMT_SUPPORTED)
void calculate_on_off_time_(uint32_t carrier_frequency, uint32_t *on_time_period, uint32_t *off_time_period);
void mark_(uint32_t on_time, uint32_t off_time, uint32_t usec);
@@ -21,7 +21,7 @@ from esphome.const import (
KEY_FRAMEWORK_VERSION,
KEY_TARGET_FRAMEWORK,
KEY_TARGET_PLATFORM,
PLATFORM_RP2040,
PLATFORM_RP2,
ThreadModel,
)
from esphome.core import (
@@ -40,27 +40,34 @@ from .const import (
KEY_BOARD,
KEY_LWIP_OPTS,
KEY_PIO_FILES,
KEY_RP2040,
KEY_RP2,
KEY_VARIANT,
MCU_TO_VARIANT,
STANDARD_BOARDS,
VARIANT_FRIENDLY,
VARIANTS,
rp2040_ns,
rp2_ns,
)
# force import gpio to register pin schema
from .gpio import rp2040_pin_to_code # noqa: F401
from .gpio import rp2_pin_to_code # noqa: F401
_LOGGER = logging.getLogger(__name__)
CODEOWNERS = ["@jesserockz"]
AUTO_LOAD = ["preferences"]
IS_TARGET_PLATFORM = True
# Legacy top-level YAML keys that route here. The framework
# (esphome/loader.py + esphome/config.py) handles both the deprecation
# warning and the key-rename pass; this declaration is the only place a
# component needs to opt in. See ComponentManifest.aliases for details.
ALIASES = ["rp2040"]
ALIAS_REMOVAL_VERSION = "2027.7.0"
def get_board() -> str:
"""Return the configured board name."""
return CORE.data[KEY_RP2040][KEY_BOARD]
return CORE.data[KEY_RP2][KEY_BOARD]
def board_has_wifi() -> bool:
@@ -90,22 +97,22 @@ def board_id_has_wifi(board_id: str) -> bool:
def set_core_data(config: ConfigType) -> ConfigType:
CORE.data[KEY_RP2040] = {}
CORE.data[KEY_CORE][KEY_TARGET_PLATFORM] = PLATFORM_RP2040
CORE.data[KEY_RP2] = {}
CORE.data[KEY_CORE][KEY_TARGET_PLATFORM] = PLATFORM_RP2
CORE.data[KEY_CORE][KEY_TARGET_FRAMEWORK] = "arduino"
CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION] = cv.Version.parse(
config[CONF_FRAMEWORK][CONF_VERSION]
)
CORE.data[KEY_RP2040][KEY_BOARD] = config[CONF_BOARD]
CORE.data[KEY_RP2040][KEY_VARIANT] = config[CONF_VARIANT]
CORE.data[KEY_RP2][KEY_BOARD] = config[CONF_BOARD]
CORE.data[KEY_RP2][KEY_VARIANT] = config[CONF_VARIANT]
CORE.data[KEY_RP2040][KEY_PIO_FILES] = {}
CORE.data[KEY_RP2][KEY_PIO_FILES] = {}
return config
def get_rp2040_variant(core_obj: EsphomeCore | None = None) -> str:
return (core_obj or CORE).data[KEY_RP2040][KEY_VARIANT]
return (core_obj or CORE).data[KEY_RP2][KEY_VARIANT]
def only_on_variant(
@@ -121,7 +128,7 @@ def only_on_variant(
unsupported = [unsupported]
def validator_(obj: Any) -> Any:
if not CORE.is_rp2040:
if not CORE.is_rp2:
raise cv.Invalid(f"{msg_prefix} is only available on RP2040")
variant = get_rp2040_variant()
if supported is not None and variant not in supported:
@@ -306,13 +313,18 @@ CONFIG_SCHEMA = cv.All(
@coroutine_with_priority(CoroPriority.PLATFORM)
async def to_code(config):
cg.add(rp2040_ns.setup_preferences())
cg.add(rp2_ns.setup_preferences())
# Allow LDF to properly discover dependency including those in preprocessor
# conditionals
cg.add_platformio_option("lib_ldf_mode", "chain+")
cg.add_platformio_option("lib_compat_mode", "strict")
cg.add_platformio_option("board", config[CONF_BOARD])
cg.add_build_flag("-DUSE_RP2")
# USE_RP2040 kept defined as a backwards-compat alias for external
# custom components that may still test for it. Internal code uses
# USE_RP2 (the canonical name for the RP2 chip family — covers
# RP2040, RP2350, and any future RP2-series chips).
cg.add_build_flag("-DUSE_RP2040")
cg.add_define("USE_NATIVE_64BIT_TIME")
cg.set_cpp_standard("gnu++20")
@@ -327,7 +339,8 @@ async def to_code(config):
conf = config[CONF_FRAMEWORK]
cg.add_platformio_option("framework", "arduino")
cg.add_build_flag("-DUSE_ARDUINO")
cg.add_build_flag("-DUSE_RP2040_FRAMEWORK_ARDUINO")
cg.add_build_flag("-DUSE_RP2_FRAMEWORK_ARDUINO")
cg.add_build_flag("-DUSE_RP2040_FRAMEWORK_ARDUINO") # back-compat alias
# cg.add_build_flag("-DPICO_BOARD=pico_w")
cg.add_platformio_option("platform", conf[CONF_PLATFORM_VERSION])
cg.add_platformio_option(
@@ -359,8 +372,12 @@ async def to_code(config):
cg.RawExpression(f"VERSION_CODE({ver.major}, {ver.minor}, {ver.patch})"),
)
cg.add_define("USE_RP2040_WATCHDOG_TIMEOUT", config[CONF_WATCHDOG_TIMEOUT])
cg.add_define("USE_RP2040_CRASH_HANDLER")
cg.add_define("USE_RP2_WATCHDOG_TIMEOUT", config[CONF_WATCHDOG_TIMEOUT])
cg.add_define(
"USE_RP2040_WATCHDOG_TIMEOUT", config[CONF_WATCHDOG_TIMEOUT]
) # back-compat alias
cg.add_define("USE_RP2_CRASH_HANDLER")
cg.add_define("USE_RP2040_CRASH_HANDLER") # back-compat alias
_configure_lwip()
@@ -465,7 +482,7 @@ def _configure_lwip() -> None:
}
# Store for copy_files() to generate the header
CORE.data[KEY_RP2040][KEY_LWIP_OPTS] = lwip_defines
CORE.data[KEY_RP2][KEY_LWIP_OPTS] = lwip_defines
# Add a pre-build extra script that injects our lwip_override directory
# into CCFLAGS so our lwipopts.h shadows the framework's version.
@@ -500,7 +517,7 @@ def _generate_lwipopts_h() -> None:
"""
from jinja2 import Environment
lwip_defines = CORE.data[KEY_RP2040].get(KEY_LWIP_OPTS)
lwip_defines = CORE.data[KEY_RP2].get(KEY_LWIP_OPTS)
if not lwip_defines:
return
@@ -527,7 +544,7 @@ def add_pio_file(component: str, key: str, data: str):
raise EsphomeError(
f"[{component}] Invalid PIO key: {key}. Allowed characters: [{ascii_letters}{digits}_]\nPlease report an issue https://github.com/esphome/esphome/issues"
) from e
CORE.data[KEY_RP2040][KEY_PIO_FILES][key] = data
CORE.data[KEY_RP2][KEY_PIO_FILES][key] = data
def generate_pio_files() -> bool:
@@ -536,7 +553,7 @@ def generate_pio_files() -> bool:
shutil.rmtree(CORE.relative_build_path("src/pio"), ignore_errors=True)
includes: list[str] = []
files = CORE.data[KEY_RP2040][KEY_PIO_FILES]
files = CORE.data[KEY_RP2][KEY_PIO_FILES]
if not files:
return False
for key, data in files.items():
@@ -581,7 +598,7 @@ def copy_files():
# RP2040 crash handler stacktrace decoding
# Matches output from esphome/components/rp2040/crash_handler.cpp
# Matches output from esphome/components/rp2/crash_handler.cpp
_CRASH_RE = re.compile(r"CRASH DETECTED ON PREVIOUS BOOT")
_CRASH_ADDR_RE = re.compile(
r"(?:PC|LR|BT\d):\s+(0x[0-9a-fA-F]{8})\s+\((?:fault location|return address|stack backtrace)\)"
@@ -1,14 +1,14 @@
# Auto-generated by generate_boards.py — do not edit manually
# To regenerate: python esphome/components/rp2040/generate_boards.py <arduino-pico-path>
# To regenerate: python esphome/components/rp2/generate_boards.py <arduino-pico-path>
# arduino-pico maps pins >= {{ cyw43_gpio_offset }} to CYW43 wireless chip GPIOs
CYW43_GPIO_OFFSET = {{ cyw43_gpio_offset }}
CYW43_MAX_GPIO = {{ cyw43_max_gpio }}
DEFAULT_MAX_PIN = {{ default_max_pin }}
RP2040_BASE_PINS = {}
RP2_BASE_PINS = {}
RP2040_BOARD_PINS = {
RP2_BOARD_PINS = {
{%- for name, pins in board_pins %}
{{ name | repr }}: {{ pins | format_pins }},
{%- endfor %}
@@ -23,3 +23,10 @@ BOARDS = {
},
{%- endfor %}
}
# Deprecated: use RP2_BASE_PINS / RP2_BOARD_PINS instead. Kept as back-compat
# aliases so external custom components / tooling that imported the legacy
# names via the ``rp2040`` package alias keep working.
# Scheduled for removal in 2027.7.0.
RP2040_BASE_PINS = RP2_BASE_PINS
RP2040_BOARD_PINS = RP2_BOARD_PINS
@@ -1,14 +1,14 @@
# Auto-generated by generate_boards.py — do not edit manually
# To regenerate: python esphome/components/rp2040/generate_boards.py <arduino-pico-path>
# To regenerate: python esphome/components/rp2/generate_boards.py <arduino-pico-path>
# arduino-pico maps pins >= 64 to CYW43 wireless chip GPIOs
CYW43_GPIO_OFFSET = 64
CYW43_MAX_GPIO = 66
DEFAULT_MAX_PIN = 29
RP2040_BASE_PINS = {}
RP2_BASE_PINS = {}
RP2040_BOARD_PINS = {
RP2_BOARD_PINS = {
"0xcb_helios": {
"LED": 17,
"MISO": 20,
@@ -2299,3 +2299,10 @@ BOARDS = {
"max_pin": 29,
},
}
# Deprecated: use RP2_BASE_PINS / RP2_BOARD_PINS instead. Kept as back-compat
# aliases so external custom components / tooling that imported the legacy
# names via the ``rp2040`` package alias keep working.
# Scheduled for removal in 2027.7.0.
RP2040_BASE_PINS = RP2_BASE_PINS
RP2040_BOARD_PINS = RP2_BOARD_PINS
@@ -2,7 +2,7 @@ import esphome.codegen as cg
KEY_BOARD = "board"
KEY_LWIP_OPTS = "lwip_opts"
KEY_RP2040 = "rp2040"
KEY_RP2 = "rp2"
KEY_PIO_FILES = "pio_files"
KEY_VARIANT = "variant"
@@ -31,4 +31,4 @@ STANDARD_BOARDS = {
VARIANT_RP2350: "rpipico2w",
}
rp2040_ns = cg.esphome_ns.namespace("rp2040")
rp2_ns = cg.esphome_ns.namespace("rp2")
+6
View File
@@ -0,0 +1,6 @@
#ifdef USE_RP2
// HAL functions live in hal.cpp. core.cpp is intentionally empty for
// rp2 — there is no extra component bootstrap to keep here.
#endif // USE_RP2
@@ -1,12 +1,12 @@
#pragma once
#ifdef USE_RP2040
#ifdef USE_RP2
#include <Arduino.h>
#include <pico.h>
extern "C" unsigned long ulMainGetRunTimeCounterValue();
namespace esphome::rp2040 {} // namespace esphome::rp2040
namespace esphome::rp2 {} // namespace esphome::rp2
#endif // USE_RP2040
#endif // USE_RP2
@@ -1,7 +1,7 @@
#ifdef USE_RP2040
#ifdef USE_RP2
#include "esphome/core/defines.h"
#ifdef USE_RP2040_CRASH_HANDLER
#ifdef USE_RP2_CRASH_HANDLER
#include "crash_handler.h"
#include "esphome/core/log.h"
@@ -51,9 +51,9 @@ static inline bool is_code_addr(uint32_t val) {
static constexpr size_t MAX_BACKTRACE = 4;
namespace esphome::rp2040 {
namespace esphome::rp2 {
static const char *const TAG = "rp2040.crash";
static const char *const TAG = "rp2.crash";
// Placed in .noinit so BSS zero-init cannot race with crash_handler_read_and_clear().
// The valid field is explicitly cleared in crash_handler_read_and_clear() instead.
@@ -117,7 +117,7 @@ void crash_handler_log() {
ESP_LOGE(TAG, "%s", hint);
}
} // namespace esphome::rp2040
} // namespace esphome::rp2
// --- HardFault handler ---
// Overrides the weak isr_hardfault from arduino-pico's crt0.S.
@@ -236,5 +236,5 @@ extern "C" void __attribute__((naked, used)) isr_hardfault() {
: "i"(hard_fault_handler_c));
}
#endif // USE_RP2040_CRASH_HANDLER
#endif // USE_RP2040
#endif // USE_RP2_CRASH_HANDLER
#endif // USE_RP2
@@ -1,12 +1,12 @@
#pragma once
#ifdef USE_RP2040
#ifdef USE_RP2
#include "esphome/core/defines.h"
#ifdef USE_RP2040_CRASH_HANDLER
#ifdef USE_RP2_CRASH_HANDLER
namespace esphome::rp2040 {
namespace esphome::rp2 {
/// Read crash data from watchdog scratch registers and clear them.
void crash_handler_read_and_clear();
@@ -17,7 +17,7 @@ void crash_handler_log();
/// Returns true if crash data was found this boot.
bool crash_handler_has_data();
} // namespace esphome::rp2040
} // namespace esphome::rp2
#endif // USE_RP2040_CRASH_HANDLER
#endif // USE_RP2040
#endif // USE_RP2_CRASH_HANDLER
#endif // USE_RP2
@@ -1,6 +1,6 @@
"""Generate boards.py from arduino-pico board definitions.
Usage: python esphome/components/rp2040/generate_boards.py <arduino-pico-path>
Usage: python esphome/components/rp2/generate_boards.py <arduino-pico-path>
"""
import json
@@ -1,12 +1,12 @@
#ifdef USE_RP2040
#ifdef USE_RP2
#include "gpio.h"
#include "esphome/core/log.h"
namespace esphome {
namespace rp2040 {
namespace rp2 {
static const char *const TAG = "rp2040";
static const char *const TAG = "rp2";
static int flags_to_mode(gpio::Flags flags, uint8_t pin) {
if (flags == gpio::FLAG_INPUT) { // NOLINT(bugprone-branch-clone)
@@ -30,7 +30,7 @@ struct ISRPinArg {
bool inverted;
};
ISRInternalGPIOPin RP2040GPIOPin::to_isr() const {
ISRInternalGPIOPin RP2GPIOPin::to_isr() const {
auto *arg = new ISRPinArg{}; // NOLINT(cppcoreguidelines-owning-memory)
arg->pin = this->pin_;
arg->inverted = this->inverted_;
@@ -38,7 +38,7 @@ ISRInternalGPIOPin RP2040GPIOPin::to_isr() const {
return ISRInternalGPIOPin((void *) arg);
}
void RP2040GPIOPin::attach_interrupt(void (*func)(void *), void *arg, gpio::InterruptType type) const {
void RP2GPIOPin::attach_interrupt(void (*func)(void *), void *arg, gpio::InterruptType type) const {
PinStatus arduino_mode = LOW;
switch (type) {
case gpio::INTERRUPT_RISING_EDGE:
@@ -60,25 +60,23 @@ void RP2040GPIOPin::attach_interrupt(void (*func)(void *), void *arg, gpio::Inte
attachInterrupt(pin_, func, arduino_mode, arg);
}
void RP2040GPIOPin::pin_mode(gpio::Flags flags) {
void RP2GPIOPin::pin_mode(gpio::Flags flags) {
pinMode(pin_, flags_to_mode(flags, pin_)); // NOLINT
}
size_t RP2040GPIOPin::dump_summary(char *buffer, size_t len) const {
return snprintf(buffer, len, "GPIO%u", this->pin_);
}
size_t RP2GPIOPin::dump_summary(char *buffer, size_t len) const { return snprintf(buffer, len, "GPIO%u", this->pin_); }
bool RP2040GPIOPin::digital_read() {
bool RP2GPIOPin::digital_read() {
return bool(digitalRead(pin_)) != inverted_; // NOLINT
}
void RP2040GPIOPin::digital_write(bool value) {
void RP2GPIOPin::digital_write(bool value) {
digitalWrite(pin_, value != inverted_ ? 1 : 0); // NOLINT
}
void RP2040GPIOPin::detach_interrupt() const { detachInterrupt(pin_); }
void RP2GPIOPin::detach_interrupt() const { detachInterrupt(pin_); }
} // namespace rp2040
} // namespace rp2
using namespace rp2040;
using namespace rp2;
bool IRAM_ATTR ISRInternalGPIOPin::digital_read() {
auto *arg = reinterpret_cast<ISRPinArg *>(this->arg_);
@@ -115,4 +113,4 @@ void IRAM_ATTR ISRInternalGPIOPin::pin_mode(gpio::Flags flags) {
} // namespace esphome
#endif // USE_RP2040
#endif // USE_RP2
@@ -1,13 +1,13 @@
#pragma once
#ifdef USE_RP2040
#ifdef USE_RP2
#include <Arduino.h>
#include "esphome/core/hal.h"
namespace esphome::rp2040 {
namespace esphome::rp2 {
class RP2040GPIOPin final : public InternalGPIOPin {
class RP2GPIOPin final : public InternalGPIOPin {
public:
void set_pin(uint8_t pin) { pin_ = pin; }
void set_inverted(bool inverted) { inverted_ = inverted; }
@@ -32,6 +32,6 @@ class RP2040GPIOPin final : public InternalGPIOPin {
gpio::Flags flags_{};
};
} // namespace esphome::rp2040
} // namespace esphome::rp2
#endif // USE_RP2040
#endif // USE_RP2
@@ -16,22 +16,22 @@ from esphome.const import (
from esphome.core import CORE
from . import boards
from .const import KEY_BOARD, KEY_RP2040, rp2040_ns
from .const import KEY_BOARD, KEY_RP2, rp2_ns
RP2040GPIOPin = rp2040_ns.class_("RP2040GPIOPin", cg.InternalGPIOPin)
RP2GPIOPin = rp2_ns.class_("RP2GPIOPin", cg.InternalGPIOPin)
def _lookup_pin(value):
board = CORE.data[KEY_RP2040][KEY_BOARD]
board_pins = boards.RP2040_BOARD_PINS.get(board, {})
board = CORE.data[KEY_RP2][KEY_BOARD]
board_pins = boards.RP2_BOARD_PINS.get(board, {})
while isinstance(board_pins, str):
board_pins = boards.RP2040_BOARD_PINS[board_pins]
board_pins = boards.RP2_BOARD_PINS[board_pins]
if value in board_pins:
return board_pins[value]
if value in boards.RP2040_BASE_PINS:
return boards.RP2040_BASE_PINS[value]
if value in boards.RP2_BASE_PINS:
return boards.RP2_BASE_PINS[value]
raise cv.Invalid(f"Cannot resolve pin name '{value}' for board {board}.")
@@ -61,7 +61,7 @@ def _board_max_virtual_pin(board):
def validate_gpio_pin(value):
value = _translate_pin(value)
board = CORE.data[KEY_RP2040][KEY_BOARD]
board = CORE.data[KEY_RP2][KEY_BOARD]
max_virtual = _board_max_virtual_pin(board)
if max_virtual is not None and boards.CYW43_GPIO_OFFSET <= value <= max_virtual:
return value
@@ -72,7 +72,7 @@ def validate_gpio_pin(value):
def validate_supports(value):
board = CORE.data[KEY_RP2040][KEY_BOARD]
board = CORE.data[KEY_RP2][KEY_BOARD]
if (
_board_max_virtual_pin(board) is None
or value[CONF_NUMBER] < boards.CYW43_GPIO_OFFSET
@@ -89,9 +89,9 @@ def validate_supports(value):
return value
RP2040_PIN_SCHEMA = cv.All(
RP2_PIN_SCHEMA = cv.All(
pins.gpio_base_schema(
RP2040GPIOPin,
RP2GPIOPin,
validate_gpio_pin,
modes=pins.GPIO_STANDARD_MODES + (CONF_ANALOG,),
),
@@ -99,8 +99,8 @@ RP2040_PIN_SCHEMA = cv.All(
)
@pins.PIN_SCHEMA_REGISTRY.register("rp2040", RP2040_PIN_SCHEMA)
async def rp2040_pin_to_code(config):
@pins.PIN_SCHEMA_REGISTRY.register("rp2", RP2_PIN_SCHEMA)
async def rp2_pin_to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
num = config[CONF_NUMBER]
cg.add(var.set_pin(num))
@@ -1,23 +1,23 @@
#ifdef USE_RP2040
#ifdef USE_RP2
#include "core.h"
#include "esphome/core/defines.h"
#include "esphome/core/hal.h"
#ifdef USE_RP2040_CRASH_HANDLER
#ifdef USE_RP2_CRASH_HANDLER
#include "crash_handler.h"
#endif
#include "hardware/watchdog.h"
// Empty rp2040 namespace block to satisfy ci-custom's lint_namespace check.
// Empty rp2 namespace block to satisfy ci-custom's lint_namespace check.
// HAL functions live in namespace esphome (root) — they are not part of the
// rp2040 component's API.
namespace esphome::rp2040 {} // namespace esphome::rp2040
// rp2 component's API.
namespace esphome::rp2 {} // namespace esphome::rp2
namespace esphome {
// yield(), delay(), micros(), millis(), millis_64(), delayMicroseconds(),
// arch_feed_wdt(), arch_get_cpu_cycle_count() inlined in components/rp2040/hal.h.
// arch_feed_wdt(), arch_get_cpu_cycle_count() inlined in components/rp2/hal.h.
void arch_restart() {
watchdog_reboot(0, 0, 10);
while (1) {
@@ -26,11 +26,11 @@ void arch_restart() {
}
void arch_init() {
#ifdef USE_RP2040_CRASH_HANDLER
rp2040::crash_handler_read_and_clear();
#ifdef USE_RP2_CRASH_HANDLER
rp2::crash_handler_read_and_clear();
#endif
#if USE_RP2040_WATCHDOG_TIMEOUT > 0
watchdog_enable(USE_RP2040_WATCHDOG_TIMEOUT, false);
#if USE_RP2_WATCHDOG_TIMEOUT > 0
watchdog_enable(USE_RP2_WATCHDOG_TIMEOUT, false);
#endif
}
@@ -38,4 +38,4 @@ uint32_t arch_get_cpu_freq_hz() { return RP2040::f_cpu(); }
} // namespace esphome
#endif // USE_RP2040
#endif // USE_RP2
@@ -1,6 +1,6 @@
#pragma once
#ifdef USE_RP2040
#ifdef USE_RP2
#include <cstdint>
@@ -25,7 +25,7 @@ extern "C" uint64_t time_us_64(void);
extern "C" void watchdog_update(void);
extern "C" unsigned long ulMainGetRunTimeCounterValue(void);
namespace esphome::rp2040 {}
namespace esphome::rp2 {}
namespace esphome {
@@ -58,4 +58,4 @@ uint32_t arch_get_cpu_freq_hz();
} // namespace esphome
#endif // USE_RP2040
#endif // USE_RP2
@@ -1,7 +1,7 @@
#include "esphome/core/helpers.h"
#include "esphome/core/defines.h"
#ifdef USE_RP2040
#ifdef USE_RP2
#include "esphome/core/hal.h"
@@ -89,4 +89,4 @@ void get_mac_address_raw(uint8_t *mac) { // NOLINT(readability-non-const-parame
} // namespace esphome
#endif // USE_RP2040
#endif // USE_RP2
@@ -0,0 +1,27 @@
#pragma once
#ifdef USE_RP2
#include <cstddef>
#include <cstdint>
namespace esphome::rp2 {
class RP2PreferenceBackend final {
public:
bool save(const uint8_t *data, size_t len);
bool load(uint8_t *data, size_t len);
size_t offset = 0;
uint32_t type = 0;
};
class RP2Preferences;
RP2Preferences *get_preferences();
} // namespace esphome::rp2
namespace esphome {
using PreferenceBackend = rp2::RP2PreferenceBackend;
} // namespace esphome
#endif // USE_RP2
@@ -1,4 +1,4 @@
#ifdef USE_RP2040
#ifdef USE_RP2
#include <Arduino.h>
@@ -12,7 +12,7 @@
#include "esphome/core/helpers.h"
#include "esphome/core/log.h"
namespace esphome::rp2040 {
namespace esphome::rp2 {
static const char *const TAG = "preferences";
@@ -37,7 +37,7 @@ template<class It> uint8_t calculate_crc(It first, It last, uint32_t type) {
return crc;
}
bool RP2040PreferenceBackend::save(const uint8_t *data, size_t len) {
bool RP2PreferenceBackend::save(const uint8_t *data, size_t len) {
const size_t buffer_size = len + 1;
if (buffer_size > PREF_MAX_BUFFER_SIZE)
return false;
@@ -58,7 +58,7 @@ bool RP2040PreferenceBackend::save(const uint8_t *data, size_t len) {
return true;
}
bool RP2040PreferenceBackend::load(uint8_t *data, size_t len) {
bool RP2PreferenceBackend::load(uint8_t *data, size_t len) {
const size_t buffer_size = len + 1;
if (buffer_size > PREF_MAX_BUFFER_SIZE)
return false;
@@ -80,27 +80,27 @@ bool RP2040PreferenceBackend::load(uint8_t *data, size_t len) {
return true;
}
RP2040Preferences::RP2040Preferences() : eeprom_sector_(&_EEPROM_start) {}
RP2Preferences::RP2Preferences() : eeprom_sector_(&_EEPROM_start) {}
void RP2040Preferences::setup() {
void RP2Preferences::setup() {
ESP_LOGVV(TAG, "Loading preferences from flash");
memcpy(s_flash_storage, this->eeprom_sector_, RP2040_FLASH_STORAGE_SIZE);
}
ESPPreferenceObject RP2040Preferences::make_preference(size_t length, uint32_t type) {
ESPPreferenceObject RP2Preferences::make_preference(size_t length, uint32_t type) {
uint32_t start = this->current_flash_offset;
uint32_t end = start + length + 1;
if (end > RP2040_FLASH_STORAGE_SIZE) {
return {};
}
auto *pref = new RP2040PreferenceBackend(); // NOLINT(cppcoreguidelines-owning-memory)
auto *pref = new RP2PreferenceBackend(); // NOLINT(cppcoreguidelines-owning-memory)
pref->offset = start;
pref->type = type;
this->current_flash_offset = end;
return ESPPreferenceObject(pref);
}
bool RP2040Preferences::sync() {
bool RP2Preferences::sync() {
if (!s_flash_dirty)
return true;
if (s_prevent_write)
@@ -121,7 +121,7 @@ bool RP2040Preferences::sync() {
return true;
}
bool RP2040Preferences::reset() {
bool RP2Preferences::reset() {
ESP_LOGD(TAG, "Erasing storage");
{
InterruptLock lock;
@@ -133,9 +133,9 @@ bool RP2040Preferences::reset() {
return true;
}
static RP2040Preferences s_preferences; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
static RP2Preferences s_preferences; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
RP2040Preferences *get_preferences() { return &s_preferences; }
RP2Preferences *get_preferences() { return &s_preferences; }
void setup_preferences() {
s_preferences.setup();
@@ -143,10 +143,10 @@ void setup_preferences() {
}
void preferences_prevent_write(bool prevent) { s_prevent_write = prevent; }
} // namespace esphome::rp2040
} // namespace esphome::rp2
namespace esphome {
ESPPreferences *global_preferences; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
} // namespace esphome
#endif // USE_RP2040
#endif // USE_RP2
@@ -1,14 +1,14 @@
#pragma once
#ifdef USE_RP2040
#ifdef USE_RP2
#include "esphome/core/preference_backend.h"
namespace esphome::rp2040 {
namespace esphome::rp2 {
class RP2040Preferences final : public PreferencesMixin<RP2040Preferences> {
class RP2Preferences final : public PreferencesMixin<RP2Preferences> {
public:
using PreferencesMixin<RP2040Preferences>::make_preference;
RP2040Preferences();
using PreferencesMixin<RP2Preferences>::make_preference;
RP2Preferences();
void setup();
ESPPreferenceObject make_preference(size_t length, uint32_t type, bool in_flash) {
return this->make_preference(length, type);
@@ -26,8 +26,8 @@ class RP2040Preferences final : public PreferencesMixin<RP2040Preferences> {
void setup_preferences();
void preferences_prevent_write(bool prevent);
} // namespace esphome::rp2040
} // namespace esphome::rp2
DECLARE_PREFERENCE_ALIASES(esphome::rp2040::RP2040Preferences)
DECLARE_PREFERENCE_ALIASES(esphome::rp2::RP2Preferences)
#endif // USE_RP2040
#endif // USE_RP2
@@ -13,12 +13,12 @@
* Saves ~8.9 KB of flash.
*/
#if defined(USE_RP2040) && !defined(USE_FULL_PRINTF)
#if defined(USE_RP2) && !defined(USE_FULL_PRINTF)
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
namespace esphome::rp2040 {}
namespace esphome::rp2 {}
static constexpr size_t PRINTF_BUFFER_SIZE = 512;
@@ -71,4 +71,4 @@ int __wrap_fprintf(FILE *stream, const char *fmt, ...) {
} // extern "C"
// NOLINTEND(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming)
#endif // USE_RP2040 && !USE_FULL_PRINTF
#endif // USE_RP2 && !USE_FULL_PRINTF
-6
View File
@@ -1,6 +0,0 @@
#ifdef USE_RP2040
// HAL functions live in hal.cpp. core.cpp is intentionally empty for
// rp2040 — there is no extra component bootstrap to keep here.
#endif // USE_RP2040
@@ -1,27 +0,0 @@
#pragma once
#ifdef USE_RP2040
#include <cstddef>
#include <cstdint>
namespace esphome::rp2040 {
class RP2040PreferenceBackend final {
public:
bool save(const uint8_t *data, size_t len);
bool load(uint8_t *data, size_t len);
size_t offset = 0;
uint32_t type = 0;
};
class RP2040Preferences;
RP2040Preferences *get_preferences();
} // namespace esphome::rp2040
namespace esphome {
using PreferenceBackend = rp2040::RP2040PreferenceBackend;
} // namespace esphome
#endif // USE_RP2040
+1 -1
View File
@@ -3,7 +3,7 @@ import esphome.config_validation as cv
from esphome.const import CONF_ENABLE_ON_BOOT, CONF_ID
from esphome.types import ConfigType
DEPENDENCIES = ["rp2040"]
DEPENDENCIES = ["rp2"]
CODEOWNERS = ["@bdraco"]
rp2040_ble_ns = cg.esphome_ns.namespace("rp2040_ble")
@@ -1,6 +1,6 @@
#include "led_strip.h"
#ifdef USE_RP2040
#ifdef USE_RP2
#include "esphome/core/helpers.h"
#include "esphome/core/log.h"
@@ -1,6 +1,6 @@
#pragma once
#ifdef USE_RP2040
#ifdef USE_RP2
#include "esphome/core/color.h"
#include "esphome/core/component.h"
@@ -128,4 +128,4 @@ class RP2040PIOLEDStripLightOutput final : public light::AddressableLight {
} // namespace esphome::rp2040_pio_led_strip
#endif // USE_RP2040
#endif // USE_RP2
@@ -2,7 +2,7 @@ from dataclasses import dataclass
from esphome import pins
import esphome.codegen as cg
from esphome.components import light, rp2040
from esphome.components import light, rp2
import esphome.config_validation as cv
from esphome.const import (
CONF_CHIPSET,
@@ -130,9 +130,9 @@ def time_to_cycles(time_us):
CONF_PIO = "pio"
AUTO_LOAD = ["rp2040_pio"]
AUTO_LOAD = ["rp2_pio"]
CODEOWNERS = ["@Papa-DMan"]
DEPENDENCIES = ["rp2040"]
DEPENDENCIES = ["rp2"]
rp2040_pio_led_strip_ns = cg.esphome_ns.namespace("rp2040_pio_led_strip")
RP2040PIOLEDStripLightOutput = rp2040_pio_led_strip_ns.class_(
@@ -250,7 +250,7 @@ async def to_code(config):
if chipset := config.get(CONF_CHIPSET):
cg.add(var.set_chipset(chipset))
_LOGGER.info("Generating PIO assembly code")
rp2040.add_pio_file(
rp2.add_pio_file(
__name__,
key,
generate_assembly_code(
@@ -265,7 +265,7 @@ async def to_code(config):
else:
cg.add(var.set_chipset(Chipset.CHIPSET_CUSTOM))
_LOGGER.info("Generating custom PIO assembly code")
rp2040.add_pio_file(
rp2.add_pio_file(
__name__,
key,
generate_assembly_code(
+1 -1
View File
@@ -5,7 +5,7 @@ import esphome.config_validation as cv
from esphome.const import CONF_FREQUENCY, CONF_ID, CONF_PIN
CODEOWNERS = ["@jesserockz"]
DEPENDENCIES = ["rp2040"]
DEPENDENCIES = ["rp2"]
rp2040_pwm_ns = cg.esphome_ns.namespace("rp2040_pwm")
+1 -1
View File
@@ -1,4 +1,4 @@
#ifdef USE_RP2040
#ifdef USE_RP2
#include "rp2040_pwm.h"
#include "esphome/core/defines.h"
+2 -2
View File
@@ -1,6 +1,6 @@
#pragma once
#ifdef USE_RP2040
#ifdef USE_RP2
#include "esphome/components/output/float_output.h"
#include "esphome/core/automation.h"
@@ -54,4 +54,4 @@ template<typename... Ts> class SetFrequencyAction final : public Action<Ts...> {
} // namespace esphome::rp2040_pwm
#endif // USE_RP2040
#endif // USE_RP2
@@ -3,7 +3,7 @@ import platform
import esphome.codegen as cg
import esphome.config_validation as cv
DEPENDENCIES = ["rp2040"]
DEPENDENCIES = ["rp2"]
PIOASM_REPO_VERSION = "1.5.0-b"
+2 -2
View File
@@ -1,7 +1,7 @@
#include "sha256.h"
// Only compile SHA256 implementation on platforms that support it
#if defined(USE_ESP32) || defined(USE_ESP8266) || defined(USE_RP2040) || defined(USE_LIBRETINY) || defined(USE_HOST)
#if defined(USE_ESP32) || defined(USE_ESP8266) || defined(USE_RP2) || defined(USE_LIBRETINY) || defined(USE_HOST)
#include "esphome/core/helpers.h"
#include <cstring>
@@ -76,7 +76,7 @@ void SHA256::add(const uint8_t *data, size_t len) { mbedtls_sha256_update(&this-
void SHA256::calculate() { mbedtls_sha256_finish(&this->ctx_, this->digest_); }
#elif defined(USE_ESP8266) || defined(USE_RP2040)
#elif defined(USE_ESP8266) || defined(USE_RP2)
SHA256::~SHA256() = default;

Some files were not shown because too many files have changed in this diff Show More