You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ESP32 ULP RISC-V编译报错:`.bss'不在`ram'区域问题解决

链接错误:ulp_main段.bss地址不在ram区域内(ESP IDF环境)

问题代码与现象

变量定义

int32_t pres_log_last_5_readings_raw[5];
int32_t final_arr_pressure[100];
int32_t final_array_index = 0;

循环拷贝代码

for (int i = 0; i < 4; i++)
{
    final_arr_pressure[final_array_index] = pres_log_last_5_readings_raw[i]; // 注释下一行可正常编译
    final_array_index++;
}

错误信息

启用final_array_index++后触发链接错误:

/Users/user/.espressif/tools/riscv32-esp-elf/esp-2022r1-11.2.0/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/11.2.0/../../../../riscv32-esp-elf/bin/ld: address 0x10dc of ulp_main section `.bss' is not within region `ram'
/Users/user/.espressif/tools/riscv32-esp-elf/esp-2022r1-11.2.0/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/11.2.0/../../../../riscv32-esp-elf/bin/ld: address 0x10dc of ulp_main section `.bss' is not within region `ram'
collect2: error: ld returned 1 exit status

尝试多种代码写法均无法解决,无法确定是代码问题还是ESP IDF编译器问题。

解决方案

该问题本质是内存不足导致的,可通过以下两种方式解决:

  • 缩小数组占用:将final_arr_pressure的大小从100调整为50,减少内存占用后即可正常编译。
  • 调整RTC内存配置:执行idf.py menuconfig进入ESP IDF配置界面,找到slow rtc内存分配选项,将默认4KB调整为8KB,无需修改代码即可解决。

内容的提问来源于stack exchange,提问作者shachaf zilberman

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.07 08:20:31