arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2610.21064cs.OScs.ARcs.SE
收藏

SRAM去向何处:64 KB RISC-V微控制器上FreeRTOS-C与Embassy-Rust物联网固件的静态内存逐符号归因

Where the SRAM Goes: Per-Symbol Attribution of Static Memory in FreeRTOS-C and Embassy-Rust IoT Firmware on a 64 KB RISC-V Microcontroller

Universitas Budi Luhur(布迪卢胡尔大学)

Romi Fadli, Jan Everhard Riwurohi, Wahyu Ramadani Putri Utami, Zulfa Malika Amana

AI总结:

本研究提出静态内存逐符号归因方法,在64 KB RISC-V微控制器上对比FreeRTOS-C与Embassy-Rust固件栈的SRAM分配,发现lwIP网络内存成本更高且需额外20 KB arena,成果已公开。

摘要:

为内存受限的微控制器选择固件栈通常以二进制总大小为依据,该指标仅报告构建产物消耗的SRAM总量,却未说明SRAM的去向及原因。本文针对这一缺口提出一种逐符号归因方法,通过将带大小的ELF符号限定到.data、.bss和.stack段范围,将静态RAM分解为调度器堆、网络缓冲区与池、任务栈、链接器保留区域等架构类别。该方法通过将所有16种构建的各类别总和与基于大小的总量精确匹配完成验证。我们将其应用于8个累积固件里程碑,从裸任务框架到完整的MQTT-over-Ethernet客户端,分别用FreeRTOS-C和Embassy-Rust实现,在CH32V203RBT6(一款配备64 KB SRAM及片上以太网MAC和PHY的RISC-V微控制器)上每个里程碑均通过硬件功能一致性验证。分解结果显示,两种栈的RAM用于网络的占比几乎相同(63.8%对63.9%),但绝对成本相差4.4倍:lwIP为40719字节,smoltcp为9316字节;FreeRTOS任务栈随任务数量线性增长,约每个任务1 KB,而Embassy异步状态随状态机复杂度增长。我们还发现,lwIP无法在该平台的全静态规则下集成,需要20 KB的内存 arena,而smoltcp无需此空间。测量工具、归因工具及16种固件实现均作为成果发布。

英文摘要:

Selecting a firmware stack for a memory-constrained microcontroller is usually guided by aggregate binary sizes, which report how much SRAM a build consumes but not where it goes or why. We address that gap with a per-symbol attribution method that decomposes static RAM into architectural categories - scheduler heap, network buffers and pools, task stacks, and linker-reserved regions - by bounding sized ELF symbols to the .data, .bss and .stack section ranges. The method is validated by reconciling every category sum exactly against the size-based totals for all sixteen builds. We apply it to eight cumulative firmware milestones, from a bare task scaffold to a full MQTT-over-Ethernet client, implemented twice, in FreeRTOS-C and in Embassy-Rust, on the CH32V203RBT6, a RISC-V microcontroller with 64 KB SRAM and an on-chip Ethernet MAC and PHY, with functional parity verified on hardware at every milestone. The decomposition shows that both stacks spend a nearly identical share of their RAM on networking (63.8% versus 63.9%), yet the absolute cost differs by 4.4 times: 40,719 bytes for lwIP against 9,316 bytes for smoltcp. FreeRTOS task stacks grow linearly at roughly 1 KB per task while Embassy async state grows with state-machine complexity. We also report that lwIP could not be integrated under an all-static discipline on this platform, requiring a 20 KB arena that smoltcp does not. The measurement harness, the attribution tool, and the sixteen firmware implementations are released as artefacts.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