3

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

1 Answers1

4

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.

0___________
  • 60,014
  • 4
  • 34
  • 74
  • 'uninitialized static storage data' meaning variables that you store in global scope, or as 'static'. These get packed into your binary at compile time. And it seems they are simply too large to handle :). – ChrisB Dec 24 '22 at 23:24
  • This was indeed the case, but my bonus question is why did it let me compile when I didn't use "final_array_index++;"? – shachaf zilberman Dec 24 '22 at 23:26
  • 'final_array_index++' has nothing to do with the error you asked about here. That is a statement that will only be executed at runtime. Your error is at compiletime though (or during linking, to be precise). – ChrisB Dec 24 '22 at 23:30