mirror of
https://github.com/esphome/esphome.git
synced 2026-09-16 17:48:40 +00:00
[api] Define NATIVE_LITTLE_ENDIAN for libsodium on all targets
libsodium's autoconf-generated config normally sets NATIVE_LITTLE_ENDIAN, but PlatformIO skips autoconf. Without this define, libsodium falls back to byte-at-a-time load/store operations in poly1305 and chacha20 instead of optimized 32-bit memcpy. This saves ~340 bytes of flash and improves encryption/decryption throughput on every API noise packet. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
ad5811280a
commit
34abc08f04
@@ -453,6 +453,18 @@ async def to_code(config: ConfigType) -> None:
|
||||
# and plaintext disabled. Only a factory reset can remove it.
|
||||
cg.add_define("USE_API_PLAINTEXT")
|
||||
cg.add_define("USE_API_NOISE")
|
||||
# libsodium uses NATIVE_LITTLE_ENDIAN to enable optimized 32-bit
|
||||
# load/store via memcpy instead of byte-at-a-time operations in
|
||||
# poly1305 and chacha20.
|
||||
if (
|
||||
CORE.is_esp32
|
||||
or CORE.is_esp8266
|
||||
or CORE.is_rp2040
|
||||
or CORE.is_bk72xx
|
||||
or CORE.is_rtl87xx
|
||||
or CORE.is_ln882x
|
||||
):
|
||||
cg.add_build_flag("-DNATIVE_LITTLE_ENDIAN")
|
||||
cg.add_library("esphome/noise-c", "0.1.10")
|
||||
else:
|
||||
cg.add_define("USE_API_PLAINTEXT")
|
||||
|
||||
Reference in New Issue
Block a user