From 1612b25e708caada19993d7ebf044b6260941989 Mon Sep 17 00:00:00 2001 From: Mahavir Jain Date: Thu, 6 Aug 2026 22:07:57 +0530 Subject: [PATCH] fix(build): word-align the length symbol of embedded data files The generated assembly emitted _length immediately after the raw payload bytes, so the 32-bit word landed misaligned whenever the data size was not a multiple of 4. Consumers declare it as a 32-bit object (e.g. `extern const size_t _length` in the ULP firmware loaders), so the compiler emits an alignment-assuming word load, which is a misaligned flash read prone to spurious load faults on chips with SOC_CPU_MISALIGNED_ACCESS_ON_PMP_MISMATCH_ISSUE (ESP32-C6/H2/H21). --- tools/cmake/scripts/data_file_embed_asm.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/cmake/scripts/data_file_embed_asm.cmake b/tools/cmake/scripts/data_file_embed_asm.cmake index b8612976894..6b24ca66062 100644 --- a/tools/cmake/scripts/data_file_embed_asm.cmake +++ b/tools/cmake/scripts/data_file_embed_asm.cmake @@ -83,6 +83,8 @@ append("${data}") make_and_append_identifier("_binary_${varname}_end" "for objcopy compatibility") append_line("") +# Keep the length aligned on the word boundary (read as a 32-bit `_length`) +append_line(".balign 4") if(FILE_TYPE STREQUAL "TEXT") make_and_append_identifier("${varname}_length" "not including null byte") else()