feat(build): support aligned embedded binary data

Allow callers to align embedded binary start symbols for DMA-capable
assets.
This commit is contained in:
morris
2026-07-20 12:44:18 +08:00
committed by Gao Xu
parent 5edf9932f1
commit 3e162786cb
6 changed files with 49 additions and 5 deletions

View File

@@ -996,6 +996,10 @@ To embed a file into a project, rather than a component, you can call the functi
Place this line after the ``project()`` line in your project CMakeLists.txt file. Replace ``myproject.elf`` with your project name. The final argument can be ``TEXT`` to embed a null-terminated string, or ``BINARY`` to embed the content as-is.
Use the optional ``ALIGN`` argument to align the embedded data's start symbol to a positive power of two. For example, to align binary data to 16 bytes::
target_add_binary_data(myproject.elf "main/data.bin" BINARY ALIGN 16)
For an example of using this technique, see the "main" component of the file_serving example :example_file:`protocols/http_server/file_serving/main/CMakeLists.txt` - two files are loaded at build time and linked into the firmware.
.. highlight:: cmake

View File

@@ -996,6 +996,10 @@ CMake 文件可以使用 ``IDF_TARGET`` 变量来获取当前的硬件目标。
并将这行代码放在项目 CMakeLists.txt 的 ``project()`` 命令之后,修改 ``myproject.elf`` 为你自己的项目名。如果最后一个参数是 ``TEXT``,那么构建系统会嵌入以 null 结尾的字符串,如果最后一个参数被设置为 ``BINARY``,则将文件内容按照原样嵌入。
可选的 ``ALIGN`` 参数用于将嵌入数据的起始符号对齐到指定的正整数 2 的幂。例如,将二进制数据按 16 字节对齐::
target_add_binary_data(myproject.elf "main/data.bin" BINARY ALIGN 16)
有关使用此技术的示例,请查看 file_serving 示例 :example_file:`protocols/http_server/file_serving/main/CMakeLists.txt` 中的 main 组件,两个文件会在编译时加载并链接到固件中。
.. highlight:: cmake