Commit Graph
31363 Commits
Author SHA1 Message Date
Mat931 c19d06a07f Format partition table similar to debug component 2026-05-03 20:47:49 +02:00
Mat931 1895ef1c3e Restore 'Used size' of running app in dump_config 2026-05-03 20:03:38 +02:00
J. Nick Koston 9a73ffbae9 Merge branch 'dev' into partition-table-ota 2026-05-03 09:49:29 -05:00
J. Nick Koston 87f152965d [ota] Rename copy_source_part -> copy_dest_part and harden running-app lookup
The PartitionTablePlan field that drives the optional app copy stores
the partition that will receive the running app (i.e. the destination
in the current table at the new slot's flash offset). The old name
``copy_source_part`` described the value backwards and risked future
callers swapping the esp_partition_copy() arguments; renamed to
``copy_dest_part`` along with the matching local
``app_copy_dest_part`` and the comments around them.

Also replace esp_ota_get_running_partition() in the copy path with
find_app_partition_at(running_app_offset, running_app_size). The IDF
call can return nullptr after a prior aborted partition-table OTA in
the same boot called esp_partition_unload_all() (the same condition
the cache in get_running_app_position() exists for); the previous code
would have dereferenced nullptr on the retry that the client error
message explicitly suggests.

No functional change on the success path; nullptr deref on the failed-
retry path is now reported as OTA_RESPONSE_ERROR_PARTITION_TABLE_UPDATE.
2026-05-03 09:48:06 -05:00
J. Nick Koston c69b3c5590 [ota] Unify backend begin() signature and trim partition-table comments
Every OTA backend's begin() now takes ``(size_t image_size, OTAType
ota_type = OTA_TYPE_UPDATE_APP)``. ESPHomeOTAComponent::handle_data_()
calls ``backend_->begin(ota_size, ota_type)`` unconditionally; the
USE_OTA_PARTITIONS ifdef around the call disappears. The four non-ESP32
backends (esp8266, rp2040, libretiny, host) accept the new parameter
and reject anything other than OTA_TYPE_UPDATE_APP up front, so the
client-visible behaviour is unchanged.

Same commit also trims the verbose block comments in the partition-
table TU and the IDF backend header, keeping the genuinely non-obvious
WHYs (slot-selection policy, NvsReinitGuard semantics, unload-then-null
ordering, cache-init flag, dump_config nullptr fallback) and dropping
the procedural narration.

No functional change.
2026-05-03 09:43:55 -05:00
J. Nick Koston d5cc5206dd [ota] Move partition-table code into ota_partitions_esp_idf.cpp
Splits the partition-table OTA implementation out of the shared
ota_backend_esp_idf.cpp into a new translation unit gated by
USE_OTA_PARTITIONS. Builds without allow_partition_access compile
strictly less code and don't link esp_image_format / nvs_flash; the
common app-OTA backend is also easier to read without ~340 lines of
unrelated partition handling interleaved.

What moves: validate_new_partition_table_, update_partition_table,
get_running_app_position, the file-static running-app cache, the
NvsReinitGuard RAII helper, and the find_app_partition_at /
check_overlap helpers. What stays: begin/write/end/abort and the
factory.

Behaviour-preserving refactor.
2026-05-03 09:34:46 -05:00
J. Nick Koston 4dcccf2cdf [ota] DRY NVS reinit on update_partition_table failure paths
Replace the four explicit nvs_flash_init() calls with a small RAII
guard (NvsReinitGuard) declared right after nvs_flash_deinit(). Each
failure path now just returns; the guard reinits NVS in its destructor.
The success path disarms it before the trailing return because the
device reboots immediately afterwards and reinit would only churn the
partition cache.

No behaviour change.
2026-05-03 09:30:23 -05:00
J. Nick Koston b75f5034e5 [ota] Address remaining Copilot comments on partition-table OTA
- upload_program: allow MQTT/MQTTIP devices for --partition-table.
  MQTTIP gets resolved to a real IP by _resolve_network_devices(), so
  rejecting any non-NETWORK port_type was incorrect; only SERIAL and
  BOOTSEL are non-OTA upload paths.
- update_partition_table: re-initialize NVS on every failure path past
  nvs_flash_deinit() so components that survive a failed OTA aren't
  left with broken NVS handles. Success path stays as-is because the
  device reboots immediately afterwards.

Adds an MQTTIP upload test and refreshes the gate's comment.
2026-05-03 09:29:05 -05:00
J. Nick Koston 36c120fb07 [ota] Hoist running-app cache to file scope
The running-app position cache lived as three function-local statics
inside get_running_app_position(). They cannot be IDFOTABackend members
(the backend is per-connection, the cache must outlive a backend that
called esp_partition_unload_all() in a prior aborted partition-table
OTA), but burying them inside the function made the lifetime and
shared-across-connections semantics implicit. Move them to file scope
with s_running_app_ prefix so the process-scoped lifetime is visible
at first read, and tighten the surrounding comments.

