Home > Software engineering >  `.bss' is not within region `ram' error - esp32 ulp risv-v
`.bss' is not within region `ram' error - esp32 ulp risv-v

Time:12-25

I'm trying to copy array elements from one array to another. One of the arrays uses a int32_t index to track the current index.

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]; // This line will compile without error if the next line is commented
            final_array_index  ;

            

        }

If the line is active I will get this error:

/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

I've tried many variations but nothing seems to work, I'm not sure if the problem is with my C skills or with the esp idf compiler.

**

  • Solved:

** The right answer is indeed me running out if memory, reducing the size of the arrays to 50 fixed the problem. I do need to mention that I should have increased the memory allocation for slow rtc memory from 4kb to 8kb in idf.py menuconfig! This would solve the problem without changing the size to 50 (in my case). Thanks everyone

CodePudding user response:

This error message says that your uninitialized static storage data (stored in the .bss section) is too big. Basically, you ran out of RAM. You need to reduce the number and size of your variables.

CodePudding user response:

From the error looks like you are trying to access out-of-bounds elements. You need to make sure that final_array_index < 100 before assigning values to final_arr_pressure.

for (int i = 0; (i < 4) && (final_array_index < 100);   i,   final_array_index)
{
   final_arr_pressure[final_array_index] = pres_log_last_5_readings_raw[i];
}
  • Related