No behaviour change.
2026-05-03 09:26:03 -05:00
J. Nick Koston 4490bbf23a [ota] Extract partition-table validation into validate_new_partition_table_
Splits the non-destructive validation phase out of update_partition_table()
into a dedicated method. update_partition_table() now reads top-down as
"check buffer state, find running app, validate the new table + plan the
target slot, then commit", with the destructive write isolated to the
final block.

The chosen slot and optional copy-source partition are returned via a
small PartitionTablePlan struct so the caller no longer juggles the two
candidate-index variables. Refactor only; behaviour and error semantics
are unchanged.
2026-05-03 09:23:08 -05:00
J. Nick Koston b788529ad7 [ota] Polish partition-table review feedback
Split the combined "missing app, otadata, or nvs" verify failure into
three separate ESP_LOGE messages so users can see which check failed,
trim trailing spaces from the (err=0x%X) log strings, and document why
the partition-table espota2 test mocks SERVER_FEATURE_SUPPORTS_COMPRESSION
(intentional protocol-path coverage; the real IDFOTABackend never sets it).
2026-05-03 09:17:40 -05:00
J. Nick Koston 51c5500809 [ota] Validate partition-table binary host-side before OTA
Read the resolved partition-table file in upload_program before opening
a network connection. Reject anything that isn't 0xC00 bytes, doesn't
start with ESP_PARTITION_MAGIC, or is missing the MD5 checksum entry, so
mistakes (wrong file, swapped --file path) surface as a local error
instead of a post-handshake OTA_RESPONSE_ERROR_PARTITION_TABLE_VERIFY.

Includes unit tests covering size, magic, md5-presence, missing-file,
and end-to-end upload_program rejection, plus three real partition
tables checked in as fixtures (ESPHome build, ESP-IDF Hello-world,
esphome_dashboard prebuilt).
2026-05-03 09:15:28 -05:00
Edward Firmoandpre-commit-ci-lite[bot] 8046ff7e1e [nextion] TFT upload no longer fails when the display sends a split 0x08 ack (#16205)
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
2026-05-03 03:40:09 -05:00
J. Nick Koston b30d09b43b Merge remote-tracking branch 'upstream/dev' into integration 2026-05-01 21:53:04 -05:00
dependabot[bot] 5e9db1c8c6 Bump github/codeql-action from 4.35.2 to 4.35.3 (#16201)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-01 21:46:29 -05:00
Mat931 e7ee0c0b83 Merge branch 'dev' into partition-table-ota 2026-05-01 19:54:05 +00:00
J. Nick Koston 81d147ff9e [esp32] Drop printf wrap on IDF 6.0+ (picolibc no longer needs it) (#16189) 2026-05-01 14:31:56 -05:00
J. Nick Koston 4f8aa24f05 Merge remote-tracking branch 'upstream/esp8266-wdt-feed-100ms' into integration 2026-05-01 12:48:04 -05:00
Mat931 63c9b63fcf Apply suggestions 2026-05-01 19:42:39 +02:00
J. Nick Koston cf01be6250 [esp8266] Lower WDT_FEED_INTERVAL_MS to 100 ms
Restore tighter feed cadence on ESP8266 to match the smaller WDT
budgets on this platform. ESP8266 soft WDT is ~1.6 s and HW WDT is
~6 s; a single long iteration (mDNS reply, wifi scan, OTA verify,
lwIP TCP retransmit) can easily push the loop past a few hundred ms.
The 300 ms shared default left only ~1.3 s of soft-WDT headroom; 100 ms
restores ~16x margin to the soft WDT (matching pre-#15846 behavior in
spirit) without per-iteration arch_feed_wdt() cost.

Reports of Hardware WDT - Level1Int crashes on ESP8266 line up with
this margin being too tight under the new main-loop cadence.
2026-05-01 12:25:37 -05:00
J. Nick Koston cb81ede701 Merge remote-tracking branch 'upstream/api-logs-decode-noraise' into integration 2026-05-01 12:09:10 -05:00
J. Nick Koston c05e66669e [api] Tidy decoder warning when EsphomeError has no message
_run_idedata raises EsphomeError() with no message, so the warning
shows 'unavailable ()' which looks like a bug. Use a generic fallback
explanation when str(exc) is empty.
2026-05-01 12:09:00 -05:00
J. Nick Koston 67b839c4bb Merge remote-tracking branch 'upstream/api-logs-decode-noraise' into integration 2026-05-01 12:06:19 -05:00
J. Nick Koston f4d3fb1a18 [api] Short-circuit log-line decoder after first failure
_decode_pc shells out to PlatformIO via _run_idedata; without a
populated build dir for the device that subprocess fails for every
PC/BT line in a crash dump. Disable decoding after the first
EsphomeError (per logs session) and emit a single user-facing warning
instead of retrying on every line.

Also rename the helper to _LogLineProcessor since it now owns the
per-session decode-enabled state, not just the decode call.
2026-05-01 12:01:19 -05:00
J. Nick Koston fcc6f04805 [api] Don't tear down log connection on stack-trace decode failure
When 'esphome logs' processes a crash backtrace from the device,
process_stacktrace -> _decode_pc -> _run_idedata can raise
EsphomeError if the local build dir hasn't been populated (e.g. the
device was flashed from a different machine). on_log runs inside an
asyncio protocol callback, so the unhandled exception triggers
'Fatal error: protocol.data_received() call failed.', the loop tears
the connection down, and ReconnectLogic immediately reconnects. The
device replays the same crash trace and we loop forever.

Wrap the per-line decode in a helper that swallows EsphomeError so
the connection stays up. Also covered with unit tests for the new
helper.
2026-05-01 11:56:19 -05:00
pre-commit-ci-lite[bot] 9951a837f1 [pre-commit.ci lite] apply automatic fixes 2026-05-01 16:17:31 +00:00
Mat931 2dd8a9913b Fix 2026-05-01 18:15:40 +02:00
pre-commit-ci-lite[bot] 2068d114eb [pre-commit.ci lite] apply automatic fixes 2026-05-01 16:02:30 +00:00
Mat931 015decce4d Merge branch 'dev' into partition-table-ota 2026-05-01 16:01:01 +00:00
Mat931andJ. Nick Koston 58cb7effd4 [ota] Add extended OTA protocol (#16164)
Co-authored-by: J. Nick Koston <nick@home-assistant.io>
2026-05-01 10:40:14 -05:00
J. Nick Koston 918b1fac71 Merge branch 'ota-extended-protocol' into integration 2026-05-01 09:23:11 -05:00
J. Nick Koston 7f1cff1866 address bot nits 2026-05-01 09:22:37 -05:00
J. Nick Koston 588701fa9a Merge branch 'ota-extended-protocol' into integration 2026-05-01 09:10:26 -05:00
J. Nick Koston 28e1b32259 enforce size 2026-05-01 09:09:23 -05:00
J. Nick Koston 54ac510a25 cover 2026-05-01 09:08:58 -05:00
J. Nick Koston a6cd2a9f4d improve error reporting in case we mess it up later 2026-05-01 09:08:07 -05:00
J. Nick Koston 45c78dd5d2 bail early so listeners do not stop bluetooth if its an error 2026-05-01 09:06:37 -05:00
J. Nick Koston 4c9260d96d reduce memory 2026-05-01 09:05:46 -05:00
J. Nick Koston fd921fb9e0 Merge branch 'ota-extended-protocol' into integration 2026-05-01 09:01:46 -05:00
Kevin Ahrendt 3dd60c5713 [core] Support allocating ring buffer in internal memory (#16187) 2026-05-01 07:55:08 -05:00
Oliver Kleinecke f073c1cabe [usb_host][usb_uart] Add configurable max packet size (#14584) 2026-05-01 20:43:13 +10:00
Mat931 f94ed42ae8 Merge branch 'dev' into partition-table-ota 2026-05-01 09:12:48 +00:00
Mat931 23ac2ead27 Merge branch 'dev' into ota-extended-protocol 2026-05-01 09:12:47 +00:00
Mat931 cb97c35d36 Backport changes 2026-05-01 10:29:41 +02:00
Mat931 6182beb1f2 Apply suggestions 2026-05-01 10:15:58 +02:00
J. Nick Koston 5cc447e0da [core] Move per-platform hal_platform.h into components/platform/hal.h (#16183) 2026-04-30 21:27:31 -05:00
Clyde Stubbs 0980630f68 [lvgl] Clamp values for meter line indicators (#16180) 2026-04-30 22:23:14 -04:00
J. Nick Koston b8dfffdf06 [core] Enable ruff FLY (flynt) lint family (#16182) 2026-04-30 21:20:07 -05:00
J. Nick Koston 9d93c5a37c Merge remote-tracking branch 'upstream/move-hal-headers-to-components' into integration 2026-04-30 21:11:36 -05:00
J. Nick Koston 4e560dbd2e Merge remote-tracking branch 'upstream/dev' into integration 2026-04-30 21:11:33 -05:00